You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2016/10/17 17:58:58 UTC

[01/40] ignite git commit: IGNITE-3998: IGFS: Enabled IgfsAbstractSelfTest.testCreateConsistencyMultithreaded. This closes #1129.

Repository: ignite
Updated Branches:
  refs/heads/ignite-ssl-hotfix [created] b43bb6f6d


IGNITE-3998: IGFS: Enabled IgfsAbstractSelfTest.testCreateConsistencyMultithreaded. This closes #1129.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: a4c63ae113931615e940ada2411ebce32dba5db8
Parents: f447559
Author: iveselovskiy <iv...@gridgain.com>
Authored: Fri Sep 30 10:45:13 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 30 10:45:13 2016 +0300

----------------------------------------------------------------------
 .../processors/igfs/IgfsAbstractSelfTest.java   | 141 +++++++++----------
 1 file changed, 70 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a4c63ae1/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 e8d65f1..7058954 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
@@ -1310,77 +1310,76 @@ public abstract class IgfsAbstractSelfTest extends IgfsAbstractBaseSelfTest {
      * @throws Exception If failed.
      */
     public void testCreateConsistencyMultithreaded() throws Exception {
-        // TODO: Enable
-//        final AtomicBoolean stop = new AtomicBoolean();
-//
-//        final AtomicInteger createCtr = new AtomicInteger(); // How many times the file was re-created.
-//        final AtomicReference<Exception> err = new AtomicReference<>();
-//
-//        igfs.create(FILE, false).close();
-//
-//        int threadCnt = 50;
-//
-//        IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-//            @SuppressWarnings("ThrowFromFinallyBlock")
-//            @Override public void run() {
-//                while (!stop.get() && err.get() == null) {
-//                    IgfsOutputStream os = null;
-//
-//                    try {
-//                        os = igfs.create(FILE, true);
-//
-//                        os.write(chunk);
-//
-//                        os.close();
-//
-//                        createCtr.incrementAndGet();
-//                    }
-//                    catch (IgniteException e) {
-//                        // No-op.
-//                    }
-//                    catch (IOException 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 {
-//                        if (os != null)
-//                            try {
-//                                os.close();
-//                            }
-//                            catch (IOException ioe) {
-//                                throw new IgniteException(ioe);
-//                            }
-//                    }
-//                }
-//            }
-//        }, threadCnt);
-//
-//        long startTime = U.currentTimeMillis();
-//
-//        while (err.get() == null
-//                && createCtr.get() < 500
-//                && U.currentTimeMillis() - startTime < 60 * 1000)
-//            U.sleep(100);
-//
-//        stop.set(true);
-//
-//        fut.get();
-//
-//        awaitFileClose(igfs.asSecondary(), FILE);
-//
-//        if (err.get() != null) {
-//            X.println("Test failed: rethrowing first error: " + err.get());
-//
-//            throw err.get();
-//        }
-//
-//        checkFileContent(igfs, FILE, chunk);
+        final AtomicBoolean stop = new AtomicBoolean();
+
+        final AtomicInteger createCtr = new AtomicInteger(); // How many times the file was re-created.
+        final AtomicReference<Exception> err = new AtomicReference<>();
+
+        igfs.create(FILE, false).close();
+
+        int threadCnt = 50;
+
+        IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+            @SuppressWarnings("ThrowFromFinallyBlock")
+            @Override public void run() {
+                while (!stop.get() && err.get() == null) {
+                    IgfsOutputStream os = null;
+
+                    try {
+                        os = igfs.create(FILE, true);
+
+                        os.write(chunk);
+
+                        os.close();
+
+                        createCtr.incrementAndGet();
+                    }
+                    catch (IgniteException e) {
+                        // No-op.
+                    }
+                    catch (IOException 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 {
+                        if (os != null)
+                            try {
+                                os.close();
+                            }
+                            catch (IOException ioe) {
+                                throw new IgniteException(ioe);
+                            }
+                    }
+                }
+            }
+        }, threadCnt);
+
+        long startTime = U.currentTimeMillis();
+
+        while (err.get() == null
+                && createCtr.get() < 500
+                && U.currentTimeMillis() - startTime < 60 * 1000)
+            U.sleep(100);
+
+        stop.set(true);
+
+        fut.get();
+
+        awaitFileClose(igfs.asSecondary(), FILE);
+
+        if (err.get() != null) {
+            X.println("Test failed: rethrowing first error: " + err.get());
+
+            throw err.get();
+        }
+
+        checkFileContent(igfs, FILE, chunk);
     }
 
     /**


[11/40] ignite git commit: IGNITE-4001: Timeouts for threads in Ignite pools. This closes #1130.

Posted by av...@apache.org.
IGNITE-4001: Timeouts for threads in Ignite pools. This closes #1130.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 23461b8d33922772ef8e7217e9e87b3f3b0b37b1
Parents: a92f20b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 6 10:14:59 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 6 10:14:59 2016 +0300

----------------------------------------------------------------------
 .../configuration/IgniteConfiguration.java      | 18 +++--
 .../org/apache/ignite/internal/IgnitionEx.java  | 71 ++++++++++----------
 .../processors/igfs/IgfsThreadFactory.java      | 61 +++++++++++++++++
 3 files changed, 112 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/23461b8d/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 19b9a4d..73de470 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -149,29 +149,38 @@ public class IgniteConfiguration {
     public static final int DFLT_PUBLIC_THREAD_CNT = Math.max(8, AVAILABLE_PROC_CNT) * 2;
 
     /** Default keep alive time for public thread pool. */
+    @Deprecated
     public static final long DFLT_PUBLIC_KEEP_ALIVE_TIME = 0;
 
     /** Default limit of threads used for rebalance. */
     public static final int DFLT_REBALANCE_THREAD_POOL_SIZE = 1;
 
     /** Default max queue capacity of public thread pool. */
+    @Deprecated
     public static final int DFLT_PUBLIC_THREADPOOL_QUEUE_CAP = Integer.MAX_VALUE;
 
     /** Default size of system thread pool. */
     public static final int DFLT_SYSTEM_CORE_THREAD_CNT = DFLT_PUBLIC_THREAD_CNT;
 
     /** Default max size of system thread pool. */
+    @Deprecated
     public static final int DFLT_SYSTEM_MAX_THREAD_CNT = DFLT_PUBLIC_THREAD_CNT;
 
     /** Default keep alive time for system thread pool. */
+    @Deprecated
     public static final long DFLT_SYSTEM_KEEP_ALIVE_TIME = 0;
 
     /** Default keep alive time for utility thread pool. */
+    @Deprecated
     public static final long DFLT_UTILITY_KEEP_ALIVE_TIME = 10_000;
 
     /** Default max queue capacity of system thread pool. */
+    @Deprecated
     public static final int DFLT_SYSTEM_THREADPOOL_QUEUE_CAP = Integer.MAX_VALUE;
 
+    /** Default Ignite thread keep alive time. */
+    public static final long DFLT_THREAD_KEEP_ALIVE_TIME = 60_000L;
+
     /** Default size of peer class loading thread pool. */
     public static final int DFLT_P2P_THREAD_CNT = 2;
 
@@ -240,13 +249,13 @@ public class IgniteConfiguration {
     private int utilityCachePoolSize = DFLT_SYSTEM_CORE_THREAD_CNT;
 
     /** Utility cache pool keep alive time. */
-    private long utilityCacheKeepAliveTime = DFLT_UTILITY_KEEP_ALIVE_TIME;
+    private long utilityCacheKeepAliveTime = DFLT_THREAD_KEEP_ALIVE_TIME;
 
     /** Marshaller pool size. */
     private int marshCachePoolSize = DFLT_SYSTEM_CORE_THREAD_CNT;
 
     /** Marshaller pool keep alive time. */
-    private long marshCacheKeepAliveTime = DFLT_UTILITY_KEEP_ALIVE_TIME;
+    private long marshCacheKeepAliveTime = DFLT_THREAD_KEEP_ALIVE_TIME;
 
     /** P2P pool size. */
     private int p2pPoolSize = DFLT_P2P_THREAD_CNT;
@@ -492,6 +501,7 @@ public class IgniteConfiguration {
         cacheCfg = cfg.getCacheConfiguration();
         cacheKeyCfg = cfg.getCacheKeyConfiguration();
         cacheSanityCheckEnabled = cfg.isCacheSanityCheckEnabled();
+        callbackPoolSize = cfg.getAsyncCallbackPoolSize();
         connectorCfg = cfg.getConnectorConfiguration();
         classLdr = cfg.getClassLoader();
         clientMode = cfg.isClientMode();
@@ -792,7 +802,7 @@ public class IgniteConfiguration {
     /**
      * Keep alive time of thread pool that is in charge of processing utility cache messages.
      * <p>
-     * If not provided, executor service will have keep alive time {@link #DFLT_UTILITY_KEEP_ALIVE_TIME}.
+     * If not provided, executor service will have keep alive time {@link #DFLT_THREAD_KEEP_ALIVE_TIME}.
      *
      * @return Thread pool keep alive time (in milliseconds) to be used in grid for utility cache messages.
      */
@@ -814,7 +824,7 @@ public class IgniteConfiguration {
     /**
      * Keep alive time of thread pool that is in charge of processing marshaller messages.
      * <p>
-     * If not provided, executor service will have keep alive time {@link #DFLT_UTILITY_KEEP_ALIVE_TIME}.
+     * If not provided, executor service will have keep alive time {@link #DFLT_THREAD_KEEP_ALIVE_TIME}.
      *
      * @return Thread pool keep alive time (in milliseconds) to be used in grid for marshaller messages.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/23461b8d/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 2914c7c..001f599 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -36,7 +36,6 @@ import java.util.Map.Entry;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -62,6 +61,7 @@ import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.TransactionConfiguration;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.igfs.IgfsThreadFactory;
 import org.apache.ignite.internal.processors.igfs.IgfsUtils;
 import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
@@ -119,10 +119,7 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_PUBLIC_KEEP_ALIVE_TIME;
-import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_PUBLIC_THREADPOOL_QUEUE_CAP;
-import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_SYSTEM_KEEP_ALIVE_TIME;
-import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_SYSTEM_THREADPOOL_QUEUE_CAP;
+import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_THREAD_KEEP_ALIVE_TIME;
 import static org.apache.ignite.internal.IgniteComponentType.SPRING;
 import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.RESTART_JVM;
 
@@ -1457,28 +1454,28 @@ public class IgnitionEx {
         private volatile IgniteKernal grid;
 
         /** Executor service. */
-        private ExecutorService execSvc;
+        private ThreadPoolExecutor execSvc;
 
         /** System executor service. */
-        private ExecutorService sysExecSvc;
+        private ThreadPoolExecutor sysExecSvc;
 
         /** Management executor service. */
-        private ExecutorService mgmtExecSvc;
+        private ThreadPoolExecutor mgmtExecSvc;
 
         /** P2P executor service. */
-        private ExecutorService p2pExecSvc;
+        private ThreadPoolExecutor p2pExecSvc;
 
         /** IGFS executor service. */
-        private ExecutorService igfsExecSvc;
+        private ThreadPoolExecutor igfsExecSvc;
 
         /** REST requests executor service. */
-        private ExecutorService restExecSvc;
+        private ThreadPoolExecutor restExecSvc;
 
         /** Utility cache executor service. */
-        private ExecutorService utilityCacheExecSvc;
+        private ThreadPoolExecutor utilityCacheExecSvc;
 
         /** Marshaller cache executor service. */
-        private ExecutorService marshCacheExecSvc;
+        private ThreadPoolExecutor marshCacheExecSvc;
 
         /** Continuous query executor service. */
         private IgniteStripedThreadPoolExecutor callbackExecSvc;
@@ -1642,12 +1639,10 @@ public class IgnitionEx {
                 cfg.getGridName(),
                 cfg.getPublicThreadPoolSize(),
                 cfg.getPublicThreadPoolSize(),
-                DFLT_PUBLIC_KEEP_ALIVE_TIME,
-                new LinkedBlockingQueue<Runnable>(DFLT_PUBLIC_THREADPOOL_QUEUE_CAP));
+                DFLT_THREAD_KEEP_ALIVE_TIME,
+                new LinkedBlockingQueue<Runnable>());
 
-            if (!myCfg.isClientMode())
-                // Pre-start all threads as they are guaranteed to be needed.
-                ((ThreadPoolExecutor)execSvc).prestartAllCoreThreads();
+            execSvc.allowCoreThreadTimeOut(true);
 
             // Note that since we use 'LinkedBlockingQueue', number of
             // maximum threads has no effect.
@@ -1656,11 +1651,10 @@ public class IgnitionEx {
                 cfg.getGridName(),
                 cfg.getSystemThreadPoolSize(),
                 cfg.getSystemThreadPoolSize(),
-                DFLT_SYSTEM_KEEP_ALIVE_TIME,
-                new LinkedBlockingQueue<Runnable>(DFLT_SYSTEM_THREADPOOL_QUEUE_CAP));
+                DFLT_THREAD_KEEP_ALIVE_TIME,
+                new LinkedBlockingQueue<Runnable>());
 
-            // Pre-start all threads as they are guaranteed to be needed.
-            ((ThreadPoolExecutor)sysExecSvc).prestartAllCoreThreads();
+            sysExecSvc.allowCoreThreadTimeOut(true);
 
             // Note that since we use 'LinkedBlockingQueue', number of
             // maximum threads has no effect.
@@ -1671,9 +1665,11 @@ public class IgnitionEx {
                 cfg.getGridName(),
                 cfg.getManagementThreadPoolSize(),
                 cfg.getManagementThreadPoolSize(),
-                0,
+                DFLT_THREAD_KEEP_ALIVE_TIME,
                 new LinkedBlockingQueue<Runnable>());
 
+            mgmtExecSvc.allowCoreThreadTimeOut(true);
+
             // Note that since we use 'LinkedBlockingQueue', number of
             // maximum threads has no effect.
             // Note, that we do not pre-start threads here as class loading pool may
@@ -1683,20 +1679,21 @@ public class IgnitionEx {
                 cfg.getGridName(),
                 cfg.getPeerClassLoadingThreadPoolSize(),
                 cfg.getPeerClassLoadingThreadPoolSize(),
-                0,
+                DFLT_THREAD_KEEP_ALIVE_TIME,
                 new LinkedBlockingQueue<Runnable>());
 
+            p2pExecSvc.allowCoreThreadTimeOut(true);
+
             // Note that we do not pre-start threads here as igfs pool may not be needed.
             igfsExecSvc = new IgniteThreadPoolExecutor(
-                "igfs",
-                cfg.getGridName(),
                 cfg.getIgfsThreadPoolSize(),
                 cfg.getIgfsThreadPoolSize(),
-                0,
-                new LinkedBlockingQueue<Runnable>());
+                DFLT_THREAD_KEEP_ALIVE_TIME,
+                new LinkedBlockingQueue<Runnable>(),
+                new IgfsThreadFactory(cfg.getGridName(), "igfs"),
+                null /* Abort policy will be used. */);
 
-            // Pre-start all threads to avoid HadoopClassLoader leaks.
-            ((ThreadPoolExecutor)igfsExecSvc).prestartAllCoreThreads();
+            igfsExecSvc.allowCoreThreadTimeOut(true);
 
             // Note that we do not pre-start threads here as this pool may not be needed.
             callbackExecSvc = new IgniteStripedThreadPoolExecutor(
@@ -1710,9 +1707,11 @@ public class IgnitionEx {
                     myCfg.getGridName(),
                     myCfg.getConnectorConfiguration().getThreadPoolSize(),
                     myCfg.getConnectorConfiguration().getThreadPoolSize(),
-                    ConnectorConfiguration.DFLT_KEEP_ALIVE_TIME,
-                    new LinkedBlockingQueue<Runnable>(ConnectorConfiguration.DFLT_THREADPOOL_QUEUE_CAP)
+                    DFLT_THREAD_KEEP_ALIVE_TIME,
+                    new LinkedBlockingQueue<Runnable>()
                 );
+
+                restExecSvc.allowCoreThreadTimeOut(true);
             }
 
             utilityCacheExecSvc = new IgniteThreadPoolExecutor(
@@ -1721,7 +1720,9 @@ public class IgnitionEx {
                 myCfg.getUtilityCacheThreadPoolSize(),
                 myCfg.getUtilityCacheThreadPoolSize(),
                 myCfg.getUtilityCacheKeepAliveTime(),
-                new LinkedBlockingQueue<Runnable>(DFLT_SYSTEM_THREADPOOL_QUEUE_CAP));
+                new LinkedBlockingQueue<Runnable>());
+
+            utilityCacheExecSvc.allowCoreThreadTimeOut(true);
 
             marshCacheExecSvc = new IgniteThreadPoolExecutor(
                 "marshaller-cache",
@@ -1729,7 +1730,9 @@ public class IgnitionEx {
                 myCfg.getMarshallerCacheThreadPoolSize(),
                 myCfg.getMarshallerCacheThreadPoolSize(),
                 myCfg.getMarshallerCacheKeepAliveTime(),
-                new LinkedBlockingQueue<Runnable>(DFLT_SYSTEM_THREADPOOL_QUEUE_CAP));
+                new LinkedBlockingQueue<Runnable>());
+
+            marshCacheExecSvc.allowCoreThreadTimeOut(true);
 
             // Register Ignite MBean for current grid instance.
             registerFactoryMbean(myCfg.getMBeanServer());

http://git-wip-us.apache.org/repos/asf/ignite/blob/23461b8d/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsThreadFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsThreadFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsThreadFactory.java
new file mode 100644
index 0000000..32cab0f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsThreadFactory.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.internal.processors.hadoop.HadoopClassLoader;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.thread.IgniteThreadFactory;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Special thread factory used only for IGFS pool which prevents {@link HadoopClassLoader} leak into
+ * {@code Thread.contextClassLoader} field. To achieve this we switch context class loader back and forth when
+ * creating threads.
+ */
+public class IgfsThreadFactory extends IgniteThreadFactory {
+    /**
+     * Constructor.
+     *
+     * @param gridName Grid name.
+     * @param threadName Thread name.
+     */
+    public IgfsThreadFactory(String gridName, String threadName) {
+        super(gridName, threadName);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Thread newThread(@NotNull Runnable r) {
+        Thread curThread = Thread.currentThread();
+
+        ClassLoader oldLdr = curThread.getContextClassLoader();
+
+        curThread.setContextClassLoader(IgfsThreadFactory.class.getClassLoader());
+
+        try {
+            return super.newThread(r);
+        }
+        finally {
+            curThread.setContextClassLoader(oldLdr);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(IgfsThreadFactory.class, this);
+    }
+}


[25/40] ignite git commit: IGNITE-3875: Added separate thread pool for data streamer. This closes #1067.

Posted by av...@apache.org.
IGNITE-3875: Added separate thread pool for data streamer. This closes #1067.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: f597aff1bdf65d3d430cf85c9932391a72c2d7dc
Parents: 0659beb
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Wed Oct 12 15:44:08 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Oct 12 15:44:08 2016 +0300

----------------------------------------------------------------------
 .../configuration/IgniteConfiguration.java      | 31 +++++++
 .../ignite/internal/GridKernalContext.java      |  7 ++
 .../ignite/internal/GridKernalContextImpl.java  | 12 +++
 .../apache/ignite/internal/IgniteKernal.java    |  3 +
 .../org/apache/ignite/internal/IgnitionEx.java  | 20 +++-
 .../managers/communication/GridIoManager.java   |  2 +
 .../managers/communication/GridIoPolicy.java    |  3 +
 .../closure/GridClosureProcessor.java           |  3 +-
 .../datastreamer/DataStreamProcessor.java       | 82 +++++++++++++++--
 .../datastreamer/DataStreamerImpl.java          | 31 +------
 .../internal/processors/pool/PoolProcessor.java |  3 +
 .../DataStreamProcessorSelfTest.java            | 97 ++++++++++++++++++++
 .../junits/GridTestKernalContext.java           | 12 +--
 13 files changed, 262 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 73de470..412ecbf 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -148,6 +148,9 @@ public class IgniteConfiguration {
     /** Default core size of public thread pool. */
     public static final int DFLT_PUBLIC_THREAD_CNT = Math.max(8, AVAILABLE_PROC_CNT) * 2;
 
+    /** Default size of data streamer thread pool. */
+    public static final int DFLT_DATA_STREAMER_POOL_SIZE = DFLT_PUBLIC_THREAD_CNT;
+
     /** Default keep alive time for public thread pool. */
     @Deprecated
     public static final long DFLT_PUBLIC_KEEP_ALIVE_TIME = 0;
@@ -245,6 +248,9 @@ public class IgniteConfiguration {
     /** IGFS pool size. */
     private int igfsPoolSize = AVAILABLE_PROC_CNT;
 
+    /** Data stream pool size. */
+    private int dataStreamerPoolSize = DFLT_DATA_STREAMER_POOL_SIZE;
+
     /** Utility cache pool size. */
     private int utilityCachePoolSize = DFLT_SYSTEM_CORE_THREAD_CNT;
 
@@ -508,6 +514,7 @@ public class IgniteConfiguration {
         clockSyncFreq = cfg.getClockSyncFrequency();
         clockSyncSamples = cfg.getClockSyncSamples();
         consistentId = cfg.getConsistentId();
+        dataStreamerPoolSize = cfg.getDataStreamerThreadPoolSize();
         deployMode = cfg.getDeploymentMode();
         discoStartupDelay = cfg.getDiscoveryStartupDelay();
         failureDetectionTimeout = cfg.getFailureDetectionTimeout();
@@ -789,6 +796,17 @@ public class IgniteConfiguration {
     }
 
     /**
+     * Size of thread pool that is in charge of processing data stream messages.
+     * <p>
+     * If not provided, executor service will have size {@link #DFLT_DATA_STREAMER_POOL_SIZE}.
+     *
+     * @return Thread pool size to be used for data stream messages.
+     */
+    public int getDataStreamerThreadPoolSize() {
+        return dataStreamerPoolSize;
+    }
+
+    /**
      * Default size of thread pool that is in charge of processing utility cache messages.
      * <p>
      * If not provided, executor service will have size {@link #DFLT_SYSTEM_CORE_THREAD_CNT}.
@@ -912,6 +930,19 @@ public class IgniteConfiguration {
     }
 
     /**
+     * Set thread pool size that will be used to process data stream messages.
+     *
+     * @param poolSize Executor service to use for data stream messages.
+     * @see IgniteConfiguration#getDataStreamerThreadPoolSize()
+     * @return {@code this} for chaining.
+     */
+    public IgniteConfiguration setDataStreamerThreadPoolSize(int poolSize) {
+        dataStreamerPoolSize = poolSize;
+
+        return this;
+    }
+
+    /**
      * Sets default thread pool size that will be used to process utility cache messages.
      *
      * @param poolSize Default executor service size to use for utility cache messages.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index e608af2..178239b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@ -532,6 +532,13 @@ public interface GridKernalContext extends Iterable<GridComponent> {
     public ExecutorService getIgfsExecutorService();
 
     /**
+     * Executor service that is in charge of processing data stream messages.
+     *
+     * @return Thread pool implementation to be used for data stream messages.
+     */
+    public ExecutorService getDataStreamerExecutorService();
+
+    /**
      * Should return an instance of fully configured thread pool to be used for
      * processing of client messages (REST requests).
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index ddef345..1a9663b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -312,6 +312,10 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
 
     /** */
     @GridToStringExclude
+    private ExecutorService dataStreamExecSvc;
+
+    /** */
+    @GridToStringExclude
     protected ExecutorService restExecSvc;
 
     /** */
@@ -380,6 +384,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
      * @param p2pExecSvc P2P executor service.
      * @param mgmtExecSvc Management executor service.
      * @param igfsExecSvc IGFS executor service.
+     * @param dataStreamExecSvc data stream executor service.
      * @param restExecSvc REST executor service.
      * @param affExecSvc Affinity executor service.
      * @param plugins Plugin providers.
@@ -398,6 +403,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         ExecutorService p2pExecSvc,
         ExecutorService mgmtExecSvc,
         ExecutorService igfsExecSvc,
+        ExecutorService dataStreamExecSvc,
         ExecutorService restExecSvc,
         ExecutorService affExecSvc,
         IgniteStripedThreadPoolExecutor callbackExecSvc,
@@ -416,6 +422,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         this.p2pExecSvc = p2pExecSvc;
         this.mgmtExecSvc = mgmtExecSvc;
         this.igfsExecSvc = igfsExecSvc;
+        this.dataStreamExecSvc = dataStreamExecSvc;
         this.restExecSvc = restExecSvc;
         this.affExecSvc = affExecSvc;
         this.callbackExecSvc = callbackExecSvc;
@@ -956,6 +963,11 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
     }
 
     /** {@inheritDoc} */
+    @Override public ExecutorService getDataStreamerExecutorService() {
+        return dataStreamExecSvc;
+    }
+
+    /** {@inheritDoc} */
     @Override public ExecutorService getRestExecutorService() {
         return restExecSvc;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 586215a..e838dd2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -666,6 +666,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
      * @param p2pExecSvc P2P executor service.
      * @param mgmtExecSvc Management executor service.
      * @param igfsExecSvc IGFS executor service.
+     * @param dataStreamExecSvc data stream executor service.
      * @param restExecSvc Reset executor service.
      * @param affExecSvc Affinity executor service.
      * @param errHnd Error handler to use for notification about startup problems.
@@ -680,6 +681,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         ExecutorService p2pExecSvc,
         ExecutorService mgmtExecSvc,
         ExecutorService igfsExecSvc,
+        ExecutorService dataStreamExecSvc,
         ExecutorService restExecSvc,
         ExecutorService affExecSvc,
         IgniteStripedThreadPoolExecutor callbackExecSvc,
@@ -786,6 +788,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                 p2pExecSvc,
                 mgmtExecSvc,
                 igfsExecSvc,
+                dataStreamExecSvc,
                 restExecSvc,
                 affExecSvc,
                 callbackExecSvc,

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index a6860b3..104599c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1468,6 +1468,9 @@ public class IgnitionEx {
         /** IGFS executor service. */
         private ThreadPoolExecutor igfsExecSvc;
 
+        /** Data streamer executor service. */
+        private ThreadPoolExecutor dataStreamerExecSvc;
+
         /** REST requests executor service. */
         private ThreadPoolExecutor restExecSvc;
 
@@ -1687,6 +1690,17 @@ public class IgnitionEx {
 
             p2pExecSvc.allowCoreThreadTimeOut(true);
 
+            // Note that we do not pre-start threads here as this pool may not be needed.
+            dataStreamerExecSvc = new IgniteThreadPoolExecutor(
+                "data-streamer",
+                cfg.getGridName(),
+                cfg.getDataStreamerThreadPoolSize(),
+                cfg.getDataStreamerThreadPoolSize(),
+                DFLT_THREAD_KEEP_ALIVE_TIME,
+                new LinkedBlockingQueue<Runnable>());
+
+            dataStreamerExecSvc.allowCoreThreadTimeOut(true);
+
             // Note that we do not pre-start threads here as igfs pool may not be needed.
             igfsExecSvc = new IgniteThreadPoolExecutor(
                 cfg.getIgfsThreadPoolSize(),
@@ -1759,7 +1773,7 @@ public class IgnitionEx {
                 grid = grid0;
 
                 grid0.start(myCfg, utilityCacheExecSvc, marshCacheExecSvc, execSvc, sysExecSvc, p2pExecSvc, mgmtExecSvc,
-                    igfsExecSvc, restExecSvc, affExecSvc, callbackExecSvc,
+                    igfsExecSvc, dataStreamerExecSvc, restExecSvc, affExecSvc, callbackExecSvc,
                     new CA() {
                         @Override public void apply() {
                             startLatch.countDown();
@@ -2377,6 +2391,10 @@ public class IgnitionEx {
 
             p2pExecSvc = null;
 
+            U.shutdownNow(getClass(), dataStreamerExecSvc, log);
+
+            dataStreamerExecSvc = null;
+
             U.shutdownNow(getClass(), igfsExecSvc, log);
 
             igfsExecSvc = null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index cd43318..ba41dab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -84,6 +84,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
 import static org.apache.ignite.internal.GridTopic.TOPIC_COMM_USER;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.AFFINITY_POOL;
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.DATA_STREAMER_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.IGFS_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.MANAGEMENT_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.MARSH_CACHE_POOL;
@@ -574,6 +575,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
                 case UTILITY_CACHE_POOL:
                 case MARSH_CACHE_POOL:
                 case IGFS_POOL:
+                case DATA_STREAMER_POOL:
                 {
                     if (msg.isOrdered())
                         processOrderedMessage(nodeId, msg, plc, msgC);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java
index 00590ba..71279d9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java
@@ -46,6 +46,9 @@ public class GridIoPolicy {
     /** Marshaller cache execution pool. */
     public static final byte IGFS_POOL = 7;
 
+    /** Data streamer execution pool. */
+    public static final byte DATA_STREAMER_POOL = 8;
+
     /**
      * Defines the range of reserved pools that are not available for plugins.
      * @param key The key.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
index d388584..4bd22c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
@@ -27,7 +27,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Callable;
-import java.util.concurrent.Executor;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.TimeUnit;
 import org.apache.ignite.IgniteCheckedException;
@@ -970,7 +969,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param plc Policy to choose executor pool.
      * @return Future.
      */
-    private <R> IgniteInternalFuture<R> callLocalSafe(Callable<R> c, byte plc) {
+    public  <R> IgniteInternalFuture<R> callLocalSafe(Callable<R> c, byte plc) {
         try {
             return callLocal(c, plc);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
index 7663735..bd33f62 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
@@ -21,10 +21,12 @@ import java.util.Collection;
 import java.util.UUID;
 import java.util.concurrent.DelayQueue;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.managers.communication.GridIoManager;
+import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.managers.communication.GridMessageListener;
 import org.apache.ignite.internal.managers.deployment.GridDeployment;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
@@ -35,6 +37,7 @@ import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.worker.GridWorker;
+import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.stream.StreamReceiver;
@@ -42,12 +45,23 @@ import org.apache.ignite.thread.IgniteThread;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.internal.GridTopic.TOPIC_DATASTREAM;
-import static org.apache.ignite.internal.managers.communication.GridIoPolicy.PUBLIC_POOL;
 
 /**
- *
+ * Data stream processor.
  */
 public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
+    /** Data streamer separate pool feature major version. */
+    private static final int DATA_STREAMER_POOL_MAJOR_VER = 1;
+
+    /** Data streamer separate pool feature minor version. */
+    private static final int DATA_STREAMER_POOL_MINOR_VER = 6;
+
+    /** Data streamer separate pool feature maintenance version. */
+    private static final int DATA_STREAMER_POOL_MAINTENANCE_VER = 10;
+
+    /** Default pool for data streamer messages processing. */
+    public static final byte DFLT_POLICY = GridIoPolicy.PUBLIC_POOL;
+
     /** Loaders map (access is not supposed to be highly concurrent). */
     private Collection<DataStreamerImpl> ldrs = new GridConcurrentHashSet<>();
 
@@ -218,13 +232,15 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
                 IgniteInternalFuture<?> fut = ctx.cache().context().exchange().affinityReadyFuture(rmtAffVer);
 
                 if (fut != null && !fut.isDone()) {
+                    final byte plc = threadIoPolicy();
+
                     fut.listen(new CI1<IgniteInternalFuture<?>>() {
                         @Override public void apply(IgniteInternalFuture<?> t) {
                             ctx.closure().runLocalSafe(new Runnable() {
                                 @Override public void run() {
                                     processRequest(nodeId, req);
                                 }
-                            }, false);
+                            }, plc);
                         }
                     });
 
@@ -340,12 +356,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
         DataStreamerResponse res = new DataStreamerResponse(reqId, errBytes, forceLocDep);
 
         try {
-            Byte plc = GridIoManager.currentPolicy();
-
-            if (plc == null)
-                plc = PUBLIC_POOL;
-
-            ctx.io().send(nodeId, resTopic, res, plc);
+            ctx.io().send(nodeId, resTopic, res, threadIoPolicy());
         }
         catch (IgniteCheckedException e) {
             if (ctx.discovery().alive(nodeId))
@@ -355,6 +366,59 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
         }
     }
 
+    /**
+     * Get IO policy.
+     *
+     * @return IO policy.
+     */
+    private static byte threadIoPolicy() {
+        Byte plc = GridIoManager.currentPolicy();
+
+        if (plc == null)
+            plc = DFLT_POLICY;
+
+        return plc;
+    }
+
+    /**
+     * Get IO policy for particular node.
+     *
+     * @param node Node.
+     * @return Policy.
+     */
+    public static byte ioPolicy(ClusterNode node) {
+        assert node != null;
+
+        if (node.isLocal() || node.version().greaterThanEqual(
+            DATA_STREAMER_POOL_MAJOR_VER,
+            DATA_STREAMER_POOL_MINOR_VER,
+            DATA_STREAMER_POOL_MAINTENANCE_VER))
+            return GridIoPolicy.DATA_STREAMER_POOL;
+        else
+            return DFLT_POLICY;
+    }
+
+    /**
+     * Get IO policy for particular node with provided resolver.
+     *
+     * @param rslvr Resolver.
+     * @param node Node.
+     * @return IO policy.
+     */
+    public static byte ioPolicy(@Nullable IgniteClosure<ClusterNode, Byte> rslvr, ClusterNode node) {
+        assert node != null;
+
+        Byte res = null;
+
+        if (rslvr != null)
+            res = rslvr.apply(node);
+
+        if (res == null)
+            res = ioPolicy(node);
+
+        return res;
+    }
+
     /** {@inheritDoc} */
     @Override public void printMemoryStats() {
         X.println(">>>");

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index c2f226c..46f6380 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -39,7 +39,6 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.cache.CacheException;
 import javax.cache.expiry.ExpiryPolicy;
-
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
@@ -60,7 +59,6 @@ import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
-import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.managers.communication.GridMessageListener;
 import org.apache.ignite.internal.managers.deployment.GridDeployment;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
@@ -106,16 +104,12 @@ import org.jsr166.ConcurrentHashMap8;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
 import static org.apache.ignite.internal.GridTopic.TOPIC_DATASTREAM;
-import static org.apache.ignite.internal.managers.communication.GridIoPolicy.PUBLIC_POOL;
 
 /**
  * Data streamer implementation.
  */
 @SuppressWarnings("unchecked")
 public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed {
-    /** Default policy reoslver. */
-    private static final DefaultIoPolicyResolver DFLT_IO_PLC_RSLVR = new DefaultIoPolicyResolver();
-
     /** Isolated receiver. */
     private static final StreamReceiver ISOLATED_UPDATER = new IsolatedUpdater();
 
@@ -126,7 +120,7 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
     private byte[] updaterBytes;
 
     /** IO policy resovler for data load request. */
-    private IgniteClosure<ClusterNode, Byte> ioPlcRslvr = DFLT_IO_PLC_RSLVR;
+    private IgniteClosure<ClusterNode, Byte> ioPlcRslvr;
 
     /** Max remap count before issuing an error. */
     private static final int DFLT_MAX_REMAP_CNT = 32;
@@ -1313,14 +1307,12 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
 
             IgniteInternalFuture<Object> fut;
 
-            Byte plc = ioPlcRslvr.apply(node);
-
-            if (plc == null)
-                plc = PUBLIC_POOL;
+            byte plc = DataStreamProcessor.ioPolicy(ioPlcRslvr, node);
 
-            if (isLocNode && plc == GridIoPolicy.PUBLIC_POOL) {
+            if (isLocNode) {
                 fut = ctx.closure().callLocalSafe(
-                    new DataStreamerUpdateJob(ctx, log, cacheName, entries, false, skipStore, keepBinary, rcvr), false);
+                    new DataStreamerUpdateJob(ctx, log, cacheName, entries, false, skipStore, keepBinary, rcvr),
+                    plc);
 
                 locFuts.add(fut);
 
@@ -1684,19 +1676,6 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
     }
 
     /**
-     * Default IO policy resolver.
-     */
-    private static class DefaultIoPolicyResolver implements IgniteClosure<ClusterNode, Byte> {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** {@inheritDoc} */
-        @Override public Byte apply(ClusterNode gridNode) {
-            return PUBLIC_POOL;
-        }
-    }
-
-    /**
      * Key object wrapper. Using identity equals prevents slow down in case of hash code collision.
      */
     private static class KeyCacheObjectWrapper {

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
index 41e805e..5d38e16 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
@@ -123,6 +123,9 @@ public class PoolProcessor extends GridProcessorAdapter {
 
                 return ctx.getIgfsExecutorService();
 
+            case GridIoPolicy.DATA_STREAMER_POOL:
+                return ctx.getDataStreamerExecutorService();
+
             default: {
                 if (plc < 0)
                     throw new IgniteCheckedException("Policy cannot be negative: " + plc);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java
index 9fedc35..401b09c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java
@@ -33,6 +33,7 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.affinity.Affinity;
@@ -49,6 +50,7 @@ import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteClosure;
@@ -59,6 +61,7 @@ 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.stream.StreamReceiver;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.jetbrains.annotations.Nullable;
 
@@ -949,6 +952,100 @@ public class DataStreamProcessorSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testLocalDataStreamerDedicatedThreadPool() throws Exception {
+        try {
+            useCache = true;
+
+            Ignite ignite = startGrid(1);
+
+            final IgniteCache<String, String> cache = ignite.cache(null);
+
+            IgniteDataStreamer<String, String> ldr = ignite.dataStreamer(null);
+            try {
+                ldr.receiver(new StreamReceiver<String, String>() {
+                    @Override public void receive(IgniteCache<String, String> cache,
+                        Collection<Map.Entry<String, String>> entries) throws IgniteException {
+                        String threadName = Thread.currentThread().getName();
+
+                        cache.put("key", threadName);
+                    }
+                });
+                ldr.addData("key", "value");
+
+                ldr.tryFlush();
+
+                GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                    @Override public boolean apply() {
+                        return cache.get("key") != null;
+                    }
+                }, 3_000);
+            }
+            finally {
+                ldr.close(true);
+            }
+
+            assertNotNull(cache.get("key"));
+
+            assertTrue(cache.get("key").startsWith("data-streamer"));
+
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRemoteDataStreamerDedicatedThreadPool() throws Exception {
+        try {
+            useCache = true;
+
+            Ignite ignite = startGrid(1);
+
+            useCache = false;
+
+            Ignite client = startGrid(0);
+
+            final IgniteCache<String, String> cache = ignite.cache(null);
+
+            IgniteDataStreamer<String, String> ldr = client.dataStreamer(null);
+            try {
+                ldr.receiver(new StreamReceiver<String, String>() {
+                    @Override public void receive(IgniteCache<String, String> cache,
+                        Collection<Map.Entry<String, String>> entries) throws IgniteException {
+                        String threadName = Thread.currentThread().getName();
+
+                        cache.put("key", threadName);
+                    }
+                });
+
+                ldr.addData("key", "value");
+
+                ldr.tryFlush();
+
+                GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                    @Override public boolean apply() {
+                        return cache.get("key") != null;
+                    }
+                }, 3_000);
+            }
+            finally {
+                ldr.close(true);
+            }
+
+            assertNotNull(cache.get("key"));
+
+            assertTrue(cache.get("key").startsWith("data-streamer"));
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
      *
      */
     public static class TestObject {

http://git-wip-us.apache.org/repos/asf/ignite/blob/f597aff1/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
index cba67e0..1d72d46 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
@@ -62,6 +62,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
                 null,
                 null,
                 null,
+                null,
                 U.allPluginProviders());
 
         GridTestUtils.setFieldValue(grid(), "cfg", config());
@@ -95,11 +96,6 @@ public class GridTestKernalContext extends GridKernalContextImpl {
         }
     }
 
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridTestKernalContext.class, this, super.toString());
-    }
-
     /**
      * Sets system executor service.
      *
@@ -109,7 +105,6 @@ public class GridTestKernalContext extends GridKernalContextImpl {
         this.sysExecSvc = sysExecSvc;
     }
 
-
     /**
      * Sets executor service.
      *
@@ -118,4 +113,9 @@ public class GridTestKernalContext extends GridKernalContextImpl {
     public void setExecutorService(ExecutorService execSvc){
         this.execSvc = execSvc;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(GridTestKernalContext.class, this, super.toString());
+    }
 }


[26/40] ignite git commit: IGNITE-2355: Hadoop: added ability to configure multiple job tracker addresses. This closes #1153.

Posted by av...@apache.org.
IGNITE-2355: Hadoop: added ability to configure multiple job tracker addresses. This closes #1153.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 2ab094e08373dc6667af44d48a38b4f044953a79
Parents: f597aff
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Wed Oct 12 16:48:51 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Oct 12 16:48:51 2016 +0300

----------------------------------------------------------------------
 .../ignite/testframework/GridTestUtils.java     |  37 +++
 .../IgniteHadoopClientProtocolProvider.java     |  53 ++--
 .../hadoop/impl/HadoopAbstractSelfTest.java     |   4 +-
 ...opClientProtocolMultipleServersSelfTest.java | 307 +++++++++++++++++++
 .../testsuites/IgniteHadoopTestSuite.java       |   2 +
 5 files changed, 381 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2ab094e0/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index 524c643..b3ce46b 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -264,6 +264,43 @@ public final class GridTestUtils {
     }
 
     /**
+     * Checks whether callable throws an exception with specified cause.
+     *
+     * @param log Logger (optional).
+     * @param call Callable.
+     * @param cls Exception class.
+     * @param msg Exception message (optional). If provided exception message
+     *      and this message should be equal.
+     * @return Thrown throwable.
+     */
+    public static Throwable assertThrowsAnyCause(@Nullable IgniteLogger log, Callable<?> call,
+        Class<? extends Throwable> cls, @Nullable String msg) {
+        assert call != null;
+        assert cls != null;
+
+        try {
+            call.call();
+        }
+        catch (Throwable e) {
+            Throwable t = e;
+
+            while (t != null) {
+                if (cls == t.getClass() && (msg == null || (t.getMessage() != null || t.getMessage().contains(msg)))) {
+                    log.info("Caught expected exception: " + t.getMessage());
+
+                    return t;
+                }
+
+                t = t.getCause();
+            }
+
+            fail("Unexpected exception", e);
+        }
+
+        throw new AssertionError("Exception has not been thrown.");
+    }
+
+    /**
      * Checks whether callable throws expected exception or its child or not.
      *
      * @param log Logger (optional).

http://git-wip-us.apache.org/repos/asf/ignite/blob/2ab094e0/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopClientProtocolProvider.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopClientProtocolProvider.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopClientProtocolProvider.java
index 343b5ed..1efe625 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopClientProtocolProvider.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/mapreduce/IgniteHadoopClientProtocolProvider.java
@@ -17,11 +17,18 @@
 
 package org.apache.ignite.hadoop.mapreduce;
 
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.ConcurrentHashMap;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.MRConfig;
 import org.apache.hadoop.mapreduce.protocol.ClientProtocol;
 import org.apache.hadoop.mapreduce.protocol.ClientProtocolProvider;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.client.GridClient;
 import org.apache.ignite.internal.client.GridClientConfiguration;
@@ -32,11 +39,6 @@ import org.apache.ignite.internal.processors.hadoop.impl.proto.HadoopClientProto
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
 import org.apache.ignite.internal.util.typedef.F;
 
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Collections;
-import java.util.concurrent.ConcurrentHashMap;
-
 import static org.apache.ignite.internal.client.GridClientProtocol.TCP;
 
 
@@ -53,17 +55,27 @@ public class IgniteHadoopClientProtocolProvider extends ClientProtocolProvider {
     /** {@inheritDoc} */
     @Override public ClientProtocol create(Configuration conf) throws IOException {
         if (FRAMEWORK_NAME.equals(conf.get(MRConfig.FRAMEWORK_NAME))) {
-            String addr = conf.get(MRConfig.MASTER_ADDRESS);
+            Collection<String> addrs = conf.getTrimmedStringCollection(MRConfig.MASTER_ADDRESS);
 
-            if (F.isEmpty(addr))
-                throw new IOException("Failed to create client protocol because server address is not specified (is " +
-                    MRConfig.MASTER_ADDRESS + " property set?).");
+            if (F.isEmpty(addrs))
+                throw new IOException("Failed to create client protocol because Ignite node addresses are not " +
+                    "specified (did you set " + MRConfig.MASTER_ADDRESS + " property?).");
 
-            if (F.eq(addr, "local"))
+            if (F.contains(addrs, "local"))
                 throw new IOException("Local execution mode is not supported, please point " +
-                    MRConfig.MASTER_ADDRESS + " to real Ignite node.");
+                    MRConfig.MASTER_ADDRESS + " to real Ignite nodes.");
+
+            Collection<String> addrs0 = new ArrayList<>(addrs.size());
+
+            // Set up port by default if need
+            for (String addr : addrs) {
+                if (!addr.contains(":"))
+                    addrs0.add(addr + ':' + ConnectorConfiguration.DFLT_TCP_PORT);
+                else
+                    addrs0.add(addr);
+            }
 
-            return createProtocol(addr, conf);
+            return new HadoopClientProtocol(conf, client(conf.get(MRConfig.MASTER_ADDRESS), addrs0));
         }
 
         return null;
@@ -91,24 +103,25 @@ public class IgniteHadoopClientProtocolProvider extends ClientProtocolProvider {
      * @throws IOException If failed.
      */
     private static ClientProtocol createProtocol(String addr, Configuration conf) throws IOException {
-        return new HadoopClientProtocol(conf, client(addr));
+        return new HadoopClientProtocol(conf, client(addr, Collections.singletonList(addr)));
     }
 
     /**
      * Create client.
      *
-     * @param addr Endpoint address.
+     * @param clusterName Ignite cluster logical name.
+     * @param addrs Endpoint addresses.
      * @return Client.
      * @throws IOException If failed.
      */
-    private static GridClient client(String addr) throws IOException {
+    private static GridClient client(String clusterName, Collection<String> addrs) throws IOException {
         try {
-            IgniteInternalFuture<GridClient> fut = cliMap.get(addr);
+            IgniteInternalFuture<GridClient> fut = cliMap.get(clusterName);
 
             if (fut == null) {
                 GridFutureAdapter<GridClient> fut0 = new GridFutureAdapter<>();
 
-                IgniteInternalFuture<GridClient> oldFut = cliMap.putIfAbsent(addr, fut0);
+                IgniteInternalFuture<GridClient> oldFut = cliMap.putIfAbsent(clusterName, fut0);
 
                 if (oldFut != null)
                     return oldFut.get();
@@ -116,7 +129,7 @@ public class IgniteHadoopClientProtocolProvider extends ClientProtocolProvider {
                     GridClientConfiguration cliCfg = new GridClientConfiguration();
 
                     cliCfg.setProtocol(TCP);
-                    cliCfg.setServers(Collections.singletonList(addr));
+                    cliCfg.setServers(addrs);
                     cliCfg.setMarshaller(new GridClientJdkMarshaller());
                     cliCfg.setMaxConnectionIdleTime(24 * 60 * 60 * 1000L); // 1 day.
                     cliCfg.setDaemon(true);
@@ -131,7 +144,7 @@ public class IgniteHadoopClientProtocolProvider extends ClientProtocolProvider {
                     catch (GridClientException e) {
                         fut0.onDone(e);
 
-                        throw new IOException("Failed to establish connection with Ignite node: " + addr, e);
+                        throw new IOException("Failed to establish connection with Ignite: " + addrs, e);
                     }
                 }
             }
@@ -139,7 +152,7 @@ public class IgniteHadoopClientProtocolProvider extends ClientProtocolProvider {
                 return fut.get();
         }
         catch (IgniteCheckedException e) {
-            throw new IOException("Failed to establish connection with Ignite node: " + addr, e);
+            throw new IOException("Failed to establish connection with Ignite \u0441\u0434\u0433\u044b\u0435: " + addrs, e);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/2ab094e0/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopAbstractSelfTest.java
index 68009dd..12351c6 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopAbstractSelfTest.java
@@ -48,7 +48,7 @@ public abstract class HadoopAbstractSelfTest extends GridCommonAbstractTest {
     private static TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
     /** REST port. */
-    protected static final int REST_PORT = 11212;
+    protected static final int REST_PORT = ConnectorConfiguration.DFLT_TCP_PORT;
 
     /** IGFS name. */
     protected static final String igfsName = null;
@@ -185,7 +185,7 @@ public abstract class HadoopAbstractSelfTest extends GridCommonAbstractTest {
     /**
      * @return IGFS data cache configuration.
      */
-    private CacheConfiguration dataCacheConfiguration() {
+    protected CacheConfiguration dataCacheConfiguration() {
         CacheConfiguration cfg = new CacheConfiguration();
 
         cfg.setName(igfsDataCacheName);

http://git-wip-us.apache.org/repos/asf/ignite/blob/2ab094e0/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java
new file mode 100644
index 0000000..04747d0
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.impl.client;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.Callable;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.JobStatus;
+import org.apache.hadoop.mapreduce.MRConfig;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.OutputCommitter;
+import org.apache.hadoop.mapreduce.OutputFormat;
+import org.apache.hadoop.mapreduce.RecordWriter;
+import org.apache.hadoop.mapreduce.Reducer;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
+import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.hadoop.mapreduce.IgniteHadoopClientProtocolProvider;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.client.GridServerUnreachableException;
+import org.apache.ignite.internal.processors.hadoop.impl.HadoopAbstractSelfTest;
+import org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ * Hadoop client protocol configured with multiple ignite servers tests.
+ */
+@SuppressWarnings("ResultOfMethodCallIgnored")
+public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractSelfTest {
+    /** Input path. */
+    private static final String PATH_INPUT = "/input";
+
+    /** Job name. */
+    private static final String JOB_NAME = "myJob";
+
+    /** {@inheritDoc} */
+    @Override protected boolean igfsEnabled() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean restEnabled() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        startGrids(gridCount());
+
+        awaitPartitionMapExchange();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        super.afterTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheConfiguration dataCacheConfiguration() {
+        CacheConfiguration cfg = super.dataCacheConfiguration();
+
+        cfg.setBackups(1);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void beforeJob() throws Exception {
+        IgniteFileSystem igfs = grid(0).fileSystem(HadoopAbstractSelfTest.igfsName);
+
+        igfs.format();
+
+        igfs.mkdirs(new IgfsPath(PATH_INPUT));
+
+        try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(igfs.create(
+            new IgfsPath(PATH_INPUT + "/test.file"), true)))) {
+
+            bw.write("word");
+        }
+    }
+
+    /**
+     * Test job submission.
+     *
+     * @param conf Hadoop configuration.
+     * @throws Exception If failed.
+     */
+    public void checkJobSubmit(Configuration conf) throws Exception {
+        final Job job = Job.getInstance(conf);
+
+        job.setJobName(JOB_NAME);
+
+        job.setOutputKeyClass(Text.class);
+        job.setOutputValueClass(IntWritable.class);
+
+        job.setInputFormatClass(TextInputFormat.class);
+        job.setOutputFormatClass(OutFormat.class);
+
+        job.setMapperClass(TestMapper.class);
+        job.setReducerClass(TestReducer.class);
+
+        job.setNumReduceTasks(0);
+
+        FileInputFormat.setInputPaths(job, new Path(PATH_INPUT));
+
+        job.submit();
+
+        job.waitForCompletion(false);
+
+        assert job.getStatus().getState() == JobStatus.State.SUCCEEDED : job.getStatus().getState();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ConstantConditions")
+    public void testMultipleAddresses() throws Exception {
+        beforeJob();
+
+        stopGrid(0);
+
+        U.sleep(5000);
+
+        checkJobSubmit(configMultipleAddrs(gridCount()));
+
+        startGrid(0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings({"ConstantConditions", "ThrowableResultOfMethodCallIgnored"})
+    public void testSingleAddress() throws Exception {
+        stopGrid(0);
+
+        U.sleep(5000);
+
+        GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    checkJobSubmit(configSingleAddress());
+                    return null;
+                }
+            },
+            GridServerUnreachableException.class, "Failed to connect to any of the servers in list");
+
+        startGrid(0);
+
+        awaitPartitionMapExchange();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ConstantConditions")
+    public void testMixedAddrs() throws Exception {
+        beforeJob();
+
+        stopGrid(1);
+
+        U.sleep(5000);
+
+        checkJobSubmit(configMixed());
+
+        startGrid(1);
+
+        awaitPartitionMapExchange();
+    }
+
+    /**
+     * @return Configuration.
+     */
+    private Configuration configSingleAddress() {
+        Configuration conf = HadoopUtils.safeCreateConfiguration();
+
+        setupFileSystems(conf);
+
+        conf.set(MRConfig.FRAMEWORK_NAME, IgniteHadoopClientProtocolProvider.FRAMEWORK_NAME);
+        conf.set(MRConfig.MASTER_ADDRESS, "127.0.0.1:" + REST_PORT);
+
+        conf.set("fs.defaultFS", "igfs:///");
+
+        return conf;
+    }
+
+    /**
+     * @param serversCnt Count ov servers.
+     * @return Configuration.
+     */
+    private Configuration configMultipleAddrs(int serversCnt) {
+        Configuration conf = HadoopUtils.safeCreateConfiguration();
+
+        setupFileSystems(conf);
+
+        conf.set(MRConfig.FRAMEWORK_NAME, IgniteHadoopClientProtocolProvider.FRAMEWORK_NAME);
+
+        Collection<String> addrs = new ArrayList<>(serversCnt);
+
+        for (int i = 0; i < serversCnt; ++i)
+            addrs.add("127.0.0.1:" + Integer.toString(REST_PORT + i));
+
+        conf.set(MRConfig.MASTER_ADDRESS, F.concat(addrs, ","));
+
+        conf.set("fs.defaultFS", "igfs:///");
+
+        return conf;
+    }
+
+    /**
+     * @return Configuration.
+     */
+    private Configuration configMixed() {
+        Configuration conf = HadoopUtils.safeCreateConfiguration();
+
+        setupFileSystems(conf);
+
+        conf.set(MRConfig.FRAMEWORK_NAME, IgniteHadoopClientProtocolProvider.FRAMEWORK_NAME);
+
+        Collection<String> addrs = new ArrayList<>();
+
+        addrs.add("localhost");
+        addrs.add("127.0.0.1:" + Integer.toString(REST_PORT + 1));
+
+        conf.set(MRConfig.MASTER_ADDRESS, F.concat(addrs, ","));
+
+        conf.set("fs.defaultFS", "igfs:///");
+
+        return conf;
+    }
+
+    /**
+     * Test mapper.
+     */
+    public static class TestMapper extends Mapper<Object, Text, Text, IntWritable> {
+        /** {@inheritDoc} */
+        @Override public void map(Object key, Text val, Context ctx) throws IOException, InterruptedException {
+            // No-op.
+        }
+    }
+
+    /**
+     * Test reducer.
+     */
+    public static class TestReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
+
+        /** {@inheritDoc} */
+        @Override public void reduce(Text key, Iterable<IntWritable> values, Context ctx) throws IOException,
+            InterruptedException {
+            // No-op.
+        }
+    }
+
+    /**
+     * Test output formatter.
+     */
+    public static class OutFormat extends OutputFormat {
+        /** {@inheritDoc} */
+        @Override public RecordWriter getRecordWriter(TaskAttemptContext context) throws IOException,
+            InterruptedException {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void checkOutputSpecs(JobContext context) throws IOException, InterruptedException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public OutputCommitter getOutputCommitter(TaskAttemptContext context) throws IOException,
+            InterruptedException {
+            return null;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/2ab094e0/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
index bbd92d1..959bc59 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
@@ -24,6 +24,7 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.internal.processors.hadoop.HadoopTestClassLoader;
 import org.apache.ignite.internal.processors.hadoop.impl.client.HadoopClientProtocolEmbeddedSelfTest;
+import org.apache.ignite.internal.processors.hadoop.impl.client.HadoopClientProtocolMultipleServersSelfTest;
 import org.apache.ignite.internal.processors.hadoop.impl.client.HadoopClientProtocolSelfTest;
 import org.apache.ignite.internal.processors.hadoop.impl.HadoopTxConfigCacheTest;
 import org.apache.ignite.internal.processors.hadoop.impl.fs.KerberosHadoopFileSystemFactorySelfTest;
@@ -194,6 +195,7 @@ public class IgniteHadoopTestSuite extends TestSuite {
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopClientProtocolSelfTest.class.getName())));
         suite.addTest(new TestSuite(ldr.loadClass(HadoopClientProtocolEmbeddedSelfTest.class.getName())));
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopClientProtocolMultipleServersSelfTest.class.getName())));
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopCommandLineTest.class.getName())));
 


[29/40] ignite git commit: IGNITE-4034 Get rid of specialized methods in platform targets

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/jni/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/src/java.cpp b/modules/platforms/cpp/jni/src/java.cpp
index 56e042c..56fc4b1 100644
--- a/modules/platforms/cpp/jni/src/java.cpp
+++ b/modules/platforms/cpp/jni/src/java.cpp
@@ -214,10 +214,12 @@ namespace ignite
             JniMethod M_PLATFORM_PROCESSOR_GET_CACHE_NAMES = JniMethod("getCacheNames", "(J)V", false);
 
             const char* C_PLATFORM_TARGET = "org/apache/ignite/internal/processors/platform/PlatformTarget";
+            JniMethod M_PLATFORM_TARGET_IN_LONG_OUT_LONG = JniMethod("inLongOutLong", "(IJ)J", false);
             JniMethod M_PLATFORM_TARGET_IN_STREAM_OUT_LONG = JniMethod("inStreamOutLong", "(IJ)J", false);
             JniMethod M_PLATFORM_TARGET_IN_STREAM_OUT_OBJECT = JniMethod("inStreamOutObject", "(IJ)Ljava/lang/Object;", false);
             JniMethod M_PLATFORM_TARGET_IN_STREAM_OUT_STREAM = JniMethod("inStreamOutStream", "(IJJ)V", false);
             JniMethod M_PLATFORM_TARGET_IN_OBJECT_STREAM_OUT_STREAM = JniMethod("inObjectStreamOutStream", "(ILjava/lang/Object;JJ)V", false);
+            JniMethod M_PLATFORM_TARGET_IN_OBJECT_STREAM_OUT_OBJECT_STREAM = JniMethod("inObjectStreamOutObjectStream", "(ILjava/lang/Object;JJ)Ljava/lang/Object;", false);
             JniMethod M_PLATFORM_TARGET_OUT_LONG = JniMethod("outLong", "(I)J", false);
             JniMethod M_PLATFORM_TARGET_OUT_STREAM = JniMethod("outStream", "(IJ)V", false);
             JniMethod M_PLATFORM_TARGET_OUT_OBJECT = JniMethod("outObject", "(I)Ljava/lang/Object;", false);
@@ -226,72 +228,10 @@ namespace ignite
             JniMethod M_PLATFORM_TARGET_LISTEN_FUTURE_AND_GET = JniMethod("listenFutureAndGet", "(JI)Lorg/apache/ignite/internal/processors/platform/utils/PlatformListenable;", false);
             JniMethod M_PLATFORM_TARGET_LISTEN_FOR_OPERATION_AND_GET = JniMethod("listenFutureForOperationAndGet", "(JII)Lorg/apache/ignite/internal/processors/platform/utils/PlatformListenable;", false);
 
-            const char* C_PLATFORM_CLUSTER_GRP = "org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup";
-            JniMethod M_PLATFORM_CLUSTER_GRP_FOR_OTHERS = JniMethod("forOthers", "(Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;)Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
-            JniMethod M_PLATFORM_CLUSTER_GRP_FOR_REMOTES = JniMethod("forRemotes", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
-            JniMethod M_PLATFORM_CLUSTER_GRP_FOR_DAEMONS = JniMethod("forDaemons", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
-            JniMethod M_PLATFORM_CLUSTER_GRP_FOR_RANDOM = JniMethod("forRandom", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
-            JniMethod M_PLATFORM_CLUSTER_GRP_FOR_OLDEST = JniMethod("forOldest", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
-            JniMethod M_PLATFORM_CLUSTER_GRP_FOR_YOUNGEST = JniMethod("forYoungest", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
-            JniMethod M_PLATFORM_CLUSTER_GRP_RESET_METRICS = JniMethod("resetMetrics", "()V", false);
-
-            const char* C_PLATFORM_MESSAGING = "org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging";
-            JniMethod M_PLATFORM_MESSAGING_WITH_ASYNC = JniMethod("withAsync", "()Lorg/apache/ignite/internal/processors/platform/messaging/PlatformMessaging;", false);
-
-            const char* C_PLATFORM_COMPUTE = "org/apache/ignite/internal/processors/platform/compute/PlatformCompute";
-            JniMethod M_PLATFORM_COMPUTE_WITH_NO_FAILOVER = JniMethod("withNoFailover", "()V", false);
-            JniMethod M_PLATFORM_COMPUTE_WITH_TIMEOUT = JniMethod("withTimeout", "(J)V", false);
-            JniMethod M_PLATFORM_COMPUTE_EXECUTE_NATIVE = JniMethod("executeNative", "(JJ)Lorg/apache/ignite/internal/processors/platform/utils/PlatformListenable;", false);
-
-            const char* C_PLATFORM_CACHE = "org/apache/ignite/internal/processors/platform/cache/PlatformCache";
-            JniMethod M_PLATFORM_CACHE_WITH_SKIP_STORE = JniMethod("withSkipStore", "()Lorg/apache/ignite/internal/processors/platform/cache/PlatformCache;", false);
-            JniMethod M_PLATFORM_CACHE_WITH_NO_RETRIES = JniMethod("withNoRetries", "()Lorg/apache/ignite/internal/processors/platform/cache/PlatformCache;", false);
-            JniMethod M_PLATFORM_CACHE_WITH_EXPIRY_PLC = JniMethod("withExpiryPolicy", "(JJJ)Lorg/apache/ignite/internal/processors/platform/cache/PlatformCache;", false);
-            JniMethod M_PLATFORM_CACHE_WITH_ASYNC = JniMethod("withAsync", "()Lorg/apache/ignite/internal/processors/platform/cache/PlatformCache;", false);
-            JniMethod M_PLATFORM_CACHE_WITH_KEEP_PORTABLE = JniMethod("withKeepBinary", "()Lorg/apache/ignite/internal/processors/platform/cache/PlatformCache;", false);
-            JniMethod M_PLATFORM_CACHE_CLEAR = JniMethod("clear", "()V", false);
-            JniMethod M_PLATFORM_CACHE_REMOVE_ALL = JniMethod("removeAll", "()V", false);
-            JniMethod M_PLATFORM_CACHE_ITERATOR = JniMethod("iterator", "()Lorg/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator;", false);
-            JniMethod M_PLATFORM_CACHE_LOCAL_ITERATOR = JniMethod("localIterator", "(I)Lorg/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator;", false);
-            JniMethod M_PLATFORM_CACHE_ENTER_LOCK = JniMethod("enterLock", "(J)V", false);
-            JniMethod M_PLATFORM_CACHE_EXIT_LOCK = JniMethod("exitLock", "(J)V", false);
-            JniMethod M_PLATFORM_CACHE_TRY_ENTER_LOCK = JniMethod("tryEnterLock", "(JJ)Z", false);
-            JniMethod M_PLATFORM_CACHE_CLOSE_LOCK = JniMethod("closeLock", "(J)V", false);
-            JniMethod M_PLATFORM_CACHE_REBALANCE = JniMethod("rebalance", "(J)V", false);
-            JniMethod M_PLATFORM_CACHE_SIZE = JniMethod("size", "(IZ)I", false);
-
-            const char* C_PLATFORM_AFFINITY = "org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity";
-            JniMethod C_PLATFORM_AFFINITY_PARTITIONS = JniMethod("partitions", "()I", false);
-
-            const char* C_PLATFORM_DATA_STREAMER = "org/apache/ignite/internal/processors/platform/datastreamer/PlatformDataStreamer";
-            JniMethod M_PLATFORM_DATA_STREAMER_LISTEN_TOPOLOGY = JniMethod("listenTopology", "(J)V", false);
-            JniMethod M_PLATFORM_DATA_STREAMER_GET_ALLOW_OVERWRITE = JniMethod("allowOverwrite", "()Z", false);
-            JniMethod M_PLATFORM_DATA_STREAMER_SET_ALLOW_OVERWRITE = JniMethod("allowOverwrite", "(Z)V", false);
-            JniMethod M_PLATFORM_DATA_STREAMER_GET_SKIP_STORE = JniMethod("skipStore", "()Z", false);
-            JniMethod M_PLATFORM_DATA_STREAMER_SET_SKIP_STORE = JniMethod("skipStore", "(Z)V", false);
-            JniMethod M_PLATFORM_DATA_STREAMER_GET_PER_NODE_BUFFER_SIZE = JniMethod("perNodeBufferSize", "()I", false);
-            JniMethod M_PLATFORM_DATA_STREAMER_SET_PER_NODE_BUFFER_SIZE = JniMethod("perNodeBufferSize", "(I)V", false);
-            JniMethod M_PLATFORM_DATA_STREAMER_GET_PER_NODE_PARALLEL_OPS = JniMethod("perNodeParallelOperations", "()I", false);
-            JniMethod M_PLATFORM_DATA_STREAMER_SET_PER_NODE_PARALLEL_OPS = JniMethod("perNodeParallelOperations", "(I)V", false);
-
-            const char* C_PLATFORM_TRANSACTIONS = "org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions";
-            JniMethod M_PLATFORM_TRANSACTIONS_TX_START = JniMethod("txStart", "(IIJI)J", false);
-            JniMethod M_PLATFORM_TRANSACTIONS_TX_COMMIT = JniMethod("txCommit", "(J)I", false);
-            JniMethod M_PLATFORM_TRANSACTIONS_TX_ROLLBACK = JniMethod("txRollback", "(J)I", false);
-            JniMethod M_PLATFORM_TRANSACTIONS_TX_COMMIT_ASYNC = JniMethod("txCommitAsync", "(JJ)V", false);
-            JniMethod M_PLATFORM_TRANSACTIONS_TX_ROLLBACK_ASYNC = JniMethod("txRollbackAsync", "(JJ)V", false);
-            JniMethod M_PLATFORM_TRANSACTIONS_TX_STATE = JniMethod("txState", "(J)I", false);
-            JniMethod M_PLATFORM_TRANSACTIONS_TX_SET_ROLLBACK_ONLY = JniMethod("txSetRollbackOnly", "(J)Z", false);
-            JniMethod M_PLATFORM_TRANSACTIONS_TX_CLOSE = JniMethod("txClose", "(J)I", false);
-            JniMethod M_PLATFORM_TRANSACTIONS_RESET_METRICS = JniMethod("resetMetrics", "()V", false);
-
-            const char* C_PLATFORM_CACHE_STORE_CALLBACK = "org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback";
-            JniMethod M_PLATFORM_CACHE_STORE_CALLBACK_INVOKE = JniMethod("invoke", "(J)V", false);
-
             const char* C_PLATFORM_CALLBACK_UTILS = "org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils";
 
             JniMethod M_PLATFORM_CALLBACK_UTILS_CACHE_STORE_CREATE = JniMethod("cacheStoreCreate", "(JJ)J", true);
-            JniMethod M_PLATFORM_CALLBACK_UTILS_CACHE_STORE_INVOKE = JniMethod("cacheStoreInvoke", "(JJJLjava/lang/Object;)I", true);
+            JniMethod M_PLATFORM_CALLBACK_UTILS_CACHE_STORE_INVOKE = JniMethod("cacheStoreInvoke", "(JJJ)I", true);
             JniMethod M_PLATFORM_CALLBACK_UTILS_CACHE_STORE_DESTROY = JniMethod("cacheStoreDestroy", "(JJ)V", true);
             JniMethod M_PLATFORM_CALLBACK_UTILS_CACHE_STORE_SESSION_CREATE = JniMethod("cacheStoreSessionCreate", "(JJ)J", true);
 
@@ -378,56 +318,6 @@ namespace ignite
             JniMethod M_PLATFORM_IGNITION_STOP = JniMethod("stop", "(Ljava/lang/String;Z)Z", true);
             JniMethod M_PLATFORM_IGNITION_STOP_ALL = JniMethod("stopAll", "(Z)V", true);
 
-            const char* C_PLATFORM_ABSTRACT_QRY_CURSOR = "org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor";
-            JniMethod M_PLATFORM_ABSTRACT_QRY_CURSOR_ITER = JniMethod("iterator", "()V", false);
-            JniMethod M_PLATFORM_ABSTRACT_QRY_CURSOR_ITER_HAS_NEXT = JniMethod("iteratorHasNext", "()Z", false);
-            JniMethod M_PLATFORM_ABSTRACT_QRY_CURSOR_CLOSE = JniMethod("close", "()V", false);
-
-            const char* C_PLATFORM_CONT_QRY = "org/apache/ignite/internal/processors/platform/cache/query/PlatformContinuousQuery";
-            JniMethod M_PLATFORM_CONT_QRY_CLOSE = JniMethod("close", "()V", false);
-            JniMethod M_PLATFORM_CONT_QRY_GET_INITIAL_QUERY_CURSOR = JniMethod("getInitialQueryCursor", "()Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
-
-            const char* C_PLATFORM_EVENTS = "org/apache/ignite/internal/processors/platform/events/PlatformEvents";
-            JniMethod M_PLATFORM_EVENTS_WITH_ASYNC = JniMethod("withAsync", "()Lorg/apache/ignite/internal/processors/platform/events/PlatformEvents;", false);
-            JniMethod M_PLATFORM_EVENTS_STOP_LOCAL_LISTEN = JniMethod("stopLocalListen", "(J)Z", false);
-            JniMethod M_PLATFORM_EVENTS_LOCAL_LISTEN = JniMethod("localListen", "(JI)V", false);
-            JniMethod M_PLATFORM_EVENTS_IS_ENABLED = JniMethod("isEnabled", "(I)Z", false);
-
-            const char* C_PLATFORM_SERVICES = "org/apache/ignite/internal/processors/platform/services/PlatformServices";
-			JniMethod M_PLATFORM_SERVICES_WITH_ASYNC = JniMethod("withAsync", "()Lorg/apache/ignite/internal/processors/platform/services/PlatformServices;", false);
-			JniMethod M_PLATFORM_SERVICES_WITH_SERVER_KEEP_PORTABLE = JniMethod("withServerKeepBinary", "()Lorg/apache/ignite/internal/processors/platform/services/PlatformServices;", false);
-			JniMethod M_PLATFORM_SERVICES_CANCEL = JniMethod("cancel", "(Ljava/lang/String;)V", false);
-			JniMethod M_PLATFORM_SERVICES_CANCEL_ALL = JniMethod("cancelAll", "()V", false);
-			JniMethod M_PLATFORM_SERVICES_SERVICE_PROXY = JniMethod("serviceProxy", "(Ljava/lang/String;Z)Ljava/lang/Object;", false);
-
-            const char* C_PLATFORM_ATOMIC_LONG = "org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicLong";
-            JniMethod M_PLATFORM_ATOMIC_LONG_GET = JniMethod("get", "()J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_INCREMENT_AND_GET = JniMethod("incrementAndGet", "()J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_GET_AND_INCREMENT = JniMethod("getAndIncrement", "()J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_ADD_AND_GET = JniMethod("addAndGet", "(J)J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_GET_AND_ADD = JniMethod("getAndAdd", "(J)J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_DECREMENT_AND_GET = JniMethod("decrementAndGet", "()J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_GET_AND_DECREMENT = JniMethod("getAndDecrement", "()J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_GET_AND_SET = JniMethod("getAndSet", "(J)J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_COMPARE_AND_SET_AND_GET = JniMethod("compareAndSetAndGet", "(JJ)J", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_IS_CLOSED = JniMethod("isClosed", "()Z", false);
-            JniMethod M_PLATFORM_ATOMIC_LONG_CLOSE = JniMethod("close", "()V", false);
-
-            const char* C_PLATFORM_ATOMIC_SEQUENCE = "org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence";
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_GET = JniMethod("get", "()J", false);
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_INCREMENT_AND_GET = JniMethod("incrementAndGet", "()J", false);
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_GET_AND_INCREMENT = JniMethod("getAndIncrement", "()J", false);
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_ADD_AND_GET = JniMethod("addAndGet", "(J)J", false);
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_GET_AND_ADD = JniMethod("getAndAdd", "(J)J", false);
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_GET_BATCH_SIZE = JniMethod("getBatchSize", "()I", false);
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_SET_BATCH_SIZE = JniMethod("setBatchSize", "(I)V", false);
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_IS_CLOSED = JniMethod("isClosed", "()Z", false);
-            JniMethod M_PLATFORM_ATOMIC_SEQUENCE_CLOSE = JniMethod("close", "()V", false);
-
-            const char* C_PLATFORM_ATOMIC_REFERENCE = "org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference";
-            JniMethod M_PLATFORM_ATOMIC_REFERENCE_IS_CLOSED = JniMethod("isClosed", "()Z", false);
-            JniMethod M_PLATFORM_ATOMIC_REFERENCE_CLOSE = JniMethod("close", "()V", false);
-
             const char* C_PLATFORM_LISTENABLE = "org/apache/ignite/internal/processors/platform/utils/PlatformListenable";
             JniMethod M_PLATFORM_LISTENABLE_CANCEL = JniMethod("cancel", "()Z", false);
             JniMethod M_PLATFORM_LISTENABLE_IS_CANCELED = JniMethod("isCancelled", "()Z", false);
@@ -584,78 +474,8 @@ namespace ignite
             }
 
             void JniMembers::Initialize(JNIEnv* env) {
-                c_PlatformAbstractQryCursor = FindClass(env, C_PLATFORM_ABSTRACT_QRY_CURSOR);
-                m_PlatformAbstractQryCursor_iter = FindMethod(env, c_PlatformAbstractQryCursor, M_PLATFORM_ABSTRACT_QRY_CURSOR_ITER);
-                m_PlatformAbstractQryCursor_iterHasNext = FindMethod(env, c_PlatformAbstractQryCursor, M_PLATFORM_ABSTRACT_QRY_CURSOR_ITER_HAS_NEXT);
-                m_PlatformAbstractQryCursor_close = FindMethod(env, c_PlatformAbstractQryCursor, M_PLATFORM_ABSTRACT_QRY_CURSOR_CLOSE);
-
-                c_PlatformAffinity = FindClass(env, C_PLATFORM_AFFINITY);
-                m_PlatformAffinity_partitions = FindMethod(env, c_PlatformAffinity, C_PLATFORM_AFFINITY_PARTITIONS);
-
-                c_PlatformCache = FindClass(env, C_PLATFORM_CACHE);
-                m_PlatformCache_withSkipStore = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_WITH_SKIP_STORE);
-                m_PlatformCache_withNoRetries = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_WITH_NO_RETRIES);
-                m_PlatformCache_withExpiryPolicy = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_WITH_EXPIRY_PLC);
-                m_PlatformCache_withAsync = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_WITH_ASYNC);
-                m_PlatformCache_withKeepPortable = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_WITH_KEEP_PORTABLE);
-                m_PlatformCache_clear = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_CLEAR);
-                m_PlatformCache_removeAll = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_REMOVE_ALL);
-                m_PlatformCache_iterator = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_ITERATOR);
-                m_PlatformCache_localIterator = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_LOCAL_ITERATOR);
-                m_PlatformCache_enterLock = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_ENTER_LOCK);
-                m_PlatformCache_exitLock = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_EXIT_LOCK);
-                m_PlatformCache_tryEnterLock = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_TRY_ENTER_LOCK);
-                m_PlatformCache_closeLock = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_CLOSE_LOCK);
-                m_PlatformCache_rebalance = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_REBALANCE);
-                m_PlatformCache_size = FindMethod(env, c_PlatformCache, M_PLATFORM_CACHE_SIZE);
-
-                c_PlatformCacheStoreCallback = FindClass(env, C_PLATFORM_CACHE_STORE_CALLBACK);
-                m_PlatformCacheStoreCallback_invoke = FindMethod(env, c_PlatformCacheStoreCallback, M_PLATFORM_CACHE_STORE_CALLBACK_INVOKE);
-
                 c_IgniteException = FindClass(env, C_IGNITE_EXCEPTION);
 
-                c_PlatformClusterGroup = FindClass(env, C_PLATFORM_CLUSTER_GRP);
-                m_PlatformClusterGroup_forOthers = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_OTHERS);
-                m_PlatformClusterGroup_forRemotes = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_REMOTES);
-                m_PlatformClusterGroup_forDaemons = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_DAEMONS);
-                m_PlatformClusterGroup_forRandom = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_RANDOM);
-                m_PlatformClusterGroup_forOldest = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_OLDEST);
-                m_PlatformClusterGroup_forYoungest = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_YOUNGEST);
-                m_PlatformClusterGroup_resetMetrics = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_RESET_METRICS);
-
-                c_PlatformCompute = FindClass(env, C_PLATFORM_COMPUTE);
-                m_PlatformCompute_withNoFailover = FindMethod(env, c_PlatformCompute, M_PLATFORM_COMPUTE_WITH_NO_FAILOVER);
-                m_PlatformCompute_withTimeout = FindMethod(env, c_PlatformCompute, M_PLATFORM_COMPUTE_WITH_TIMEOUT);
-                m_PlatformCompute_executeNative = FindMethod(env, c_PlatformCompute, M_PLATFORM_COMPUTE_EXECUTE_NATIVE);
-
-                c_PlatformContinuousQuery = FindClass(env, C_PLATFORM_CONT_QRY);
-                m_PlatformContinuousQuery_close = FindMethod(env, c_PlatformContinuousQuery, M_PLATFORM_CONT_QRY_CLOSE);
-                m_PlatformContinuousQuery_getInitialQueryCursor = FindMethod(env, c_PlatformContinuousQuery, M_PLATFORM_CONT_QRY_GET_INITIAL_QUERY_CURSOR);
-
-                c_PlatformDataStreamer = FindClass(env, C_PLATFORM_DATA_STREAMER);
-                m_PlatformDataStreamer_listenTopology = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_LISTEN_TOPOLOGY);
-                m_PlatformDataStreamer_getAllowOverwrite = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_GET_ALLOW_OVERWRITE);
-                m_PlatformDataStreamer_setAllowOverwrite = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_SET_ALLOW_OVERWRITE);
-                m_PlatformDataStreamer_getSkipStore = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_GET_SKIP_STORE);
-                m_PlatformDataStreamer_setSkipStore = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_SET_SKIP_STORE);
-                m_PlatformDataStreamer_getPerNodeBufSize = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_GET_PER_NODE_BUFFER_SIZE);
-                m_PlatformDataStreamer_setPerNodeBufSize = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_SET_PER_NODE_BUFFER_SIZE);
-                m_PlatformDataStreamer_getPerNodeParallelOps = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_GET_PER_NODE_PARALLEL_OPS);
-                m_PlatformDataStreamer_setPerNodeParallelOps = FindMethod(env, c_PlatformDataStreamer, M_PLATFORM_DATA_STREAMER_SET_PER_NODE_PARALLEL_OPS);
-
-                c_PlatformEvents = FindClass(env, C_PLATFORM_EVENTS);
-                m_PlatformEvents_withAsync = FindMethod(env, c_PlatformEvents, M_PLATFORM_EVENTS_WITH_ASYNC);
-                m_PlatformEvents_stopLocalListen = FindMethod(env, c_PlatformEvents, M_PLATFORM_EVENTS_STOP_LOCAL_LISTEN);
-                m_PlatformEvents_localListen = FindMethod(env, c_PlatformEvents, M_PLATFORM_EVENTS_LOCAL_LISTEN);
-                m_PlatformEvents_isEnabled = FindMethod(env, c_PlatformEvents, M_PLATFORM_EVENTS_IS_ENABLED);
-
-				c_PlatformServices = FindClass(env, C_PLATFORM_SERVICES);
-				m_PlatformServices_withAsync = FindMethod(env, c_PlatformServices, M_PLATFORM_SERVICES_WITH_ASYNC);
-				m_PlatformServices_withServerKeepPortable = FindMethod(env, c_PlatformServices, M_PLATFORM_SERVICES_WITH_SERVER_KEEP_PORTABLE);
-				m_PlatformServices_cancel = FindMethod(env, c_PlatformServices, M_PLATFORM_SERVICES_CANCEL);
-				m_PlatformServices_cancelAll = FindMethod(env, c_PlatformServices, M_PLATFORM_SERVICES_CANCEL_ALL);
-				m_PlatformServices_serviceProxy = FindMethod(env, c_PlatformServices, M_PLATFORM_SERVICES_SERVICE_PROXY);
-
                 c_PlatformIgnition = FindClass(env, C_PLATFORM_IGNITION);
                 m_PlatformIgnition_start = FindMethod(env, c_PlatformIgnition, M_PLATFORM_IGNITION_START);
                 m_PlatformIgnition_instance = FindMethod(env, c_PlatformIgnition, M_PLATFORM_IGNITION_INSTANCE);
@@ -663,9 +483,6 @@ namespace ignite
                 m_PlatformIgnition_stop = FindMethod(env, c_PlatformIgnition, M_PLATFORM_IGNITION_STOP);
                 m_PlatformIgnition_stopAll = FindMethod(env, c_PlatformIgnition, M_PLATFORM_IGNITION_STOP_ALL);
 
-                c_PlatformMessaging = FindClass(env, C_PLATFORM_MESSAGING);
-                m_PlatformMessaging_withAsync = FindMethod(env, c_PlatformMessaging, M_PLATFORM_MESSAGING_WITH_ASYNC);
-
                 c_PlatformProcessor = FindClass(env, C_PLATFORM_PROCESSOR);
                 m_PlatformProcessor_releaseStart = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_RELEASE_START);
                 m_PlatformProcessor_cache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CACHE);
@@ -692,6 +509,7 @@ namespace ignite
 				m_PlatformProcessor_getCacheNames = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_CACHE_NAMES);
 
                 c_PlatformTarget = FindClass(env, C_PLATFORM_TARGET);
+                m_PlatformTarget_inLongOutLong = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_LONG_OUT_LONG);
                 m_PlatformTarget_inStreamOutLong = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_LONG);
                 m_PlatformTarget_inStreamOutObject = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_OBJECT);
                 m_PlatformTarget_outLong = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_OUT_LONG);
@@ -699,78 +517,29 @@ namespace ignite
                 m_PlatformTarget_outObject = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_OUT_OBJECT);
                 m_PlatformTarget_inStreamOutStream = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_STREAM);
                 m_PlatformTarget_inObjectStreamOutStream = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_OBJECT_STREAM_OUT_STREAM);
+                m_PlatformTarget_inObjectStreamOutObjectStream = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_OBJECT_STREAM_OUT_OBJECT_STREAM);
                 m_PlatformTarget_listenFuture = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_LISTEN_FUTURE);
                 m_PlatformTarget_listenFutureForOperation = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_LISTEN_FOR_OPERATION);
                 m_PlatformTarget_listenFutureAndGet = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_LISTEN_FUTURE_AND_GET);
                 m_PlatformTarget_listenFutureForOperationAndGet = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_LISTEN_FOR_OPERATION_AND_GET);
 
-                c_PlatformTransactions = FindClass(env, C_PLATFORM_TRANSACTIONS);
-                m_PlatformTransactions_txStart = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_TX_START);
-                m_PlatformTransactions_txCommit = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_TX_COMMIT);
-                m_PlatformTransactions_txRollback = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_TX_ROLLBACK);
-                m_PlatformTransactions_txCommitAsync = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_TX_COMMIT_ASYNC);
-                m_PlatformTransactions_txRollbackAsync = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_TX_ROLLBACK_ASYNC);
-                m_PlatformTransactions_txState = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_TX_STATE);
-                m_PlatformTransactions_txSetRollbackOnly = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_TX_SET_ROLLBACK_ONLY);
-                m_PlatformTransactions_txClose = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_TX_CLOSE);
-                m_PlatformTransactions_resetMetrics = FindMethod(env, c_PlatformTransactions, M_PLATFORM_TRANSACTIONS_RESET_METRICS);
-
                 c_PlatformUtils = FindClass(env, C_PLATFORM_UTILS);
                 m_PlatformUtils_reallocate = FindMethod(env, c_PlatformUtils, M_PLATFORM_UTILS_REALLOC);
                 m_PlatformUtils_errData = FindMethod(env, c_PlatformUtils, M_PLATFORM_UTILS_ERR_DATA);
 
-                c_PlatformAtomicLong = FindClass(env, C_PLATFORM_ATOMIC_LONG);
-                m_PlatformAtomicLong_get = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_GET);
-                m_PlatformAtomicLong_incrementAndGet = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_INCREMENT_AND_GET);
-                m_PlatformAtomicLong_getAndIncrement = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_GET_AND_INCREMENT);
-                m_PlatformAtomicLong_addAndGet = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_ADD_AND_GET);
-                m_PlatformAtomicLong_getAndAdd = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_GET_AND_ADD);
-                m_PlatformAtomicLong_decrementAndGet = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_DECREMENT_AND_GET);
-                m_PlatformAtomicLong_getAndDecrement = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_GET_AND_DECREMENT);
-                m_PlatformAtomicLong_getAndSet = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_GET_AND_SET);
-                m_PlatformAtomicLong_compareAndSetAndGet = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_COMPARE_AND_SET_AND_GET);
-                m_PlatformAtomicLong_isClosed = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_IS_CLOSED);
-                m_PlatformAtomicLong_close = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_CLOSE);
-
-                jclass c_PlatformAtomicSequence = FindClass(env, C_PLATFORM_ATOMIC_SEQUENCE);
-                m_PlatformAtomicSequence_get = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_GET);
-                m_PlatformAtomicSequence_incrementAndGet = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_INCREMENT_AND_GET);
-                m_PlatformAtomicSequence_getAndIncrement = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_GET_AND_INCREMENT);
-                m_PlatformAtomicSequence_addAndGet = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_ADD_AND_GET);
-                m_PlatformAtomicSequence_getAndAdd = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_GET_AND_ADD);
-                m_PlatformAtomicSequence_getBatchSize = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_GET_BATCH_SIZE);
-                m_PlatformAtomicSequence_setBatchSize = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_SET_BATCH_SIZE);
-                m_PlatformAtomicSequence_isClosed = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_IS_CLOSED);
-                m_PlatformAtomicSequence_close = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_CLOSE);
-
-                jclass c_PlatformAtomicReference = FindClass(env, C_PLATFORM_ATOMIC_REFERENCE);
-                m_PlatformAtomicReference_isClosed = FindMethod(env, c_PlatformAtomicReference, M_PLATFORM_ATOMIC_REFERENCE_IS_CLOSED);
-                m_PlatformAtomicReference_close = FindMethod(env, c_PlatformAtomicReference, M_PLATFORM_ATOMIC_REFERENCE_CLOSE);
-
                 c_PlatformListenable = FindClass(env, C_PLATFORM_LISTENABLE);
                 m_PlatformListenable_cancel = FindMethod(env, c_PlatformListenable, M_PLATFORM_LISTENABLE_CANCEL);                    
-                m_PlatformListenable_isCancelled = FindMethod(env, c_PlatformListenable, M_PLATFORM_LISTENABLE_IS_CANCELED);
+                m_PlatformListenable_isCancelled = FindMethod(env, c_PlatformListenable, M_PLATFORM_LISTENABLE_IS_CANCELED);                    
 
                 // Find utility classes which are not used from context, but are still required in other places.
                 CheckClass(env, C_PLATFORM_NO_CALLBACK_EXCEPTION);
             }
 
             void JniMembers::Destroy(JNIEnv* env) {
-                DeleteClass(env, c_PlatformAbstractQryCursor);
-                DeleteClass(env, c_PlatformAffinity);
-                DeleteClass(env, c_PlatformCache);
-                DeleteClass(env, c_PlatformCacheStoreCallback);
                 DeleteClass(env, c_IgniteException);
-                DeleteClass(env, c_PlatformClusterGroup);
-                DeleteClass(env, c_PlatformCompute);
-                DeleteClass(env, c_PlatformContinuousQuery);
-                DeleteClass(env, c_PlatformDataStreamer);
-                DeleteClass(env, c_PlatformEvents);
                 DeleteClass(env, c_PlatformIgnition);
-                DeleteClass(env, c_PlatformMessaging);
                 DeleteClass(env, c_PlatformProcessor);
                 DeleteClass(env, c_PlatformTarget);
-                DeleteClass(env, c_PlatformTransactions);
                 DeleteClass(env, c_PlatformUtils);
             }
 
@@ -1488,6 +1257,16 @@ namespace ignite
                 ExceptionCheck(env);
             }
 
+            long long JniContext::TargetInLongOutLong(jobject obj, int opType, long long val, JniErrorInfo* err) {
+                JNIEnv* env = Attach();
+
+                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformTarget_inLongOutLong, opType, val);
+
+                ExceptionCheck(env, err);
+
+                return res;
+            }
+
             long long JniContext::TargetInStreamOutLong(jobject obj, int opType, long long memPtr, JniErrorInfo* err) {
                 JNIEnv* env = Attach();
 
@@ -1524,6 +1303,16 @@ namespace ignite
                 ExceptionCheck(env, err);
             }
 
+            jobject JniContext::TargetInObjectStreamOutObjectStream(jobject obj, int opType, void* arg, long long inMemPtr, long long outMemPtr, JniErrorInfo* err) {
+                JNIEnv* env = Attach();
+
+                jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformTarget_inObjectStreamOutObjectStream, opType, arg, inMemPtr, outMemPtr);
+
+                ExceptionCheck(env, err);
+
+                return LocalToGlobal(env, res);
+            }
+
             long long JniContext::TargetOutLong(jobject obj, int opType, JniErrorInfo* err)
             {
                 JNIEnv* env = Attach();
@@ -1592,83 +1381,6 @@ namespace ignite
                 return LocalToGlobal(env, res);
             }
 
-            int JniContext::AffinityPartitions(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jint parts = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformAffinity_partitions);
-
-                ExceptionCheck(env);
-
-                return parts;
-            }
-
-            jobject JniContext::CacheWithSkipStore(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject cache = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformCache_withSkipStore);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, cache);
-            }
-
-            jobject JniContext::CacheWithNoRetries(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject cache = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformCache_withNoRetries);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, cache);
-            }
-
-            jobject JniContext::CacheWithExpiryPolicy(jobject obj, long long create, long long update, long long access) {
-                JNIEnv* env = Attach();
-
-                jobject cache = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformCache_withExpiryPolicy,
-                    create, update, access);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, cache);
-            }
-
-            jobject JniContext::CacheWithAsync(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject cache = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformCache_withAsync);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, cache);
-            }
-
-            jobject JniContext::CacheWithKeepPortable(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject cache = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformCache_withKeepPortable);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, cache);
-            }
-
-            void JniContext::CacheClear(jobject obj, JniErrorInfo* err) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCache_clear);
-
-                ExceptionCheck(env, err);
-            }
-
-            void JniContext::CacheRemoveAll(jobject obj, JniErrorInfo* err) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCache_removeAll);
-
-                ExceptionCheck(env, err);
-            }
-
             jobject JniContext::CacheOutOpQueryCursor(jobject obj, int type, long long memPtr, JniErrorInfo* err) {
                 JNIEnv* env = Attach();
 
@@ -1691,932 +1403,179 @@ namespace ignite
                 return LocalToGlobal(env, res);
             }
 
-            jobject JniContext::CacheIterator(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformCache_iterator);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, res);
-            }
-
-            jobject JniContext::CacheLocalIterator(jobject obj, int peekModes) {
-                JNIEnv*env = Attach();
-
-                jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformCache_localIterator, peekModes);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, res);
-            }
-
-            void JniContext::CacheEnterLock(jobject obj, long long id) {
+            bool JniContext::ListenableCancel(jobject obj)
+            {
                 JNIEnv* env = Attach();
 
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCache_enterLock, id);
+                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformListenable_cancel);
 
                 ExceptionCheck(env);
-            }
-
-            void JniContext::CacheExitLock(jobject obj, long long id) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCache_exitLock, id);
 
-                ExceptionCheck(env);
+                return res != 0;;
             }
 
-            bool JniContext::CacheTryEnterLock(jobject obj, long long id, long long timeout) {
+            bool JniContext::ListenableIsCancelled(jobject obj)
+            {
                 JNIEnv* env = Attach();
 
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformCache_tryEnterLock, id, timeout);
+                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformListenable_isCancelled);
 
                 ExceptionCheck(env);
 
-                return res != 0;
+                return res != 0;;
             }
 
-            void JniContext::CacheCloseLock(jobject obj, long long id) {
-                JNIEnv* env = Attach();
+			jobject JniContext::Acquire(jobject obj)
+            {
+                if (obj) {
 
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCache_closeLock, id);
+                    JNIEnv* env = Attach();
 
-                ExceptionCheck(env);
-            }
+                    jobject obj0 = env->NewGlobalRef(obj);
 
-            void JniContext::CacheRebalance(jobject obj, long long futId) {
-                JNIEnv* env = Attach();
+                    ExceptionCheck(env);
 
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCache_rebalance, futId);
+                    return obj0;
+                }
 
-                ExceptionCheck(env);
+                return NULL;
             }
 
-            int JniContext::CacheSize(jobject obj, int peekModes, bool loc, JniErrorInfo* err) {
-                JNIEnv* env = Attach();
-
-                jint res = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformCache_size, peekModes, loc);
-
-                ExceptionCheck(env, err);
+            void JniContext::Release(jobject obj) {
+                if (obj)
+                {
+                    JavaVM* jvm = JVM.GetJvm();
 
-                return res;
-            }
+                    if (jvm)
+                    {
+                        JNIEnv* env;
 
-            void JniContext::CacheStoreCallbackInvoke(jobject obj, long long memPtr) {
-                JNIEnv* env = Attach();
+                        jint attachRes = jvm->AttachCurrentThread(reinterpret_cast<void**>(&env), NULL);
 
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCacheStoreCallback_invoke, memPtr);
+                        if (attachRes == JNI_OK)
+                        {
+                            AttachHelper::OnThreadAttach();
 
-                ExceptionCheck(env);
+                            env->DeleteGlobalRef(obj);
+                        }
+                    }
+                }
             }
 
-            void JniContext::ComputeWithNoFailover(jobject obj) {
+            void JniContext::ThrowToJava(char* msg) {
                 JNIEnv* env = Attach();
 
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCompute_withNoFailover);
-
-                ExceptionCheck(env);
+                env->ThrowNew(jvm->GetMembers().c_IgniteException, msg);
             }
 
-            void JniContext::ComputeWithTimeout(jobject obj, long long timeout) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformCompute_withTimeout, timeout);
-
-                ExceptionCheck(env);
+            void JniContext::DestroyJvm() {
+                jvm->GetJvm()->DestroyJavaVM();
             }
 
-            void* JniContext::ComputeExecuteNative(jobject obj, long long taskPtr, long long topVer) {
-                JNIEnv* env = Attach();
+            /**
+             * Attach thread to JVM.
+             */
+            JNIEnv* JniContext::Attach() {
+                JNIEnv* env;
 
-                jobject res = env->CallObjectMethod(obj,
-                    jvm->GetMembers().m_PlatformCompute_executeNative, taskPtr, topVer);
+                jint attachRes = jvm->GetJvm()->AttachCurrentThread(reinterpret_cast<void**>(&env), NULL);
 
-                ExceptionCheck(env);
+                if (attachRes == JNI_OK)
+                    AttachHelper::OnThreadAttach();
+                else {
+                    if (hnds.error)
+                        hnds.error(hnds.target, IGNITE_JNI_ERR_JVM_ATTACH, NULL, 0, NULL, 0, NULL, 0);
+                }
 
-                return LocalToGlobal(env, res);
+                return env;
             }
 
-            void JniContext::ContinuousQueryClose(jobject obj) {
-                JNIEnv* env = Attach();
+            void JniContext::ExceptionCheck(JNIEnv* env) {
+                ExceptionCheck(env, NULL);
+            }
 
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformContinuousQuery_close);
+            void JniContext::ExceptionCheck(JNIEnv* env, JniErrorInfo* errInfo)
+            {
+                if (env->ExceptionCheck()) {
+                    jthrowable err = env->ExceptionOccurred();
 
-                ExceptionCheck(env);
-            }
+                    if (PRINT_EXCEPTION)
+                        env->CallVoidMethod(err, jvm->GetJavaMembers().m_Throwable_printStackTrace);
 
-            jobject JniContext::ContinuousQueryGetInitialQueryCursor(jobject obj) {
-                JNIEnv* env = Attach();
+                    env->ExceptionClear();
 
-                jobject res = env->CallObjectMethod(obj,
-                    jvm->GetMembers().m_PlatformContinuousQuery_getInitialQueryCursor);
+                    // Get error class name and message.
+                    jclass cls = env->GetObjectClass(err);
 
-                ExceptionCheck(env);
+                    jstring clsName = static_cast<jstring>(env->CallObjectMethod(cls, jvm->GetJavaMembers().m_Class_getName));
+                    jstring msg = static_cast<jstring>(env->CallObjectMethod(err, jvm->GetJavaMembers().m_Throwable_getMessage));
 
-                return LocalToGlobal(env,  res);
-            }
+                    env->DeleteLocalRef(cls);
 
-            void JniContext::DataStreamerListenTopology(jobject obj, long long ptr) {
-                JNIEnv* env = Attach();
+                    int clsNameLen;
+                    std::string clsName0 = JavaStringToCString(env, clsName, &clsNameLen);
 
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_listenTopology, ptr);
+                    int msgLen;
+                    std::string msg0 = JavaStringToCString(env, msg, &msgLen);
 
-                ExceptionCheck(env);
-            }
+                    if (errInfo)
+                    {
+                        JniErrorInfo errInfo0(IGNITE_JNI_ERR_GENERIC, clsName0.c_str(), msg0.c_str());
 
-            bool JniContext::DataStreamerAllowOverwriteGet(jobject obj) {
-                JNIEnv* env = Attach();
+                        *errInfo = errInfo0;
+                    }
 
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_getAllowOverwrite);
+                    // Get error additional data (if any).
+                    jbyteArray errData = static_cast<jbyteArray>(env->CallStaticObjectMethod(
+                        jvm->GetMembers().c_PlatformUtils, jvm->GetMembers().m_PlatformUtils_errData, err));
 
-                ExceptionCheck(env);
+                    if (errData)
+                    {
+                        jbyte* errBytesNative = env->GetByteArrayElements(errData, NULL);
 
-                return res != 0;
-            }
+                        int errBytesLen = env->GetArrayLength(errData);
 
-            void JniContext::DataStreamerAllowOverwriteSet(jobject obj, bool val) {
-                JNIEnv* env = Attach();
+                        if (hnds.error)
+                            hnds.error(hnds.target, IGNITE_JNI_ERR_GENERIC, clsName0.c_str(), clsNameLen, msg0.c_str(), msgLen,
+                                errBytesNative, errBytesLen);
 
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_setAllowOverwrite, val);
+                        env->ReleaseByteArrayElements(errData, errBytesNative, JNI_ABORT);
+                    }
+                    else
+                    {
+                        if (hnds.error)
+                            hnds.error(hnds.target, IGNITE_JNI_ERR_GENERIC, clsName0.c_str(), clsNameLen, msg0.c_str(), msgLen,
+                                NULL, 0);
+                    }
 
-                ExceptionCheck(env);
+                    env->DeleteLocalRef(err);
+                }
             }
 
-            bool JniContext::DataStreamerSkipStoreGet(jobject obj) {
-                JNIEnv* env = Attach();
+            /**
+             * Convert local reference to global.
+             */
+            jobject JniContext::LocalToGlobal(JNIEnv* env, jobject localRef) {
+                if (localRef) {
+                    jobject globalRef = env->NewGlobalRef(localRef);
 
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_getSkipStore);
+                    env->DeleteLocalRef(localRef); // Clear local ref irrespective of result.
 
-                ExceptionCheck(env);
+                    if (!globalRef)
+                        ExceptionCheck(env);
 
-                return res != 0;
+                    return globalRef;
+                }
+                else
+                    return NULL;
             }
 
-            void JniContext::DataStreamerSkipStoreSet(jobject obj, bool val) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_setSkipStore, val);
+            JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr) {
+                IGNITE_SAFE_FUNC(env, envPtr, CacheStoreCreateHandler, cacheStoreCreate, memPtr);
+            }
 
-                ExceptionCheck(env);
-            }
-
-            int JniContext::DataStreamerPerNodeBufferSizeGet(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jint res = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_getPerNodeBufSize);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            void JniContext::DataStreamerPerNodeBufferSizeSet(jobject obj, int val) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_setPerNodeBufSize, val);
-
-                ExceptionCheck(env);
-            }
-
-            int JniContext::DataStreamerPerNodeParallelOperationsGet(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jint res = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_getPerNodeParallelOps);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            void JniContext::DataStreamerPerNodeParallelOperationsSet(jobject obj, int val) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformDataStreamer_setPerNodeParallelOps, val);
-
-                ExceptionCheck(env);
-            }
-
-            jobject JniContext::MessagingWithAsync(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject msg = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformMessaging_withAsync);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, msg);
-            }
-
-            jobject JniContext::ProjectionForOthers(jobject obj, jobject prj) {
-                JNIEnv* env = Attach();
-
-                jobject newPrj = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformClusterGroup_forOthers, prj);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, newPrj);
-            }
-
-            jobject JniContext::ProjectionForRemotes(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject newPrj = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformClusterGroup_forRemotes);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, newPrj);
-            }
-
-            jobject JniContext::ProjectionForDaemons(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject newPrj = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformClusterGroup_forDaemons);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, newPrj);
-            }
-
-            jobject JniContext::ProjectionForRandom(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject newPrj = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformClusterGroup_forRandom);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, newPrj);
-            }
-
-            jobject JniContext::ProjectionForOldest(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject newPrj = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformClusterGroup_forOldest);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, newPrj);
-            }
-
-            jobject JniContext::ProjectionForYoungest(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject newPrj = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformClusterGroup_forYoungest);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, newPrj);
-            }
-
-            void JniContext::ProjectionResetMetrics(jobject obj) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformClusterGroup_resetMetrics);
-
-                ExceptionCheck(env);
-            }
-
-            jobject JniContext::ProjectionOutOpRet(jobject obj, int type, long long memPtr) {
-                JNIEnv* env = Attach();
-
-                jobject res = env->CallObjectMethod(
-                    obj, jvm->GetMembers().m_PlatformTarget_inStreamOutObject, type, memPtr);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, res);
-            }
-
-
-            void JniContext::QueryCursorIterator(jobject obj, JniErrorInfo* errInfo) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAbstractQryCursor_iter);
-
-                ExceptionCheck(env, errInfo);
-            }
-
-            bool JniContext::QueryCursorIteratorHasNext(jobject obj, JniErrorInfo* errInfo)
-            {
-                JNIEnv* env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformAbstractQryCursor_iterHasNext);
-
-                ExceptionCheck(env, errInfo);
-
-                return res != 0;
-            }
-
-            void JniContext::QueryCursorClose(jobject obj, JniErrorInfo* errInfo) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAbstractQryCursor_close);
-
-                ExceptionCheck(env, errInfo);
-            }
-
-            long long JniContext::TransactionsStart(jobject obj, int concurrency,
-                int isolation, long long timeout, int txSize, JniErrorInfo* errInfo) {
-                JNIEnv* env = Attach();
-
-                long long id = env->CallLongMethod(obj,
-                    jvm->GetMembers().m_PlatformTransactions_txStart,
-                    concurrency, isolation, timeout, txSize);
-
-                ExceptionCheck(env, errInfo);
-
-                return id;
-            }
-
-            int JniContext::TransactionsCommit(jobject obj, long long id, JniErrorInfo* errInfo) {
-                JNIEnv* env = Attach();
-
-                int res = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformTransactions_txCommit, id);
-
-                ExceptionCheck(env, errInfo);
-
-                return res;
-            }
-
-            void JniContext::TransactionsCommitAsync(jobject obj, long long id, long long futId) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformTransactions_txCommitAsync, id, futId);
-
-                ExceptionCheck(env);
-            }
-
-            int JniContext::TransactionsRollback(jobject obj, long long id, JniErrorInfo* errInfo) {
-                JNIEnv* env = Attach();
-
-                int res = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformTransactions_txRollback, id);
-
-                ExceptionCheck(env, errInfo);
-
-                return res;
-            }
-
-            void JniContext::TransactionsRollbackAsync(jobject obj, long long id, long long futId) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformTransactions_txRollbackAsync, id, futId);
-
-                ExceptionCheck(env);
-            }
-
-            int JniContext::TransactionsClose(jobject obj, long long id, JniErrorInfo* errInfo) {
-                JNIEnv* env = Attach();
-
-                jint state = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformTransactions_txClose, id);
-
-                ExceptionCheck(env, errInfo);
-
-                return state;
-            }
-
-            int JniContext::TransactionsState(jobject obj, long long id, JniErrorInfo* errInfo) {
-                JNIEnv* env = Attach();
-
-                jint state = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformTransactions_txState, id);
-
-                ExceptionCheck(env, errInfo);
-
-                return state;
-            }
-
-            bool JniContext::TransactionsSetRollbackOnly(jobject obj, long long id, JniErrorInfo* errInfo) {
-                JNIEnv* env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformTransactions_txSetRollbackOnly, id);
-
-                ExceptionCheck(env, errInfo);
-
-                return res != 0;
-            }
-
-            void JniContext::TransactionsResetMetrics(jobject obj) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformTransactions_resetMetrics);
-
-                ExceptionCheck(env);
-            }
-
-            jobject JniContext::EventsWithAsync(jobject obj) {
-                JNIEnv * env = Attach();
-
-                jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformEvents_withAsync);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, res);
-            }
-
-            bool JniContext::EventsStopLocalListen(jobject obj, long long hnd) {
-                JNIEnv * env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformEvents_stopLocalListen, hnd);
-
-                ExceptionCheck(env);
-
-                return res != 0;
-            }
-
-            void JniContext::EventsLocalListen(jobject obj, long long hnd, int type) {
-                JNIEnv * env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformEvents_localListen, hnd, type);
-
-                ExceptionCheck(env);
-            }
-
-            bool JniContext::EventsIsEnabled(jobject obj, int type) {
-                JNIEnv * env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformEvents_isEnabled, type);
-
-                ExceptionCheck(env);
-
-                return res != 0;
-            }
-
-			jobject JniContext::ServicesWithAsync(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformServices_withAsync);
-
-				ExceptionCheck(env);
-
-				return LocalToGlobal(env, res);
-            }
-
-            jobject JniContext::ServicesWithServerKeepPortable(jobject obj) {
-                JNIEnv* env = Attach();
-
-                jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformServices_withServerKeepPortable);
-
-                ExceptionCheck(env);
-
-                return LocalToGlobal(env, res);
-            }
-
-			void JniContext::ServicesCancel(jobject obj, char* name) {
-                JNIEnv* env = Attach();
-
-				jstring name0 = name != NULL ? env->NewStringUTF(name) : NULL;
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformServices_cancel, name0);
-
-				if (name0)
-					env->DeleteLocalRef(name0);
-
-				ExceptionCheck(env);
-            }
-
-			void JniContext::ServicesCancelAll(jobject obj) {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformServices_cancelAll);
-
-				ExceptionCheck(env);
-            }
-
-			void* JniContext::ServicesGetServiceProxy(jobject obj, char* name, bool sticky) {
-				JNIEnv* env = Attach();
-
-				jstring name0 = name != NULL ? env->NewStringUTF(name) : NULL;
-
-                jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformServices_serviceProxy, name0, sticky);
-
-				if (name0)
-					env->DeleteLocalRef(name0);
-
-				ExceptionCheck(env);
-
-				return LocalToGlobal(env, res);;
-			}
-
-            long long JniContext::AtomicLongGet(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_get);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicLongIncrementAndGet(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_incrementAndGet);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicLongGetAndIncrement(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_getAndIncrement);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicLongAddAndGet(jobject obj, long long value)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_addAndGet, value);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicLongGetAndAdd(jobject obj, long long value)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_getAndAdd, value);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicLongDecrementAndGet(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_decrementAndGet);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicLongGetAndDecrement(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_getAndDecrement);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicLongGetAndSet(jobject obj, long long value)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_getAndSet, value);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicLongCompareAndSetAndGet(jobject obj, long long expVal, long long newVal)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_compareAndSetAndGet, expVal, newVal);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            bool JniContext::AtomicLongIsClosed(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_isClosed);
-
-                ExceptionCheck(env);
-
-                return res != 0;;
-            }
-
-            void JniContext::AtomicLongClose(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAtomicLong_close);
-
-                ExceptionCheck(env);
-            }
-
-            long long JniContext::AtomicSequenceGet(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_get);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicSequenceIncrementAndGet(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_incrementAndGet);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicSequenceGetAndIncrement(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_getAndIncrement);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicSequenceAddAndGet(jobject obj, long long l)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_addAndGet, l);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            long long JniContext::AtomicSequenceGetAndAdd(jobject obj, long long l)
-            {
-                JNIEnv* env = Attach();
-
-                long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_getAndAdd, l);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            int JniContext::AtomicSequenceGetBatchSize(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                int res = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_getBatchSize);
-
-                ExceptionCheck(env);
-
-                return res;
-            }
-
-            void JniContext::AtomicSequenceSetBatchSize(jobject obj, int size)
-            {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_setBatchSize, size);
-
-                ExceptionCheck(env);
-            }
-
-            bool JniContext::AtomicSequenceIsClosed(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_isClosed);
-
-                ExceptionCheck(env);
-
-                return res != 0;
-            }
-
-            void JniContext::AtomicSequenceClose(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_close);
-
-                ExceptionCheck(env);
-            }
-
-            bool JniContext::AtomicReferenceIsClosed(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformAtomicReference_isClosed);
-
-                ExceptionCheck(env);
-
-                return res != 0;
-            }
-
-            void JniContext::AtomicReferenceClose(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAtomicReference_close);
-
-                ExceptionCheck(env);
-            }
-
-            bool JniContext::ListenableCancel(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformListenable_cancel);
-
-                ExceptionCheck(env);
-
-                return res != 0;;
-            }
-
-            bool JniContext::ListenableIsCancelled(jobject obj)
-            {
-                JNIEnv* env = Attach();
-
-                jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformListenable_isCancelled);
-
-                ExceptionCheck(env);
-
-                return res != 0;;
-            }
-
-			jobject JniContext::Acquire(jobject obj)
-            {
-                if (obj) {
-
-                    JNIEnv* env = Attach();
-
-                    jobject obj0 = env->NewGlobalRef(obj);
-
-                    ExceptionCheck(env);
-
-                    return obj0;
-                }
-
-                return NULL;
-            }
-
-            void JniContext::Release(jobject obj) {
-                if (obj)
-                {
-                    JavaVM* jvm = JVM.GetJvm();
-
-                    if (jvm)
-                    {
-                        JNIEnv* env;
-
-                        jint attachRes = jvm->AttachCurrentThread(reinterpret_cast<void**>(&env), NULL);
-
-                        if (attachRes == JNI_OK)
-                        {
-                            AttachHelper::OnThreadAttach();
-
-                            env->DeleteGlobalRef(obj);
-                        }
-                    }
-                }
-            }
-
-            void JniContext::ThrowToJava(char* msg) {
-                JNIEnv* env = Attach();
-
-                env->ThrowNew(jvm->GetMembers().c_IgniteException, msg);
-            }
-
-            void JniContext::DestroyJvm() {
-                jvm->GetJvm()->DestroyJavaVM();
-            }
-
-            /**
-             * Attach thread to JVM.
-             */
-            JNIEnv* JniContext::Attach() {
-                JNIEnv* env;
-
-                jint attachRes = jvm->GetJvm()->AttachCurrentThread(reinterpret_cast<void**>(&env), NULL);
-
-                if (attachRes == JNI_OK)
-                    AttachHelper::OnThreadAttach();
-                else {
-                    if (hnds.error)
-                        hnds.error(hnds.target, IGNITE_JNI_ERR_JVM_ATTACH, NULL, 0, NULL, 0, NULL, 0);
-                }
-
-                return env;
-            }
-
-            void JniContext::ExceptionCheck(JNIEnv* env) {
-                ExceptionCheck(env, NULL);
-            }
-
-            void JniContext::ExceptionCheck(JNIEnv* env, JniErrorInfo* errInfo)
-            {
-                if (env->ExceptionCheck()) {
-                    jthrowable err = env->ExceptionOccurred();
-
-                    if (PRINT_EXCEPTION)
-                        env->CallVoidMethod(err, jvm->GetJavaMembers().m_Throwable_printStackTrace);
-
-                    env->ExceptionClear();
-
-                    // Get error class name and message.
-                    jclass cls = env->GetObjectClass(err);
-
-                    jstring clsName = static_cast<jstring>(env->CallObjectMethod(cls, jvm->GetJavaMembers().m_Class_getName));
-                    jstring msg = static_cast<jstring>(env->CallObjectMethod(err, jvm->GetJavaMembers().m_Throwable_getMessage));
-
-                    env->DeleteLocalRef(cls);
-
-                    int clsNameLen;
-                    std::string clsName0 = JavaStringToCString(env, clsName, &clsNameLen);
-
-                    int msgLen;
-                    std::string msg0 = JavaStringToCString(env, msg, &msgLen);
-
-                    if (errInfo)
-                    {
-                        JniErrorInfo errInfo0(IGNITE_JNI_ERR_GENERIC, clsName0.c_str(), msg0.c_str());
-
-                        *errInfo = errInfo0;
-                    }
-
-                    // Get error additional data (if any).
-                    jbyteArray errData = static_cast<jbyteArray>(env->CallStaticObjectMethod(
-                        jvm->GetMembers().c_PlatformUtils, jvm->GetMembers().m_PlatformUtils_errData, err));
-
-                    if (errData)
-                    {
-                        jbyte* errBytesNative = env->GetByteArrayElements(errData, NULL);
-
-                        int errBytesLen = env->GetArrayLength(errData);
-
-                        if (hnds.error)
-                            hnds.error(hnds.target, IGNITE_JNI_ERR_GENERIC, clsName0.c_str(), clsNameLen, msg0.c_str(), msgLen,
-                                errBytesNative, errBytesLen);
-
-                        env->ReleaseByteArrayElements(errData, errBytesNative, JNI_ABORT);
-                    }
-                    else
-                    {
-                        if (hnds.error)
-                            hnds.error(hnds.target, IGNITE_JNI_ERR_GENERIC, clsName0.c_str(), clsNameLen, msg0.c_str(), msgLen,
-                                NULL, 0);
-                    }
-
-                    env->DeleteLocalRef(err);
-                }
-            }
-
-            /**
-             * Convert local reference to global.
-             */
-            jobject JniContext::LocalToGlobal(JNIEnv* env, jobject localRef) {
-                if (localRef) {
-                    jobject globalRef = env->NewGlobalRef(localRef);
-
-                    env->DeleteLocalRef(localRef); // Clear local ref irrespective of result.
-
-                    if (!globalRef)
-                        ExceptionCheck(env);
-
-                    return globalRef;
-                }
-                else
-                    return NULL;
-            }
-
-            JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr) {
-                IGNITE_SAFE_FUNC(env, envPtr, CacheStoreCreateHandler, cacheStoreCreate, memPtr);
-            }
-
-            JNIEXPORT jint JNICALL JniCacheStoreInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr, jlong memPtr, jobject cb) {
-                if (cb)
-                {
-                    jobject cb0 = env->NewGlobalRef(cb);
-
-                    if (cb0)
-                    {
-                        JniGlobalRefGuard guard(env, cb0);
-
-                        IGNITE_SAFE_FUNC(env, envPtr, CacheStoreInvokeHandler, cacheStoreInvoke, objPtr, memPtr, cb0);
-                    }
-                    else
-                        return 0;
-                }
-                else {
-                    IGNITE_SAFE_FUNC(env, envPtr, CacheStoreInvokeHandler, cacheStoreInvoke, objPtr, memPtr, NULL);
-                }
+            JNIEXPORT jint JNICALL JniCacheStoreInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr, jlong memPtr) {
+                IGNITE_SAFE_FUNC(env, envPtr, CacheStoreInvokeHandler, cacheStoreInvoke, objPtr, memPtr);
             }
 
             JNIEXPORT void JNICALL JniCacheStoreDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index 62dc2df..e8448eb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -1889,6 +1889,50 @@ namespace Apache.Ignite.Core.Tests.Cache
             }, threads);
         }
 
+        /// <summary>
+        /// Simple cache lock test (while <see cref="TestLock"/> is ignored).
+        /// </summary>
+        [Test]
+        public void TestLockSimple()
+        {
+            if (!LockingEnabled())
+                return;
+
+            var cache = Cache();
+
+            const int key = 7;
+
+            Action<ICacheLock> checkLock = lck =>
+            {
+                using (lck)
+                {
+                    Assert.Throws<InvalidOperationException>(lck.Exit); // can't exit if not entered
+
+                    lck.Enter();
+
+                    Assert.IsTrue(cache.IsLocalLocked(key, true));
+                    Assert.IsTrue(cache.IsLocalLocked(key, false));
+
+                    lck.Exit();
+
+                    Assert.IsFalse(cache.IsLocalLocked(key, true));
+                    Assert.IsFalse(cache.IsLocalLocked(key, false));
+
+                    Assert.IsTrue(lck.TryEnter());
+
+                    Assert.IsTrue(cache.IsLocalLocked(key, true));
+                    Assert.IsTrue(cache.IsLocalLocked(key, false));
+
+                    lck.Exit();
+                }
+
+                Assert.Throws<ObjectDisposedException>(lck.Enter); // Can't enter disposed lock
+            };
+
+            checkLock(cache.Lock(key));
+            checkLock(cache.LockAll(new[] { key, 1, 2, 3 }));
+        }
+
         [Test]
         [Ignore("IGNITE-835")]
         public void TestLock()

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
index 3269651..2d38c72 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -322,6 +322,7 @@ namespace Apache.Ignite.Core.Tests.Services
 
             // .. but setter does not
             var ex = Assert.Throws<ServiceInvocationException>(() => { prx.TestProperty = new object(); });
+            Assert.IsNotNull(ex.InnerException);
             Assert.AreEqual("Object of type 'System.Object' cannot be converted to type 'System.Int32'.",
                 ex.InnerException.Message);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 823f9f2..667f807 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -166,6 +166,7 @@
     <Compile Include="Common\Package-Info.cs" />
     <Compile Include="Impl\Binary\BinaryWriterExtensions.cs" />
     <Compile Include="Impl\Cache\Affinity\AffinityFunctionBase.cs" />
+    <Compile Include="Impl\Cache\ICacheLockInternal.cs" />
     <Compile Include="Impl\Common\Platform.cs" />
     <Compile Include="Impl\Cache\Affinity\AffinityFunctionSerializer.cs" />
     <Compile Include="Impl\Cache\Affinity\PlatformAffinityFunction.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
index 00e13c5..4ff1f2e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
@@ -76,6 +76,9 @@ namespace Apache.Ignite.Core.Impl.Cache
         private const int OpPrimaryPartitions = 14;
 
         /** */
+        private const int OpPartitions = 15;
+
+        /** */
         private readonly bool _keepBinary;
         
         /** Grid. */
@@ -101,7 +104,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** <inheritDoc /> */
         public int Partitions
         {
-            get { return UU.AffinityPartitions(Target); }
+            get { return (int) DoOutOp(OpPartitions); }
         }
 
         /** <inheritDoc /> */

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 8a25a2c..3a82932 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -41,7 +41,7 @@ namespace Apache.Ignite.Core.Impl.Cache
     /// Native cache wrapper.
     /// </summary>
     [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
-    internal class CacheImpl<TK, TV> : PlatformTarget, ICache<TK, TV>, ICacheInternal
+    internal class CacheImpl<TK, TV> : PlatformTarget, ICache<TK, TV>, ICacheInternal, ICacheLockInternal
     {
         /** Duration: unchanged. */
         private const long DurUnchanged = -2;
@@ -89,20 +89,18 @@ namespace Apache.Ignite.Core.Impl.Cache
             _flagAsync = flagAsync;
             _flagNoRetries = flagNoRetries;
 
-            _asyncInstance = new Lazy<CacheImpl<TK, TV>>(() => new CacheImpl<TK, TV>(this));
+            _asyncInstance = new Lazy<CacheImpl<TK, TV>>(WithAsync);
         }
 
         /// <summary>
-        /// Initializes a new async instance.
+        /// Returns an instance with async mode enabled.
         /// </summary>
-        /// <param name="cache">The cache.</param>
-        private CacheImpl(CacheImpl<TK, TV> cache) : base(UU.CacheWithAsync(cache.Target), cache.Marshaller)
+        private CacheImpl<TK, TV> WithAsync()
         {
-            _ignite = cache._ignite;
-            _flagSkipStore = cache._flagSkipStore;
-            _flagKeepBinary = cache._flagKeepBinary;
-            _flagAsync = true;
-            _flagNoRetries = cache._flagNoRetries;
+            var target = DoOutOpObject((int) CacheOp.WithAsync);
+
+            return new CacheImpl<TK, TV>(_ignite, target, Marshaller, _flagSkipStore, _flagKeepBinary, 
+                true, _flagNoRetries);
         }
 
         /** <inheritDoc /> */
@@ -170,7 +168,7 @@ namespace Apache.Ignite.Core.Impl.Cache
             if (_flagSkipStore)
                 return this;
 
-            return new CacheImpl<TK, TV>(_ignite, UU.CacheWithSkipStore(Target), Marshaller, 
+            return new CacheImpl<TK, TV>(_ignite, DoOutOpObject((int) CacheOp.WithSkipStore), Marshaller,
                 true, _flagKeepBinary, _flagAsync, true);
         }
 
@@ -194,7 +192,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 return result;
             }
 
-            return new CacheImpl<TK1, TV1>(_ignite, UU.CacheWithKeepBinary(Target), Marshaller, 
+            return new CacheImpl<TK1, TV1>(_ignite, DoOutOpObject((int) CacheOp.WithKeepBinary), Marshaller,
                 _flagSkipStore, true, _flagAsync, _flagNoRetries);
         }
 
@@ -207,7 +205,12 @@ namespace Apache.Ignite.Core.Impl.Cache
             long update = ConvertDuration(plc.GetExpiryForUpdate());
             long access = ConvertDuration(plc.GetExpiryForAccess());
 
-            IUnmanagedTarget cache0 = UU.CacheWithExpiryPolicy(Target, create, update, access);
+            IUnmanagedTarget cache0 = DoOutOpObject((int)CacheOp.WithExpiryPolicy, w =>
+            {
+                w.WriteLong(create);
+                w.WriteLong(update);
+                w.WriteLong(access);
+            });
 
             return new CacheImpl<TK, TV>(_ignite, cache0, Marshaller, _flagSkipStore, _flagKeepBinary, _flagAsync, _flagNoRetries);
         }
@@ -637,7 +640,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** <inheritdoc /> */
         public void Clear()
         {
-            UU.CacheClear(Target);
+            DoOutOp((int) CacheOp.ClearCache);
         }
 
         /** <inheritDoc /> */
@@ -749,7 +752,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** <inheritDoc /> */
         public void RemoveAll()
         {
-            UU.CacheRemoveAll(Target);
+            DoOutOp((int) CacheOp.RemoveAll2);
         }
 
         /** <inheritDoc /> */
@@ -788,9 +791,11 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <returns>Size.</returns>
         private int Size0(bool loc, params CachePeekMode[] modes)
         {
-            int modes0 = EncodePeekModes(modes);
+            var modes0 = EncodePeekModes(modes);
 
-            return UU.CacheSize(Target, modes0, loc);
+            var op = loc ? CacheOp.SizeLoc : CacheOp.Size;
+
+            return (int) DoOutInOpLong((int) op, modes0);
         }
 
         /** <inheritDoc /> */
@@ -871,10 +876,10 @@ namespace Apache.Ignite.Core.Impl.Cache
         {
             IgniteArgumentCheck.NotNull(key, "key");
 
-            return DoOutInOp((int)CacheOp.Lock, writer =>
+            return DoOutInOp((int) CacheOp.Lock, writer =>
             {
                 writer.Write(key);
-            }, input => new CacheLock(input.ReadInt(), Target));
+            }, input => new CacheLock(input.ReadInt(), this));
         }
 
         /** <inheritdoc /> */
@@ -882,10 +887,10 @@ namespace Apache.Ignite.Core.Impl.Cache
         {
             IgniteArgumentCheck.NotNull(keys, "keys");
 
-            return DoOutInOp((int)CacheOp.LockAll, writer =>
+            return DoOutInOp((int) CacheOp.LockAll, writer =>
             {
                 WriteEnumerable(writer, keys);
-            }, input => new CacheLock(input.ReadInt(), Target));
+            }, input => new CacheLock(input.ReadInt(), this));
         }
 
         /** <inheritdoc /> */
@@ -914,7 +919,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** <inheritDoc /> */
         public Task Rebalance()
         {
-            return GetFuture<object>((futId, futTyp) => UU.CacheRebalance(Target, futId)).Task;
+            return GetFuture<object>((futId, futTyp) => DoOutInOpLong((int) CacheOp.Rebalance, futId)).Task;
         }
 
         /** <inheritDoc /> */
@@ -923,7 +928,7 @@ namespace Apache.Ignite.Core.Impl.Cache
             if (_flagNoRetries)
                 return this;
 
-            return new CacheImpl<TK, TV>(_ignite, UU.CacheWithNoRetries(Target), Marshaller,
+            return new CacheImpl<TK, TV>(_ignite, DoOutOpObject((int) CacheOp.WithNoRetries), Marshaller,
                 _flagSkipStore, _flagKeepBinary, _flagAsync, true);
         }
 
@@ -965,22 +970,14 @@ namespace Apache.Ignite.Core.Impl.Cache
             if (string.IsNullOrEmpty(qry.Sql))
                 throw new ArgumentException("Sql cannot be null or empty");
 
-            IUnmanagedTarget cursor;
-
-            using (var stream = IgniteManager.Memory.Allocate().GetStream())
+            var cursor = DoOutOpObject((int) CacheOp.QrySqlFields, writer =>
             {
-                var writer = Marshaller.StartMarshal(stream);
-
                 writer.WriteBoolean(qry.Local);
                 writer.WriteString(qry.Sql);
                 writer.WriteInt(qry.PageSize);
 
                 WriteQueryArgs(writer, qry.Arguments);
-
-                FinishMarshal(writer);
-
-                cursor = UU.CacheOutOpQueryCursor(Target, (int) CacheOp.QrySqlFields, stream.SynchronizeOutput());
-            }
+            });
         
             return new FieldsQueryCursor<T>(cursor, Marshaller, _flagKeepBinary, readerFunc);
         }
@@ -990,18 +987,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         {
             IgniteArgumentCheck.NotNull(qry, "qry");
 
-            IUnmanagedTarget cursor;
-
-            using (var stream = IgniteManager.Memory.Allocate().GetStream())
-            {
-                var writer = Marshaller.StartMarshal(stream);
-
-                qry.Write(writer, IsKeepBinary);
-
-                FinishMarshal(writer);
-
-                cursor = UU.CacheOutOpQueryCursor(Target, (int)qry.OpId, stream.SynchronizeOutput()); 
-            }
+            var cursor = DoOutOpObject((int) qry.OpId, writer => qry.Write(writer, IsKeepBinary));
 
             return new QueryCursor<TK, TV>(cursor, Marshaller, _flagKeepBinary);
         }
@@ -1058,41 +1044,8 @@ namespace Apache.Ignite.Core.Impl.Cache
         {
             qry.Validate();
 
-            var hnd = new ContinuousQueryHandleImpl<TK, TV>(qry, Marshaller, _flagKeepBinary);
-
-            try
-            {
-                using (var stream = IgniteManager.Memory.Allocate().GetStream())
-                {
-                    var writer = Marshaller.StartMarshal(stream);
-
-                    hnd.Start(_ignite, writer, () =>
-                    {
-                        if (initialQry != null)
-                        {
-                            writer.WriteInt((int) initialQry.OpId);
-
-                            initialQry.Write(writer, IsKeepBinary);
-                        }
-                        else
-                            writer.WriteInt(-1); // no initial query
-
-                        FinishMarshal(writer);
-
-                        // ReSharper disable once AccessToDisposedClosure
-                        return UU.CacheOutOpContinuousQuery(Target, (int) CacheOp.QryContinuous,
-                            stream.SynchronizeOutput());
-                    }, qry);
-                }
-
-                return hnd;
-            }
-            catch (Exception)
-            {
-                hnd.Dispose();
-
-                throw;
-            }
+            return new ContinuousQueryHandleImpl<TK, TV>(qry, Marshaller, _flagKeepBinary,
+                writeAction => DoOutOpObject((int) CacheOp.QryContinuous, writeAction), initialQry);
         }
 
         #endregion
@@ -1126,9 +1079,13 @@ namespace Apache.Ignite.Core.Impl.Cache
         internal CacheEnumerator<TK, TV> CreateEnumerator(bool loc, int peekModes)
         {
             if (loc)
-                return new CacheEnumerator<TK, TV>(UU.CacheLocalIterator(Target, peekModes), Marshaller, _flagKeepBinary);
+            {
+                var target = DoOutOpObject((int) CacheOp.LocIterator, w => w.WriteInt(peekModes));
 
-            return new CacheEnumerator<TK, TV>(UU.CacheIterator(Target), Marshaller, _flagKeepBinary);
+                return new CacheEnumerator<TK, TV>(target, Marshaller, _flagKeepBinary);
+            }
+
+            return new CacheEnumerator<TK, TV>(DoOutOpObject((int) CacheOp.Iterator), Marshaller, _flagKeepBinary);
         }
 
         #endregion
@@ -1312,5 +1269,33 @@ namespace Apache.Ignite.Core.Impl.Cache
                 ? new CacheResult<TR>()
                 : new CacheResult<TR>((TR)res);
         }
+
+        /** <inheritdoc /> */
+        public void Enter(long id)
+        {
+            DoOutInOpLong((int) CacheOp.EnterLock, id);
+        }
+
+        /** <inheritdoc /> */
+        public bool TryEnter(long id, TimeSpan timeout)
+        {
+            return DoOutOp((int) CacheOp.TryEnterLock, (IBinaryStream s) =>
+                   {
+                       s.WriteLong(id);
+                       s.WriteLong((long) timeout.TotalMilliseconds);
+                   }) == True;
+        }
+
+        /** <inheritdoc /> */
+        public void Exit(long id)
+        {
+            DoOutInOpLong((int) CacheOp.ExitLock, id);
+        }
+
+        /** <inheritdoc /> */
+        public void Close(long id)
+        {
+            DoOutInOpLong((int) CacheOp.CloseLock, id);
+        }
     }
 }


[39/40] ignite git commit: Re-generated GridQueryFailResponse.

Posted by av...@apache.org.
Re-generated GridQueryFailResponse.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 59de231c0d0dce56b0cf5c386b19a2880d9c0603
Parents: d3f042b
Author: sboikov <sb...@gridgain.com>
Authored: Mon Oct 17 16:31:35 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Oct 17 16:31:35 2016 +0300

----------------------------------------------------------------------
 .../query/h2/twostep/messages/GridQueryFailResponse.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/59de231c/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
index 0baf6ea..261241e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
@@ -113,13 +113,13 @@ public class GridQueryFailResponse implements Message {
                 writer.incrementState();
 
             case 1:
-                if (!writer.writeLong("qryReqId", qryReqId))
+                if (!writer.writeByte("failCode", failCode))
                     return false;
 
                 writer.incrementState();
 
             case 2:
-                if (!writer.writeByte("failCode", failCode))
+                if (!writer.writeLong("qryReqId", qryReqId))
                     return false;
 
                 writer.incrementState();
@@ -146,7 +146,7 @@ public class GridQueryFailResponse implements Message {
                 reader.incrementState();
 
             case 1:
-                qryReqId = reader.readLong("qryReqId");
+                failCode = reader.readByte("failCode");
 
                 if (!reader.isLastRead())
                     return false;
@@ -154,7 +154,7 @@ public class GridQueryFailResponse implements Message {
                 reader.incrementState();
 
             case 2:
-                failCode = reader.readByte("failCode");
+                qryReqId = reader.readLong("qryReqId");
 
                 if (!reader.isLastRead())
                     return false;
@@ -175,4 +175,4 @@ public class GridQueryFailResponse implements Message {
     @Override public byte fieldsCount() {
         return 3;
     }
-}
\ No newline at end of file
+}


[35/40] ignite git commit: GG-11360 - Implement SQL queries cancellation (#18)

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java
new file mode 100644
index 0000000..f75c907
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.near;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.cache.query.QueryCancelledException;
+import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests distributed SQL queries cancel by user or timeout.
+ */
+public class IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest extends GridCommonAbstractTest {
+    /** Grids count. */
+    private static final int GRIDS_COUNT = 3;
+
+    /** IP finder. */
+    private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** Cache size. */
+    public static final int CACHE_SIZE = 10_000;
+
+    /** Value size. */
+    public static final int VAL_SIZE = 16;
+
+    /** */
+    private static final String QUERY_1 = "select a._val, b._val from String a, String b";
+
+    /** */
+    private static final String QUERY_2 = "select a._key, count(*) from String a group by a._key";
+
+    /** */
+    private static final String QUERY_3 = "select a._val from String a";
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGridsMultiThreaded(GRIDS_COUNT);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+        TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
+        spi.setIpFinder(IP_FINDER);
+
+        CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<>();
+        ccfg.setIndexedTypes(Integer.class, String.class);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        if ("client".equals(gridName))
+            cfg.setClientMode(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        for (Ignite g : G.allGrids())
+            g.cache(null).removeAll();
+    }
+
+    /** */
+    public void testRemoteQueryExecutionTimeout() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_1, 500, TimeUnit.MILLISECONDS, true);
+    }
+
+    /** */
+    public void testRemoteQueryWithMergeTableTimeout() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_2, 500, TimeUnit.MILLISECONDS, true);
+    }
+
+    /** */
+    public void testRemoteQueryExecutionCancel0() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_1, 1, TimeUnit.MILLISECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryExecutionCancel1() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_1, 500, TimeUnit.MILLISECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryExecutionCancel2() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_1, 1, TimeUnit.SECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryExecutionCancel3() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_1, 3, TimeUnit.SECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryWithMergeTableCancel0() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_2, 1, TimeUnit.MILLISECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryWithMergeTableCancel1() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_2, 500, TimeUnit.MILLISECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryWithMergeTableCancel2() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_2, 1_500, TimeUnit.MILLISECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryWithMergeTableCancel3() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_2, 3, TimeUnit.SECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryWithoutMergeTableCancel0() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_3, 1, TimeUnit.MILLISECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryWithoutMergeTableCancel1() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_3, 500, TimeUnit.MILLISECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryWithoutMergeTableCancel2() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_3, 1_000, TimeUnit.MILLISECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryWithoutMergeTableCancel3() throws Exception {
+        testQuery(CACHE_SIZE, VAL_SIZE, QUERY_3, 3, TimeUnit.SECONDS, false);
+    }
+
+    /** */
+    public void testRemoteQueryAlreadyFinishedStop() throws Exception {
+        testQuery(100, VAL_SIZE, QUERY_3, 3, TimeUnit.SECONDS, false);
+    }
+
+    /** */
+    private void testQuery(int keyCnt, int valSize, String sql, int timeoutUnits, TimeUnit timeUnit,
+        boolean timeout) throws Exception {
+        try (Ignite client = startGrid("client")) {
+
+            IgniteCache<Object, Object> cache = client.cache(null);
+
+            assertEquals(0, cache.localSize());
+
+            int p = 1;
+            for (int i = 1; i <= keyCnt; i++) {
+                char[] tmp = new char[valSize];
+                Arrays.fill(tmp, ' ');
+                cache.put(i, new String(tmp));
+
+                if (i/(float)keyCnt >= p/10f) {
+                    log().info("Loaded " + i + " of " + keyCnt);
+
+                    p++;
+                }
+            }
+
+            assertEquals(0, cache.localSize());
+
+            SqlFieldsQuery qry = new SqlFieldsQuery(sql);
+
+            final QueryCursor<List<?>> cursor;
+            if (timeout) {
+                qry.setTimeout(timeoutUnits, timeUnit);
+
+                cursor = cache.query(qry);
+            } else {
+                cursor = cache.query(qry);
+
+                client.scheduler().runLocal(new Runnable() {
+                    @Override public void run() {
+                        cursor.close();
+                    }
+                }, timeoutUnits, timeUnit);
+            }
+
+            try(QueryCursor<List<?>> ignored = cursor) {
+                cursor.iterator();
+            }
+            catch (CacheException ex) {
+                log().error("Got expected exception", ex);
+
+                assertTrue("Must throw correct exception", ex.getCause() instanceof QueryCancelledException);
+            }
+
+            // Give some time to clean up.
+            Thread.sleep(TimeUnit.MILLISECONDS.convert(timeoutUnits, timeUnit) + 3_000);
+
+            checkCleanState();
+        }
+    }
+
+    /**
+     * Validates clean state on all participating nodes after query cancellation.
+     */
+    private void checkCleanState() {
+        for (int i = 0; i < GRIDS_COUNT; i++) {
+            IgniteEx grid = grid(i);
+
+            // Validate everything was cleaned up.
+            ConcurrentMap<UUID, ConcurrentMap<Long, ?>> map = U.field(((IgniteH2Indexing)U.field(U.field(
+                grid.context(), "qryProc"), "idx")).mapQueryExecutor(), "qryRess");
+
+            String msg = "Map executor state is not cleared";
+
+            // TODO FIXME Current implementation leaves map entry for each node that's ever executed a query.
+            for (ConcurrentMap<Long, ?> results : map.values())
+                assertEquals(msg, 0, results.size());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
index 2fa4750..8b33a46 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
@@ -33,7 +33,10 @@ 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.internal.IgniteFutureTimeoutCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.cache.query.QueryCancelledException;
 import org.apache.ignite.internal.util.GridRandom;
 import org.apache.ignite.internal.util.typedef.CAX;
 import org.apache.ignite.internal.util.typedef.F;
@@ -224,58 +227,77 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest
                     }
                     while (!locks.compareAndSet(g, 0, 1));
 
-                    if (rnd.nextBoolean()) { // Partitioned query.
-                        IgniteCache<?,?> cache = grid(g).cache("pu");
+                    try {
+                        if (rnd.nextBoolean()) { // Partitioned query.
+                            IgniteCache<?,?> cache = grid(g).cache("pu");
 
-                        SqlFieldsQuery qry = new SqlFieldsQuery(PARTITIONED_QRY);
+                            SqlFieldsQuery qry = new SqlFieldsQuery(PARTITIONED_QRY);
 
-                        boolean smallPageSize = rnd.nextBoolean();
+                            boolean smallPageSize = rnd.nextBoolean();
 
-                        if (smallPageSize)
-                            qry.setPageSize(3);
+                            if (smallPageSize)
+                                qry.setPageSize(3);
 
-                        try {
-                            assertEquals(pRes, cache.query(qry).getAll());
-                        }
-                        catch (CacheException e) {
-                            if (!smallPageSize)
-                                e.printStackTrace();
+                            try {
+                                assertEquals(pRes, cache.query(qry).getAll());
+                            } catch (CacheException e) {
+                                // Interruptions are expected here.
+                                if (e.getCause() instanceof IgniteInterruptedCheckedException)
+                                    continue;
 
-                            assertTrue("On large page size must retry.", smallPageSize);
+                                if (e.getCause() instanceof QueryCancelledException)
+                                    fail("Retry is expected");
 
-                            boolean failedOnRemoteFetch = false;
+                                if (!smallPageSize)
+                                    e.printStackTrace();
 
-                            for (Throwable th = e; th != null; th = th.getCause()) {
-                                if (!(th instanceof CacheException))
-                                    continue;
+                                assertTrue("On large page size must retry.", smallPageSize);
+
+                                boolean failedOnRemoteFetch = false;
+                                boolean failedOnInterruption = false;
+
+                                for (Throwable th = e; th != null; th = th.getCause()) {
+                                    if (th instanceof InterruptedException) {
+                                        failedOnInterruption = true;
 
-                                if (th.getMessage() != null &&
-                                    th.getMessage().startsWith("Failed to fetch data from node:")) {
-                                    failedOnRemoteFetch = true;
+                                        break;
+                                    }
 
-                                    break;
+                                    if (!(th instanceof CacheException))
+                                        continue;
+
+                                    if (th.getMessage() != null &&
+                                            th.getMessage().startsWith("Failed to fetch data from node:")) {
+                                        failedOnRemoteFetch = true;
+
+                                        break;
+                                    }
                                 }
-                            }
 
-                            if (!failedOnRemoteFetch) {
-                                e.printStackTrace();
+                                // Interruptions are expected here.
+                                if (failedOnInterruption)
+                                    continue;
 
-                                fail("Must fail inside of GridResultPage.fetchNextPage or subclass.");
-                            }
-                        }
-                    }
-                    else { // Replicated query.
-                        IgniteCache<?,?> cache = grid(g).cache("co");
+                                if (!failedOnRemoteFetch) {
+                                    e.printStackTrace();
 
-                        assertEquals(rRes, cache.query(new SqlFieldsQuery(REPLICATED_QRY)).getAll());
-                    }
+                                    fail("Must fail inside of GridResultPage.fetchNextPage or subclass.");
+                                }
+                            }
+                        } else { // Replicated query.
+                            IgniteCache<?, ?> cache = grid(g).cache("co");
 
-                    locks.set(g, 0);
+                            assertEquals(rRes, cache.query(new SqlFieldsQuery(REPLICATED_QRY)).getAll());
+                        }
+                    } finally {
+                        // Clearing lock in final handler to avoid endless loop if exception is thrown.
+                        locks.set(g, 0);
 
-                    int c = qryCnt.incrementAndGet();
+                        int c = qryCnt.incrementAndGet();
 
-                    if (c % logFreq == 0)
-                        info("Executed queries: " + c);
+                        if (c % logFreq == 0)
+                            info("Executed queries: " + c);
+                    }
                 }
             }
         }, qryThreadNum, "query-thread");
@@ -297,24 +319,26 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest
                     }
                     while (!locks.compareAndSet(g, 0, -1));
 
-                    log.info("Stop node: " + g);
-
-                    stopGrid(g);
+                    try {
+                        log.info("Stop node: " + g);
 
-                    Thread.sleep(rnd.nextInt(nodeLifeTime));
+                        stopGrid(g);
 
-                    log.info("Start node: " + g);
+                        Thread.sleep(rnd.nextInt(nodeLifeTime));
 
-                    startGrid(g);
+                        log.info("Start node: " + g);
 
-                    Thread.sleep(rnd.nextInt(nodeLifeTime));
+                        startGrid(g);
 
-                    locks.set(g, 0);
+                        Thread.sleep(rnd.nextInt(nodeLifeTime));
+                    } finally {
+                        locks.set(g, 0);
 
-                    int c = restartCnt.incrementAndGet();
+                        int c = restartCnt.incrementAndGet();
 
-                    if (c % logFreq == 0)
-                        info("Node restarts: " + c);
+                        if (c % logFreq == 0)
+                            info("Node restarts: " + c);
+                    }
                 }
 
                 return true;
@@ -333,7 +357,12 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest
 
         qrysDone.set(true);
 
-        fut1.get();
+        // Query thread can stuck in next page waiting loop because all nodes are left.
+        try {
+            fut1.get(5_000);
+        } catch (IgniteFutureTimeoutCheckedException e) {
+            fut1.cancel();
+        }
 
         info("Queries stopped.");
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java
new file mode 100644
index 0000000..68ecdff
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java
@@ -0,0 +1,158 @@
+/*
+ * 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.local;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.cache.query.QueryCancelledException;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheMode.LOCAL;
+
+/**
+ * Tests local query cancellations and timeouts.
+ */
+public class IgniteCacheLocalQueryCancelOrTimeoutSelfTest extends GridCommonAbstractTest {
+    /** Cache size. */
+    private static final int CACHE_SIZE = 10_000;
+
+    /** */
+    private static final String QUERY = "select a._val, b._val from String a, String b";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<>();
+        ccfg.setIndexedTypes(Integer.class, String.class);
+        ccfg.setCacheMode(LOCAL);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGrid(0);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        for (Ignite g : G.allGrids())
+            g.cache(null).removeAll();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @param cache Cache.
+     */
+    private void loadCache(IgniteCache<Integer, String> cache) {
+        int p = 1;
+
+        for (int i = 1; i <= CACHE_SIZE; i++) {
+            char[] tmp = new char[256];
+            Arrays.fill(tmp, ' ');
+            cache.put(i, new String(tmp));
+
+            if (i / (float)CACHE_SIZE >= p / 10f) {
+                log().info("Loaded " + i + " of " + CACHE_SIZE);
+
+                p++;
+            }
+        }
+    }
+
+    /**
+     * Tests cancellation.
+     */
+    public void testQueryCancel() {
+        testQuery(false, 1, TimeUnit.SECONDS);
+    }
+
+    /**
+     * Tests cancellation with zero timeout.
+     */
+    public void testQueryCancelZeroTimeout() {
+        testQuery(false, 1, TimeUnit.MILLISECONDS);
+    }
+
+    /**
+     * Tests timeout.
+     */
+    public void testQueryTimeout() {
+        testQuery(true, 1, TimeUnit.SECONDS);
+    }
+
+    /**
+     * Tests cancellation.
+     */
+    private void testQuery(boolean timeout, int timeoutUnits, TimeUnit timeUnit) {
+        Ignite ignite = grid(0);
+
+        IgniteCache<Integer, String> cache = ignite.cache(null);
+
+        loadCache(cache);
+
+        SqlFieldsQuery qry = new SqlFieldsQuery(QUERY);
+
+        final QueryCursor<List<?>> cursor;
+        if (timeout) {
+            qry.setTimeout(timeoutUnits, timeUnit);
+
+            cursor = cache.query(qry);
+        } else {
+            cursor = cache.query(qry);
+
+            ignite.scheduler().runLocal(new Runnable() {
+                @Override public void run() {
+                    cursor.close();
+                }
+            }, timeoutUnits, timeUnit);
+        }
+
+        try(QueryCursor<List<?>> ignored = cursor) {
+            cursor.iterator();
+
+            fail("Expecting timeout");
+        }
+        catch (Exception e) {
+            assertTrue("Must throw correct exception", e.getCause() instanceof QueryCancelledException);
+        }
+
+        // Test must exit gracefully.
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 0da71c8..289c7d7 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -347,8 +347,8 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
 
         // Fields query
         GridQueryFieldsResult fieldsRes =
-            spi.queryFields("A", "select a.a.name n1, a.a.age a1, b.a.name n2, " +
-            "b.a.age a2 from a.a, b.a where a.a.id = b.a.id ", Collections.emptySet(), null);
+            spi.execute("A", "select a.a.name n1, a.a.age a1, b.a.name n2, " +
+                "b.a.age a2 from a.a, b.a where a.a.id = b.a.id ", Collections.emptySet(), null, 0, null);
 
         String[] aliases = {"N1", "A1", "N2", "A2"};
         Object[] vals = { "Valera", 19, "Kolya", 25};
@@ -447,7 +447,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
                 time = now;
                 range *= 3;
 
-                GridQueryFieldsResult res = spi.queryFields("A", sql, Arrays.<Object>asList(1, range), null);
+                GridQueryFieldsResult res = spi.execute("A", sql, Arrays.<Object>asList(1, range), null, 0, null);
 
                 assert res.iterator().hasNext();
 
@@ -552,8 +552,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
                     return name;
                 }
 
-                @Override
-                public Class<?> type() {
+                @Override public Class<?> type() {
                     return Object.class;
                 }
             };

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
index 40fc157..9128f76 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
@@ -34,11 +34,14 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingQu
 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.IgniteCacheDistributedQueryCancelSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalFieldsQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQueryCancelOrTimeoutSelfTest;
 import org.apache.ignite.internal.processors.cache.query.GridCacheSwapScanQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryAtomicSelfTest;
 import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryLocalSelfTest;
@@ -103,6 +106,11 @@ public class IgniteCacheQuerySelfTestSuite2 extends TestSuite {
         suite.addTestSuite(IgniteCacheP2pUnmarshallingQueryErrorTest.class);
         suite.addTestSuite(IgniteCacheNoClassQuerySelfTest.class);
 
+        // Cancellation.
+        suite.addTestSuite(IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.class);
+        suite.addTestSuite(IgniteCacheDistributedQueryCancelSelfTest.class);
+        suite.addTestSuite(IgniteCacheLocalQueryCancelOrTimeoutSelfTest.class);
+
         // Other.
         suite.addTestSuite(CacheQueryNewClientSelfTest.class);
         suite.addTestSuite(CacheOffheapBatchIndexingSingleTypeTest.class);


[09/40] ignite git commit: IGNITE-3597: Removed static work directory.

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 5f65731..22d42db 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
@@ -1029,7 +1029,7 @@ public class UriDeploymentSpi extends IgniteSpiAdapter implements DeploymentSpi,
         URI uri;
 
         try {
-            uri = U.resolveWorkDirectory(DFLT_DEPLOY_DIR, false).toURI();
+            uri = U.resolveWorkDirectory(ignite.configuration().getWorkDirectory(), DFLT_DEPLOY_DIR, false).toURI();
         }
         catch (IgniteCheckedException e) {
             throw new IgniteSpiException("Failed to initialize default file scanner", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 1e8b634..8673b9c 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
@@ -2357,7 +2357,7 @@ object visor extends VisorTag {
         val folder = Option(f.getParent).getOrElse("")
         val fileName = f.getName
 
-        logFile = new File(U.resolveWorkDirectory(folder, false), fileName)
+        logFile = new File(U.resolveWorkDirectory(U.defaultWorkDirectory(), folder, false), fileName)
 
         logFile.createNewFile()
 


[19/40] ignite git commit: IGNITE-4014 Fixed "Transaction hangs if entry processor failed during serialization". This closes #1148.

Posted by av...@apache.org.
IGNITE-4014 Fixed "Transaction hangs if entry processor failed during serialization". This closes #1148.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 9a6cfce659df40b0a4624f19fd91c217b74bafea
Parents: f9a0676
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Tue Oct 11 13:59:57 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Tue Oct 11 13:59:58 2016 +0300

----------------------------------------------------------------------
 .../rendezvous/RendezvousAffinityFunction.java  |   2 +-
 .../cache/store/jdbc/CacheJdbcBlobStore.java    |   4 +-
 .../internal/GridEventConsumeHandler.java       |   8 +-
 .../internal/GridJobSiblingsResponse.java       |   3 +-
 .../internal/GridMessageListenHandler.java      |   8 +-
 .../internal/binary/BinaryEnumObjectImpl.java   |   3 +-
 .../internal/binary/BinaryMarshaller.java       |   2 +-
 .../internal/binary/BinaryWriterExImpl.java     |   3 +-
 .../GridClientOptimizedMarshaller.java          |   5 +-
 .../GridClientZipOptimizedMarshaller.java       |   5 +-
 .../apache/ignite/internal/jdbc/JdbcUtils.java  |   4 +-
 .../checkpoint/GridCheckpointManager.java       |   6 +-
 .../managers/communication/GridIoManager.java   |  12 +-
 .../deployment/GridDeploymentCommunication.java |   4 +-
 .../eventstorage/GridEventStorageManager.java   |  16 +-
 .../swapspace/GridSwapSpaceManager.java         |  13 +-
 .../processors/affinity/GridAffinityUtils.java  |   4 +-
 .../cache/CacheEntrySerializablePredicate.java  |   4 +-
 .../cache/CacheInvokeDirectResult.java          |   4 +-
 .../processors/cache/GridCacheMessage.java      |   4 +-
 .../processors/cache/GridCacheProcessor.java    |  13 +-
 .../processors/cache/GridCacheUtils.java        |   2 +-
 .../GridDistributedLockResponse.java            |   4 +-
 .../GridDistributedTxPrepareRequest.java        |   4 +-
 .../GridDistributedTxPrepareResponse.java       |   4 +-
 .../dht/GridDhtAffinityAssignmentResponse.java  |  12 +-
 .../dht/GridDhtTxFinishResponse.java            |   4 +-
 .../dht/atomic/GridDhtAtomicUpdateResponse.java |   4 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java |   2 +-
 .../atomic/GridNearAtomicUpdateResponse.java    |   4 +-
 .../dht/preloader/GridDhtForceKeysResponse.java |   4 +-
 .../GridDhtPartitionDemandMessage.java          |   4 +-
 .../preloader/GridDhtPartitionsFullMessage.java |   8 +-
 .../GridDhtPartitionsSingleMessage.java         |   8 +-
 .../distributed/near/GridNearGetResponse.java   |   4 +-
 .../near/GridNearSingleGetResponse.java         |   4 +-
 .../near/GridNearTxFinishResponse.java          |   4 +-
 .../cache/query/GridCacheLocalQueryFuture.java  |   4 +-
 .../cache/query/GridCacheQueryRequest.java      |  12 +-
 .../cache/query/GridCacheQueryResponse.java     |   4 +-
 .../cache/query/GridCacheSqlQuery.java          |   4 +-
 .../continuous/CacheContinuousQueryHandler.java |   4 +-
 .../jdbc/GridCacheQueryJdbcMetadataTask.java    |   4 +-
 .../query/jdbc/GridCacheQueryJdbcTask.java      |   6 +-
 .../cache/transactions/IgniteTxEntry.java       |   5 +-
 .../version/GridCacheRawVersionedEntry.java     |   8 +-
 .../IgniteCacheObjectProcessorImpl.java         |   3 +-
 .../closure/GridClosureProcessor.java           |   8 +-
 .../continuous/GridContinuousProcessor.java     |   6 +-
 .../processors/continuous/StartRequestData.java |   4 +-
 .../datastreamer/DataStreamProcessor.java       |   8 +-
 .../datastreamer/DataStreamerImpl.java          |   6 +-
 .../processors/igfs/IgfsAckMessage.java         |   5 +-
 .../processors/igfs/IgfsDeleteMessage.java      |   5 +-
 .../internal/processors/igfs/IgfsPaths.java     |   4 +-
 .../processors/job/GridJobProcessor.java        |  18 +-
 .../internal/processors/job/GridJobWorker.java  |   8 +-
 .../offheap/GridOffHeapProcessor.java           |   4 +-
 .../handlers/task/GridTaskCommandHandler.java   |  10 +-
 .../rest/protocols/tcp/GridTcpRestParser.java   |   4 +-
 .../service/GridServiceProcessor.java           |   9 +-
 .../processors/task/GridTaskProcessor.java      |   8 +-
 .../processors/task/GridTaskWorker.java         |  14 +-
 .../ignite/internal/util/IgniteUtils.java       | 199 +++++++
 .../ignite/marshaller/jdk/JdkMarshaller.java    |   8 +-
 .../optimized/OptimizedMarshaller.java          |  14 +-
 .../spi/checkpoint/sharedfs/SharedFsUtils.java  |   4 +-
 .../ignite/spi/discovery/tcp/ClientImpl.java    |   8 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  24 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   8 +-
 .../TcpDiscoveryMulticastIpFinder.java          |   4 +-
 .../TcpDiscoveryCustomEventMessage.java         |   3 +-
 .../spi/swapspace/file/FileSwapSpaceSpi.java    |   2 +-
 .../ignite/stream/socket/SocketStreamer.java    |   3 +-
 ...eEntryProcessorExternalizableFailedTest.java | 588 +++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |   2 +
 .../communication/HadoopMarshallerFilter.java   |  13 +-
 .../hibernate/CacheHibernateBlobStore.java      |   4 +-
 .../processors/query/h2/IgniteH2Indexing.java   |   4 +-
 .../serialization/CacheEventDeserializer.java   |   3 +-
 .../serialization/CacheEventSerializer.java     |   3 +-
 .../ignite/cache/websession/WebSessionV2.java   |  20 +-
 82 files changed, 1040 insertions(+), 252 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index aa8680c..ec12973 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -370,7 +370,7 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
             try {
                 ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-                byte[] nodeHashBytes = ignite.configuration().getMarshaller().marshal(nodeHash);
+                byte[] nodeHashBytes = U.marshal(ignite.configuration().getMarshaller(), nodeHash);
 
                 out.write(U.intToBytes(part), 0, 4); // Avoid IOException.
                 out.write(nodeHashBytes, 0, nodeHashBytes.length); // Avoid IOException.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
index 25f0f37..2739865 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
@@ -560,7 +560,7 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
      * @throws IgniteCheckedException If failed to convert.
      */
     protected byte[] toBytes(Object obj) throws IgniteCheckedException {
-        return marsh.marshal(obj);
+        return U.marshal(marsh, obj);
     }
 
     /**
@@ -575,7 +575,7 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
         if (bytes == null || bytes.length == 0)
             return null;
 
-        return marsh.unmarshal(bytes, getClass().getClassLoader());
+        return U.unmarshal(marsh, bytes, getClass().getClassLoader());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index ed6998d..715f8a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -365,7 +365,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
 
             depInfo = new GridDeploymentInfoBean(dep);
 
-            filterBytes = ctx.config().getMarshaller().marshal(filter);
+            filterBytes = U.marshal(ctx.config().getMarshaller(), filter);
         }
     }
 
@@ -382,7 +382,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
             if (dep == null)
                 throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
 
-            filter = ctx.config().getMarshaller().unmarshal(filterBytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
+            filter = U.unmarshal(ctx, filterBytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
         }
     }
 
@@ -490,7 +490,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
         void p2pMarshal(Marshaller marsh) throws IgniteCheckedException {
             assert marsh != null;
 
-            bytes = marsh.marshal(evt);
+            bytes = U.marshal(marsh, evt);
         }
 
         /**
@@ -504,7 +504,7 @@ class GridEventConsumeHandler implements GridContinuousHandler {
             assert evt == null;
             assert bytes != null;
 
-            evt = marsh.unmarshal(bytes, ldr);
+            evt = U.unmarshal(marsh, bytes, ldr);
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
index aa81cc5..727e79b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java
@@ -23,6 +23,7 @@ import java.util.Collection;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.compute.ComputeJobSibling;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -74,7 +75,7 @@ public class GridJobSiblingsResponse implements Message {
         assert marsh != null;
 
         if (siblingsBytes != null)
-            siblings = marsh.unmarshal(siblingsBytes, null);
+            siblings = U.unmarshal(marsh, siblingsBytes, null);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
index 1bca85c..0eeaa8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
@@ -154,9 +154,9 @@ public class GridMessageListenHandler implements GridContinuousHandler {
         assert ctx.config().isPeerClassLoadingEnabled();
 
         if (topic != null)
-            topicBytes = ctx.config().getMarshaller().marshal(topic);
+            topicBytes = U.marshal(ctx.config().getMarshaller(), topic);
 
-        predBytes = ctx.config().getMarshaller().marshal(pred);
+        predBytes = U.marshal(ctx.config().getMarshaller(), pred);
 
         // Deploy only listener, as it is very likely to be of some user class.
         GridPeerDeployAware pda = U.peerDeployAware(pred);
@@ -188,9 +188,9 @@ public class GridMessageListenHandler implements GridContinuousHandler {
         ClassLoader ldr = dep.classLoader();
 
         if (topicBytes != null)
-            topic = ctx.config().getMarshaller().unmarshal(topicBytes, U.resolveClassLoader(ldr, ctx.config()));
+            topic = U.unmarshal(ctx, topicBytes, U.resolveClassLoader(ldr, ctx.config()));
 
-        pred = ctx.config().getMarshaller().unmarshal(predBytes, U.resolveClassLoader(ldr, ctx.config()));
+        pred = U.unmarshal(ctx, predBytes, U.resolveClassLoader(ldr, ctx.config()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index dcfcc9d..69de3f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.jetbrains.annotations.Nullable;
@@ -247,7 +248,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
 
     /** {@inheritDoc} */
     @Override public byte[] valueBytes(CacheObjectContext cacheCtx) throws IgniteCheckedException {
-        return ctx.marshaller().marshal(this);
+        return U.marshal(ctx.marshaller(), this);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
index 168c61a..bd95103 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
@@ -90,7 +90,7 @@ public class BinaryMarshaller extends AbstractNodeNameAwareMarshaller {
         try {
             out.write(arr);
         }
-        catch (IOException e) {
+        catch (Exception e) {
             throw new BinaryObjectException("Failed to marshal the object: " + obj, e);
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 22b4d1f..1de0a65 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
 import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jetbrains.annotations.Nullable;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
@@ -174,7 +175,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
             out.writeByte(GridBinaryMarshaller.OPTM_MARSH);
 
             try {
-                byte[] arr = ctx.optimizedMarsh().marshal(obj);
+                byte[] arr = U.marshal(ctx.optimizedMarsh(), obj);
 
                 writeInt(arr.length);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
index a112736..3c65db6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
@@ -25,6 +25,7 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.MarshallerContextAdapter;
 import org.apache.ignite.internal.client.marshaller.GridClientMarshaller;
 import org.apache.ignite.internal.processors.rest.client.message.GridClientMessage;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
 import org.apache.ignite.plugin.PluginProvider;
 import org.jetbrains.annotations.Nullable;
@@ -84,7 +85,7 @@ public class GridClientOptimizedMarshaller implements GridClientMarshaller {
                 throw new IOException("Message serialization of given type is not supported: " +
                     obj.getClass().getName());
 
-            byte[] bytes = opMarsh.marshal(obj);
+            byte[] bytes = U.marshal(opMarsh, obj);
 
             ByteBuffer buf = ByteBuffer.allocate(off + bytes.length);
 
@@ -104,7 +105,7 @@ public class GridClientOptimizedMarshaller implements GridClientMarshaller {
     /** {@inheritDoc} */
     @Override public <T> T unmarshal(byte[] bytes) throws IOException {
         try {
-            return opMarsh.unmarshal(bytes, null);
+            return U.unmarshal(opMarsh, bytes, null);
         }
         catch (IgniteCheckedException e) {
             throw new IOException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientZipOptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientZipOptimizedMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientZipOptimizedMarshaller.java
index d9ce60e..b709634 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientZipOptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientZipOptimizedMarshaller.java
@@ -30,6 +30,7 @@ import java.util.zip.ZipOutputStream;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.client.marshaller.GridClientMarshaller;
 import org.apache.ignite.internal.processors.rest.client.message.GridClientMessage;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
 import org.apache.ignite.plugin.PluginProvider;
 import org.jetbrains.annotations.Nullable;
@@ -131,7 +132,7 @@ public class GridClientZipOptimizedMarshaller extends GridClientOptimizedMarshal
                 throw new IOException("Message serialization of given type is not supported: " +
                     obj.getClass().getName());
 
-            byte[] marshBytes = opMarsh.marshal(obj);
+            byte[] marshBytes = U.marshal(opMarsh, obj);
 
             boolean zip = marshBytes.length > 512;
 
@@ -158,7 +159,7 @@ public class GridClientZipOptimizedMarshaller extends GridClientOptimizedMarshal
 
             byte[] marshBytes = Arrays.copyOfRange(bytes, 1, bytes.length);
 
-            return opMarsh.unmarshal(unzip ? unzipBytes(marshBytes) : marshBytes, null);
+            return U.unmarshal(opMarsh, unzip ? unzipBytes(marshBytes) : marshBytes, null);
         }
         catch (IgniteCheckedException e) {
             throw new IOException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java
index ecea21f..04e4926 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcUtils.java
@@ -67,7 +67,7 @@ class JdbcUtils {
         assert args != null;
 
         try {
-            return MARSHALLER.marshal(args);
+            return U.marshal(MARSHALLER, args);
         }
         catch (IgniteCheckedException e) {
             throw new SQLException("Failed to unmarshal result.", e);
@@ -96,7 +96,7 @@ class JdbcUtils {
         assert bytes != null;
 
         try {
-            return MARSHALLER.unmarshal(bytes, null);
+            return U.unmarshal(MARSHALLER, bytes, null);
         }
         catch (IgniteCheckedException e) {
             throw new SQLException("Failed to unmarshal result.", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
index 6b95dad..9124caf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java
@@ -173,7 +173,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
         try {
             switch (scope) {
                 case GLOBAL_SCOPE: {
-                    byte[] data = state == null ? null : marsh.marshal(state);
+                    byte[] data = state == null ? null : U.marshal(marsh, state);
 
                     saved = getSpi(ses.getCheckpointSpi()).saveCheckpoint(key, data, timeout, override);
 
@@ -204,7 +204,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
                         timeout = ses.getEndTime() - now;
 
                     // Save it first to avoid getting null value on another node.
-                    byte[] data = state == null ? null : marsh.marshal(state);
+                    byte[] data = state == null ? null : U.marshal(marsh, state);
 
                     Set<String> keys = keyMap.get(ses.getId());
 
@@ -338,7 +338,7 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> {
 
             // Always deserialize with task/session class loader.
             if (data != null)
-                state = marsh.unmarshal(data, U.resolveClassLoader(ses.getClassLoader(), ctx.config()));
+                state = U.unmarshal(marsh, data, U.resolveClassLoader(ses.getClassLoader(), ctx.config()));
 
             record(EVT_CHECKPOINT_LOADED, key);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index bd285b2..cd43318 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -527,7 +527,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
                 int topicOrd = msg.topicOrdinal();
 
                 msg.topic(topicOrd >= 0 ? GridTopic.fromOrdinal(topicOrd) :
-                    marsh.unmarshal(msg.topicBytes(), U.resolveClassLoader(ctx.config())));
+                    U.unmarshal(marsh, msg.topicBytes(), U.resolveClassLoader(ctx.config())));
             }
 
             if (!started) {
@@ -1139,7 +1139,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         }
         else {
             if (topicOrd < 0)
-                ioMsg.topicBytes(marsh.marshal(topic));
+                ioMsg.topicBytes(U.marshal(marsh, topic));
 
             try {
                 if ((CommunicationSpi)getSpi() instanceof TcpCommunicationSpi)
@@ -1399,10 +1399,10 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         byte[] serTopic = null;
 
         if (!loc) {
-            serMsg = marsh.marshal(msg);
+            serMsg = U.marshal(marsh, msg);
 
             if (topic != null)
-                serTopic = marsh.marshal(topic);
+                serTopic = U.marshal(marsh, topic);
         }
 
         GridDeployment dep = null;
@@ -2059,7 +2059,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
 
                     // Unmarshall message topic if needed.
                     if (msgTopic == null && msgTopicBytes != null) {
-                        msgTopic = marsh.unmarshal(msgTopicBytes,
+                        msgTopic = U.unmarshal(marsh, msgTopicBytes,
                             U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()));
 
                         ioMsg.topic(msgTopic); // Save topic to avoid future unmarshallings.
@@ -2069,7 +2069,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
                         return;
 
                     if (msgBody == null) {
-                        msgBody = marsh.unmarshal(ioMsg.bodyBytes(),
+                        msgBody = U.unmarshal(marsh, ioMsg.bodyBytes(),
                             U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()));
 
                         ioMsg.body(msgBody); // Save body to avoid future unmarshallings.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
index d4b3568..a571ae4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
@@ -182,7 +182,7 @@ class GridDeploymentCommunication {
 
         if (req.responseTopic() == null) {
             try {
-                req.responseTopic(marsh.unmarshal(req.responseTopicBytes(), U.resolveClassLoader(ctx.config())));
+                req.responseTopic(U.unmarshal(marsh, req.responseTopicBytes(), U.resolveClassLoader(ctx.config())));
             }
             catch (IgniteCheckedException e) {
                 U.error(log, "Failed to process deployment request (will ignore): " + req, e);
@@ -443,7 +443,7 @@ class GridDeploymentCommunication {
             long start = U.currentTimeMillis();
 
             if (req.responseTopic() != null && !ctx.localNodeId().equals(dstNode.id()))
-                req.responseTopicBytes(marsh.marshal(req.responseTopic()));
+                req.responseTopicBytes(U.marshal(marsh, req.responseTopic()));
 
             ctx.io().send(dstNode, TOPIC_CLASSLOAD, req, GridIoPolicy.P2P_POOL);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index 0095707..5b451a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -891,11 +891,11 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
 
                 try {
                     if (res.eventsBytes() != null)
-                        res.events(marsh.<Collection<Event>>unmarshal(res.eventsBytes(),
+                        res.events(U.<Collection<Event>>unmarshal(marsh, res.eventsBytes(),
                             U.resolveClassLoader(ctx.config())));
 
                     if (res.exceptionBytes() != null)
-                        res.exception(marsh.<Throwable>unmarshal(res.exceptionBytes(),
+                        res.exception(U.<Throwable>unmarshal(marsh, res.exceptionBytes(),
                             U.resolveClassLoader(ctx.config())));
                 }
                 catch (IgniteCheckedException e) {
@@ -932,7 +932,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
 
             ioMgr.addMessageListener(resTopic, resLsnr);
 
-            byte[] serFilter = marsh.marshal(p);
+            byte[] serFilter = U.marshal(marsh, p);
 
             GridDeployment dep = ctx.deploy().deploy(p.getClass(), U.detectClassLoader(p.getClass()));
 
@@ -1023,7 +1023,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
             ctx.io().send(locNode, topic, msg, plc);
 
         if (!rmtNodes.isEmpty()) {
-            msg.responseTopicBytes(marsh.marshal(msg.responseTopic()));
+            msg.responseTopicBytes(U.marshal(marsh, msg.responseTopic()));
 
             ctx.io().send(rmtNodes, topic, msg, plc);
         }
@@ -1089,7 +1089,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
 
                 try {
                     if (req.responseTopicBytes() != null)
-                        req.responseTopic(marsh.unmarshal(req.responseTopicBytes(), U.resolveClassLoader(ctx.config())));
+                        req.responseTopic(U.unmarshal(marsh, req.responseTopicBytes(), U.resolveClassLoader(ctx.config())));
 
                     GridDeployment dep = ctx.deploy().getGlobalDeployment(
                         req.deploymentMode(),
@@ -1105,7 +1105,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
                         throw new IgniteDeploymentCheckedException("Failed to obtain deployment for event filter " +
                             "(is peer class loading turned on?): " + req);
 
-                    filter = marsh.unmarshal(req.filter(), U.resolveClassLoader(dep.classLoader(), ctx.config()));
+                    filter = U.unmarshal(marsh, req.filter(), U.resolveClassLoader(dep.classLoader(), ctx.config()));
 
                     // Resource injection.
                     ctx.resource().inject(dep, dep.deployedClass(req.filterClassName()), filter);
@@ -1140,8 +1140,8 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
                         log.debug("Sending event query response to node [nodeId=" + nodeId + "res=" + res + ']');
 
                     if (!ctx.localNodeId().equals(nodeId)) {
-                        res.eventsBytes(marsh.marshal(res.events()));
-                        res.exceptionBytes(marsh.marshal(res.exception()));
+                        res.eventsBytes(U.marshal(marsh, res.events()));
+                        res.exceptionBytes(U.marshal(marsh, res.exception()));
                     }
 
                     ctx.io().send(node, req.responseTopic(), res, PUBLIC_POOL);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
index 437603a..1d36b4e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
@@ -400,18 +400,7 @@ public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi> {
         if (swapBytes == null)
             return null;
 
-        return marsh.unmarshal(swapBytes, ldr != null ? ldr : U.gridClassLoader());
-    }
-
-    /**
-     * Marshals object.
-     *
-     * @param obj Object to marshal.
-     * @return Marshalled array.
-     * @throws IgniteCheckedException If failed.
-     */
-    private byte[] marshal(Object obj) throws IgniteCheckedException {
-        return ctx.config().getMarshaller().marshal(obj);
+        return U.unmarshal(marsh, swapBytes, ldr != null ? ldr : U.gridClassLoader());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
index 2952ebc..c24dd2d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java
@@ -77,7 +77,7 @@ class GridAffinityUtils {
             throw new IgniteDeploymentCheckedException("Failed to deploy affinity object with class: " + cls.getName());
 
         return new GridAffinityMessage(
-            ctx.config().getMarshaller().marshal(o),
+            U.marshal(ctx, o),
             cls.getName(),
             dep.classLoaderId(),
             dep.deployMode(),
@@ -110,7 +110,7 @@ class GridAffinityUtils {
             throw new IgniteDeploymentCheckedException("Failed to obtain affinity object (is peer class loading turned on?): " +
                 msg);
 
-        Object src = ctx.config().getMarshaller().unmarshal(msg.source(),
+        Object src = U.unmarshal(ctx, msg.source(),
             U.resolveClassLoader(dep.classLoader(), ctx.config()));
 
         // Resource injection.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
index 5f52cf7..623fc4b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
@@ -80,7 +80,7 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
         assert p != null || bytes != null;
 
         if (p == null) {
-            p = ctx.marshaller().unmarshal(bytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            p = U.unmarshal(ctx.marshaller(), bytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
             p.finishUnmarshal(ctx, ldr);
         }
@@ -93,7 +93,7 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
         p.prepareMarshal(ctx);
 
         if (bytes == null)
-            bytes = ctx.marshaller().marshal(p);
+            bytes = U.marshal(ctx.marshaller(), p);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
index 5dea51b..0d519f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java
@@ -106,7 +106,7 @@ public class CacheInvokeDirectResult implements Message {
         key.prepareMarshal(ctx.cacheObjectContext());
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx.marshaller(), err);
 
         if (res != null)
             res.prepareMarshal(ctx.cacheObjectContext());
@@ -121,7 +121,7 @@ public class CacheInvokeDirectResult implements Message {
         key.finishUnmarshal(ctx.cacheObjectContext(), ldr);
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx.marshaller(), errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (res != null)
             res.finishUnmarshal(ctx.cacheObjectContext(), ldr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index c5407b8..71f99d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -458,7 +458,7 @@ public abstract class GridCacheMessage implements Message {
         Marshaller marsh = ctx.marshaller();
 
         for (int i = 0; i < byteCol.length; i++)
-            args[i] = byteCol[i] == null ? null : marsh.unmarshal(byteCol[i], U.resolveClassLoader(ldr, ctx.gridConfig()));
+            args[i] = byteCol[i] == null ? null : U.unmarshal(marsh, byteCol[i], U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         return args;
     }
@@ -609,7 +609,7 @@ public abstract class GridCacheMessage implements Message {
         Marshaller marsh = ctx.marshaller();
 
         for (byte[] bytes : byteCol)
-            col.add(bytes == null ? null : marsh.<T>unmarshal(bytes, U.resolveClassLoader(ldr, ctx.gridConfig())));
+            col.add(bytes == null ? null : U.<T>unmarshal(marsh, bytes, U.resolveClassLoader(ldr, ctx.gridConfig())));
 
         return col;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/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 0a0b40a..fd6abbd 100755
--- 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
@@ -117,7 +117,6 @@ import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.lifecycle.LifecycleAware;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.MarshallerUtils;
-import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.ignite.spi.IgniteNodeValidationResult;
 import org.jetbrains.annotations.Nullable;
 
@@ -185,8 +184,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     /** */
     private IdentityHashMap<CacheStore, ThreadLocal> sesHolders = new IdentityHashMap<>();
 
-    /** Must use JDK marshaller since it is used by discovery to fire custom events. */
-    private final Marshaller marshaller;
+    /** Must use JDK marsh since it is used by discovery to fire custom events. */
+    private final Marshaller marsh;
 
     /** Count down latch for caches. */
     private final CountDownLatch cacheStartedLatch = new CountDownLatch(1);
@@ -207,7 +206,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         jCacheProxies = new ConcurrentHashMap<>();
         stopSeq = new LinkedList<>();
 
-        marshaller = MarshallerUtils.jdkMarshaller(ctx.gridName());
+        marsh = MarshallerUtils.jdkMarshaller(ctx.gridName());
     }
 
     /**
@@ -3563,7 +3562,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                         if (ldr == null)
                             ldr = val.getCacheStoreFactory().getClass().getClassLoader();
 
-                        marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
+                        U.unmarshal(marsh, U.marshal(marsh, val.getCacheStoreFactory()),
                             U.resolveClassLoader(ldr, ctx.config()));
                     }
                     catch (IgniteCheckedException e) {
@@ -3573,7 +3572,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 }
 
                 try {
-                    return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config()));
+                    return U.unmarshal(marsh, U.marshal(marsh, val), U.resolveClassLoader(ctx.config()));
                 }
                 catch (IgniteCheckedException e) {
                     throw new IgniteCheckedException("Failed to validate cache configuration " +
@@ -3615,7 +3614,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     public <T> T clone(final T obj) throws IgniteCheckedException {
         return withBinaryContext(new IgniteOutClosureX<T>() {
             @Override public T applyx() throws IgniteCheckedException {
-                return marshaller.unmarshal(marshaller.marshal(obj), U.resolveClassLoader(ctx.config()));
+                return U.unmarshal(marsh, U.marshal(marsh, obj), U.resolveClassLoader(ctx.config()));
             }
         });
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 0f4e89b..4c18f21 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -895,7 +895,7 @@ public class GridCacheUtils {
             }
         }
 
-        return ctx.marshaller().marshal(obj);
+        return U.marshal(ctx, obj);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
index 1763ff9..61a2388 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
@@ -194,7 +194,7 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage {
         prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId));
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx.marshaller(), err);
     }
 
     /** {@inheritDoc} */
@@ -204,7 +204,7 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage {
         finishUnmarshalCacheObjects(vals, ctx.cacheContext(cacheId), ldr);
 
         if (errBytes != null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index c691374..7b1dcc5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -334,7 +334,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
         // Marshal txNodes only if there is a node in topology with an older version.
         if (ctx.exchange().minimumNodeVersion(topologyVersion()).compareTo(TX_NODES_DIRECT_MARSHALLABLE_SINCE) < 0) {
             if (txNodes != null && txNodesBytes == null)
-                txNodesBytes = ctx.marshaller().marshal(txNodes);
+                txNodesBytes = U.marshal(ctx, txNodes);
         }
         else {
             if (txNodesMsg == null)
@@ -374,7 +374,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
             txNodes = F.viewReadOnly(txNodesMsg, MSG_TO_COL);
 
         if (txNodesBytes != null && txNodes == null)
-            txNodes = ctx.marshaller().unmarshal(txNodesBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            txNodes = U.unmarshal(ctx, txNodesBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
index 850c095..6c127c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
@@ -100,7 +100,7 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
         super.prepareMarshal(ctx);
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx, err);
     }
 
     /** {@inheritDoc} */
@@ -108,7 +108,7 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
         super.finishUnmarshal(ctx, ldr);
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
index e883614..cad1617 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
@@ -207,13 +207,13 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
         assert affAssignment != null ^ affAssignmentIds != null;
 
         if (affAssignment != null && affAssignmentBytes == null)
-            affAssignmentBytes = ctx.marshaller().marshal(affAssignment);
+            affAssignmentBytes = U.marshal(ctx, affAssignment);
 
         if (affAssignmentIds != null && affAssignmentIdsBytes == null)
-            affAssignmentIdsBytes = ctx.marshaller().marshal(affAssignmentIds);
+            affAssignmentIdsBytes = U.marshal(ctx, affAssignmentIds);
 
         if (idealAffAssignment != null && idealAffAssignmentBytes == null)
-            idealAffAssignmentBytes = ctx.marshaller().marshal(idealAffAssignment);
+            idealAffAssignmentBytes = U.marshal(ctx, idealAffAssignment);
     }
 
     /** {@inheritDoc} */
@@ -228,10 +228,10 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
             affAssignment = unmarshalNodes(affAssignmentBytes, ctx, ldr);
 
         if (affAssignmentIdsBytes != null && affAssignmentIds == null)
-            affAssignmentIds = ctx.marshaller().unmarshal(affAssignmentIdsBytes, ldr);
+            affAssignmentIds = U.unmarshal(ctx, affAssignmentIdsBytes, ldr);
 
         if (idealAffAssignmentBytes != null && idealAffAssignment == null)
-            idealAffAssignment = ctx.marshaller().unmarshal(idealAffAssignmentBytes, ldr);
+            idealAffAssignment = U.unmarshal(ctx, idealAffAssignmentBytes, ldr);
     }
 
     /**
@@ -247,7 +247,7 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
         ClassLoader ldr)
         throws IgniteCheckedException
     {
-        List<List<ClusterNode>> affAssignment = ctx.marshaller().unmarshal(bytes,
+        List<List<ClusterNode>> affAssignment = U.unmarshal(ctx, bytes,
             U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         // TODO IGNITE-2110: setting 'local' for nodes not needed when IGNITE-2110 is implemented.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
index 0618172..8fb1f4e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java
@@ -115,7 +115,7 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
         super.prepareMarshal(ctx);
 
         if (checkCommittedErr != null && checkCommittedErrBytes == null)
-            checkCommittedErrBytes = ctx.marshaller().marshal(checkCommittedErr);
+            checkCommittedErrBytes = U.marshal(ctx, checkCommittedErr);
 
         if (retVal != null && retVal.cacheId() != 0) {
             GridCacheContext cctx = ctx.cacheContext(retVal.cacheId());
@@ -132,7 +132,7 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
         super.finishUnmarshal(ctx, ldr);
 
         if (checkCommittedErrBytes != null && checkCommittedErr == null)
-            checkCommittedErr = ctx.marshaller().unmarshal(checkCommittedErrBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            checkCommittedErr = U.unmarshal(ctx, checkCommittedErrBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (retVal != null && retVal.cacheId() != 0) {
             GridCacheContext cctx = ctx.cacheContext(retVal.cacheId());

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
index 1334819..ff12af0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java
@@ -168,7 +168,7 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
         prepareMarshalCacheObjects(nearEvicted, cctx);
 
         if (errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx, err);
     }
 
     /** {@inheritDoc} */
@@ -182,7 +182,7 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
         finishUnmarshalCacheObjects(nearEvicted, cctx, ldr);
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
index eb9be4d..5057fbb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
@@ -659,7 +659,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
         }
 
         if (expiryPlcBytes != null && expiryPlc == null)
-            expiryPlc = ctx.marshaller().unmarshal(expiryPlcBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            expiryPlc = U.unmarshal(ctx, expiryPlcBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (partIds != null && !partIds.isEmpty()) {
             assert partIds.size() == keys.size();

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
index ff4008e..2e38733 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
@@ -397,7 +397,7 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
         super.prepareMarshal(ctx);
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx, err);
 
         GridCacheContext cctx = ctx.cacheContext(cacheId);
 
@@ -416,7 +416,7 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
         super.finishUnmarshal(ctx, ldr);
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         GridCacheContext cctx = ctx.cacheContext(cacheId);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
index fcdf402..8d90158 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java
@@ -172,7 +172,7 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
         }
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx, err);
     }
 
     /** {@inheritDoc} */
@@ -190,7 +190,7 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
         }
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/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 d90ada8..bb952d4 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
@@ -185,7 +185,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
         super.prepareMarshal(ctx);
 
         if (topic != null && topicBytes == null)
-            topicBytes = ctx.marshaller().marshal(topic);
+            topicBytes = U.marshal(ctx, topic);
     }
 
     /** {@inheritDoc} */
@@ -193,7 +193,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
         super.finishUnmarshal(ctx, ldr);
 
         if (topicBytes != null && topic == null)
-            topic = ctx.marshaller().unmarshal(topicBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            topic = U.unmarshal(ctx, topicBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/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 49942a1..a4ff04b 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
@@ -133,10 +133,10 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
         super.prepareMarshal(ctx);
 
         if (parts != null && partsBytes == null)
-            partsBytes = ctx.marshaller().marshal(parts);
+            partsBytes = U.marshal(ctx, parts);
 
         if (partCntrs != null && partCntrsBytes == null)
-            partCntrsBytes = ctx.marshaller().marshal(partCntrs);
+            partCntrsBytes = U.marshal(ctx, partCntrs);
     }
 
     /**
@@ -158,13 +158,13 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
         super.finishUnmarshal(ctx, ldr);
 
         if (partsBytes != null && parts == null)
-            parts = ctx.marshaller().unmarshal(partsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            parts = U.unmarshal(ctx, partsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (parts == null)
             parts = new HashMap<>();
 
         if (partCntrsBytes != null && partCntrs == null)
-            partCntrs = ctx.marshaller().unmarshal(partCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            partCntrs = U.unmarshal(ctx, partCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (partCntrs == null)
             partCntrs = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index a2be0b0..e4356b1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -137,10 +137,10 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
         super.prepareMarshal(ctx);
 
         if (partsBytes == null && parts != null)
-            partsBytes = ctx.marshaller().marshal(parts);
+            partsBytes = U.marshal(ctx, parts);
 
         if (partCntrsBytes == null && partCntrs != null)
-            partCntrsBytes = ctx.marshaller().marshal(partCntrs);
+            partCntrsBytes = U.marshal(ctx, partCntrs);
     }
 
     /** {@inheritDoc} */
@@ -148,10 +148,10 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
         super.finishUnmarshal(ctx, ldr);
 
         if (partsBytes != null && parts == null)
-            parts = ctx.marshaller().unmarshal(partsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            parts = U.unmarshal(ctx, partsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (partCntrsBytes != null && partCntrs == null)
-            partCntrs = ctx.marshaller().unmarshal(partCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            partCntrs = U.unmarshal(ctx, partCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
index f298515..049431e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
@@ -190,7 +190,7 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
         }
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx, err);
     }
 
     /** {@inheritDoc} */
@@ -205,7 +205,7 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
         }
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
index 95799b2..bbc968d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java
@@ -169,7 +169,7 @@ public class GridNearSingleGetResponse extends GridCacheMessage implements GridC
         }
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx, err);
     }
 
     /** {@inheritDoc} */
@@ -188,7 +188,7 @@ public class GridNearSingleGetResponse extends GridCacheMessage implements GridC
         }
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
index 0bdb09b..37fbb36 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
@@ -101,7 +101,7 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
         super.prepareMarshal(ctx);
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx, err);
     }
 
     /** {@inheritDoc} */
@@ -109,7 +109,7 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
         super.finishUnmarshal(ctx, ldr);
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
index 91ae12c..6eaca29 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryFuture.java
@@ -113,11 +113,11 @@ public class GridCacheLocalQueryFuture<K, V, R> extends GridCacheQueryFutureAdap
             Marshaller marsh = cctx.marshaller();
 
             IgniteReducer<Object, Object> rdc = qry.reducer() != null ?
-                marsh.<IgniteReducer<Object, Object>>unmarshal(marsh.marshal(qry.reducer()),
+                U.<IgniteReducer<Object, Object>>unmarshal(marsh, U.marshal(marsh, qry.reducer()),
                     U.resolveClassLoader(cctx.gridConfig())) : null;
 
             IgniteClosure<Object, Object> trans = qry.transform() != null ?
-                marsh.<IgniteClosure<Object, Object>>unmarshal(marsh.marshal(qry.transform()),
+                U.<IgniteClosure<Object, Object>>unmarshal(marsh, U.marshal(marsh, qry.transform()),
                     U.resolveClassLoader(cctx.gridConfig())) : null;
 
             return new GridCacheQueryInfo(

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
index 5610bef..60c4662 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
@@ -319,16 +319,16 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
         Marshaller mrsh = ctx.marshaller();
 
         if (keyValFilterBytes != null && keyValFilter == null)
-            keyValFilter = mrsh.unmarshal(keyValFilterBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            keyValFilter = U.unmarshal(mrsh, keyValFilterBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (rdcBytes != null && rdc == null)
-            rdc = mrsh.unmarshal(rdcBytes, ldr);
+            rdc = U.unmarshal(mrsh, rdcBytes, ldr);
 
         if (transBytes != null && trans == null)
-            trans = mrsh.unmarshal(transBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            trans = U.unmarshal(mrsh, transBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (argsBytes != null && args == null)
-            args = mrsh.unmarshal(argsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            args = U.unmarshal(mrsh, argsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
     }
 
     /** {@inheritDoc} */
@@ -343,9 +343,9 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
     void beforeLocalExecution(GridCacheContext ctx) throws IgniteCheckedException {
         Marshaller marsh = ctx.marshaller();
 
-        rdc = rdc != null ? marsh.<IgniteReducer<Object, Object>>unmarshal(marsh.marshal(rdc),
+        rdc = rdc != null ? U.<IgniteReducer<Object, Object>>unmarshal(marsh, U.marshal(marsh, rdc),
             U.resolveClassLoader(ctx.gridConfig())) : null;
-        trans = trans != null ? marsh.<IgniteClosure<Object, Object>>unmarshal(marsh.marshal(trans),
+        trans = trans != null ? U.<IgniteClosure<Object, Object>>unmarshal(marsh, U.marshal(marsh, trans),
             U.resolveClassLoader(ctx.gridConfig())) : null;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
index 9a03bdc..8492c38 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
@@ -124,7 +124,7 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
         GridCacheContext cctx = ctx.cacheContext(cacheId);
 
         if (err != null && errBytes == null)
-            errBytes = ctx.marshaller().marshal(err);
+            errBytes = U.marshal(ctx, err);
 
         if (metaDataBytes == null)
             metaDataBytes = marshalCollection(metadata, cctx);
@@ -149,7 +149,7 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
         super.finishUnmarshal(ctx, ldr);
 
         if (errBytes != null && err == null)
-            err = ctx.marshaller().unmarshal(errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+            err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
 
         if (metadata == null)
             metadata = unmarshalCollection(metaDataBytes, ctx, ldr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
index bcb37c5..4dd3636 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
@@ -141,7 +141,7 @@ public class GridCacheSqlQuery implements Message {
 
         assert params != null;
 
-        paramsBytes = m.marshal(params);
+        paramsBytes = U.marshal(m, params);
     }
 
     /**
@@ -160,7 +160,7 @@ public class GridCacheSqlQuery implements Message {
             // To avoid deserializing of enum types.
             params = ((BinaryMarshaller)m).binaryMarshaller().unmarshal(paramsBytes, ldr);
         else
-            params = m.unmarshal(paramsBytes, ldr);
+            params = U.unmarshal(m, paramsBytes, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index a5752ed..4b5074c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -1562,7 +1562,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
 
             depInfo = new GridDeploymentInfoBean(dep);
 
-            bytes = ctx.config().getMarshaller().marshal(obj);
+            bytes = U.marshal(ctx, obj);
         }
 
         /**
@@ -1580,7 +1580,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
             if (dep == null)
                 throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
 
-            return ctx.config().getMarshaller().unmarshal(bytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
+            return U.unmarshal(ctx, bytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
index a8b2da4..e95622c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcMetadataTask.java
@@ -153,7 +153,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter<String, b
 
                 status = 0;
 
-                data = MARSHALLER.marshal(F.asList(schemasMap, indexesInfo));
+                data = U.marshal(MARSHALLER, F.asList(schemasMap, indexesInfo));
             }
             catch (Throwable t) {
                 U.error(log, "Failed to get metadata for JDBC.", t);
@@ -163,7 +163,7 @@ public class GridCacheQueryJdbcMetadataTask extends ComputeTaskAdapter<String, b
                 status = 1;
 
                 try {
-                    data = MARSHALLER.marshal(err);
+                    data = U.marshal(MARSHALLER, err);
                 }
                 catch (IgniteCheckedException e) {
                     throw new IgniteException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
index 26d4b82..ca08ead 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
@@ -84,7 +84,7 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
         try {
             assert arg != null;
 
-            Map<String, Object> args = MARSHALLER.unmarshal(arg, null);
+            Map<String, Object> args = U.unmarshal(MARSHALLER, arg, null);
 
             boolean first = true;
 
@@ -165,12 +165,12 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
             if (res.getException() == null) {
                 status = 0;
 
-                bytes = MARSHALLER.marshal(res.getData());
+                bytes = U.marshal(MARSHALLER, res.getData());
             }
             else {
                 status = 1;
 
-                bytes = MARSHALLER.marshal(new SQLException(res.getException().getMessage()));
+                bytes = U.marshal(MARSHALLER, new SQLException(res.getException().getMessage()));
             }
 
             byte[] packet = new byte[bytes.length + 1];

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 194208e..fde1f52 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -922,8 +922,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
 
         // Unmarshal transform closure anyway if it exists.
         if (transformClosBytes != null && entryProcessorsCol == null)
-            entryProcessorsCol = ctx.marshaller().unmarshal(transformClosBytes,
-                U.resolveClassLoader(clsLdr, ctx.gridConfig()));
+            entryProcessorsCol = U.unmarshal(ctx, transformClosBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig()));
 
         if (filters == null)
             filters = CU.empty0();
@@ -941,7 +940,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
         val.unmarshal(this.ctx, clsLdr);
 
         if (expiryPlcBytes != null && expiryPlc == null)
-            expiryPlc = ctx.marshaller().unmarshal(expiryPlcBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig()));
+            expiryPlc = U.unmarshal(ctx, expiryPlcBytes, U.resolveClassLoader(clsLdr, ctx.gridConfig()));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
index 4c5a704..b7c96b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java
@@ -191,7 +191,7 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
         unmarshalKey(ctx, marsh);
 
         if (val == null && valBytes != null) {
-            val = marsh.unmarshal(valBytes, U.resolveClassLoader(ctx.kernalContext().config()));
+            val = U.unmarshal(marsh, valBytes, U.resolveClassLoader(ctx.kernalContext().config()));
 
             val.finishUnmarshal(ctx, null);
         }
@@ -222,7 +222,7 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
         if (key == null) {
             assert keyBytes != null;
 
-            key = marsh.unmarshal(keyBytes, U.resolveClassLoader(ctx.kernalContext().config()));
+            key = U.unmarshal(marsh, keyBytes, U.resolveClassLoader(ctx.kernalContext().config()));
 
             key.finishUnmarshal(ctx, null);
         }
@@ -239,13 +239,13 @@ public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implemen
         if (keyBytes == null) {
             key.prepareMarshal(ctx);
 
-            keyBytes = marsh.marshal(key);
+            keyBytes = U.marshal(marsh, key);
         }
 
         if (valBytes == null && val != null) {
             val.prepareMarshal(ctx);
 
-            valBytes = marsh.marshal(val);
+            valBytes = U.marshal(marsh, val);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 9fd4c1f..0eac610 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -103,8 +103,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
     /** {@inheritDoc} */
     @Override public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr)
         throws IgniteCheckedException {
-        return ctx.kernalContext().cache().context().marshaller().unmarshal(bytes, U.resolveClassLoader(clsLdr,
-            ctx.kernalContext().config()));
+        return U.unmarshal(ctx.kernalContext(), bytes, U.resolveClassLoader(clsLdr, ctx.kernalContext().config()));
     }
 
     /** {@inheritDoc} */


[15/40] ignite git commit: IGNITE-3235 Failed to initialize primitive boolean cache property of superclass

Posted by av...@apache.org.
IGNITE-3235 Failed to initialize primitive boolean cache property of superclass


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: b9c776a8423471706ecb1dc6176b38f23e799077
Parents: 952be8b
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Oct 10 11:52:57 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Oct 10 11:52:57 2016 +0300

----------------------------------------------------------------------
 .../internal/jdbc2/JdbcResultSetSelfTest.java   | 91 +++++++++++++++++++-
 .../configuration/CacheConfiguration.java       | 13 ++-
 .../processors/query/GridQueryProcessor.java    | 71 +++++++++------
 3 files changed, 142 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b9c776a8/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
index 3607f53..cc67a65 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
@@ -60,7 +60,8 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
     /** SQL query. */
     private static final String SQL =
         "select id, boolVal, byteVal, shortVal, intVal, longVal, floatVal, " +
-            "doubleVal, bigVal, strVal, arrVal, dateVal, timeVal, tsVal, urlVal, f1, f2, f3, _val " +
+            "doubleVal, bigVal, strVal, arrVal, dateVal, timeVal, tsVal, urlVal, f1, f2, f3, _val, " +
+            "boolVal2, boolVal3, boolVal4 " +
             "from TestObject where id = 1";
 
     /** Statement. */
@@ -142,6 +143,9 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
         TestObject o = new TestObject(id);
 
         o.boolVal = true;
+        o.boolVal2 = true;
+        o.boolVal3 = true;
+        o.boolVal4 = true;
         o.byteVal = 1;
         o.shortVal = 1;
         o.intVal = 1;
@@ -182,6 +186,66 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testBoolean2() throws Exception {
+        ResultSet rs = stmt.executeQuery(SQL);
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0) {
+                assert rs.getBoolean("boolVal2");
+                assert rs.getBoolean(20);
+            }
+
+            cnt++;
+        }
+
+        assert cnt == 1;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBoolean3() throws Exception {
+        ResultSet rs = stmt.executeQuery(SQL);
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0) {
+                assert rs.getBoolean("boolVal3");
+                assert rs.getBoolean(21);
+            }
+
+            cnt++;
+        }
+
+        assert cnt == 1;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBoolean4() throws Exception {
+        ResultSet rs = stmt.executeQuery(SQL);
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0) {
+                assert rs.getBoolean("boolVal4");
+                assert rs.getBoolean(22);
+            }
+
+            cnt++;
+        }
+
+        assert cnt == 1;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testByte() throws Exception {
         ResultSet rs = stmt.executeQuery(SQL);
 
@@ -562,7 +626,30 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
      * Test object.
      */
     @SuppressWarnings("UnusedDeclaration")
-    private static class TestObject implements Serializable {
+    private static class BaseTestObject implements Serializable {
+        /** */
+        @QuerySqlField(index = false)
+        protected Boolean boolVal2;
+
+        /** */
+        @QuerySqlField(index = false)
+        protected boolean boolVal3;
+
+        /** */
+        protected boolean boolVal4;
+
+        /** */
+        @QuerySqlField(index = false)
+        public boolean isBoolVal4() {
+            return boolVal4;
+        }
+    }
+
+    /**
+     * Test object.
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject extends BaseTestObject {
         /** */
         @QuerySqlField
         private final int id;

http://git-wip-us.apache.org/repos/asf/ignite/blob/b9c776a8/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index e28aad5..f65bf52 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -2668,10 +2668,17 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
         ClassProperty(Member member) {
             this.member = member;
 
-            name = member instanceof Method && member.getName().startsWith("get") && member.getName().length() > 3 ?
-                member.getName().substring(3) : member.getName();
+            name = member.getName();
 
-            ((AccessibleObject) member).setAccessible(true);
+            if (member instanceof Method) {
+                if (member.getName().startsWith("get") && member.getName().length() > 3)
+                    name = member.getName().substring(3);
+
+                if (member.getName().startsWith("is") && member.getName().length() > 2)
+                    name = member.getName().substring(2);
+            }
+
+            ((AccessibleObject)member).setAccessible(true);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b9c776a8/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 8469a7c..1605188 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -17,6 +17,30 @@
 
 package org.apache.ignite.internal.processors.query;
 
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import javax.cache.Cache;
+import javax.cache.CacheException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
@@ -68,31 +92,6 @@ import org.apache.ignite.spi.indexing.IndexingQueryFilter;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
-import javax.cache.Cache;
-import javax.cache.CacheException;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-
 import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED;
 import static org.apache.ignite.internal.IgniteComponentType.INDEXING;
 import static org.apache.ignite.internal.processors.query.GridQueryIndexType.FULLTEXT;
@@ -1686,15 +1685,31 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 // No-op.
             }
 
-            if (tmp == null) {
+            if (tmp == null) { // Boolean getter can be defined as is###().
+                bld = new StringBuilder("is");
+
+                bld.append(prop);
+
+                bld.setCharAt(2, Character.toUpperCase(bld.charAt(2)));
+
                 try {
-                    tmp = new ClassProperty(cls.getDeclaredField(prop), key, alias, coCtx);
+                    tmp = new ClassProperty(cls.getMethod(bld.toString()), key, alias, coCtx);
                 }
-                catch (NoSuchFieldException ignored) {
+                catch (NoSuchMethodException ignore) {
                     // No-op.
                 }
             }
 
+            Class cls0 = cls;
+
+            while (tmp == null && cls0 != null)
+                try {
+                    tmp = new ClassProperty(cls0.getDeclaredField(prop), key, alias, coCtx);
+                }
+                catch (NoSuchFieldException ignored) {
+                    cls0 = cls0.getSuperclass();
+                }
+
             if (tmp == null) {
                 try {
                     tmp = new ClassProperty(cls.getMethod(prop), key, alias, coCtx);


[31/40] ignite git commit: IGNITE-4034 Get rid of specialized methods in platform targets

Posted by av...@apache.org.
IGNITE-4034 Get rid of specialized methods in platform targets


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: eaf8ae246cc799c1353332fcac05cb3a8efab02c
Parents: 2ab094e
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Oct 12 19:57:09 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Oct 12 19:57:09 2016 +0300

----------------------------------------------------------------------
 .../platform/PlatformAbstractTarget.java        |   90 +-
 .../processors/platform/PlatformTarget.java     |   23 +
 .../platform/cache/PlatformCache.java           |  373 ++---
 .../cache/affinity/PlatformAffinity.java        |   14 +-
 .../query/PlatformAbstractQueryCursor.java      |   42 +-
 .../query/PlatformContinuousQueryProxy.java     |   53 +
 .../cache/store/PlatformCacheStoreCallback.java |   61 -
 .../callback/PlatformCallbackGateway.java       |    5 +-
 .../callback/PlatformCallbackUtils.java         |    3 +-
 .../platform/cluster/PlatformClusterGroup.java  |  110 +-
 .../platform/compute/PlatformCompute.java       |   77 +-
 .../datastreamer/PlatformDataStreamer.java      |  112 +-
 .../datastructures/PlatformAtomicLong.java      |  179 ++-
 .../datastructures/PlatformAtomicReference.java |   38 +-
 .../datastructures/PlatformAtomicSequence.java  |  131 +-
 .../dotnet/PlatformDotNetCacheStore.java        |  122 +-
 .../platform/events/PlatformEvents.java         |   91 +-
 .../platform/messaging/PlatformMessaging.java   |   30 +-
 .../platform/services/PlatformServices.java     |  133 +-
 .../transactions/PlatformTransactions.java      |  227 +--
 .../cpp/core/include/ignite/cache/cache.h       |   15 +-
 .../core/include/ignite/impl/cache/cache_impl.h |   41 +-
 .../ignite/impl/interop/interop_target.h        |   18 +
 .../cpp/core/src/impl/cache/cache_impl.cpp      |   48 +-
 .../core/src/impl/cache/query/query_impl.cpp    |   15 +-
 .../core/src/impl/interop/interop_target.cpp    |   25 +
 .../src/impl/transactions/transactions_impl.cpp |  130 +-
 .../cpp/jni/include/ignite/jni/exports.h        |  101 +-
 .../platforms/cpp/jni/include/ignite/jni/java.h |  217 +--
 modules/platforms/cpp/jni/project/vs/module.def |   85 +-
 modules/platforms/cpp/jni/src/exports.cpp       |  345 +----
 modules/platforms/cpp/jni/src/java.cpp          | 1315 ++----------------
 .../Cache/CacheAbstractTest.cs                  |   44 +
 .../Services/ServicesTest.cs                    |    1 +
 .../Apache.Ignite.Core.csproj                   |    1 +
 .../Impl/Cache/CacheAffinityImpl.cs             |    5 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  149 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheLock.cs  |   24 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   18 +-
 .../Impl/Cache/ICacheLockInternal.cs            |   47 +
 .../Impl/Cache/Query/AbstractQueryCursor.cs     |   10 +-
 .../Continuous/ContinuousQueryHandleImpl.cs     |  117 +-
 .../Impl/Cache/Store/CacheStore.cs              |  108 +-
 .../Impl/Cluster/ClusterGroupImpl.cs            |   54 +-
 .../Apache.Ignite.Core/Impl/Common/Future.cs    |   30 +-
 .../Impl/Compute/ComputeImpl.cs                 |   19 +-
 .../Impl/DataStructures/AtomicLong.cs           |   34 +-
 .../Impl/DataStructures/AtomicReference.cs      |    8 +-
 .../Impl/DataStructures/AtomicSequence.cs       |   26 +-
 .../Impl/Datastream/DataStreamerImpl.cs         |   49 +-
 .../Apache.Ignite.Core/Impl/Events/Events.cs    |   18 +-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |    2 +-
 .../Impl/Messaging/Messaging.cs                 |    6 +-
 .../Apache.Ignite.Core/Impl/PlatformTarget.cs   |   94 ++
 .../Impl/Services/Services.cs                   |   31 +-
 .../Impl/Transactions/TransactionsImpl.cs       |   73 +-
 .../Impl/Unmanaged/IgniteJniNativeMethods.cs    |  261 +---
 .../Impl/Unmanaged/UnmanagedCallbacks.cs        |   11 +-
 .../Impl/Unmanaged/UnmanagedUtils.cs            |  519 +------
 59 files changed, 2101 insertions(+), 3927 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
index 0cd683d..22adef8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
@@ -59,6 +59,16 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
     }
 
     /** {@inheritDoc} */
+    @Override public long inLongOutLong(int type, long val) throws Exception {
+        try {
+            return processInLongOutLong(type, val);
+        }
+        catch (Exception e) {
+            throw convertException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public long inStreamOutLong(int type, long memPtr) throws Exception {
         try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
             BinaryRawReaderEx reader = platformCtx.reader(mem);
@@ -78,8 +88,8 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
 
     /** {@inheritDoc} */
     @Override public Object inStreamOutObject(int type, long memPtr) throws Exception {
-        try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
-            BinaryRawReaderEx reader = platformCtx.reader(mem);
+        try (PlatformMemory mem = memPtr != 0 ? platformCtx.memory().get(memPtr) : null) {
+            BinaryRawReaderEx reader = mem != null ? platformCtx.reader(mem) : null;
 
             return processInStreamOutObject(type, reader);
         }
@@ -164,6 +174,54 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
         }
     }
 
+    /** {@inheritDoc} */
+    @Override public Object inObjectStreamOutObjectStream(int type, Object arg, long inMemPtr, long outMemPtr)
+        throws Exception {
+        PlatformMemory inMem = null;
+        PlatformMemory outMem = null;
+
+        try {
+            BinaryRawReaderEx reader = null;
+
+            if (inMemPtr != 0) {
+                inMem = platformCtx.memory().get(inMemPtr);
+
+                reader = platformCtx.reader(inMem);
+            }
+
+            PlatformOutputStream out = null;
+            BinaryRawWriterEx writer = null;
+
+            if (outMemPtr != 0) {
+                outMem = platformCtx.memory().get(outMemPtr);
+
+                out = outMem.output();
+
+                writer = platformCtx.writer(out);
+            }
+
+            Object res = processInObjectStreamOutObjectStream(type, arg, reader, writer);
+
+            if (out != null)
+                out.synchronize();
+
+            return res;
+        }
+        catch (Exception e) {
+            throw convertException(e);
+        }
+        finally {
+            try {
+                if (inMem != null)
+                    inMem.close();
+            }
+            finally {
+                if (outMem != null)
+                    outMem.close();
+            }
+        }
+    }
+
     /**
      * Convert caught exception.
      *
@@ -206,7 +264,7 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
      * When overridden in a derived class, gets future for the current operation.
      *
      * @return current future.
-     * @throws IgniteCheckedException
+     * @throws IgniteCheckedException If failed.
      */
     protected IgniteInternalFuture currentFuture() throws IgniteCheckedException {
         throw new IgniteCheckedException("Future listening is not supported in " + getClass());
@@ -226,6 +284,18 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
      * Process IN operation.
      *
      * @param type Type.
+     * @param val Value.
+     * @return Result.
+     * @throws IgniteCheckedException In case of exception.
+     */
+    protected long processInLongOutLong(int type, long val) throws IgniteCheckedException {
+        return throwUnsupported(type);
+    }
+
+    /**
+     * Process IN operation.
+     *
+     * @param type Type.
      * @param reader Binary reader.
      * @return Result.
      * @throws IgniteCheckedException In case of exception.
@@ -274,6 +344,20 @@ public abstract class PlatformAbstractTarget implements PlatformTarget {
     }
 
     /**
+     * Process IN-OUT operation.
+     *
+     * @param type Type.
+     * @param arg Argument.
+     * @param reader Binary reader.
+     * @param writer Binary writer.
+     * @throws IgniteCheckedException In case of exception.
+     */
+    protected Object processInObjectStreamOutObjectStream(int type, @Nullable Object arg, BinaryRawReaderEx reader,
+        BinaryRawWriterEx writer) throws IgniteCheckedException {
+        return throwUnsupported(type);
+    }
+
+    /**
      * Process OUT operation.
      *
      * @param type Type.

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
index 1ebf700..40773d0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
@@ -27,6 +27,16 @@ import org.jetbrains.annotations.Nullable;
 @SuppressWarnings("UnusedDeclaration")
 public interface PlatformTarget {
     /**
+     * Operation accepting long value and returning long value.
+     *
+     * @param type Operation type.
+     * @param val Value.
+     * @return Result.
+     * @throws Exception If case of failure.
+     */
+    public long inLongOutLong(int type, long val) throws Exception;
+
+    /**
      * Operation accepting memory stream and returning long value.
      *
      * @param type Operation type.
@@ -68,6 +78,19 @@ public interface PlatformTarget {
     public void inObjectStreamOutStream(int type, @Nullable Object arg, long inMemPtr, long outMemPtr) throws Exception;
 
     /**
+     * Operation accepting an object and a memory stream and returning result to another memory stream and an object.
+     *
+     * @param type Operation type.
+     * @param arg Argument (optional).
+     * @param inMemPtr Input memory pointer.
+     * @param outMemPtr Output memory pointer.
+     * @return Result.
+     * @throws Exception In case of failure.
+     */
+    public Object inObjectStreamOutObjectStream(int type, @Nullable Object arg, long inMemPtr, long outMemPtr)
+        throws Exception;
+
+    /**
      * Operation returning long result.
      *
      * @param type Operation type.

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 75683a8..05945e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -28,7 +28,7 @@ import org.apache.ignite.cache.query.ScanQuery;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cache.query.TextQuery;
-import org.apache.ignite.configuration.*;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.binary.BinaryRawReaderEx;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.PlatformNativeException;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformContinuousQuery;
+import org.apache.ignite.internal.processors.platform.cache.query.PlatformContinuousQueryProxy;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformFieldsQueryCursor;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformQueryCursor;
 import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
@@ -70,7 +71,7 @@ import java.util.concurrent.locks.Lock;
 /**
  * Native cache wrapper implementation.
  */
-@SuppressWarnings({"unchecked", "UnusedDeclaration", "TryFinallyCanBeTryWithResources"})
+@SuppressWarnings({"unchecked", "UnusedDeclaration", "TryFinallyCanBeTryWithResources", "TypeMayBeWeakened"})
 public class PlatformCache extends PlatformAbstractTarget {
     /** */
     public static final int OP_CLEAR = 1;
@@ -189,6 +190,54 @@ public class PlatformCache extends PlatformAbstractTarget {
     /** */
     public static final int OP_LOAD_ALL = 40;
 
+    /** */
+    public static final int OP_CLEAR_CACHE = 41;
+
+    /** */
+    public static final int OP_WITH_ASYNC = 42;
+
+    /** */
+    public static final int OP_REMOVE_ALL2 = 43;
+
+    /** */
+    public static final int OP_WITH_KEEP_BINARY = 44;
+
+    /** */
+    public static final int OP_WITH_EXPIRY_POLICY = 45;
+
+    /** */
+    public static final int OP_WITH_NO_RETRIES = 46;
+
+    /** */
+    public static final int OP_WITH_SKIP_STORE = 47;
+
+    /** */
+    public static final int OP_SIZE = 48;
+
+    /** */
+    public static final int OP_ITERATOR = 49;
+
+    /** */
+    public static final int OP_LOC_ITERATOR = 50;
+
+    /** */
+    public static final int OP_ENTER_LOCK = 51;
+
+    /** */
+    public static final int OP_EXIT_LOCK = 52;
+
+    /** */
+    public static final int OP_TRY_ENTER_LOCK = 53;
+
+    /** */
+    public static final int OP_CLOSE_LOCK = 54;
+
+    /** */
+    public static final int OP_REBALANCE = 55;
+
+    /** */
+    public static final int OP_SIZE_LOC = 56;
+
     /** Underlying JCache. */
     private final IgniteCacheProxy cache;
 
@@ -224,68 +273,21 @@ public class PlatformCache extends PlatformAbstractTarget {
         this.keepBinary = keepBinary;
     }
 
-    /**
-     * Gets cache with "skip-store" flag set.
-     *
-     * @return Cache with "skip-store" flag set.
-     */
-    public PlatformCache withSkipStore() {
-        if (cache.delegate().skipStore())
-            return this;
-
-        return new PlatformCache(platformCtx, cache.withSkipStore(), keepBinary);
-    }
-
-    /**
-     * Gets cache with "keep binary" flag.
-     *
-     * @return Cache with "keep binary" flag set.
-     */
-    public PlatformCache withKeepBinary() {
-        if (keepBinary)
-            return this;
-
-        return new PlatformCache(platformCtx, cache.withKeepBinary(), true);
-    }
-
-    /**
-     * Gets cache with provided expiry policy.
-     *
-     * @param create Create.
-     * @param update Update.
-     * @param access Access.
-     * @return Cache.
-     */
-    public PlatformCache withExpiryPolicy(final long create, final long update, final long access) {
-        IgniteCache cache0 = cache.withExpiryPolicy(new InteropExpiryPolicy(create, update, access));
-
-        return new PlatformCache(platformCtx, cache0, keepBinary);
-    }
-
-    /**
-     * Gets cache with asynchronous mode enabled.
-     *
-     * @return Cache with asynchronous mode enabled.
-     */
-    public PlatformCache withAsync() {
-        if (cache.isAsync())
-            return this;
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_CLEAR_CACHE:
+                cache.clear();
 
-        return new PlatformCache(platformCtx, (IgniteCache)cache.withAsync(), keepBinary);
-    }
+                return TRUE;
 
-    /**
-     * Gets cache with no-retries mode enabled.
-     *
-     * @return Cache with no-retries mode enabled.
-     */
-    public PlatformCache withNoRetries() {
-        CacheOperationContext opCtx = cache.operationContext();
+            case OP_REMOVE_ALL2:
+                cache.removeAll();
 
-        if (opCtx != null && opCtx.noRetries())
-            return this;
+                return TRUE;
+        }
 
-        return new PlatformCache(platformCtx, cache.withNoRetries(), keepBinary);
+        return super.processOutLong(type);
     }
 
     /** {@inheritDoc} */
@@ -388,6 +390,22 @@ public class PlatformCache extends PlatformAbstractTarget {
                 return TRUE;
             }
 
+            case OP_TRY_ENTER_LOCK: {
+                try {
+                    long id = reader.readLong();
+                    long timeout = reader.readLong();
+
+                    boolean res = timeout == -1
+                        ? lock(id).tryLock()
+                        : lock(id).tryLock(timeout, TimeUnit.MILLISECONDS);
+
+                    return res ? TRUE : FALSE;
+                }
+                catch (InterruptedException e) {
+                    throw new IgniteCheckedException(e);
+                }
+            }
+
             default:
                 return super.processInStreamOutLong(type, reader);
         }
@@ -395,6 +413,8 @@ public class PlatformCache extends PlatformAbstractTarget {
         return TRUE;
     }
 
+
+
     /**
      * Loads cache via localLoadCache or loadCache.
      */
@@ -444,7 +464,27 @@ public class PlatformCache extends PlatformAbstractTarget {
 
                 qry.start(cache, loc, bufSize, timeInterval, autoUnsubscribe, initQry);
 
-                return qry;
+                return new PlatformContinuousQueryProxy(platformCtx, qry);
+            }
+
+            case OP_WITH_EXPIRY_POLICY: {
+                long create = reader.readLong();
+                long update = reader.readLong();
+                long access = reader.readLong();
+
+                IgniteCache cache0 = cache.withExpiryPolicy(new InteropExpiryPolicy(create, update, access));
+
+                return new PlatformCache(platformCtx, cache0, keepBinary);
+            }
+
+            case OP_LOC_ITERATOR: {
+                int peekModes = reader.readInt();
+
+                CachePeekMode[] peekModes0 = PlatformUtils.decodeCachePeekModes(peekModes);
+
+                Iterator<Cache.Entry> iter = cache.localEntries(peekModes0).iterator();
+
+                return new PlatformCacheIterator(platformCtx, iter);
             }
 
             default:
@@ -654,6 +694,102 @@ public class PlatformCache extends PlatformAbstractTarget {
     }
 
     /** {@inheritDoc} */
+    @Override protected Object processOutObject(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_WITH_ASYNC: {
+                if (cache.isAsync())
+                    return this;
+
+                return new PlatformCache(platformCtx, (IgniteCache)cache.withAsync(), keepBinary);
+            }
+
+            case OP_WITH_KEEP_BINARY: {
+                if (keepBinary)
+                    return this;
+
+                return new PlatformCache(platformCtx, cache.withKeepBinary(), true);
+            }
+
+            case OP_WITH_NO_RETRIES: {
+                CacheOperationContext opCtx = cache.operationContext();
+
+                if (opCtx != null && opCtx.noRetries())
+                    return this;
+
+                return new PlatformCache(platformCtx, cache.withNoRetries(), keepBinary);
+            }
+
+            case OP_WITH_SKIP_STORE: {
+                if (cache.delegate().skipStore())
+                    return this;
+
+                return new PlatformCache(platformCtx, cache.withSkipStore(), keepBinary);
+            }
+
+            case OP_ITERATOR: {
+                Iterator<Cache.Entry> iter = cache.iterator();
+
+                return new PlatformCacheIterator(platformCtx, iter);
+            }
+        }
+
+        return super.processOutObject(type);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long processInLongOutLong(int type, long val) throws IgniteCheckedException {
+        switch (type) {
+            case OP_SIZE: {
+                CachePeekMode[] modes = PlatformUtils.decodeCachePeekModes((int)val);
+
+                return cache.size(modes);
+            }
+
+            case OP_SIZE_LOC: {
+                CachePeekMode[] modes = PlatformUtils.decodeCachePeekModes((int)val);
+
+                return cache.localSize(modes);
+            }
+
+            case OP_ENTER_LOCK: {
+                try {
+                    lock(val).lockInterruptibly();
+
+                    return TRUE;
+                }
+                catch (InterruptedException e) {
+                    throw new IgniteCheckedException("Failed to enter cache lock.", e);
+                }
+            }
+
+            case OP_EXIT_LOCK: {
+                lock(val).unlock();
+
+                return TRUE;
+            }
+
+            case OP_CLOSE_LOCK: {
+                Lock lock = lockMap.remove(val);
+
+                assert lock != null : "Failed to unregister lock: " + val;
+
+                return TRUE;
+            }
+
+            case OP_REBALANCE: {
+                PlatformFutureUtils.listen(platformCtx, cache.rebalance().chain(new C1<IgniteFuture, Object>() {
+                    @Override public Object apply(IgniteFuture fut) {
+                        return null;
+                    }
+                }), val, PlatformFutureUtils.TYP_OBJ, this);
+
+                return TRUE;
+            }
+        }
+        return super.processInLongOutLong(type, val);
+    }
+
+    /** {@inheritDoc} */
     @Override public Exception convertException(Exception e) {
         if (e instanceof CachePartialUpdateException)
             return new PlatformCachePartialUpdateException((CachePartialUpdateCheckedException)e.getCause(),
@@ -663,7 +799,7 @@ public class PlatformCache extends PlatformAbstractTarget {
             return new PlatformCachePartialUpdateException((CachePartialUpdateCheckedException)e, platformCtx, keepBinary);
 
         if (e.getCause() instanceof EntryProcessorException)
-            return (EntryProcessorException) e.getCause();
+            return (Exception)e.getCause();
 
         return super.convertException(e);
     }
@@ -737,117 +873,6 @@ public class PlatformCache extends PlatformAbstractTarget {
     }
 
     /**
-     * Clears the contents of the cache, without notifying listeners or CacheWriters.
-     *
-     * @throws IllegalStateException if the cache is closed.
-     * @throws javax.cache.CacheException if there is a problem during the clear
-     */
-    public void clear() throws IgniteCheckedException {
-        cache.clear();
-    }
-
-    /**
-     * Removes all entries.
-     *
-     * @throws org.apache.ignite.IgniteCheckedException In case of error.
-     */
-    public void removeAll() throws IgniteCheckedException {
-        cache.removeAll();
-    }
-
-    /**
-     * Read cache size.
-     *
-     * @param peekModes Encoded peek modes.
-     * @param loc Local mode flag.
-     * @return Size.
-     */
-    public int size(int peekModes, boolean loc) {
-        CachePeekMode[] modes = PlatformUtils.decodeCachePeekModes(peekModes);
-
-        return loc ? cache.localSize(modes) :  cache.size(modes);
-    }
-
-    /**
-     * Create cache iterator.
-     *
-     * @return Cache iterator.
-     */
-    public PlatformCacheIterator iterator() {
-        Iterator<Cache.Entry> iter = cache.iterator();
-
-        return new PlatformCacheIterator(platformCtx, iter);
-    }
-
-    /**
-     * Create cache iterator over local entries.
-     *
-     * @param peekModes Peke modes.
-     * @return Cache iterator.
-     */
-    public PlatformCacheIterator localIterator(int peekModes) {
-        CachePeekMode[] peekModes0 = PlatformUtils.decodeCachePeekModes(peekModes);
-
-        Iterator<Cache.Entry> iter = cache.localEntries(peekModes0).iterator();
-
-        return new PlatformCacheIterator(platformCtx, iter);
-    }
-
-    /**
-     * Enters a lock.
-     *
-     * @param id Lock id.
-     */
-    public void enterLock(long id) throws InterruptedException {
-        lock(id).lockInterruptibly();
-    }
-
-    /**
-     * Exits a lock.
-     *
-     * @param id Lock id.
-     */
-    public void exitLock(long id) {
-        lock(id).unlock();
-    }
-
-    /**
-     * Attempts to enter a lock.
-     *
-     * @param id Lock id.
-     * @param timeout Timeout, in milliseconds. -1 for infinite timeout.
-     */
-    public boolean tryEnterLock(long id, long timeout) throws InterruptedException {
-        return timeout == -1
-            ? lock(id).tryLock()
-            : lock(id).tryLock(timeout, TimeUnit.MILLISECONDS);
-    }
-
-    /**
-     * Rebalances the cache.
-     *
-     * @param futId Future id.
-     */
-    public void rebalance(long futId) {
-        PlatformFutureUtils.listen(platformCtx, cache.rebalance().chain(new C1<IgniteFuture, Object>() {
-            @Override public Object apply(IgniteFuture fut) {
-                return null;
-            }
-        }), futId, PlatformFutureUtils.TYP_OBJ, this);
-    }
-
-    /**
-     * Unregister lock.
-     *
-     * @param id Lock id.
-     */
-    public void closeLock(long id){
-        Lock lock = lockMap.remove(id);
-
-        assert lock != null : "Failed to unregister lock: " + id;
-    }
-
-    /**
      * Get lock by id.
      *
      * @param id Id.
@@ -1079,7 +1104,7 @@ public class PlatformCache extends PlatformAbstractTarget {
          * @param update Expiry for update.
          * @param access Expiry for access.
          */
-        public InteropExpiryPolicy(long create, long update, long access) {
+        private InteropExpiryPolicy(long create, long update, long access) {
             this.create = convert(create);
             this.update = convert(update);
             this.access = convert(access);

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
index acd2707..41b58aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
@@ -82,6 +82,9 @@ public class PlatformAffinity extends PlatformAbstractTarget {
     public static final int OP_PRIMARY_PARTITIONS = 14;
 
     /** */
+    public static final int OP_PARTITIONS = 15;
+
+    /** */
     private static final C1<ClusterNode, UUID> TO_NODE_ID = new C1<ClusterNode, UUID>() {
         @Nullable @Override public UUID apply(ClusterNode node) {
             return node != null ? node.id() : null;
@@ -288,10 +291,11 @@ public class PlatformAffinity extends PlatformAbstractTarget {
         }
     }
 
-    /**
-     * @return Gets number of partitions in cache.
-     */
-    public int partitions() {
-        return aff.partitions();
+    /** {@inheritDoc} */
+    @Override public long outLong(int type) throws Exception {
+        if (type == OP_PARTITIONS)
+            return aff.partitions();
+
+        return super.outLong(type);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
index ab52b52..ff28b81 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformAbstractQueryCursor.java
@@ -38,6 +38,15 @@ public abstract class PlatformAbstractQueryCursor<T> extends PlatformAbstractTar
     /** Get single entry. */
     private static final int OP_GET_SINGLE = 3;
 
+    /** Start iterating. */
+    private static final int OP_ITERATOR = 4;
+
+    /** Close iterator. */
+    private static final int OP_ITERATOR_CLOSE = 5;
+
+    /** Close iterator. */
+    private static final int OP_ITERATOR_HAS_NEXT = 6;
+
     /** Underlying cursor. */
     private final QueryCursorEx<T> cursor;
 
@@ -126,23 +135,26 @@ public abstract class PlatformAbstractQueryCursor<T> extends PlatformAbstractTar
         }
     }
 
-    /**
-     * Get cursor iterator.
-     */
-    public void iterator() {
-        iter = cursor.iterator();
-    }
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_ITERATOR:
+                iter = cursor.iterator();
 
-    /**
-     * Check whether next iterator entry exists.
-     *
-     * @return {@code True} if exists.
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    public boolean iteratorHasNext() {
-        assert iter != null : "iterator() has not been called";
+                return TRUE;
+
+            case OP_ITERATOR_CLOSE:
+                cursor.close();
+
+                return TRUE;
+
+            case OP_ITERATOR_HAS_NEXT:
+                assert iter != null : "iterator() has not been called";
+
+                return iter.hasNext() ? TRUE : FALSE;
+        }
 
-        return iter.hasNext();
+        return super.processOutLong(type);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformContinuousQueryProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformContinuousQueryProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformContinuousQueryProxy.java
new file mode 100644
index 0000000..a4d7cad
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/query/PlatformContinuousQueryProxy.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cache.query;
+
+import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
+import org.apache.ignite.internal.processors.platform.PlatformContext;
+
+/**
+ * Proxy that implements PlatformTarget.
+ */
+public class PlatformContinuousQueryProxy extends PlatformAbstractTarget  {
+    private final PlatformContinuousQuery qry;
+
+    /**
+     * Constructor.
+     *
+     * @param platformCtx Context.
+     */
+    public PlatformContinuousQueryProxy(PlatformContext platformCtx, PlatformContinuousQuery qry) {
+        super(platformCtx);
+
+        assert qry != null;
+
+        this.qry = qry;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object outObject(int type) throws Exception {
+        return qry.getInitialQueryCursor();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long outLong(int type) throws Exception {
+        qry.close();
+
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback.java
deleted file mode 100644
index ad0d081..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/store/PlatformCacheStoreCallback.java
+++ /dev/null
@@ -1,61 +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.platform.cache.store;
-
-import org.apache.ignite.internal.binary.BinaryRawReaderEx;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
-import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
-
-/**
- * Platform cache store callback.
- */
-public abstract class PlatformCacheStoreCallback {
-    /** Context. */
-    protected final PlatformContext ctx;
-
-    /**
-     * Constructor.
-     *
-     * @param ctx Context.
-     */
-    protected PlatformCacheStoreCallback(PlatformContext ctx) {
-        this.ctx = ctx;
-    }
-
-    /**
-     * Invoke the callback.
-     *
-     * @param memPtr Memory pointer.
-     */
-    public void invoke(long memPtr) {
-        if (memPtr > 0) {
-            try (PlatformMemory mem = ctx.memory().get(memPtr)) {
-                BinaryRawReaderEx reader = ctx.reader(mem);
-
-                invoke0(reader);
-            }
-        }
-    }
-
-    /**
-     * Internal invoke routine.
-     *
-     * @param reader Reader.
-     */
-    protected abstract void invoke0(BinaryRawReaderEx reader);
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
index ac1416c..0017b2d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
@@ -71,14 +71,13 @@ public class PlatformCallbackGateway {
     /**
      * @param objPtr Object pointer.
      * @param memPtr Memory pointer.
-     * @param cb Callback.
      * @return Result.
      */
-    public int cacheStoreInvoke(long objPtr, long memPtr, Object cb) {
+    public int cacheStoreInvoke(long objPtr, long memPtr) {
         enter();
 
         try {
-            return PlatformCallbackUtils.cacheStoreInvoke(envPtr, objPtr, memPtr, cb);
+            return PlatformCallbackUtils.cacheStoreInvoke(envPtr, objPtr, memPtr);
         }
         finally {
             leave();

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
index 7b36e5e..174b014 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
@@ -37,10 +37,9 @@ public class PlatformCallbackUtils {
      * @param envPtr Environment pointer.
      * @param objPtr Object pointer.
      * @param memPtr Memory pointer.
-     * @param cb Callback.
      * @return Result.
      */
-    static native int cacheStoreInvoke(long envPtr, long objPtr, long memPtr, Object cb);
+    static native int cacheStoreInvoke(long envPtr, long objPtr, long memPtr);
 
     /**
      * @param envPtr Environment pointer.

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
index d80079c..a94e045 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.binary.BinaryRawWriterEx;
 import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Interop projection.
@@ -80,6 +81,27 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
     /** */
     private static final int OP_SCHEMA = 15;
 
+    /** */
+    private static final int OP_FOR_OTHERS = 16;
+
+    /** */
+    private static final int OP_FOR_REMOTES = 17;
+
+    /** */
+    private static final int OP_FOR_DAEMONS = 18;
+
+    /** */
+    private static final int OP_FOR_RANDOM = 19;
+
+    /** */
+    private static final int OP_FOR_OLDEST = 20;
+
+    /** */
+    private static final int OP_FOR_YOUNGEST = 21;
+
+    /** */
+    private static final int OP_RESET_METRICS = 22;
+
     /** Projection. */
     private final ClusterGroupEx prj;
 
@@ -260,47 +282,58 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
         }
     }
 
-    /**
-     * @param exclude Projection to exclude.
-     * @return New projection.
-     */
-    public PlatformClusterGroup forOthers(PlatformClusterGroup exclude) {
-        return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forOthers(exclude.prj));
-    }
+    /** {@inheritDoc} */
+    @Override protected Object processInObjectStreamOutObjectStream(
+            int type, @Nullable Object arg, BinaryRawReaderEx reader, BinaryRawWriterEx writer)
+            throws IgniteCheckedException {
+        switch (type) {
+            case OP_FOR_OTHERS: {
+                PlatformClusterGroup exclude = (PlatformClusterGroup) arg;
 
-    /**
-     * @return New projection.
-     */
-    public PlatformClusterGroup forRemotes() {
-        return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forRemotes());
-    }
+                assert exclude != null;
 
-    /**
-     * @return New projection.
-     */
-    public PlatformClusterGroup forDaemons() {
-        return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forDaemons());
-    }
+                return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forOthers(exclude.prj));
+            }
+        }
 
-    /**
-     * @return New projection.
-     */
-    public PlatformClusterGroup forRandom() {
-        return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forRandom());
+        return super.processInObjectStreamOutObjectStream(type, arg, reader, writer);
     }
 
-    /**
-     * @return New projection.
-     */
-    public PlatformClusterGroup forOldest() {
-        return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forOldest());
+    /** {@inheritDoc} */
+    @Override protected Object processOutObject(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_FOR_REMOTES:
+                return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forRemotes());
+
+            case OP_FOR_DAEMONS:
+                return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forDaemons());
+
+            case OP_FOR_RANDOM:
+                return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forRandom());
+
+            case OP_FOR_OLDEST:
+                return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forOldest());
+
+            case OP_FOR_YOUNGEST:
+                return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forYoungest());
+        }
+
+        return super.processOutObject(type);
     }
 
-    /**
-     * @return New projection.
-     */
-    public PlatformClusterGroup forYoungest() {
-        return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forYoungest());
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_RESET_METRICS: {
+                assert prj instanceof IgniteCluster; // Can only be invoked on top-level cluster group.
+
+                ((IgniteCluster)prj).resetMetrics();
+
+                return TRUE;
+            }
+        }
+
+        return super.processOutLong(type);
     }
 
     /**
@@ -311,15 +344,6 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
     }
 
     /**
-     * Resets local I/O, job, and task execution metrics.
-     */
-    public void resetMetrics() {
-        assert prj instanceof IgniteCluster; // Can only be invoked on top-level cluster group.
-
-        ((IgniteCluster)prj).resetMetrics();
-    }
-
-    /**
      * Pings a remote node.
      */
     private boolean pingNode(UUID nodeId) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java
index 9eb746c..36d709a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java
@@ -31,7 +31,6 @@ import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
 import org.apache.ignite.internal.processors.platform.utils.PlatformListenable;
-import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
 import org.apache.ignite.internal.util.future.IgniteFutureImpl;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteInClosure;
@@ -64,6 +63,15 @@ public class PlatformCompute extends PlatformAbstractTarget {
     /** */
     private static final int OP_UNICAST = 5;
 
+    /** */
+    private static final int OP_WITH_NO_FAILOVER = 6;
+
+    /** */
+    private static final int OP_WITH_TIMEOUT = 7;
+
+    /** */
+    private static final int OP_EXEC_NATIVE = 8;
+
     /** Compute instance. */
     private final IgniteComputeImpl compute;
 
@@ -104,11 +112,48 @@ public class PlatformCompute extends PlatformAbstractTarget {
             case OP_AFFINITY:
                 return processClosures(reader.readLong(), reader, false, true);
 
+            case OP_EXEC_NATIVE: {
+                long taskPtr = reader.readLong();
+                long topVer = reader.readLong();
+
+                final PlatformFullTask task = new PlatformFullTask(platformCtx, computeForPlatform, taskPtr, topVer);
+
+                return executeNative0(task);
+            }
+
             default:
                 return super.processInStreamOutObject(type, reader);
         }
     }
 
+    /** {@inheritDoc} */
+    @Override protected long processInLongOutLong(int type, long val) throws IgniteCheckedException {
+        switch (type) {
+            case OP_WITH_TIMEOUT: {
+                compute.withTimeout(val);
+                computeForPlatform.withTimeout(val);
+
+                return TRUE;
+            }
+        }
+
+        return super.processInLongOutLong(type, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_WITH_NO_FAILOVER: {
+                compute.withNoFailover();
+                computeForPlatform.withNoFailover();
+
+                return TRUE;
+            }
+        }
+
+        return super.processOutLong(type);
+    }
+
     /**
      * Process closure execution request.
      *  @param taskPtr Task pointer.
@@ -200,36 +245,6 @@ public class PlatformCompute extends PlatformAbstractTarget {
         }
     }
 
-    /**
-     * Execute native full-fledged task.
-     *
-     * @param taskPtr Pointer to the task.
-     * @param topVer Topology version.
-     */
-    public PlatformListenable executeNative(long taskPtr, long topVer) {
-        final PlatformFullTask task = new PlatformFullTask(platformCtx, computeForPlatform, taskPtr, topVer);
-
-        return executeNative0(task);
-    }
-
-    /**
-     * Set "withTimeout" state.
-     *
-     * @param timeout Timeout (milliseconds).
-     */
-    public void withTimeout(long timeout) {
-        compute.withTimeout(timeout);
-        computeForPlatform.withTimeout(timeout);
-    }
-
-    /**
-     * Set "withNoFailover" state.
-     */
-    public void withNoFailover() {
-        compute.withNoFailover();
-        computeForPlatform.withNoFailover();
-    }
-
     /** <inheritDoc /> */
     @Override protected IgniteInternalFuture currentFuture() throws IgniteCheckedException {
         IgniteInternalFuture fut = curFut.get();

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastreamer/PlatformDataStreamer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastreamer/PlatformDataStreamer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastreamer/PlatformDataStreamer.java
index 78d5d86..2822b7f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastreamer/PlatformDataStreamer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastreamer/PlatformDataStreamer.java
@@ -59,6 +59,33 @@ public class PlatformDataStreamer extends PlatformAbstractTarget {
     /** */
     private static final int OP_RECEIVER = 2;
 
+    /** */
+    private static final int OP_ALLOW_OVERWRITE = 3;
+
+    /** */
+    private static final int OP_SET_ALLOW_OVERWRITE = 4;
+
+    /** */
+    private static final int OP_SKIP_STORE = 5;
+
+    /** */
+    private static final int OP_SET_SKIP_STORE = 6;
+
+    /** */
+    private static final int OP_PER_NODE_BUFFER_SIZE = 7;
+
+    /** */
+    private static final int OP_SET_PER_NODE_BUFFER_SIZE = 8;
+
+    /** */
+    private static final int OP_PER_NODE_PARALLEL_OPS = 9;
+
+    /** */
+    private static final int OP_SET_PER_NODE_PARALLEL_OPS = 10;
+
+    /** */
+    private static final int OP_LISTEN_TOPOLOGY = 11;
+
     /** Cache name. */
     private final String cacheName;
 
@@ -126,7 +153,7 @@ public class PlatformDataStreamer extends PlatformAbstractTarget {
 
                 return TRUE;
 
-            case OP_RECEIVER:
+            case OP_RECEIVER: {
                 long ptr = reader.readLong();
 
                 Object rec = reader.readObjectDetached();
@@ -134,39 +161,84 @@ public class PlatformDataStreamer extends PlatformAbstractTarget {
                 ldr.receiver(platformCtx.createStreamReceiver(rec, ptr, keepBinary));
 
                 return TRUE;
+            }
 
             default:
                 return super.processInStreamOutLong(type, reader);
         }
     }
 
-    /**
-     * Listen topology changes.
-     *
-     * @param ptr Pointer.
-     */
-    public void listenTopology(final long ptr) {
-        lsnr = new GridLocalEventListener() {
-            @Override public void onEvent(Event evt) {
-                DiscoveryEvent discoEvt = (DiscoveryEvent)evt;
+    /** {@inheritDoc}  */
+    @Override protected long processInLongOutLong(int type, final long val) throws IgniteCheckedException {
+        switch (type) {
+            case OP_SET_ALLOW_OVERWRITE:
+                ldr.allowOverwrite(val == TRUE);
+
+                return TRUE;
+
+            case OP_SET_PER_NODE_BUFFER_SIZE:
+                ldr.perNodeBufferSize((int) val);
+
+                return TRUE;
+
+            case OP_SET_SKIP_STORE:
+                ldr.skipStore(val == TRUE);
+
+                return TRUE;
 
-                long topVer = discoEvt.topologyVersion();
-                int topSize = platformCtx.kernalContext().discovery().cacheNodes(
-                    cacheName, new AffinityTopologyVersion(topVer)).size();
+            case OP_SET_PER_NODE_PARALLEL_OPS:
+                ldr.perNodeParallelOperations((int) val);
+
+                return TRUE;
+
+            case OP_LISTEN_TOPOLOGY: {
+                lsnr = new GridLocalEventListener() {
+                    @Override public void onEvent(Event evt) {
+                        DiscoveryEvent discoEvt = (DiscoveryEvent)evt;
+
+                        long topVer = discoEvt.topologyVersion();
+                        int topSize = platformCtx.kernalContext().discovery().cacheNodes(
+                                cacheName, new AffinityTopologyVersion(topVer)).size();
+
+                        platformCtx.gateway().dataStreamerTopologyUpdate(val, topVer, topSize);
+                    }
+                };
 
-                platformCtx.gateway().dataStreamerTopologyUpdate(ptr, topVer, topSize);
+                platformCtx.kernalContext().event().addLocalEventListener(lsnr,
+                        EVT_NODE_JOINED, EVT_NODE_FAILED, EVT_NODE_LEFT);
+
+                GridDiscoveryManager discoMgr = platformCtx.kernalContext().discovery();
+
+                AffinityTopologyVersion topVer = discoMgr.topologyVersionEx();
+
+                int topSize = discoMgr.cacheNodes(cacheName, topVer).size();
+
+                platformCtx.gateway().dataStreamerTopologyUpdate(val, topVer.topologyVersion(), topSize);
+
+                return TRUE;
             }
-        };
+        }
+
+        return super.processInLongOutLong(type, val);
+    }
 
-        platformCtx.kernalContext().event().addLocalEventListener(lsnr, EVT_NODE_JOINED, EVT_NODE_FAILED, EVT_NODE_LEFT);
+    /** {@inheritDoc}  */
+    @Override public long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_ALLOW_OVERWRITE:
+                return ldr.allowOverwrite() ? TRUE : FALSE;
 
-        GridDiscoveryManager discoMgr = platformCtx.kernalContext().discovery();
+            case OP_PER_NODE_BUFFER_SIZE:
+                return ldr.perNodeBufferSize();
 
-        AffinityTopologyVersion topVer = discoMgr.topologyVersionEx();
+            case OP_SKIP_STORE:
+                return ldr.skipStore() ? TRUE : FALSE;
 
-        int topSize = discoMgr.cacheNodes(cacheName, topVer).size();
+            case OP_PER_NODE_PARALLEL_OPS:
+                return ldr.perNodeParallelOperations();
+        }
 
-        platformCtx.gateway().dataStreamerTopologyUpdate(ptr, topVer.topologyVersion(), topSize);
+        return super.processOutLong(type);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicLong.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicLong.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicLong.java
index 4a5b2e5..5331956 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicLong.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicLong.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.processors.platform.datastructures;
 
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
 import org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl;
 import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
@@ -28,6 +30,42 @@ public class PlatformAtomicLong extends PlatformAbstractTarget {
     /** */
     private final GridCacheAtomicLongImpl atomicLong;
 
+    /** */
+    private static final int OP_ADD_AND_GET = 1;
+
+    /** */
+    private static final int OP_CLOSE = 2;
+
+    /** */
+    private static final int OP_COMPARE_AND_SET = 3;
+
+    /** */
+    private static final int OP_COMPARE_AND_SET_AND_GET = 4;
+
+    /** */
+    private static final int OP_DECREMENT_AND_GET = 5;
+
+    /** */
+    private static final int OP_GET = 6;
+
+    /** */
+    private static final int OP_GET_AND_ADD = 7;
+
+    /** */
+    private static final int OP_GET_AND_DECREMENT = 8;
+
+    /** */
+    private static final int OP_GET_AND_INCREMENT = 9;
+
+    /** */
+    private static final int OP_GET_AND_SET = 10;
+
+    /** */
+    private static final int OP_INCREMENT_AND_GET = 11;
+
+    /** */
+    private static final int OP_IS_CLOSED = 12;
+
     /**
      * Ctor.
      * @param ctx Context.
@@ -41,109 +79,68 @@ public class PlatformAtomicLong extends PlatformAbstractTarget {
         this.atomicLong = atomicLong;
     }
 
-    /**
-     * Reads the value.
-     *
-     * @return Current atomic long value.
-     */
-    public long get() {
-        return atomicLong.get();
-    }
+    /** {@inheritDoc} */
+    @Override protected long processInStreamOutLong(int type, BinaryRawReaderEx reader) throws IgniteCheckedException {
+        switch (type) {
+            case OP_COMPARE_AND_SET:
+                long cmp = reader.readLong();
+                long val = reader.readLong();
 
-    /**
-     * Increments the value.
-     *
-     * @return Current atomic long value.
-     */
-    public long incrementAndGet() {
-        return atomicLong.incrementAndGet();
-    }
+                return atomicLong.compareAndSet(cmp, val) ? TRUE : FALSE;
 
-    /**
-     * Increments the value.
-     *
-     * @return Original atomic long value.
-     */
-    public long getAndIncrement() {
-        return atomicLong.getAndIncrement();
-    }
+            case OP_COMPARE_AND_SET_AND_GET:
+                long expVal = reader.readLong();
+                long newVal = reader.readLong();
 
-    /**
-     * Adds a value.
-     *
-     * @return Current atomic long value.
-     */
-    public long addAndGet(long val) {
-        return atomicLong.addAndGet(val);
-    }
+                return atomicLong.compareAndSetAndGet(expVal, newVal);
+        }
 
-    /**
-     * Adds a value.
-     *
-     * @return Original atomic long value.
-     */
-    public long getAndAdd(long val) {
-        return atomicLong.getAndAdd(val);
+        return super.processInStreamOutLong(type, reader);
     }
 
-    /**
-     * Decrements the value.
-     *
-     * @return Current atomic long value.
-     */
-    public long decrementAndGet() {
-        return atomicLong.decrementAndGet();
-    }
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_CLOSE:
+                atomicLong.close();
 
-    /**
-     * Decrements the value.
-     *
-     * @return Original atomic long value.
-     */
-    public long getAndDecrement() {
-        return atomicLong.getAndDecrement();
-    }
+                return TRUE;
 
-    /**
-     * Gets current value of atomic long and sets new value
-     *
-     * @return Original atomic long value.
-     */
-    public long getAndSet(long val) {
-        return atomicLong.getAndSet(val);
-    }
+            case OP_DECREMENT_AND_GET:
+                return atomicLong.decrementAndGet();
 
-    /**
-     * Compares two values for equality and, if they are equal, replaces the first value.
-     *
-     * @return Original atomic long value.
-     */
-    public long compareAndSetAndGet(long expVal, long newVal) {
-        return atomicLong.compareAndSetAndGet(expVal, newVal);
-    }
+            case OP_GET:
+                return atomicLong.get();
 
-    /**
-     * Compares two values for equality and, if they are equal, replaces the first value.
-     *
-     * @return Original atomic long value.
-     */
-    public boolean compareAndSet(long cmp, long val) {
-        return atomicLong.compareAndSet(cmp, val);
-    }
+            case OP_GET_AND_DECREMENT:
+                return atomicLong.getAndDecrement();
 
-    /**
-     * Gets status of atomic.
-     *
-     * @return {@code true} if atomic was removed from cache, {@code false} in other case.
-     */
-    public boolean isClosed() {
-        return atomicLong.removed();
+            case OP_GET_AND_INCREMENT:
+                return atomicLong.getAndIncrement();
+
+            case OP_INCREMENT_AND_GET:
+                return atomicLong.incrementAndGet();
+
+            case OP_IS_CLOSED:
+                return atomicLong.removed() ? TRUE : FALSE;
+        }
+
+        return super.processOutLong(type);
     }
 
-    /**
-     * Removes this atomic long.
-     */
-    public void close() {
-        atomicLong.close();
+    /** {@inheritDoc} */
+    @Override protected long processInLongOutLong(int type, long val) throws IgniteCheckedException {
+        switch (type) {
+            case OP_ADD_AND_GET:
+                return atomicLong.addAndGet(val);
+
+            case OP_GET_AND_ADD:
+                return atomicLong.getAndAdd(val);
+
+            case OP_GET_AND_SET:
+                return atomicLong.getAndSet(val);
+        }
+
+        return super.processInLongOutLong(type, val);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java
index 5080139..e5fc08d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.datastructures.GridCacheAtomicRefer
 import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
+import org.omg.CORBA.TRANSACTION_REQUIRED;
 
 /**
  * Platform atomic reference wrapper.
@@ -40,6 +41,12 @@ public class PlatformAtomicReference extends PlatformAbstractTarget {
     private static final int OP_COMPARE_AND_SET_AND_GET = 3;
 
     /** */
+    private static final int OP_CLOSE = 4;
+
+    /** */
+    private static final int OP_IS_CLOSED = 5;
+
+    /** */
     private final GridCacheAtomicReferenceImpl atomicRef;
 
     /**
@@ -87,22 +94,6 @@ public class PlatformAtomicReference extends PlatformAbstractTarget {
         atomicRef = ref;
     }
 
-    /**
-     * Returns a value indicating whether this instance has been closed.
-     *
-     * @return Value indicating whether this instance has been closed.
-     */
-    public boolean isClosed() {
-        return atomicRef.removed();
-    }
-
-    /**
-     * Closes this instance.
-     */
-    public void close() {
-        atomicRef.close();
-    }
-
     /** {@inheritDoc} */
     @Override protected void processOutStream(int type, BinaryRawWriterEx writer) throws IgniteCheckedException {
         if (type == OP_GET)
@@ -142,5 +133,20 @@ public class PlatformAtomicReference extends PlatformAbstractTarget {
         else
             super.processInStreamOutStream(type, reader, writer);
     }
+
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_CLOSE:
+                atomicRef.close();
+
+                return TRUE;
+
+            case OP_IS_CLOSED:
+                return atomicRef.removed() ? TRUE : FALSE;
+        }
+
+        return super.processOutLong(type);
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java
index ce7e364..ec946ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.platform.datastructures;
 
 import org.apache.ignite.IgniteAtomicSequence;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 
@@ -28,6 +29,33 @@ public class PlatformAtomicSequence extends PlatformAbstractTarget {
     /** */
     private final IgniteAtomicSequence atomicSeq;
 
+    /** */
+    private static final int OP_ADD_AND_GET = 1;
+
+    /** */
+    private static final int OP_CLOSE = 2;
+
+    /** */
+    private static final int OP_GET = 3;
+
+    /** */
+    private static final int OP_GET_AND_ADD = 4;
+
+    /** */
+    private static final int OP_GET_AND_INCREMENT = 5;
+
+    /** */
+    private static final int OP_GET_BATCH_SIZE = 6;
+
+    /** */
+    private static final int OP_INCREMENT_AND_GET = 7;
+
+    /** */
+    private static final int OP_IS_CLOSED = 8;
+
+    /** */
+    private static final int OP_SET_BATCH_SIZE = 9;
+
     /**
      * Ctor.
      * @param ctx Context.
@@ -41,82 +69,49 @@ public class PlatformAtomicSequence extends PlatformAbstractTarget {
         this.atomicSeq = atomicSeq;
     }
 
-    /**
-     * Reads the value.
-     *
-     * @return Current atomic sequence value.
-     */
-    public long get() {
-        return atomicSeq.get();
-    }
 
-    /**
-     * Increments and reads the value.
-     *
-     * @return Current atomic sequence value.
-     */
-    public long incrementAndGet() {
-        return atomicSeq.incrementAndGet();
-    }
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_CLOSE:
+                atomicSeq.close();
 
-    /**
-     * Reads and increments the value.
-     *
-     * @return Original atomic sequence value.
-     */
-    public long getAndIncrement() {
-        return atomicSeq.getAndIncrement();
-    }
+                return TRUE;
 
-    /**
-     * Adds a value.
-     *
-     * @return Current atomic sequence value.
-     */
-    public long addAndGet(long l) {
-        return atomicSeq.addAndGet(l);
-    }
+            case OP_GET:
+                return atomicSeq.get();
 
-    /**
-     * Adds a value.
-     *
-     * @return Original atomic sequence value.
-     */
-    public long getAndAdd(long l) {
-        return atomicSeq.getAndAdd(l);
-    }
+            case OP_GET_AND_INCREMENT:
+                return atomicSeq.getAndIncrement();
 
-    /**
-     * Gets the batch size.
-     *
-     * @return Batch size.
-     */
-    public int getBatchSize() {
-        return atomicSeq.batchSize();
-    }
+            case OP_INCREMENT_AND_GET:
+                return atomicSeq.incrementAndGet();
 
-    /**
-     * Sets the batch size.
-     *
-     * @param size Batch size.
-     */
-    public void setBatchSize(int size) {
-        atomicSeq.batchSize(size);
-    }
+            case OP_IS_CLOSED:
+                return atomicSeq.removed() ? TRUE : FALSE;
 
-    /**
-     * Gets status of atomic.
-     *
-     * @return {@code true} if atomic was removed from cache, {@code false} in other case.
-     */
-    public boolean isClosed() {
-        return atomicSeq.removed();
+            case OP_GET_BATCH_SIZE:
+                return atomicSeq.batchSize();
+        }
+
+        return super.processOutLong(type);
     }
 
-    /**
-     * Removes this atomic.
-     */
-    public void close() {
-        atomicSeq.close();
+    /** {@inheritDoc} */
+    @Override protected long processInLongOutLong(int type, long val) throws IgniteCheckedException {
+        switch (type) {
+            case OP_ADD_AND_GET:
+                return atomicSeq.addAndGet(val);
+
+            case OP_GET_AND_ADD:
+                return atomicSeq.getAndAdd(val);
+
+            case OP_SET_BATCH_SIZE:
+                atomicSeq.batchSize((int)val);
+
+                return TRUE;
+        }
+
+        return super.processInLongOutLong(type, val);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
index 45d9208..68b1d22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.binary.BinaryRawReaderEx;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheStore;
-import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheStoreCallback;
 import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
 import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
 import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
@@ -34,6 +33,7 @@ import org.apache.ignite.internal.util.lang.IgniteInClosureX;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.resources.CacheStoreSessionResource;
 import org.jetbrains.annotations.Nullable;
 
@@ -168,7 +168,11 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
                     writer.writeString(ses.cacheName());
                     writer.writeObject(key);
                 }
-            }, new LoadCallback<>(platformCtx, val));
+            }, new IgniteInClosureX<BinaryRawReaderEx>() {
+                @Override public void applyx(BinaryRawReaderEx reader) {
+                    val.set((V)reader.readObjectDetached());
+                }
+            });
 
             return val.get();
         }
@@ -182,14 +186,23 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
         try {
             final Map<K, V> loaded = new HashMap<>();
 
+            final Collection keys0 = (Collection)keys;
+
             doInvoke(new IgniteInClosureX<BinaryRawWriterEx>() {
                 @Override public void applyx(BinaryRawWriterEx writer) throws IgniteCheckedException {
                     writer.writeByte(OP_LOAD_ALL);
                     writer.writeLong(session());
                     writer.writeString(ses.cacheName());
-                    writer.writeCollection((Collection)keys);
+                    writer.writeCollection(keys0);
+                }
+            }, new IgniteInClosureX<BinaryRawReaderEx>() {
+                @Override public void applyx(BinaryRawReaderEx reader) {
+                    int cnt = reader.readInt();
+
+                    for (int i = 0; i < cnt; i++)
+                        loaded.put((K) reader.readObjectDetached(), (V) reader.readObjectDetached());
                 }
-            }, new LoadAllCallback<>(platformCtx, loaded));
+            });
 
             return loaded;
         }
@@ -208,7 +221,14 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
                     writer.writeString(ses.cacheName());
                     writer.writeObjectArray(args);
                 }
-            }, new LoadCacheCallback<>(platformCtx, clo));
+            }, new IgniteInClosureX<BinaryRawReaderEx>() {
+                @Override public void applyx(BinaryRawReaderEx reader) {
+                    int cnt = reader.readInt();
+
+                    for (int i = 0; i < cnt; i++)
+                        clo.apply((K) reader.readObjectDetached(), (V) reader.readObjectDetached());
+                }
+            });
         }
         catch (IgniteCheckedException e) {
             throw new CacheLoaderException(e);
@@ -374,11 +394,11 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
      * Perform actual invoke.
      *
      * @param task Task.
-     * @param cb Optional callback.
+     * @param readClo Reader.
      * @return Result.
      * @throws org.apache.ignite.IgniteCheckedException If failed.
      */
-    protected int doInvoke(IgniteInClosureX<BinaryRawWriterEx> task, @Nullable PlatformCacheStoreCallback cb)
+    protected int doInvoke(IgniteInClosure<BinaryRawWriterEx> task, IgniteInClosure<BinaryRawReaderEx> readClo)
         throws IgniteCheckedException{
         try (PlatformMemory mem = platformCtx.memory().allocate()) {
             PlatformOutputStream out = mem.output();
@@ -389,7 +409,15 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
 
             out.synchronize();
 
-            return platformCtx.gateway().cacheStoreInvoke(ptr, mem.pointer(), cb);
+            int res = platformCtx.gateway().cacheStoreInvoke(ptr, mem.pointer());
+
+            if (readClo != null) {
+                BinaryRawReaderEx reader = platformCtx.reader(mem);
+
+                readClo.apply(reader);
+            }
+
+            return res;
         }
     }
 
@@ -403,82 +431,4 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
 
         platformCtx.gateway().cacheStoreDestroy(ptr);
     }
-
-    /**
-     * Load callback.
-     */
-    private static class LoadCallback<V> extends PlatformCacheStoreCallback {
-        /** Value. */
-        private final GridTuple<V> val;
-
-        /**
-         * Constructor.
-         *
-         * @param ctx Context.
-         * @param val Value.
-         */
-        public LoadCallback(PlatformContext ctx, GridTuple<V> val) {
-            super(ctx);
-
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
-        @Override protected void invoke0(BinaryRawReaderEx reader) {
-            val.set((V)reader.readObjectDetached());
-        }
-    }
-
-    /**
-     * Load callback.
-     */
-    private static class LoadAllCallback<K, V> extends PlatformCacheStoreCallback {
-        /** Value. */
-        private final Map<K, V> loaded;
-
-        /**
-         * Constructor.
-         *
-         * @param ctx Context.
-         * @param loaded Map with loaded values.
-         */
-        public LoadAllCallback(PlatformContext ctx, Map<K, V> loaded) {
-            super(ctx);
-
-            this.loaded = loaded;
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
-        @Override protected void invoke0(BinaryRawReaderEx reader) {
-            loaded.put((K) reader.readObjectDetached(), (V) reader.readObjectDetached());
-        }
-    }
-
-    /**
-     * Load callback.
-     */
-    private static class LoadCacheCallback<K, V> extends PlatformCacheStoreCallback {
-        /** Value. */
-        private final IgniteBiInClosure<K, V> clo;
-
-        /**
-         * Constructor.
-         *
-         * @param ctx Context.
-         * @param clo Closure.
-         */
-        public LoadCacheCallback(PlatformContext ctx, IgniteBiInClosure<K, V> clo) {
-            super(ctx);
-
-            this.clo = clo;
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
-        @Override protected void invoke0(BinaryRawReaderEx reader) {
-            clo.apply((K) reader.readObjectDetached(), (V) reader.readObjectDetached());
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
index 71708af..f133524 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
@@ -69,6 +69,18 @@ public class PlatformEvents extends PlatformAbstractTarget {
     private static final int OP_GET_ENABLED_EVENTS = 10;
 
     /** */
+    private static final int OP_WITH_ASYNC = 11;
+
+    /** */
+    private static final int OP_IS_ENABLED = 12;
+
+    /** */
+    private static final int OP_LOCAL_LISTEN = 13;
+
+    /** */
+    private static final int OP_STOP_LOCAL_LISTEN = 14;
+
+    /** */
     private final IgniteEvents events;
 
     /** */
@@ -94,50 +106,6 @@ public class PlatformEvents extends PlatformAbstractTarget {
         eventColResWriter = new EventCollectionResultWriter(platformCtx);
     }
 
-    /**
-     * Gets events with asynchronous mode enabled.
-     *
-     * @return Events with asynchronous mode enabled.
-     */
-    public PlatformEvents withAsync() {
-        if (events.isAsync())
-            return this;
-
-        return new PlatformEvents(platformCtx, events.withAsync());
-    }
-
-    /**
-     * Adds an event listener for local events.
-     *
-     * @param hnd Interop listener handle.
-     * @param type Event type.
-     */
-    @SuppressWarnings({"unchecked"})
-    public void localListen(long hnd, int type) {
-        events.localListen(localFilter(hnd), type);
-    }
-
-    /**
-     * Removes an event listener for local events.
-     *
-     * @param hnd Interop listener handle.
-     */
-    @SuppressWarnings({"UnusedDeclaration", "unchecked"})
-    public boolean stopLocalListen(long hnd) {
-        return events.stopLocalListen(localFilter(hnd));
-    }
-
-    /**
-     * Check if event is enabled.
-     *
-     * @param type Event type.
-     * @return {@code True} if event of passed in type is enabled.
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    public boolean isEnabled(int type) {
-        return events.isEnabled(type);
-    }
-
     /** {@inheritDoc} */
     @Override protected long processInStreamOutLong(int type, BinaryRawReaderEx reader)
         throws IgniteCheckedException {
@@ -163,6 +131,11 @@ public class PlatformEvents extends PlatformAbstractTarget {
 
                 return TRUE;
 
+            case OP_LOCAL_LISTEN:
+                events.localListen(localFilter(reader.readLong()), reader.readInt());
+
+                return TRUE;
+
             default:
                 return super.processInStreamOutLong(type, reader);
         }
@@ -270,12 +243,38 @@ public class PlatformEvents extends PlatformAbstractTarget {
         }
     }
 
-    /** <inheritDoc /> */
+    /** {@inheritDoc} */
+    @Override protected Object processOutObject(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_WITH_ASYNC:
+                if (events.isAsync())
+                    return this;
+
+                return new PlatformEvents(platformCtx, events.withAsync());
+        }
+
+        return super.processOutObject(type);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long processInLongOutLong(int type, long val) throws IgniteCheckedException {
+        switch (type) {
+            case OP_IS_ENABLED:
+                return events.isEnabled((int)val) ? TRUE : FALSE;
+
+            case OP_STOP_LOCAL_LISTEN:
+                return events.stopLocalListen(localFilter(val)) ? TRUE : FALSE;
+        }
+
+        return super.processInLongOutLong(type, val);
+    }
+
+    /** {@inheritDoc} */
     @Override protected IgniteInternalFuture currentFuture() throws IgniteCheckedException {
         return ((IgniteFutureImpl)events.future()).internalFuture();
     }
 
-    /** <inheritDoc /> */
+    /** {@inheritDoc} */
     @Nullable @Override protected PlatformFutureUtils.Writer futureWriter(int opId) {
         switch (opId) {
             case OP_WAIT_FOR_LOCAL:

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
index 619fea7..1b05eca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
@@ -56,6 +56,9 @@ public class PlatformMessaging extends PlatformAbstractTarget {
     public static final int OP_STOP_REMOTE_LISTEN = 7;
 
     /** */
+    public static final int OP_WITH_ASYNC = 8;
+
+    /** */
     private final IgniteMessaging messaging;
 
     /**
@@ -72,18 +75,6 @@ public class PlatformMessaging extends PlatformAbstractTarget {
         this.messaging = messaging;
     }
 
-    /**
-     * Gets messaging with asynchronous mode enabled.
-     *
-     * @return Messaging with asynchronous mode enabled.
-     */
-    public PlatformMessaging withAsync() {
-        if (messaging.isAsync())
-            return this;
-
-        return new PlatformMessaging (platformCtx, messaging.withAsync());
-    }
-
     /** {@inheritDoc} */
     @Override protected long processInStreamOutLong(int type, BinaryRawReaderEx reader)
         throws IgniteCheckedException {
@@ -160,8 +151,21 @@ public class PlatformMessaging extends PlatformAbstractTarget {
         }
     }
 
-    /** <inheritDoc /> */
+    /** {@inheritDoc} */
     @Override protected IgniteInternalFuture currentFuture() throws IgniteCheckedException {
         return ((IgniteFutureImpl)messaging.future()).internalFuture();
     }
+
+    /** {@inheritDoc} */
+    @Override protected Object processOutObject(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_WITH_ASYNC:
+                if (messaging.isAsync())
+                    return this;
+
+                return new PlatformMessaging (platformCtx, messaging.withAsync());
+        }
+
+        return super.processOutObject(type);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
index f355741..7aaf597 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
@@ -67,6 +67,21 @@ public class PlatformServices extends PlatformAbstractTarget {
     private static final int OP_DESCRIPTORS = 5;
 
     /** */
+    private static final int OP_WITH_ASYNC = 6;
+
+    /** */
+    private static final int OP_WITH_SERVER_KEEP_BINARY = 7;
+
+    /** */
+    private static final int OP_SERVICE_PROXY = 8;
+
+    /** */
+    private static final int OP_CANCEL = 9;
+
+    /** */
+    private static final int OP_CANCEL_ALL = 10;
+
+    /** */
     private static final byte PLATFORM_JAVA = 0;
 
     /** */
@@ -99,63 +114,6 @@ public class PlatformServices extends PlatformAbstractTarget {
     }
 
     /**
-     * Gets services with asynchronous mode enabled.
-     *
-     * @return Services with asynchronous mode enabled.
-     */
-    public PlatformServices withAsync() {
-        if (services.isAsync())
-            return this;
-
-        return new PlatformServices(platformCtx, services.withAsync(), srvKeepBinary);
-    }
-
-    /**
-     * Gets services with server "keep binary" mode enabled.
-     *
-     * @return Services with server "keep binary" mode enabled.
-     */
-    public PlatformServices withServerKeepBinary() {
-        return srvKeepBinary ? this : new PlatformServices(platformCtx, services, true);
-    }
-
-    /**
-     * Cancels service deployment.
-     *
-     * @param name Name of service to cancel.
-     */
-    public void cancel(String name) {
-        services.cancel(name);
-    }
-
-    /**
-     * Cancels all deployed services.
-     */
-    public void cancelAll() {
-        services.cancelAll();
-    }
-
-    /**
-     * Gets a remote handle on the service.
-     *
-     * @param name Service name.
-     * @param sticky Whether or not Ignite should always contact the same remote service.
-     * @return Either proxy over remote service or local service if it is deployed locally.
-     */
-    public Object serviceProxy(String name, boolean sticky) {
-        ServiceDescriptor d = findDescriptor(name);
-
-        if (d == null)
-            throw new IgniteException("Failed to find deployed service: " + name);
-
-        Object proxy = PlatformService.class.isAssignableFrom(d.serviceClass())
-            ? services.serviceProxy(name, PlatformService.class, sticky)
-            : new GridServiceProxy<>(services.clusterGroup(), name, Service.class, sticky, platformCtx.kernalContext());
-
-        return new ServiceProxyHolder(proxy, d.serviceClass());
-    }
-
-    /**
      * Finds a service descriptor by name.
      *
      * @param name Service name.
@@ -205,6 +163,14 @@ public class PlatformServices extends PlatformAbstractTarget {
                 return TRUE;
             }
 
+            case OP_CANCEL: {
+                String name = reader.readString();
+
+                services.cancel(name);
+
+                return TRUE;
+            }
+
             default:
                 return super.processInStreamOutLong(type, reader);
         }
@@ -315,7 +281,58 @@ public class PlatformServices extends PlatformAbstractTarget {
         }
     }
 
-    /** <inheritDoc /> */
+    /** {@inheritDoc} */
+    @Override protected Object processOutObject(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_WITH_ASYNC:
+                if (services.isAsync())
+                    return this;
+
+                return new PlatformServices(platformCtx, services.withAsync(), srvKeepBinary);
+
+            case OP_WITH_SERVER_KEEP_BINARY:
+                return srvKeepBinary ? this : new PlatformServices(platformCtx, services, true);
+        }
+
+        return super.processOutObject(type);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_CANCEL_ALL:
+                services.cancelAll();
+
+                return TRUE;
+        }
+
+        return super.processOutLong(type);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object processInStreamOutObject(int type, BinaryRawReaderEx reader) throws IgniteCheckedException {
+        switch (type) {
+            case OP_SERVICE_PROXY: {
+                String name = reader.readString();
+                boolean sticky = reader.readBoolean();
+
+                ServiceDescriptor d = findDescriptor(name);
+
+                if (d == null)
+                    throw new IgniteException("Failed to find deployed service: " + name);
+
+                Object proxy = PlatformService.class.isAssignableFrom(d.serviceClass())
+                    ? services.serviceProxy(name, PlatformService.class, sticky)
+                    : new GridServiceProxy<>(services.clusterGroup(), name, Service.class, sticky,
+                        platformCtx.kernalContext());
+
+                return new ServiceProxyHolder(proxy, d.serviceClass());
+            }
+        }
+        return super.processInStreamOutObject(type, reader);
+    }
+
+    /** {@inheritDoc} */
     @Override protected IgniteInternalFuture currentFuture() throws IgniteCheckedException {
         return ((IgniteFutureImpl)services.future()).internalFuture();
     }


[12/40] ignite git commit: IGNITE-3163 IGFS: Added working directory support to IgniteHadoopIgfsSecondaryFileSystem. This closes #1030. This closes #1058. This closes #1132.

Posted by av...@apache.org.
IGNITE-3163 IGFS: Added working directory support to IgniteHadoopIgfsSecondaryFileSystem. This closes #1030. This closes #1058. This closes #1132.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: b94b0aeae4c42b1d35128c6b1de97e3fa318d497
Parents: 23461b8
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Thu Oct 6 10:22:50 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 6 10:22:50 2016 +0300

----------------------------------------------------------------------
 .../HadoopBasicFileSystemFactoryDelegate.java       | 16 +++++++++++++++-
 .../HadoopKerberosFileSystemFactoryDelegate.java    |  7 ++++++-
 .../hadoop/impl/igfs/Hadoop1DualAbstractTest.java   | 12 +++++++++---
 .../HadoopSecondaryFileSystemConfigurationTest.java | 12 ++++++++++++
 4 files changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b94b0aea/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java
index a190b14..59488be 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.hadoop.impl.delegate;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.hadoop.fs.BasicHadoopFileSystemFactory;
 import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
@@ -52,6 +53,9 @@ public class HadoopBasicFileSystemFactoryDelegate implements HadoopFileSystemFac
     /** User name mapper. */
     private UserNameMapper usrNameMapper;
 
+    /** Work directory. */
+    protected Path workDir;
+
     /**
      * Constructor.
      *
@@ -110,7 +114,12 @@ public class HadoopBasicFileSystemFactoryDelegate implements HadoopFileSystemFac
      * @throws InterruptedException if the current thread is interrupted.
      */
     protected FileSystem create(String usrName) throws IOException, InterruptedException {
-        return FileSystem.get(fullUri, cfg, usrName);
+        FileSystem fs = FileSystem.get(fullUri, cfg, usrName);
+
+        if (workDir != null)
+            fs.setWorkingDirectory(workDir);
+
+        return fs;
     }
 
     /** {@inheritDoc} */
@@ -150,6 +159,11 @@ public class HadoopBasicFileSystemFactoryDelegate implements HadoopFileSystemFac
             }
         }
 
+        String strWorkDir = fullUri.getPath();
+
+        if (!"/".equals(strWorkDir))
+            workDir = new Path(strWorkDir);
+
         usrNameMapper = proxy0.getUserNameMapper();
 
         if (usrNameMapper != null && usrNameMapper instanceof LifecycleAware)

http://git-wip-us.apache.org/repos/asf/ignite/blob/b94b0aea/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java
index c71dedb..75093bb 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java
@@ -61,7 +61,12 @@ public class HadoopKerberosFileSystemFactoryDelegate extends HadoopBasicFileSyst
 
         return proxyUgi.doAs(new PrivilegedExceptionAction<FileSystem>() {
             @Override public FileSystem run() throws Exception {
-                return FileSystem.get(fullUri, cfg);
+                FileSystem fs = FileSystem.get(fullUri, cfg);
+
+                if (workDir != null)
+                    fs.setWorkingDirectory(workDir);
+
+                return fs;
             }
         });
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b94b0aea/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java
index a585e54..367a406 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java
@@ -58,6 +58,9 @@ public abstract class Hadoop1DualAbstractTest extends IgfsDualAbstractSelfTest {
     /** Secondary file system authority. */
     private static final String SECONDARY_AUTHORITY = IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1:" + PORT;
 
+    /** Secondary file system authority. */
+    private static final String SECONDARY_WORKDIR = "workdir/test";
+
     /** Secondary Fs configuration full path. */
     protected String secondaryConfFullPath;
 
@@ -117,13 +120,16 @@ public abstract class Hadoop1DualAbstractTest extends IgfsDualAbstractSelfTest {
      * @throws IOException On failure.
      */
     protected void prepareConfiguration() throws IOException {
-        Configuration secondaryConf = HadoopSecondaryFileSystemConfigurationTest.configuration(IGFS_SCHEME, SECONDARY_AUTHORITY, true, true);
+        Configuration secondaryConf = HadoopSecondaryFileSystemConfigurationTest.configuration(IGFS_SCHEME,
+            SECONDARY_AUTHORITY, true, true);
 
         secondaryConf.setInt("fs.igfs.block.size", 1024);
 
-        secondaryConfFullPath = HadoopSecondaryFileSystemConfigurationTest.writeConfiguration(secondaryConf, HadoopSecondaryFileSystemConfigurationTest.SECONDARY_CFG_PATH);
+        secondaryConfFullPath = HadoopSecondaryFileSystemConfigurationTest.writeConfiguration(secondaryConf,
+            HadoopSecondaryFileSystemConfigurationTest.SECONDARY_CFG_PATH);
 
-        secondaryUri = HadoopSecondaryFileSystemConfigurationTest.mkUri(IGFS_SCHEME, SECONDARY_AUTHORITY);
+        secondaryUri = HadoopSecondaryFileSystemConfigurationTest.mkUri(IGFS_SCHEME, SECONDARY_AUTHORITY,
+            SECONDARY_WORKDIR);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b94b0aea/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java
index fd75233..ae03f14 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java
@@ -580,4 +580,16 @@ public class HadoopSecondaryFileSystemConfigurationTest extends IgfsCommonAbstra
     static String mkUri(String scheme, String authority) {
         return scheme + "://" + authority + "/";
     }
+
+    /**
+     * Makes URI.
+     *
+     * @param scheme the scheme
+     * @param authority the authority
+     * @param path Path part of URI.
+     * @return URI String
+     */
+    static String mkUri(String scheme, String authority, String path) {
+        return scheme + "://" + authority + "/" + path;
+    }
 }
\ No newline at end of file


[18/40] ignite git commit: IGNITE-4014 Fixed "Transaction hangs if entry processor failed during serialization". This closes #1148.

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
index a96d6eb..d388584 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
@@ -1127,16 +1127,16 @@ public class GridClosureProcessor extends GridProcessorAdapter {
                         if (closureBytes == null) {
                             closure = c.job;
 
-                            closureBytes = marsh.marshal(c.job);
+                            closureBytes = U.marshal(marsh, c.job);
                         }
 
                         if (c.job == closure)
-                            c.job = marsh.unmarshal(closureBytes, U.resolveClassLoader(ctx.config()));
+                            c.job = U.unmarshal(marsh, closureBytes, U.resolveClassLoader(ctx.config()));
                         else
-                            c.job = marsh.unmarshal(marsh.marshal(c.job), U.resolveClassLoader(ctx.config()));
+                            c.job = U.unmarshal(marsh, U.marshal(marsh, c.job), U.resolveClassLoader(ctx.config()));
                     }
                     else
-                        job = marsh.unmarshal(marsh.marshal(job), U.resolveClassLoader(ctx.config()));
+                        job = U.unmarshal(marsh, U.marshal(marsh, job), U.resolveClassLoader(ctx.config()));
                 }
                 else
                     hadLocNode = true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index ad7ad4f..f078b1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -293,7 +293,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
 
                 if (msg.data() == null && msg.dataBytes() != null) {
                     try {
-                        msg.data(marsh.unmarshal(msg.dataBytes(), U.resolveClassLoader(ctx.config())));
+                        msg.data(U.unmarshal(marsh, msg.dataBytes(), U.resolveClassLoader(ctx.config())));
                     }
                     catch (IgniteCheckedException e) {
                         U.error(log, "Failed to process message (ignoring): " + msg, e);
@@ -729,7 +729,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
 
                     if (msg.data() == null && msg.dataBytes() != null) {
                         try {
-                            msg.data(marsh.unmarshal(msg.dataBytes(), U.resolveClassLoader(ctx.config())));
+                            msg.data(U.unmarshal(marsh, msg.dataBytes(), U.resolveClassLoader(ctx.config())));
                         }
                         catch (IgniteCheckedException e) {
                             U.error(log, "Failed to process message (ignoring): " + msg, e);
@@ -1316,7 +1316,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
         if (!msg.messages() &&
             msg.data() != null &&
             (nodes.size() > 1 || !ctx.localNodeId().equals(F.first(nodes).id())))
-            msg.dataBytes(marsh.marshal(msg.data()));
+            msg.dataBytes(U.marshal(marsh, msg.data()));
 
         for (ClusterNode node : nodes) {
             int cnt = 0;

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
index cdfe0e1..2314f29 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/StartRequestData.java
@@ -95,7 +95,7 @@ class StartRequestData implements Externalizable {
     void p2pMarshal(Marshaller marsh) throws IgniteCheckedException {
         assert marsh != null;
 
-        prjPredBytes = marsh.marshal(prjPred);
+        prjPredBytes = U.marshal(marsh, prjPred);
     }
 
     /**
@@ -109,7 +109,7 @@ class StartRequestData implements Externalizable {
         assert prjPred == null;
         assert prjPredBytes != null;
 
-        prjPred = marsh.unmarshal(prjPredBytes, ldr);
+        prjPred = U.unmarshal(marsh, prjPredBytes, ldr);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
index c7c1f5e..7663735 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessor.java
@@ -90,7 +90,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
         if (ctx.config().isDaemon())
             return;
 
-        marshErrBytes = marsh.marshal(new IgniteCheckedException("Failed to marshal response error, " +
+        marshErrBytes = U.marshal(marsh, new IgniteCheckedException("Failed to marshal response error, " +
             "see node log for details."));
 
         flusher = new IgniteThread(new GridWorker(ctx.gridName(), "grid-data-loader-flusher", log) {
@@ -235,7 +235,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
             Object topic;
 
             try {
-                topic = marsh.unmarshal(req.responseTopicBytes(), U.resolveClassLoader(null, ctx.config()));
+                topic = U.unmarshal(marsh, req.responseTopicBytes(), U.resolveClassLoader(null, ctx.config()));
             }
             catch (IgniteCheckedException e) {
                 U.error(log, "Failed to unmarshal topic from request: " + req, e);
@@ -275,7 +275,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
             StreamReceiver<K, V> updater;
 
             try {
-                updater = marsh.unmarshal(req.updaterBytes(), U.resolveClassLoader(clsLdr, ctx.config()));
+                updater = U.unmarshal(marsh, req.updaterBytes(), U.resolveClassLoader(clsLdr, ctx.config()));
 
                 if (updater != null)
                     ctx.resource().injectGeneric(updater);
@@ -329,7 +329,7 @@ public class DataStreamProcessor<K, V> extends GridProcessorAdapter {
         byte[] errBytes;
 
         try {
-            errBytes = err != null ? marsh.marshal(err) : null;
+            errBytes = err != null ? U.marshal(marsh, err) : null;
         }
         catch (Exception e) {
             U.error(log, "Failed to marshal error [err=" + err + ", marshErr=" + e + ']', e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index 05e6488..c2f226c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -1353,11 +1353,11 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
                     if (updaterBytes == null) {
                         assert rcvr != null;
 
-                        updaterBytes = ctx.config().getMarshaller().marshal(rcvr);
+                        updaterBytes = U.marshal(ctx, rcvr);
                     }
 
                     if (topicBytes == null)
-                        topicBytes = ctx.config().getMarshaller().marshal(topic);
+                        topicBytes = U.marshal(ctx, topic);
                 }
                 catch (IgniteCheckedException e) {
                     U.error(log, "Failed to marshal (request will not be sent).", e);
@@ -1488,7 +1488,7 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
                 try {
                     GridPeerDeployAware jobPda0 = jobPda;
 
-                    err = ctx.config().getMarshaller().unmarshal(
+                    err = U.unmarshal(ctx,
                         errBytes,
                         U.resolveClassLoader(jobPda0 != null ? jobPda0.classLoader() : null, ctx.config()));
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
index bca4592..275e7eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java
@@ -21,6 +21,7 @@ import java.io.Externalizable;
 import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -96,7 +97,7 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
         super.prepareMarshal(marsh);
 
         if (err != null && errBytes == null)
-            errBytes = marsh.marshal(err);
+            errBytes = U.marshal(marsh, err);
     }
 
     /** {@inheritDoc} */
@@ -104,7 +105,7 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
         super.finishUnmarshal(marsh, ldr);
 
         if (errBytes != null && err == null)
-            err = marsh.unmarshal(errBytes, ldr);
+            err = U.unmarshal(marsh, errBytes, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
index e59b257..3224c20 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.GridDirectTransient;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -95,7 +96,7 @@ public class IgfsDeleteMessage extends IgfsCommunicationMessage {
         super.prepareMarshal(marsh);
 
         if (err != null)
-            errBytes = marsh.marshal(err);
+            errBytes = U.marshal(marsh, err);
     }
 
     /** {@inheritDoc} */
@@ -103,7 +104,7 @@ public class IgfsDeleteMessage extends IgfsCommunicationMessage {
         super.finishUnmarshal(marsh, ldr);
 
         if (errBytes != null)
-            err = marsh.unmarshal(errBytes, ldr);
+            err = U.unmarshal(marsh, errBytes, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
index 72b5a19..9752411 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
@@ -74,7 +74,7 @@ public class IgfsPaths implements Externalizable {
         else {
             ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-            new JdkMarshaller().marshal(payload, out);
+            U.marshal(new JdkMarshaller(), payload, out);
 
             payloadBytes = out.toByteArray();
         }
@@ -105,7 +105,7 @@ public class IgfsPaths implements Externalizable {
         else {
             ByteArrayInputStream in = new ByteArrayInputStream(payloadBytes);
 
-            return new JdkMarshaller().unmarshal(in, clsLdr);
+            return U.unmarshal(new JdkMarshaller(), in, clsLdr);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index 563a3d8..2f04402 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -407,7 +407,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
         boolean loc = ctx.localNodeId().equals(taskNode.id()) && !ctx.config().isMarshalLocalJobs();
 
         GridTaskSessionRequest req = new GridTaskSessionRequest(ses.getId(), ses.getJobId(),
-            loc ? null : marsh.marshal(attrs), attrs);
+            loc ? null : U.marshal(marsh, attrs), attrs);
 
         Object topic = TOPIC_TASK.topic(ses.getJobId(), ctx.discovery().localNode().id());
 
@@ -521,7 +521,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
             ctx.io().send(taskNode, TOPIC_JOB_SIBLINGS,
                 new GridJobSiblingsRequest(ses.getId(),
                     loc ? topic : null,
-                    loc ? null : marsh.marshal(topic)),
+                    loc ? null : U.marshal(marsh, topic)),
                 SYSTEM_POOL);
 
             // 4. Listen to discovery events.
@@ -1028,7 +1028,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
                             if (siblings0 == null) {
                                 assert req.getSiblingsBytes() != null;
 
-                                siblings0 = marsh.unmarshal(req.getSiblingsBytes(), U.resolveClassLoader(ctx.config()));
+                                siblings0 = U.unmarshal(marsh, req.getSiblingsBytes(), U.resolveClassLoader(ctx.config()));
                             }
 
                             siblings = new ArrayList<>(siblings0);
@@ -1040,7 +1040,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
                             sesAttrs = req.getSessionAttributes();
 
                             if (sesAttrs == null)
-                                sesAttrs = marsh.unmarshal(req.getSessionAttributesBytes(),
+                                sesAttrs = U.unmarshal(marsh, req.getSessionAttributesBytes(),
                                     U.resolveClassLoader(dep.classLoader(), ctx.config()));
                         }
 
@@ -1068,7 +1068,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
                         Map<? extends Serializable, ? extends Serializable> jobAttrs = req.getJobAttributes();
 
                         if (jobAttrs == null)
-                            jobAttrs = marsh.unmarshal(req.getJobAttributesBytes(),
+                            jobAttrs = U.unmarshal(marsh, req.getJobAttributesBytes(),
                                 U.resolveClassLoader(dep.classLoader(), ctx.config()));
 
                         jobCtx = new GridJobContextImpl(ctx, req.getJobId(), jobAttrs);
@@ -1343,11 +1343,11 @@ public class GridJobProcessor extends GridProcessorAdapter {
                 locNodeId,
                 req.getSessionId(),
                 req.getJobId(),
-                loc ? null : marsh.marshal(ex),
+                loc ? null : U.marshal(marsh, ex),
                 ex,
-                loc ? null : marsh.marshal(null),
+                loc ? null : U.marshal(marsh, null),
                 null,
-                loc ? null : marsh.marshal(null),
+                loc ? null : U.marshal(marsh, null),
                 null,
                 false,
                 null);
@@ -1439,7 +1439,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
             boolean loc = ctx.localNodeId().equals(nodeId) && !ctx.config().isMarshalLocalJobs();
 
             Map<?, ?> attrs = loc ? req.getAttributes() :
-                (Map<?, ?>)marsh.unmarshal(req.getAttributesBytes(),
+                (Map<?, ?>)U.unmarshal(marsh, req.getAttributesBytes(),
                     U.resolveClassLoader(ses.getClassLoader(), ctx.config()));
 
             if (ctx.event().isRecordable(EVT_TASK_SESSION_ATTR_SET)) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
index 16fadaf..8169eb1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobWorker.java
@@ -421,7 +421,7 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
 
         try {
             if (job == null) {
-                job = marsh.unmarshal(jobBytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
+                job = U.unmarshal(marsh, jobBytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
 
                 // No need to hold reference any more.
                 jobBytes = null;
@@ -804,11 +804,11 @@ public class GridJobWorker extends GridWorker implements GridTimeoutObject {
                                 ctx.localNodeId(),
                                 ses.getId(),
                                 ses.getJobId(),
-                                loc ? null : marsh.marshal(ex),
+                                loc ? null : U.marshal(marsh, ex),
                                 loc ? ex : null,
-                                loc ? null: marsh.marshal(res),
+                                loc ? null: U.marshal(marsh, res),
                                 loc ? res : null,
-                                loc ? null : marsh.marshal(attrs),
+                                loc ? null : U.marshal(marsh, attrs),
                                 loc ? attrs : null,
                                 isCancelled(),
                                 retry ? ctx.cache().context().exchange().readyAffinityVersion() : null);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
index d9d4421..b91e9ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java
@@ -108,7 +108,7 @@ public class GridOffHeapProcessor extends GridProcessorAdapter {
     private byte[] keyBytes(KeyCacheObject key, @Nullable byte[] keyBytes) throws IgniteCheckedException {
         assert key != null;
 
-        return keyBytes != null ? keyBytes : marsh.marshal(key);
+        return keyBytes != null ? keyBytes : U.marshal(marsh, key);
     }
 
     /**
@@ -212,7 +212,7 @@ public class GridOffHeapProcessor extends GridProcessorAdapter {
         if (valBytes == null)
             return null;
 
-        return marsh.unmarshal(valBytes, U.resolveClassLoader(ldr, ctx.config()));
+        return U.unmarshal(marsh, valBytes, U.resolveClassLoader(ldr, ctx.config()));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
index 2749e96..947435c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
@@ -135,14 +135,13 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
                             res.error(err.getMessage());
                         else {
                             res.result(desc.result());
-                            res.resultBytes(ctx.config().getMarshaller().marshal(desc.result()));
+                            res.resultBytes(U.marshal(ctx, desc.result()));
                         }
                     }
                     else
                         res.found(false);
 
-                    Object topic = ctx.config().getMarshaller().unmarshal(req.topicBytes(),
-                        U.resolveClassLoader(ctx.config()));
+                    Object topic = U.unmarshal(ctx, req.topicBytes(), U.resolveClassLoader(ctx.config()));
 
                     ctx.io().send(nodeId, topic, res, SYSTEM_POOL);
                 }
@@ -440,8 +439,7 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
                     res = (GridTaskResultResponse)msg;
 
                 try {
-                    res.result(ctx.config().getMarshaller().unmarshal(res.resultBytes(),
-                        U.resolveClassLoader(ctx.config())));
+                    res.result(U.unmarshal(ctx, res.resultBytes(), U.resolveClassLoader(ctx.config())));
                 }
                 catch (IgniteCheckedException e) {
                     U.error(log, "Failed to unmarshal task result: " + res, e);
@@ -494,7 +492,7 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter {
 
             // 2. Send message.
             try {
-                byte[] topicBytes = ctx.config().getMarshaller().marshal(topic);
+                byte[] topicBytes = U.marshal(ctx, topic);
 
                 ctx.io().send(taskNode, TOPIC_REST, new GridTaskResultRequest(taskId, topic, topicBytes), SYSTEM_POOL);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
index 5beff75..de9851c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
@@ -718,7 +718,7 @@ public class GridTcpRestParser implements GridNioParser {
         assert bytes != null;
 
         if ((flags & SERIALIZED_FLAG) != 0)
-            return jdkMarshaller.unmarshal(bytes, null);
+            return U.unmarshal(jdkMarshaller, bytes, null);
 
         int masked = flags & 0xff00;
 
@@ -800,7 +800,7 @@ public class GridTcpRestParser implements GridNioParser {
             flags |= BYTE_ARR_FLAG;
         }
         else {
-            jdkMarshaller.marshal(obj, out);
+            U.marshal(jdkMarshaller, obj, out);
 
             flags |= SERIALIZED_FLAG;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 7b76c48..527d360 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -464,7 +464,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
             LazyServiceConfiguration cfg0;
 
             try {
-                byte[] srvcBytes = marsh.marshal(cfg.getService());
+                byte[] srvcBytes = U.marshal(marsh, cfg.getService());
 
                 cfg0 = new LazyServiceConfiguration(cfg, srvcBytes);
             }
@@ -1144,7 +1144,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
         if (cfg instanceof LazyServiceConfiguration) {
             byte[] bytes = ((LazyServiceConfiguration)cfg).serviceBytes();
 
-            Service srvc = m.unmarshal(bytes, U.resolveClassLoader(null, ctx.config()));
+            Service srvc = U.unmarshal(m, bytes, U.resolveClassLoader(null, ctx.config()));
 
             ctx.resource().inject(srvc);
 
@@ -1154,10 +1154,9 @@ public class GridServiceProcessor extends GridProcessorAdapter {
             Service svc = cfg.getService();
 
             try {
-                byte[] bytes = m.marshal(svc);
+                byte[] bytes = U.marshal(m, svc);
 
-                Service cp = m.unmarshal(bytes,
-                    U.resolveClassLoader(svc.getClass().getClassLoader(), ctx.config()));
+                Service cp = U.unmarshal(m, bytes, U.resolveClassLoader(svc.getClass().getClassLoader(), ctx.config()));
 
                 ctx.resource().inject(cp);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index 6d97229..d32b51c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -914,7 +914,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
                     GridTaskSessionRequest req = new GridTaskSessionRequest(
                         ses.getId(),
                         null,
-                        loc ? null : marsh.marshal(attrs),
+                        loc ? null : U.marshal(marsh, attrs),
                         attrs);
 
                     // Make sure to go through IO manager always, since order
@@ -1030,7 +1030,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
             boolean loc = ctx.localNodeId().equals(nodeId) && !ctx.config().isMarshalLocalJobs();
 
             Map<?, ?> attrs = loc ? msg.getAttributes() :
-                marsh.<Map<?, ?>>unmarshal(msg.getAttributesBytes(),
+                U.<Map<?, ?>>unmarshal(marsh, msg.getAttributesBytes(),
                     U.resolveClassLoader(task.getTask().getClass().getClassLoader(), ctx.config()));
 
             GridTaskSessionImpl ses = task.getSession();
@@ -1306,7 +1306,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
                     if (topic == null) {
                         assert req.topicBytes() != null;
 
-                        topic = marsh.unmarshal(req.topicBytes(), U.resolveClassLoader(ctx.config()));
+                        topic = U.unmarshal(marsh, req.topicBytes(), U.resolveClassLoader(ctx.config()));
                     }
 
                     boolean loc = ctx.localNodeId().equals(nodeId);
@@ -1314,7 +1314,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
                     ctx.io().send(nodeId, topic,
                         new GridJobSiblingsResponse(
                             loc ? siblings : null,
-                            loc ? null : marsh.marshal(siblings)),
+                            loc ? null : U.marshal(marsh, siblings)),
                         SYSTEM_POOL);
                 }
                 catch (IgniteCheckedException e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index 452e48c..0be69d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -805,15 +805,15 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
                     try {
                         boolean loc = ctx.localNodeId().equals(res.getNodeId()) && !ctx.config().isMarshalLocalJobs();
 
-                        Object res0 = loc ? res.getJobResult() : marsh.unmarshal(res.getJobResultBytes(),
+                        Object res0 = loc ? res.getJobResult() : U.unmarshal(marsh, res.getJobResultBytes(),
                             U.resolveClassLoader(clsLdr, ctx.config()));
 
                         IgniteException ex = loc ? res.getException() :
-                            marsh.<IgniteException>unmarshal(res.getExceptionBytes(),
+                            U.<IgniteException>unmarshal(marsh, res.getExceptionBytes(),
                                 U.resolveClassLoader(clsLdr, ctx.config()));
 
                         Map<Object, Object> attrs = loc ? res.getJobAttributes() :
-                            marsh.<Map<Object, Object>>unmarshal(res.getJobAttributesBytes(),
+                            U.<Map<Object, Object>>unmarshal(marsh, res.getJobAttributesBytes(),
                                 U.resolveClassLoader(clsLdr, ctx.config()));
 
                         jobRes.onResponse(res0, ex, attrs, res.isCancelled());
@@ -1347,16 +1347,16 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
                         ses.getTaskName(),
                         ses.getUserVersion(),
                         ses.getTaskClassName(),
-                        loc ? null : marsh.marshal(res.getJob()),
+                        loc ? null : U.marshal(marsh, res.getJob()),
                         loc ? res.getJob() : null,
                         ses.getStartTime(),
                         timeout,
                         ses.getTopology(),
-                        loc ? null : marsh.marshal(ses.getJobSiblings()),
+                        loc ? null : U.marshal(marsh, ses.getJobSiblings()),
                         loc ? ses.getJobSiblings() : null,
-                        loc ? null : marsh.marshal(sesAttrs),
+                        loc ? null : U.marshal(marsh, sesAttrs),
                         loc ? sesAttrs : null,
-                        loc ? null : marsh.marshal(jobAttrs),
+                        loc ? null : U.marshal(marsh, jobAttrs),
                         loc ? jobAttrs : null,
                         ses.getCheckpointSpi(),
                         dep.classLoaderId(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/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 f07266b..1e8d648 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
@@ -182,6 +182,7 @@ import org.apache.ignite.internal.managers.communication.GridIoManager;
 import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo;
 import org.apache.ignite.internal.mxbean.IgniteStandardMXBean;
 import org.apache.ignite.internal.processors.cache.GridCacheAttributes;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx;
 import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
@@ -213,6 +214,7 @@ import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.lifecycle.LifecycleAware;
+import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.plugin.PluginProvider;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -9634,6 +9636,203 @@ public abstract class IgniteUtils {
         return t0.compareTo(t1) > 0 ? t0 : t1;
     }
 
+
+    /**
+     * Unmarshals object from the input stream using given class loader.
+     * This method should not close given input stream.
+     * <p/>
+     * This method wraps marshaller invocations and guaranty throws {@link IgniteCheckedException} in fail case.
+     *
+     * @param <T> Type of unmarshalled object.
+     * @param in Input stream.
+     * @param clsLdr Class loader to use.
+     * @return Unmarshalled object.
+     * @throws IgniteCheckedException If unmarshalling failed.
+     */
+    public static <T> T unmarshal(Marshaller marsh, InputStream in, @Nullable ClassLoader clsLdr)
+        throws IgniteCheckedException {
+        assert marsh != null;
+        assert in != null;
+
+        try {
+            return marsh.unmarshal(in, clsLdr);
+        }
+        catch (IgniteCheckedException e) {
+            throw e;
+        }
+        catch (Exception e) {
+            throw new IgniteCheckedException(e);
+        }
+    }
+
+    /**
+     * Unmarshals object from the input stream using given class loader.
+     * This method should not close given input stream.
+     * <p/>
+     * This method wraps marshaller invocations and guaranty throws {@link IgniteCheckedException} in fail case.
+     *
+     * @param <T> Type of unmarshalled object.
+     * @param marsh Marshaller.
+     * @param arr Byte array.
+     * @param clsLdr Class loader to use.
+     * @return Unmarshalled object.
+     * @throws IgniteCheckedException If unmarshalling failed.
+     */
+    public static <T> T unmarshal(Marshaller marsh, byte[] arr, @Nullable ClassLoader clsLdr)
+        throws IgniteCheckedException {
+        assert marsh != null;
+        assert arr != null;
+
+        try {
+            return marsh.unmarshal(arr, clsLdr);
+        }
+        catch (IgniteCheckedException e) {
+            throw e;
+        }
+        catch (Exception e) {
+            throw new IgniteCheckedException(e);
+        }
+    }
+
+    /**
+     * Unmarshals object from the input stream using given class loader.
+     * This method should not close given input stream.
+     * <p/>
+     * This method wraps marshaller invocations and guaranty throws {@link IgniteCheckedException} in fail case.
+     *
+     * @param <T> Type of unmarshalled object.
+     * @param ctx Kernal contex.
+     * @param arr Byte array.
+     * @param clsLdr Class loader to use.
+     * @return Unmarshalled object.
+     * @throws IgniteCheckedException If unmarshalling failed.
+     */
+    public static <T> T unmarshal(GridKernalContext ctx, byte[] arr, @Nullable ClassLoader clsLdr)
+        throws IgniteCheckedException {
+        assert ctx != null;
+        assert arr != null;
+
+        try {
+            return U.unmarshal(ctx.config().getMarshaller(), arr, clsLdr);
+        }
+        catch (IgniteCheckedException e) {
+            throw e;
+        }
+        catch (Exception e) {
+            throw new IgniteCheckedException(e);
+        }
+    }
+
+    /**
+     * Unmarshals object from the input stream using given class loader.
+     * This method should not close given input stream.
+     * <p/>
+     * This method wraps marshaller invocations and guaranty throws {@link IgniteCheckedException} in fail case.
+     *
+     * @param <T> Type of unmarshalled object.
+     * @param ctx Kernal contex.
+     * @param arr Byte array.
+     * @param clsLdr Class loader to use.
+     * @return Unmarshalled object.
+     * @throws IgniteCheckedException If unmarshalling failed.
+     */
+    public static <T> T unmarshal(GridCacheSharedContext ctx, byte[] arr, @Nullable ClassLoader clsLdr)
+        throws IgniteCheckedException {
+        assert ctx != null;
+        assert arr != null;
+
+        try {
+            return U.unmarshal(ctx.marshaller(), arr, clsLdr);
+        }
+        catch (IgniteCheckedException e) {
+            throw e;
+        }
+        catch (Exception e) {
+            throw new IgniteCheckedException(e);
+        }
+    }
+
+    /**
+     * Marshals object to byte array.
+     * <p/>
+     * This method wraps marshaller invocations and guaranty throws {@link IgniteCheckedException} in fail case.
+     *
+     * @param marsh Marshaller.
+     * @param obj Object to marshal.
+     * @return Byte array.
+     * @throws IgniteCheckedException If marshalling failed.
+     */
+    public static byte[] marshal(Marshaller marsh, Object obj) throws IgniteCheckedException {
+        assert marsh != null;
+
+        try {
+            return marsh.marshal(obj);
+        }
+        catch (IgniteCheckedException e) {
+            throw e;
+        }
+        catch (Exception e) {
+            throw new IgniteCheckedException(e);
+        }
+    }
+
+    /**
+     * Marshals object to byte array.
+     * <p/>
+     * This method wraps marshaller invocations and guaranty throws {@link IgniteCheckedException} in fail case.
+     *
+     * @param marsh Marshaller.
+     * @param obj Object to marshal.
+     * @param out Output stream.
+     * @throws IgniteCheckedException If marshalling failed.
+     */
+    public static void marshal(Marshaller marsh, @Nullable Object obj, OutputStream out)
+        throws IgniteCheckedException {
+        assert marsh != null;
+
+        try {
+            marsh.marshal(obj, out);
+        }
+        catch (IgniteCheckedException e) {
+            throw e;
+        }
+        catch (Exception e) {
+            throw new IgniteCheckedException(e);
+        }
+    }
+
+    /**
+     * Marshals object to byte array. Wrap marshaller
+     * <p/>
+     * This method wraps marshaller invocations and guaranty throws {@link IgniteCheckedException} in fail case.
+     *
+     * @param ctx Kernal context.
+     * @param obj Object to marshal.
+     * @return Byte array.
+     * @throws IgniteCheckedException If marshalling failed.
+     */
+    public static byte[] marshal(GridKernalContext ctx, Object obj) throws IgniteCheckedException {
+        assert ctx != null;
+
+        return marshal(ctx.config().getMarshaller(), obj);
+    }
+
+    /**
+     * Marshals object to byte array. Wrap marshaller
+     * <p/>
+     * This method wraps marshaller invocations and guaranty throws {@link IgniteCheckedException} in fail case.
+     *
+     * @param ctx Cache context.
+     * @param obj Object to marshal.
+     * @return Byte array.
+     * @throws IgniteCheckedException If marshalling failed.
+     */
+    public static byte[] marshal(GridCacheSharedContext ctx, Object obj) throws IgniteCheckedException {
+        assert ctx != null;
+
+        return marshal(ctx.marshaller(), obj);
+    }
+
     /**
      * Get current Ignite name.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
index 7a130d3..54172dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
@@ -80,7 +80,7 @@ public class JdkMarshaller extends AbstractNodeNameAwareMarshaller {
 
             objOut.flush();
         }
-        catch (IOException e) {
+        catch (Exception e) {
             throw new IgniteCheckedException("Failed to serialize object: " + obj, e);
         }
         finally{
@@ -119,14 +119,14 @@ public class JdkMarshaller extends AbstractNodeNameAwareMarshaller {
 
             return (T)objIn.readObject();
         }
-        catch (IOException e) {
-            throw new IgniteCheckedException("Failed to deserialize object with given class loader: " + clsLdr, e);
-        }
         catch (ClassNotFoundException e) {
             throw new IgniteCheckedException("Failed to find class with given class loader for unmarshalling " +
                 "(make sure same versions of all classes are available on all nodes or enable peer-class-loading): " +
                 clsLdr, e);
         }
+        catch (Exception e) {
+            throw new IgniteCheckedException("Failed to deserialize object with given class loader: " + clsLdr, e);
+        }
         finally{
             U.closeQuiet(objIn);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
index 37f7acb..467dddf 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
@@ -193,7 +193,7 @@ public class OptimizedMarshaller extends AbstractNodeNameAwareMarshaller {
 
             return objOut.out().array();
         }
-        catch (IOException e) {
+        catch (Exception e) {
             throw new IgniteCheckedException("Failed to serialize object: " + obj, e);
         }
         finally {
@@ -217,14 +217,14 @@ public class OptimizedMarshaller extends AbstractNodeNameAwareMarshaller {
 
             return (T)objIn.readObject();
         }
-        catch (IOException e) {
-            throw new IgniteCheckedException("Failed to deserialize object with given class loader: " + clsLdr, e);
-        }
         catch (ClassNotFoundException e) {
             throw new IgniteCheckedException("Failed to find class with given class loader for unmarshalling " +
                 "(make sure same versions of all classes are available on all nodes or enable peer-class-loading): " +
                 clsLdr, e);
         }
+        catch (Exception e) {
+            throw new IgniteCheckedException("Failed to deserialize object with given class loader: " + clsLdr, e);
+        }
         finally {
             OptimizedObjectStreamRegistry.closeIn(objIn);
         }
@@ -246,14 +246,14 @@ public class OptimizedMarshaller extends AbstractNodeNameAwareMarshaller {
 
             return (T)objIn.readObject();
         }
-        catch (IOException e) {
-            throw new IgniteCheckedException("Failed to deserialize object with given class loader: " + clsLdr, e);
-        }
         catch (ClassNotFoundException e) {
             throw new IgniteCheckedException("Failed to find class with given class loader for unmarshalling " +
                 "(make sure same version of all classes are available on all nodes or enable peer-class-loading): " +
                 clsLdr, e);
         }
+        catch (Exception e) {
+            throw new IgniteCheckedException("Failed to deserialize object with given class loader: " + clsLdr, e);
+        }
         finally {
             OptimizedObjectStreamRegistry.closeIn(objIn);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
index b1698fa..f8c4130 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
@@ -61,7 +61,7 @@ final class SharedFsUtils {
         InputStream in = new FileInputStream(file);
 
         try {
-            return (SharedFsCheckpointData)m.unmarshal(in, U.gridClassLoader());
+            return U.unmarshal(m, in, U.gridClassLoader());
         }
         finally {
             U.close(in, log);
@@ -91,7 +91,7 @@ final class SharedFsUtils {
         try {
             out = new FileOutputStream(file);
 
-            m.marshal(data, out);
+            U.marshal(m, data, out);
         }
         finally {
             U.close(out, log);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 2c85645..2d948da 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -431,7 +431,7 @@ class ClientImpl extends TcpDiscoveryImpl {
 
         try {
             sockWriter.sendMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
-                spi.marshaller().marshal(evt)));
+                U.marshal(spi.marshaller(), evt)));
         }
         catch (IgniteCheckedException e) {
             throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -701,7 +701,7 @@ class ClientImpl extends TcpDiscoveryImpl {
             Map<String, Object> attrs = new HashMap<>(node.getAttributes());
 
             attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
-                spi.marshaller().marshal(attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)));
+                U.marshal(spi.marshaller(), attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)));
 
             node.setAttributes(attrs);
         }
@@ -902,7 +902,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                         TcpDiscoveryAbstractMessage msg;
 
                         try {
-                            msg = spi.marshaller().unmarshal(in, U.resolveClassLoader(spi.ignite().configuration()));
+                            msg = U.unmarshal(spi.marshaller(), in, U.resolveClassLoader(spi.ignite().configuration()));
                         }
                         catch (IgniteCheckedException e) {
                             if (log.isDebugEnabled())
@@ -1232,7 +1232,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                         List<TcpDiscoveryAbstractMessage> msgs = null;
 
                         while (!isInterrupted()) {
-                            TcpDiscoveryAbstractMessage msg = spi.marshaller().unmarshal(in,
+                            TcpDiscoveryAbstractMessage msg = U.unmarshal(spi.marshaller(), in,
                                 U.resolveClassLoader(spi.ignite().configuration()));
 
                             if (msg instanceof TcpDiscoveryClientReconnectMessage) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 135a737..78a5f39 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -744,7 +744,7 @@ class ServerImpl extends TcpDiscoveryImpl {
     @Override public void sendCustomEvent(DiscoverySpiCustomMessage evt) {
         try {
             msgWorker.addMessage(new TcpDiscoveryCustomEventMessage(getLocalNodeId(), evt,
-                spi.marshaller().marshal(evt)));
+                U.marshal(spi.marshaller(), evt)));
         }
         catch (IgniteCheckedException e) {
             throw new IgniteSpiException("Failed to marshal custom event: " + evt, e);
@@ -827,7 +827,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                         Map<String, Object> attrs = new HashMap<>(locNode.attributes());
 
-                        attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, spi.marshaller().marshal(subj));
+                        attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, U.marshal(spi.marshaller(), subj));
                         attrs.remove(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS);
 
                         locNode.setAttributes(attrs);
@@ -1243,7 +1243,7 @@ class ServerImpl extends TcpDiscoveryImpl {
             Map<String, Object> attrs = new HashMap<>(node.getAttributes());
 
             attrs.put(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS,
-                spi.marshaller().marshal(attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)));
+                U.marshal(spi.marshaller(), attrs.get(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS)));
 
             node.setAttributes(attrs);
         }
@@ -1266,7 +1266,7 @@ class ServerImpl extends TcpDiscoveryImpl {
             if (credBytes == null)
                 return null;
 
-            return spi.marshaller().unmarshal(credBytes, null);
+            return U.unmarshal(spi.marshaller(), credBytes, null);
         }
         catch (IgniteCheckedException e) {
             throw new IgniteSpiException("Failed to unmarshal node security credentials: " + node.id(), e);
@@ -2380,7 +2380,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                 for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values()) {
                     if (msgBytes == null) {
                         try {
-                            msgBytes = spi.marshaller().marshal(msg);
+                            msgBytes = U.marshal(spi.marshaller(), msg);
                         }
                         catch (IgniteCheckedException e) {
                             U.error(log, "Failed to marshal message: " + msg, e);
@@ -2399,7 +2399,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                         if (clientMsgWorker.clientNodeId.equals(node.id())) {
                             try {
-                                msg0 = spi.marshaller().unmarshal(msgBytes,
+                                msg0 = U.unmarshal(spi.marshaller(), msgBytes,
                                     U.resolveClassLoader(spi.ignite().configuration()));
 
                                 prepareNodeAddedMessage(msg0, clientMsgWorker.clientNodeId, null, null, null);
@@ -3157,7 +3157,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                             // Stick in authentication subject to node (use security-safe attributes for copy).
                             Map<String, Object> attrs = new HashMap<>(node.getAttributes());
 
-                            attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, spi.marshaller().marshal(subj));
+                            attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, U.marshal(spi.marshaller(), subj));
 
                             node.setAttributes(attrs);
                         }
@@ -3805,7 +3805,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                         else {
                             SecurityContext subj = spi.nodeAuth.authenticateNode(node, cred);
 
-                            SecurityContext coordSubj = spi.marshaller().unmarshal(
+                            SecurityContext coordSubj = U.unmarshal(spi.marshaller(),
                                 node.<byte[]>attribute(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT),
                                 U.resolveClassLoader(spi.ignite().configuration()));
 
@@ -4872,7 +4872,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                         if (nextMsg != null) {
                             try {
                                 TcpDiscoveryCustomEventMessage ackMsg = new TcpDiscoveryCustomEventMessage(
-                                    getLocalNodeId(), nextMsg, spi.marshaller().marshal(nextMsg));
+                                    getLocalNodeId(), nextMsg, U.marshal(spi.marshaller(), nextMsg));
 
                                 ackMsg.topologyVersion(msg.topologyVersion());
 
@@ -5017,7 +5017,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                             msgObj);
 
                         if (msgObj.isMutable())
-                            msg.message(msgObj, spi.marshaller().marshal(msgObj));
+                            msg.message(msgObj, U.marshal(spi.marshaller(), msgObj));
                     }
                     catch (Throwable e) {
                         U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -5455,7 +5455,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                 while (!isInterrupted()) {
                     try {
-                        TcpDiscoveryAbstractMessage msg = spi.marshaller().unmarshal(in,
+                        TcpDiscoveryAbstractMessage msg = U.unmarshal(spi.marshaller(), in,
                             U.resolveClassLoader(spi.ignite().configuration()));
 
                         msg.senderNodeId(nodeId);
@@ -5946,7 +5946,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                 byte[] msgBytes = msgT.get2();
 
                 if (msgBytes == null)
-                    msgBytes = spi.marshaller().marshal(msg);
+                    msgBytes = U.marshal(spi.marshaller(), msg);
 
                 if (msg instanceof TcpDiscoveryClientAckResponse) {
                     if (clientVer == null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 426eb8e..a8704e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1380,7 +1380,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
         IgniteCheckedException err = null;
 
         try {
-            marshaller().marshal(msg, out);
+            U.marshal(marshaller(), msg, out);
         }
         catch (IgniteCheckedException e) {
             err = e;
@@ -1464,7 +1464,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
         try {
             sock.setSoTimeout((int)timeout);
 
-            T res = marshaller().unmarshal(in == null ? sock.getInputStream() : in,
+            T res = U.unmarshal(marshaller(), in == null ? sock.getInputStream() : in,
                 U.resolveClassLoader(ignite.configuration()));
 
             return res;
@@ -1682,7 +1682,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
 
         for (Map.Entry<Integer, Serializable> entry : data.entrySet()) {
             try {
-                byte[] bytes = marshaller().marshal(entry.getValue());
+                byte[] bytes = U.marshal(marshaller(), entry.getValue());
 
                 data0.put(entry.getKey(), bytes);
             }
@@ -1713,7 +1713,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
 
         for (Map.Entry<Integer, byte[]> entry : data.entrySet()) {
             try {
-                Serializable compData = marshaller().unmarshal(entry.getValue(), clsLdr);
+                Serializable compData = U.unmarshal(marshaller(), entry.getValue(), clsLdr);
 
                 data0.put(entry.getKey(), compData);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index 5bbe90e..e96abe9 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -690,7 +690,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
         private AddressResponse(Collection<InetSocketAddress> addrs) throws IgniteCheckedException {
             this.addrs = addrs;
 
-            byte[] addrsData = marsh.marshal(addrs);
+            byte[] addrsData = U.marshal(marsh, addrs);
             data = new byte[U.IGNITE_HEADER.length + addrsData.length];
 
             if (data.length > MAX_DATA_LENGTH)
@@ -709,7 +709,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
 
             this.data = data;
 
-            addrs = marsh.unmarshal(Arrays.copyOfRange(data, U.IGNITE_HEADER.length, data.length), null);
+            addrs = U.unmarshal(marsh, Arrays.copyOfRange(data, U.IGNITE_HEADER.length, data.length), null);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
index c0e39d3..219c0ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.spi.discovery.tcp.messages;
 import java.util.UUID;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage;
 import org.jetbrains.annotations.NotNull;
@@ -77,7 +78,7 @@ public class TcpDiscoveryCustomEventMessage extends TcpDiscoveryAbstractMessage
      */
     @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, ClassLoader ldr) throws Throwable {
         if (msg == null) {
-            msg = marsh.unmarshal(msgBytes, ldr);
+            msg = U.unmarshal(marsh, msgBytes, ldr);
 
             assert msg != null;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
index 222f463..f0ac7bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
@@ -596,7 +596,7 @@ public class FileSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi,
 
         if (keyBytes == null) {
             try {
-                keyBytes = ignite.configuration().getMarshaller().marshal(key.key());
+                keyBytes = U.marshal(ignite.configuration().getMarshaller(), key.key());
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteSpiException("Failed to marshal key: " + key.key(), e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
index a5b89e4..d1c8d19 100644
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
+++ b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
 import org.apache.ignite.internal.util.nio.GridNioSession;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.MarshallerUtils;
 import org.apache.ignite.stream.StreamAdapter;
@@ -231,7 +232,7 @@ public class SocketStreamer<T, K, V> extends StreamAdapter<T, K, V> {
         /** {@inheritDoc} */
         @Override public T convert(byte[] msg) {
             try {
-                return marsh.unmarshal(msg, null);
+                return U.unmarshal(marsh, msg, null);
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java
new file mode 100644
index 0000000..031774e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java
@@ -0,0 +1,588 @@
+/*
+ * 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.query.continuous;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.NotNull;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
+
+/**
+ *
+ */
+public class CacheEntryProcessorExternalizableFailedTest extends GridCommonAbstractTest {
+    /** */
+    private static final int EXPECTED_VALUE = 42;
+
+    /** */
+    private static final int WRONG_VALUE = -1;
+
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final int NODES = 3;
+
+    /** */
+    public static final int ITERATION_CNT = 1;
+
+    /** */
+    public static final int KEYS = 10;
+
+    /** */
+    private boolean client;
+
+    /** */
+    private boolean failOnWrite = false;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGridsMultiThreaded(getServerNodeCount());
+
+        client = true;
+
+        startGrid(getServerNodeCount());
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+
+        super.afterTestsStopped();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        failOnWrite = false;
+    }
+
+    /**
+     * @return Server nodes.
+     */
+    private int getServerNodeCount() {
+        return NODES;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticFullSync() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticOnePhaseCommit() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticOnePhaseCommitWithNearCache() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1)
+            .setNearConfiguration(new NearCacheConfiguration());
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticOnePhaseCommitFullSync() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
+            .setNearConfiguration(new NearCacheConfiguration());
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimistic() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticWithNearCache() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2)
+            .setNearConfiguration(new NearCacheConfiguration());
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticFullSync() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticOnePhaseCommit() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticOnePhaseCommitFullSync() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
+            .setNearConfiguration(new NearCacheConfiguration());
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimistic() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticFullSyncWithNearCache() throws Exception {
+        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
+
+        failOnWrite = true;
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
+
+        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @param ccfg Cache configuration.
+     * @throws Exception If failed.
+     */
+    private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency txConcurrency,
+        TransactionIsolation txIsolation) throws Exception {
+        IgniteEx cln = grid(getServerNodeCount());
+
+        grid(0).createCache(ccfg);
+
+        IgniteCache clnCache;
+
+        if (ccfg.getNearConfiguration() != null)
+            clnCache = cln.createNearCache(ccfg.getName(), ccfg.getNearConfiguration());
+        else
+            clnCache = cln.cache(ccfg.getName());
+
+        putKeys(clnCache, EXPECTED_VALUE);
+
+        try {
+            // Explicit tx.
+            for (int i = 0; i < ITERATION_CNT; i++) {
+                try (final Transaction tx = cln.transactions().txStart(txConcurrency, txIsolation)) {
+                    putKeys(clnCache, WRONG_VALUE);
+
+                    clnCache.invoke(KEYS, createEntryProcessor());
+
+                    GridTestUtils.assertThrowsWithCause(new Callable<Object>() {
+                        @Override public Object call() throws Exception {
+                            tx.commit();
+
+                            return null;
+                        }
+                    }, UnsupportedOperationException.class);
+                }
+
+                assertNull(cln.transactions().tx());
+
+                checkKeys(clnCache, EXPECTED_VALUE);
+            }
+
+            // From affinity node.
+            Ignite grid = grid(ThreadLocalRandom.current().nextInt(NODES));
+
+            final IgniteCache cache = grid.cache(ccfg.getName());
+
+            // Explicit tx.
+            for (int i = 0; i < ITERATION_CNT; i++) {
+                try (final Transaction tx = grid.transactions().txStart(txConcurrency, txIsolation)) {
+                    putKeys(cache, WRONG_VALUE);
+
+                    cache.invoke(KEYS, createEntryProcessor());
+
+                    GridTestUtils.assertThrowsWithCause(new Callable<Object>() {
+                        @Override public Object call() throws Exception {
+                            tx.commit();
+
+                            return null;
+                        }
+                    }, UnsupportedOperationException.class);
+                }
+
+                assertNull(cln.transactions().tx());
+
+                checkKeys(cache, EXPECTED_VALUE);
+            }
+
+            final IgniteCache clnCache0 = clnCache;
+
+            // Implicit tx.
+            for (int i = 0; i < ITERATION_CNT; i++) {
+                GridTestUtils.assertThrowsWithCause(new Callable<Object>() {
+                    @Override public Object call() throws Exception {
+                        clnCache0.invoke(KEYS, createEntryProcessor());
+
+                        return null;
+                    }
+                }, UnsupportedOperationException.class);
+
+                assertNull(cln.transactions().tx());
+            }
+
+            checkKeys(clnCache, EXPECTED_VALUE);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+        finally {
+            grid(0).destroyCache(ccfg.getName());
+        }
+    }
+
+    /**
+     * @return Entry processor.
+     */
+    @NotNull private EntryProcessor<Integer, Integer, Integer> createEntryProcessor() {
+        return failOnWrite ? new ExternalizableFailedWriteEntryProcessor() :
+            new ExternalizableFailedReadEntryProcessor();
+    }
+
+    /**
+     * @param cache Cache.
+     * @param val Value.
+     */
+    private void putKeys(IgniteCache cache, int val) {
+        cache.put(KEYS, val);
+    }
+
+    /**
+     * @param cache Cache.
+     * @param expVal Expected value.
+     */
+    private void checkKeys(IgniteCache cache, int expVal) {
+        assertEquals(expVal, cache.get(KEYS));
+    }
+
+    /**
+     * @return Cache configuration.
+     */
+    private CacheConfiguration cacheConfiguration(CacheWriteSynchronizationMode wrMode, int backup) {
+        return new CacheConfiguration("test-cache-" + wrMode + "-" + backup)
+            .setAtomicityMode(TRANSACTIONAL)
+            .setWriteSynchronizationMode(FULL_SYNC)
+            .setBackups(backup);
+    }
+
+    /**
+     *
+     */
+    private static class ExternalizableFailedWriteEntryProcessor implements EntryProcessor<Integer, Integer, Integer>,
+        Externalizable{
+        /** */
+        public ExternalizableFailedWriteEntryProcessor() {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer process(MutableEntry<Integer, Integer> entry, Object... arguments)
+            throws EntryProcessorException {
+            entry.setValue(42);
+
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            throw new UnsupportedOperationException();
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            // No-op.
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ExternalizableFailedReadEntryProcessor implements EntryProcessor<Integer, Integer, Integer>,
+        Externalizable {
+        /** */
+        public ExternalizableFailedReadEntryProcessor() {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer process(MutableEntry<Integer, Integer> entry, Object... arguments)
+            throws EntryProcessorException {
+            entry.setValue(42);
+
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 5ad4cb8..388c3a3 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -140,6 +140,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheGet
 import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearTxExceptionSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxExceptionSelfTest;
 import org.apache.ignite.internal.processors.cache.local.GridCacheLocalTxExceptionSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheEntryProcessorExternalizableFailedTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.CacheEntryProcessorNonSerializableTest;
 import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest;
 import org.apache.ignite.internal.processors.datastreamer.DataStreamerImplSelfTest;
@@ -191,6 +192,7 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(IgniteCacheAtomicLocalWithStoreInvokeTest.class);
         suite.addTestSuite(IgniteCacheTxInvokeTest.class);
         suite.addTestSuite(CacheEntryProcessorNonSerializableTest.class);
+        suite.addTestSuite(CacheEntryProcessorExternalizableFailedTest.class);
         suite.addTestSuite(IgniteCacheEntryProcessorCallTest.class);
         GridTestUtils.addTestIfNeeded(suite, CacheEntryProcessorCopySelfTest.class, ignoredTests);
         suite.addTestSuite(IgniteCacheTxNearEnabledInvokeTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
index 3f79469..eeca564 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopMarshallerFilter.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.processors.hadoop.message.HadoopMessage;
 import org.apache.ignite.internal.util.nio.GridNioFilterAdapter;
 import org.apache.ignite.internal.util.nio.GridNioFuture;
 import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
 
 /**
@@ -29,15 +30,15 @@ import org.apache.ignite.marshaller.Marshaller;
  */
 public class HadoopMarshallerFilter extends GridNioFilterAdapter {
     /** Marshaller. */
-    private Marshaller marshaller;
+    private Marshaller marsh;
 
     /**
-     * @param marshaller Marshaller to use.
+     * @param marsh Marshaller to use.
      */
-    public HadoopMarshallerFilter(Marshaller marshaller) {
+    public HadoopMarshallerFilter(Marshaller marsh) {
         super("HadoopMarshallerFilter");
 
-        this.marshaller = marshaller;
+        this.marsh = marsh;
     }
 
     /** {@inheritDoc} */
@@ -59,14 +60,14 @@ public class HadoopMarshallerFilter extends GridNioFilterAdapter {
     @Override public GridNioFuture<?> onSessionWrite(GridNioSession ses, Object msg) throws IgniteCheckedException {
         assert msg instanceof HadoopMessage : "Invalid message type: " + msg;
 
-        return proceedSessionWrite(ses, marshaller.marshal(msg));
+        return proceedSessionWrite(ses, U.marshal(marsh, msg));
     }
 
     @Override public void onMessageReceived(GridNioSession ses, Object msg) throws IgniteCheckedException {
         assert msg instanceof byte[];
 
         // Always unmarshal with system classloader.
-        proceedMessageReceived(ses, marshaller.unmarshal((byte[])msg, null));
+        proceedMessageReceived(ses, U.unmarshal(marsh, (byte[])msg, null));
     }
 
     /** {@inheritDoc} */


[04/40] ignite git commit: IGNITE-2881: Fixed SPI queries.

Posted by av...@apache.org.
IGNITE-2881: Fixed SPI queries.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 59b46d3e6ea073d054ca2262d676b055a74bbb1f
Parents: 5e7ef86
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Oct 3 10:40:04 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Oct 3 10:40:04 2016 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/query/SpiQuery.java |   8 +-
 .../processors/cache/IgniteCacheProxy.java      |  34 ++-
 .../cache/query/GridCacheQueryManager.java      |   2 +-
 .../cache/query/IndexingSpiQuerySelfTest.java   | 218 +++++++++++++++++++
 .../cache/query/IndexingSpiQueryTxSelfTest.java | 162 ++++++++++++++
 .../IgniteBinaryCacheQueryTestSuite.java        |   1 -
 .../IgniteCacheQuerySelfTestSuite.java          |   5 +
 7 files changed, 416 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/59b46d3e/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
index 0c11437..c3aa472 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SpiQuery.java
@@ -58,13 +58,13 @@ public final class SpiQuery<K, V> extends Query<Cache.Entry<K, V>> {
     }
 
     /** {@inheritDoc} */
-    @Override public SqlQuery<K, V> setPageSize(int pageSize) {
-        return (SqlQuery<K, V>)super.setPageSize(pageSize);
+    @Override public SpiQuery<K, V> setPageSize(int pageSize) {
+        return (SpiQuery<K, V>)super.setPageSize(pageSize);
     }
 
     /** {@inheritDoc} */
-    @Override public SqlQuery<K, V> setLocal(boolean loc) {
-        return (SqlQuery<K, V>)super.setLocal(loc);
+    @Override public SpiQuery<K, V> setLocal(boolean loc) {
+        return (SpiQuery<K, V>)super.setLocal(loc);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/59b46d3e/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 81d4b49..58c7c9c 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
@@ -533,11 +533,11 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
     @SuppressWarnings("unchecked")
     private QueryCursor<Cache.Entry<K, V>> query(final Query filter, @Nullable ClusterGroup grp)
         throws IgniteCheckedException {
-        final CacheQuery<Map.Entry<K, V>> qry;
+        final CacheQuery qry;
 
         boolean isKeepBinary = opCtx != null && opCtx.isKeepBinary();
 
-        final CacheQueryFuture<Map.Entry<K, V>> fut;
+        final CacheQueryFuture fut;
 
         if (filter instanceof TextQuery) {
             TextQuery p = (TextQuery)filter;
@@ -561,8 +561,8 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
                 qry.projection(grp);
 
             fut = ctx.kernalContext().query().executeQuery(ctx,
-                new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() {
-                    @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() throws IgniteCheckedException {
+                new IgniteOutClosureX<CacheQueryFuture<Cache.Entry<K, V>>>() {
+                    @Override public CacheQueryFuture<Cache.Entry<K, V>> applyx() throws IgniteCheckedException {
                         return qry.execute(((SpiQuery)filter).getArgs());
                     }
                 }, false);
@@ -577,21 +577,39 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
 
         return new QueryCursorImpl<>(new GridCloseableIteratorAdapter<Entry<K, V>>() {
             /** */
-            private Map.Entry<K, V> cur;
+            private Cache.Entry<K, V> cur;
 
             @Override protected Entry<K, V> onNext() throws IgniteCheckedException {
                 if (!onHasNext())
                     throw new NoSuchElementException();
 
-                Map.Entry<K, V> e = cur;
+                Cache.Entry<K, V> e = cur;
 
                 cur = null;
 
-                return new CacheEntryImpl<>(e.getKey(), e.getValue());
+                return e;
             }
 
             @Override protected boolean onHasNext() throws IgniteCheckedException {
-                return cur != null || (cur = fut.next()) != null;
+                if (cur != null)
+                    return true;
+
+                Object next = fut.next();
+
+                // Workaround a bug: if IndexingSpi is configured future represents Iterator<Cache.Entry>
+                // instead of Iterator<Map.Entry> due to IndexingSpi interface.
+                if (next == null)
+                    return false;
+
+                if (next instanceof Cache.Entry)
+                    cur = (Cache.Entry)next;
+                else {
+                    Map.Entry e = (Map.Entry)next;
+
+                    cur = new CacheEntryImpl(e.getKey(), e.getValue());
+                }
+
+                return true;
             }
 
             @Override protected void onClose() throws IgniteCheckedException {

http://git-wip-us.apache.org/repos/asf/ignite/blob/59b46d3e/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 9699f09..7bd1a51 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
@@ -690,7 +690,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
         T2<String, List<Object>> resKey = null;
 
-        if (qry.clause() == null) {
+        if (qry.clause() == null && qry.type() != SPI) {
             assert !loc;
 
             throw new IgniteCheckedException("Received next page request after iterator was removed. " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/59b46d3e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
new file mode 100644
index 0000000..94b0c8a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
@@ -0,0 +1,218 @@
+/*
+ * 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.query;
+
+import junit.framework.TestCase;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SpiQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
+import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
+import org.apache.ignite.spi.IgniteSpiAdapter;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.indexing.IndexingQueryFilter;
+import org.apache.ignite.spi.indexing.IndexingSpi;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.apache.ignite.transactions.TransactionState;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import javax.cache.Cache;
+
+/**
+ * Indexing Spi query test
+ */
+public class IndexingSpiQuerySelfTest extends TestCase {
+    /** {@inheritDoc} */
+    @Override public void tearDown() throws Exception {
+        Ignition.stopAll(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSimpleIndexingSpi() throws Exception {
+        IgniteConfiguration cfg = configuration();
+
+        cfg.setIndexingSpi(new MyIndexingSpi());
+
+        Ignite ignite = Ignition.start(cfg);
+
+        CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>("test-cache");
+
+        ccfg.setIndexedTypes(Integer.class, Integer.class);
+
+        IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
+
+        for (int i = 0; i < 10; i++)
+            cache.put(i, i);
+
+        QueryCursor<Cache.Entry<Integer, Integer>> cursor = cache.query(new SpiQuery<Integer, Integer>().setArgs(2, 5));
+
+        for (Cache.Entry<Integer, Integer> entry : cursor)
+            System.out.println(entry);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+    public void testIndexingSpiFailure() throws Exception {
+        IgniteConfiguration cfg = configuration();
+
+        cfg.setIndexingSpi(new MyBrokenIndexingSpi());
+
+        Ignite ignite = Ignition.start(cfg);
+
+        CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>("test-cache");
+
+        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+        ccfg.setIndexedTypes(Integer.class, Integer.class);
+
+        final IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
+
+        final IgniteTransactions txs = ignite.transactions();
+
+        for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+            for (final TransactionIsolation isolation : TransactionIsolation.values()) {
+                System.out.println("Run in transaction: " + concurrency + " " + isolation);
+
+                GridTestUtils.assertThrowsWithCause(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        Transaction tx;
+
+                        try (Transaction tx0 = tx = txs.txStart(concurrency, isolation)) {
+                            cache.put(1, 1);
+
+                            tx0.commit();
+                        }
+
+                        assertEquals(TransactionState.ROLLED_BACK, tx.state());
+                        return null;
+                    }
+                }, IgniteTxHeuristicCheckedException.class);
+            }
+        }
+    }
+
+    /**
+     * @return Configuration.
+     */
+    private IgniteConfiguration configuration() {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /**
+     * Indexing Spi implementation for test
+     */
+    private static class MyIndexingSpi extends IgniteSpiAdapter implements IndexingSpi {
+        /** Index. */
+        private final SortedMap<Object, Object> idx = new TreeMap<>();
+
+        /** {@inheritDoc} */
+        @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void spiStop() throws IgniteSpiException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public Iterator<Cache.Entry<?, ?>> query(@Nullable String spaceName, Collection<Object> params,
+            @Nullable IndexingQueryFilter filters) throws IgniteSpiException {
+            if (params.size() < 2)
+                throw new IgniteSpiException("Range parameters required.");
+
+            Iterator<Object> paramsIt = params.iterator();
+
+            Object from = paramsIt.next();
+            Object to = paramsIt.next();
+
+            SortedMap<Object, Object> map = idx.subMap(from, to);
+
+            Collection<Cache.Entry<?, ?>> res = new ArrayList<>(map.size());
+
+            for (Map.Entry<Object, Object> entry : map.entrySet())
+                res.add(new CacheEntryImpl<>(entry.getKey(), entry.getValue()));
+
+            return res.iterator();
+        }
+
+        /** {@inheritDoc} */
+        @Override public void store(@Nullable String spaceName, Object key, Object val, long expirationTime)
+            throws IgniteSpiException {
+            idx.put(key, val);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void remove(@Nullable String spaceName, Object key) throws IgniteSpiException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void onSwap(@Nullable String spaceName, Object key) throws IgniteSpiException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
+            // No-op.
+        }
+    }
+
+    /**
+     * Broken Indexing Spi implementation for test
+     */
+    private class MyBrokenIndexingSpi extends MyIndexingSpi {
+        /** {@inheritDoc} */
+        @Override public void store(@Nullable String spaceName, Object key, Object val,
+            long expirationTime) throws IgniteSpiException {
+            throw new IgniteSpiException("Test exception");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/59b46d3e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
new file mode 100644
index 0000000..78ed1fd
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
+import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
+import org.apache.ignite.spi.IgniteSpiAdapter;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.indexing.IndexingQueryFilter;
+import org.apache.ignite.spi.indexing.IndexingSpi;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.apache.ignite.transactions.TransactionState;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.Cache;
+
+/**
+ * Indexing Spi transactional query test
+ */
+public class IndexingSpiQueryTxSelfTest extends GridCacheAbstractSelfTest {
+    /** */
+    private static AtomicInteger cnt;
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 4;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        cnt = new AtomicInteger();
+
+        super.beforeTestsStarted();
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
+
+        if (cnt.getAndIncrement() == 0)
+            cfg.setClientMode(true);
+        else {
+            cfg.setIndexingSpi(new MyBrokenIndexingSpi());
+
+            CacheConfiguration ccfg = cacheConfiguration(gridName);
+            ccfg.setName("test-cache");
+            ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+            ccfg.setIndexedTypes(Integer.class, Integer.class);
+
+            cfg.setCacheConfiguration(ccfg);
+        }
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+    public void testIndexingSpiWithTx() throws Exception {
+        IgniteEx ignite = grid(0);
+
+        final IgniteCache<Integer, Integer> cache = ignite.cache("test-cache");
+
+        final IgniteTransactions txs = ignite.transactions();
+
+        for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+            for (final TransactionIsolation isolation : TransactionIsolation.values()) {
+                System.out.println("Run in transaction: " + concurrency + " " + isolation);
+
+                GridTestUtils.assertThrowsWithCause(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        Transaction tx;
+
+                        try (Transaction tx0 = tx = txs.txStart(concurrency, isolation)) {
+                            cache.put(1, 1);
+
+                            tx0.commit();
+                        }
+
+                        assertEquals(TransactionState.ROLLED_BACK, tx.state());
+
+                        return null;
+                    }
+                }, IgniteTxHeuristicCheckedException.class);
+            }
+        }
+    }
+
+    /**
+     * Indexing SPI implementation for test
+     */
+    private static class MyBrokenIndexingSpi extends IgniteSpiAdapter implements IndexingSpi {
+        /** {@inheritDoc} */
+        @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void spiStop() throws IgniteSpiException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public Iterator<Cache.Entry<?, ?>> query(@Nullable String spaceName, Collection<Object> params,
+            @Nullable IndexingQueryFilter filters) throws IgniteSpiException {
+           return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void store(@Nullable String spaceName, Object key, Object val, long expirationTime)
+            throws IgniteSpiException {
+            throw new IgniteSpiException("Test exception");
+        }
+
+        /** {@inheritDoc} */
+        @Override public void remove(@Nullable String spaceName, Object key) throws IgniteSpiException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void onSwap(@Nullable String spaceName, Object key) throws IgniteSpiException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/59b46d3e/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
index 761d4bd..3cb603c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
@@ -24,7 +24,6 @@ import org.apache.ignite.internal.processors.cache.BinarySerializationQueryWithR
 import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryLostPartitionTest;
 import org.apache.ignite.testframework.config.GridTestProperties;
 
 /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/59b46d3e/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 e7f55a1..2174147 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
@@ -60,6 +60,8 @@ import org.apache.ignite.internal.processors.cache.distributed.replicated.Ignite
 import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.query.GridCacheQueryTransformerSelfTest;
+import org.apache.ignite.internal.processors.cache.query.IndexingSpiQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryTxSelfTest;
 import org.apache.ignite.internal.processors.query.IgniteSqlSchemaIndexingTest;
 import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest;
 import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest;
@@ -127,6 +129,9 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         suite.addTestSuite(IgniteBinaryObjectQueryArgumentsOffheapLocalTest.class);
         suite.addTestSuite(IgniteBinaryObjectLocalQueryArgumentsTest.class);
 
+        suite.addTestSuite(IndexingSpiQuerySelfTest.class);
+        suite.addTestSuite(IndexingSpiQueryTxSelfTest.class);
+
         return suite;
     }
 }


[22/40] ignite git commit: Update notifier fixes

Posted by av...@apache.org.
Update notifier fixes

(cherry picked from commit a5c85ca)


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 359a392f1c53217c691c4c40762c51fd330666e2
Parents: bba019f
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Fri Jan 15 09:58:41 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Tue Oct 11 16:14:00 2016 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/internal/IgniteKernal.java   | 4 ++--
 .../ignite/internal/processors/cluster/ClusterProcessor.java     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/359a392f/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index e0a36a7..d9854bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -793,8 +793,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
             startProcessor(clusterProc);
 
-            fillNodeAttributes(clusterProc.updateNotifierEnabled());
-
             U.onGridStart();
 
             // Start and configure resource processor first as it contains resources used
@@ -896,6 +894,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                 provider.start(ctx.plugins().pluginContextForProvider(provider));
             }
 
+            fillNodeAttributes(clusterProc.updateNotifierEnabled());
+
             gw.writeLock();
 
             try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/359a392f/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
index 5ccd680..6500cf3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
@@ -245,4 +245,4 @@ public class ClusterProcessor extends GridProcessorAdapter {
             }
         }
     }
-}
+}
\ No newline at end of file


[33/40] ignite git commit: IGNITE-1924 Incomplete marshaller cache rebalancing causes Grid hangs under SSL

Posted by av...@apache.org.
IGNITE-1924 Incomplete marshaller cache rebalancing causes Grid hangs under SSL


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 447e07c0bb5af75bce6a14612606904e4e3d9705
Parents: b1ec58f
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Oct 14 11:40:41 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Oct 14 11:40:41 2016 +0300

----------------------------------------------------------------------
 .../dht/GridDhtAffinityAssignmentRequest.java   |  2 +-
 .../util/nio/GridNioSessionMetaKey.java         |  7 +-
 .../util/nio/ssl/BlockingSslHandler.java        |  9 +-
 .../internal/util/nio/ssl/GridNioSslFilter.java | 63 ++++++++++---
 .../util/nio/ssl/GridNioSslHandler.java         | 17 ++--
 .../internal/util/nio/ssl/GridSslMeta.java      | 94 ++++++++++++++++++++
 .../communication/tcp/TcpCommunicationSpi.java  | 49 ++++++----
 ...mmunicationSpiConcurrentConnectSelfTest.java | 14 +++
 ...nicationSpiConcurrentConnectSslSelfTest.java | 35 ++++++++
 ...GridTcpCommunicationSpiRecoverySelfTest.java | 14 +++
 ...dTcpCommunicationSpiRecoverySslSelfTest.java | 35 ++++++++
 .../tcp/IgniteCacheSslStartStopSelfTest.java    |  1 -
 .../IgniteSpiCommunicationSelfTestSuite.java    |  4 +
 13 files changed, 301 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
index 0ef7606..6959906 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
@@ -130,6 +130,6 @@ public class GridDhtAffinityAssignmentRequest extends GridCacheMessage {
 
     /** {@inheritDoc} */
     @Override public String toString() {
-        return S.toString(GridDhtAffinityAssignmentRequest.class, this);
+        return S.toString(GridDhtAffinityAssignmentRequest.class, this, super.toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
index b5387d9..bdb3a29 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
@@ -26,8 +26,8 @@ public enum GridNioSessionMetaKey {
     /** NIO parser state. */
     PARSER_STATE,
 
-    /** SSL handler. */
-    SSL_HANDLER,
+    /** SSL Meta. */
+    SSL_META,
 
     /** NIO operation (request type). */
     NIO_OPERATION,
@@ -44,9 +44,6 @@ public enum GridNioSessionMetaKey {
     /** Message writer. */
     MSG_WRITER,
 
-    /** SSL engine. */
-    SSL_ENGINE,
-
     /** Ack closure. */
     ACK_CLOSURE;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
index bb566cd..273df5d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
@@ -113,6 +113,13 @@ public class BlockingSslHandler {
     }
 
     /**
+     *
+     */
+    public ByteBuffer inputBuffer(){
+        return inNetBuf;
+    }
+
+    /**
      * Performs handshake procedure with remote peer.
      *
      * @throws GridNioException If filter processing has thrown an exception.
@@ -255,7 +262,7 @@ public class BlockingSslHandler {
      * @throws SSLException If failed to process SSL data.
      */
     public ByteBuffer decode(ByteBuffer buf) throws IgniteCheckedException, SSLException {
-        inNetBuf.clear();
+        appBuf.clear();
 
         if (buf.limit() > inNetBuf.remaining()) {
             inNetBuf = expandBuffer(inNetBuf, inNetBuf.capacity() + buf.limit() * 2);

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
index 63cdd83..d6f9d10 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
@@ -35,7 +35,7 @@ import org.apache.ignite.internal.util.nio.GridNioSession;
 import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
-import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.SSL_HANDLER;
+import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.SSL_META;
 
 /**
  * Implementation of SSL filter using {@link SSLEngine}
@@ -154,28 +154,61 @@ public class GridNioSslFilter extends GridNioFilterAdapter {
         if (log.isDebugEnabled())
             log.debug("Remote client connected, creating SSL handler and performing initial handshake: " + ses);
 
-        SSLEngine engine = sslCtx.createSSLEngine();
+        SSLEngine engine;
 
-        engine.setUseClientMode(clientMode);
+        boolean handshake;
 
-        if (!clientMode) {
-            engine.setWantClientAuth(wantClientAuth);
+        GridSslMeta sslMeta = ses.meta(SSL_META.ordinal());
 
-            engine.setNeedClientAuth(needClientAuth);
+        if (sslMeta == null) {
+            engine = sslCtx.createSSLEngine();
+
+            engine.setUseClientMode(clientMode);
+
+            if (!clientMode) {
+                engine.setWantClientAuth(wantClientAuth);
+
+                engine.setNeedClientAuth(needClientAuth);
+            }
+
+            if (enabledCipherSuites != null)
+                engine.setEnabledCipherSuites(enabledCipherSuites);
+
+            if (enabledProtos != null)
+                engine.setEnabledProtocols(enabledProtos);
+
+            sslMeta = new GridSslMeta();
+
+            ses.addMeta(SSL_META.ordinal(), sslMeta);
+
+            handshake = true;
         }
+        else {
+            engine = sslMeta.sslEngine();
 
-        if (enabledCipherSuites != null)
-            engine.setEnabledCipherSuites(enabledCipherSuites);
+            assert engine != null;
 
-        if (enabledProtos != null)
-            engine.setEnabledProtocols(enabledProtos);
+            handshake = false;
+        }
 
         try {
-            GridNioSslHandler hnd = new GridNioSslHandler(this, ses, engine, directBuf, order, log);
+            GridNioSslHandler hnd = new GridNioSslHandler(this,
+                ses,
+                engine,
+                directBuf,
+                order,
+                log,
+                handshake,
+                sslMeta.encodedBuffer());
 
-            ses.addMeta(SSL_HANDLER.ordinal(), hnd);
+            sslMeta.handler(hnd);
 
             hnd.handshake();
+
+            ByteBuffer alreadyDecoded = sslMeta.decodedBuffer();
+
+            if (alreadyDecoded != null)
+                proceedMessageReceived(ses, alreadyDecoded);
         }
         catch (SSLException e) {
             U.error(log, "Failed to start SSL handshake (will close inbound connection): " + ses, e);
@@ -379,7 +412,11 @@ public class GridNioSslFilter extends GridNioFilterAdapter {
      * @return SSL handler.
      */
     private GridNioSslHandler sslHandler(GridNioSession ses) {
-        GridNioSslHandler hnd = ses.meta(SSL_HANDLER.ordinal());
+        GridSslMeta sslMeta = ses.meta(SSL_META.ordinal());
+
+        assert sslMeta != null;
+
+        GridNioSslHandler hnd = sslMeta.handler();
 
         if (hnd == null)
             throw new IgniteException("Failed to process incoming message (received message before SSL handler " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
index 3272b8e..eb8dad4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
@@ -43,7 +43,6 @@ import static javax.net.ssl.SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING;
 import static javax.net.ssl.SSLEngineResult.Status;
 import static javax.net.ssl.SSLEngineResult.Status.BUFFER_UNDERFLOW;
 import static javax.net.ssl.SSLEngineResult.Status.CLOSED;
-import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.SSL_ENGINE;
 import static org.apache.ignite.internal.util.nio.ssl.GridNioSslFilter.HANDSHAKE_FUT_META_KEY;
 
 /**
@@ -104,6 +103,8 @@ class GridNioSslHandler extends ReentrantLock {
      * @param log Logger to use.
      * @param directBuf Direct buffer flag.
      * @param order Byte order.
+     * @param handshake is handshake required.
+     * @param encBuf encoded buffer to be used.
      * @throws SSLException If exception occurred when starting SSL handshake.
      */
     GridNioSslHandler(GridNioSslFilter parent,
@@ -111,7 +112,9 @@ class GridNioSslHandler extends ReentrantLock {
         SSLEngine engine,
         boolean directBuf,
         ByteOrder order,
-        IgniteLogger log) throws SSLException {
+        IgniteLogger log,
+        boolean handshake,
+        ByteBuffer encBuf) throws SSLException {
         assert parent != null;
         assert ses != null;
         assert engine != null;
@@ -125,11 +128,9 @@ class GridNioSslHandler extends ReentrantLock {
 
         sslEngine = engine;
 
-        if (ses.meta(SSL_ENGINE.ordinal()) == null)
+        if (handshake)
             sslEngine.beginHandshake();
         else {
-            sslEngine = ses.meta(SSL_ENGINE.ordinal());
-
             handshakeFinished = true;
             initHandshakeComplete = true;
         }
@@ -147,6 +148,12 @@ class GridNioSslHandler extends ReentrantLock {
 
         inNetBuf.order(order);
 
+        if (encBuf != null) {
+            encBuf.flip();
+
+            inNetBuf.put(encBuf); // Buffer contains bytes read but not handled by sslEngine at BlockingSslHandler.
+        }
+
         // Initially buffer is empty.
         outNetBuf.position(0);
         outNetBuf.limit(0);

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
new file mode 100644
index 0000000..5ca68b7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.nio.ssl;
+
+import java.nio.ByteBuffer;
+import javax.net.ssl.SSLEngine;
+
+/**
+ *
+ */
+public class GridSslMeta {
+    /** GridNioSslHandler. */
+    private GridNioSslHandler hnd;
+
+    /** Data already decoded by blocking ssl handler. */
+    private ByteBuffer decodedBuf;
+
+    /** Data read but not decoded by blocking ssl handler. */
+    private ByteBuffer encodedBuf;
+
+    /** Ssl engine. */
+    private SSLEngine sslEngine;
+
+    /**
+     *
+     */
+    public SSLEngine sslEngine() {
+        return sslEngine;
+    }
+
+    /**
+     * @param sslEngine Ssl engine.
+     */
+    public void sslEngine(SSLEngine sslEngine) {
+        this.sslEngine = sslEngine;
+    }
+
+    /**
+     *
+     */
+    public GridNioSslHandler handler() {
+        return hnd;
+    }
+
+    /**
+     * @param hnd Handler.
+     */
+    public void handler(GridNioSslHandler hnd) {
+        this.hnd = hnd;
+    }
+
+    /**
+     *
+     */
+    public ByteBuffer decodedBuffer() {
+        return decodedBuf;
+    }
+
+    /**
+     * @param decodedBuf Decoded buffer.
+     */
+    public void decodedBuffer(ByteBuffer decodedBuf) {
+        this.decodedBuf = decodedBuf;
+    }
+
+    /**
+     *
+     */
+    public ByteBuffer encodedBuffer() {
+        return encodedBuf;
+    }
+
+    /**
+     * @param encodedBuf Encoded buffer.
+     */
+    public void encodedBuffer(ByteBuffer encodedBuf) {
+        this.encodedBuf = encodedBuf;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index d61cee6..0bbb4d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -90,6 +90,7 @@ import org.apache.ignite.internal.util.nio.GridShmemCommunicationClient;
 import org.apache.ignite.internal.util.nio.GridTcpNioCommunicationClient;
 import org.apache.ignite.internal.util.nio.ssl.BlockingSslHandler;
 import org.apache.ignite.internal.util.nio.ssl.GridNioSslFilter;
+import org.apache.ignite.internal.util.nio.ssl.GridSslMeta;
 import org.apache.ignite.internal.util.typedef.CI2;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.X;
@@ -131,6 +132,7 @@ import org.jsr166.LongAdder8;
 
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
+import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.SSL_META;
 
 /**
  * <tt>TcpCommunicationSpi</tt> is default communication SPI which uses
@@ -2376,19 +2378,28 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
 
                     long rcvCnt = -1;
 
-                    SSLEngine sslEngine = null;
+                    Map<Integer, Object> meta = new HashMap<>();
+
+                    GridSslMeta sslMeta = null;
 
                     try {
                         ch.socket().connect(addr, (int)timeoutHelper.nextTimeoutChunk(connTimeout));
 
                         if (isSslEnabled()) {
-                            sslEngine = ignite.configuration().getSslContextFactory().create().createSSLEngine();
+                            meta.put(SSL_META.ordinal(), sslMeta = new GridSslMeta());
+
+                            SSLEngine sslEngine = ignite.configuration().getSslContextFactory().create().createSSLEngine();
 
                             sslEngine.setUseClientMode(true);
+
+                            sslMeta.sslEngine(sslEngine);
                         }
 
-                        rcvCnt = safeHandshake(ch, recoveryDesc, node.id(),
-                            timeoutHelper.nextTimeoutChunk(connTimeout0), sslEngine);
+                        rcvCnt = safeHandshake(ch,
+                            recoveryDesc,
+                            node.id(),
+                            timeoutHelper.nextTimeoutChunk(connTimeout0),
+                            sslMeta);
 
                         if (rcvCnt == -1)
                             return null;
@@ -2399,16 +2410,8 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                     }
 
                     try {
-                        Map<Integer, Object> meta = new HashMap<>();
-
                         meta.put(NODE_ID_META, node.id());
 
-                        if (isSslEnabled()) {
-                            assert sslEngine != null;
-
-                            meta.put(GridNioSessionMetaKey.SSL_ENGINE.ordinal(), sslEngine);
-                        }
-
                         if (recoveryDesc != null) {
                             recoveryDesc.onHandshake(rcvCnt);
 
@@ -2560,7 +2563,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
      * @param recovery Recovery descriptor if use recovery handshake, otherwise {@code null}.
      * @param rmtNodeId Remote node.
      * @param timeout Timeout for handshake.
-     * @param ssl SSL engine if used cryptography, otherwise {@code null}.
+     * @param sslMeta Session meta.
      * @throws IgniteCheckedException If handshake failed or wasn't completed withing timeout.
      * @return Handshake response.
      */
@@ -2570,7 +2573,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
         @Nullable GridNioRecoveryDescriptor recovery,
         UUID rmtNodeId,
         long timeout,
-        @Nullable SSLEngine ssl
+        GridSslMeta sslMeta
     ) throws IgniteCheckedException {
         HandshakeTimeoutObject<T> obj = new HandshakeTimeoutObject<>(client, U.currentTimeMillis() + timeout);
 
@@ -2592,7 +2595,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                     ByteBuffer buf;
 
                     if (isSslEnabled()) {
-                        sslHnd = new BlockingSslHandler(ssl, ch, directBuf, ByteOrder.nativeOrder(), log);
+                        assert sslMeta != null;
+
+                        sslHnd = new BlockingSslHandler(sslMeta.sslEngine(), ch, directBuf, ByteOrder.nativeOrder(), log);
 
                         if (!sslHnd.handshake())
                             throw new IgniteCheckedException("SSL handshake is not completed.");
@@ -2710,11 +2715,21 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
 
                                 i += decode.remaining();
 
-                                buf.flip();
-                                buf.compact();
+                                buf.clear();
                             }
 
                             rcvCnt = decode.getLong(1);
+
+                            if (decode.limit() > 9) {
+                                decode.position(9);
+
+                                sslMeta.decodedBuffer(decode);
+                            }
+
+                            ByteBuffer inBuf = sslHnd.inputBuffer();
+
+                            if (inBuf.position() > 0)
+                                sslMeta.encodedBuffer(inBuf);
                         }
                         else {
                             buf = ByteBuffer.allocate(9);

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
index 97eb34c..8635d94 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
@@ -49,6 +50,7 @@ import org.apache.ignite.spi.communication.GridTestMessage;
 import org.apache.ignite.testframework.GridSpiTestContext;
 import org.apache.ignite.testframework.GridTestNode;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.IgniteMock;
 import org.apache.ignite.testframework.junits.IgniteTestResources;
 import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
 import org.apache.ignite.testframework.junits.spi.GridSpiTest;
@@ -78,6 +80,9 @@ public class GridTcpCommunicationSpiConcurrentConnectSelfTest<T extends Communic
     /** */
     private static int port = 60_000;
 
+    /** Use ssl. */
+    protected boolean useSsl;
+
     /**
      *
      */
@@ -351,6 +356,15 @@ public class GridTcpCommunicationSpiConcurrentConnectSelfTest<T extends Communic
 
             rsrcs.inject(spi);
 
+            if (useSsl) {
+                IgniteMock ignite = GridTestUtils.getFieldValue(spi, IgniteSpiAdapter.class, "ignite");
+
+                IgniteConfiguration cfg = ignite.configuration()
+                    .setSslContextFactory(GridTestUtils.sslFactory());
+
+                ignite.setStaticCfg(cfg);
+            }
+
             spi.setListener(lsnr);
 
             node.setAttributes(spi.getNodeAttributes());

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSslSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSslSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSslSelfTest.java
new file mode 100644
index 0000000..f2b9a50
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSslSelfTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.spi.communication.tcp;
+
+/**
+ *
+ */
+public class GridTcpCommunicationSpiConcurrentConnectSslSelfTest extends GridTcpCommunicationSpiConcurrentConnectSelfTest {
+    /**
+     * Default constructor.
+     */
+    public GridTcpCommunicationSpiConcurrentConnectSslSelfTest() {
+        useSsl = true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return super.getTestTimeout() * 4;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
index 94dc665..3234d74 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
@@ -29,6 +29,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
@@ -46,6 +47,7 @@ import org.apache.ignite.spi.communication.GridTestMessage;
 import org.apache.ignite.testframework.GridSpiTestContext;
 import org.apache.ignite.testframework.GridTestNode;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.IgniteMock;
 import org.apache.ignite.testframework.junits.IgniteTestResources;
 import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
 import org.apache.ignite.testframework.junits.spi.GridSpiTest;
@@ -74,6 +76,9 @@ public class GridTcpCommunicationSpiRecoverySelfTest<T extends CommunicationSpi>
     /** */
     protected static int port = 30_000;
 
+    /** Use ssl. */
+    protected boolean useSsl;
+
     /**
      *
      */
@@ -670,6 +675,15 @@ public class GridTcpCommunicationSpiRecoverySelfTest<T extends CommunicationSpi>
 
             rsrcs.inject(spi);
 
+            if (useSsl) {
+                IgniteMock ignite = GridTestUtils.getFieldValue(spi, IgniteSpiAdapter.class, "ignite");
+
+                IgniteConfiguration cfg = ignite.configuration()
+                    .setSslContextFactory(GridTestUtils.sslFactory());
+
+                ignite.setStaticCfg(cfg);
+            }
+
             spi.setListener(new TestListener());
 
             node.setAttributes(spi.getNodeAttributes());

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySslSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySslSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySslSelfTest.java
new file mode 100644
index 0000000..4182ea1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySslSelfTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.spi.communication.tcp;
+
+/**
+ *
+ */
+public class GridTcpCommunicationSpiRecoverySslSelfTest extends GridTcpCommunicationSpiRecoverySelfTest {
+    /**
+     * Default constructor.
+     */
+    public GridTcpCommunicationSpiRecoverySslSelfTest() {
+        useSsl = true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return super.getTestTimeout() * 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
index 12bd020..3324fcc 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
@@ -32,7 +32,6 @@ public class IgniteCacheSslStartStopSelfTest extends IgniteCachePutRetryAbstract
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        fail("https://issues.apache.org/jira/browse/IGNITE-1924");
         cfg.setSslContextFactory(GridTestUtils.sslFactory());
 
         return cfg;

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
index d48c2c4..eb88524 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
@@ -19,12 +19,14 @@ package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConcurrentConnectSelfTest;
+import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConcurrentConnectSslSelfTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConfigSelfTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiMultithreadedSelfTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiMultithreadedShmemTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoveryAckSelfTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoverySelfTest;
+import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoverySslSelfTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiShmemSelfTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiStartStopSelfTest;
 import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiTcpFailureDetectionSelfTest;
@@ -46,8 +48,10 @@ public class IgniteSpiCommunicationSelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(GridTcpCommunicationSpiRecoveryAckSelfTest.class));
         suite.addTest(new TestSuite(IgniteTcpCommunicationRecoveryAckClosureSelfTest.class));
         suite.addTest(new TestSuite(GridTcpCommunicationSpiRecoverySelfTest.class));
+        suite.addTest(new TestSuite(GridTcpCommunicationSpiRecoverySslSelfTest.class));
 
         suite.addTest(new TestSuite(GridTcpCommunicationSpiConcurrentConnectSelfTest.class));
+        suite.addTest(new TestSuite(GridTcpCommunicationSpiConcurrentConnectSslSelfTest.class));
 
         suite.addTest(new TestSuite(GridTcpCommunicationSpiTcpSelfTest.class));
         suite.addTest(new TestSuite(GridTcpCommunicationSpiTcpNoDelayOffSelfTest.class));


[38/40] ignite git commit: Fixed indexing test in according to changes from #80abd1b.

Posted by av...@apache.org.
Fixed indexing test in according to changes from #80abd1b.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: d3f042b9ba6c605500ab7155c40a41850babefdb
Parents: 43ac3f5
Author: sboikov <sb...@gridgain.com>
Authored: Mon Oct 17 12:28:31 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Oct 17 12:28:31 2016 +0300

----------------------------------------------------------------------
 .../query/h2/GridIndexingSpiAbstractSelfTest.java           | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d3f042b9/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 289c7d7..6e493ea 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.apache.ignite.spi.IgniteSpiCloseableIterator;
 import org.apache.ignite.spi.IgniteSpiException;
 import org.apache.ignite.testframework.GridStringLogger;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -353,9 +354,11 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         String[] aliases = {"N1", "A1", "N2", "A2"};
         Object[] vals = { "Valera", 19, "Kolya", 25};
 
-        assertTrue(fieldsRes.iterator().hasNext());
+        IgniteSpiCloseableIterator<List<?>> it = fieldsRes.iterator();
 
-        List<?> fields = fieldsRes.iterator().next();
+        assertTrue(it.hasNext());
+
+        List<?> fields = it.next();
 
         assertEquals(4, fields.size());
 
@@ -366,7 +369,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
             assertEquals(vals[i++], f);
         }
 
-        assertFalse(fieldsRes.iterator().hasNext());
+        assertFalse(it.hasNext());
 
         // Remove
         spi.remove(typeAA.space(), key(2), aa(2, "Valera", 19));


[02/40] ignite git commit: IGNITE-3868: ODBC: Fixed connection string parsing. This closes #1051.

Posted by av...@apache.org.
IGNITE-3868: ODBC: Fixed connection string parsing. This closes #1051.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: a12298c0baf19407f3110ba3c4f0aab88b67946d
Parents: a4c63ae
Author: Igor Sapego <is...@gridgain.com>
Authored: Fri Sep 30 11:00:51 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 30 11:00:51 2016 +0300

----------------------------------------------------------------------
 modules/platforms/cpp/odbc/src/odbc.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a12298c0/modules/platforms/cpp/odbc/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp
index 9df64d3..7416ad2 100644
--- a/modules/platforms/cpp/odbc/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -289,9 +289,7 @@ namespace ignite
         if (!diag.IsSuccessful())
             return diag.GetReturnCode();
 
-        std::string outConnectStr = connection->GetConfiguration().ToConnectString();
-
-        size_t reslen = CopyStringToBuffer(outConnectStr,
+        size_t reslen = CopyStringToBuffer(connectStr,
             reinterpret_cast<char*>(outConnectionString),
             static_cast<size_t>(outConnectionStringBufferLen));
 
@@ -753,7 +751,7 @@ namespace ignite
         LOG_MSG("columnSizeRes: %lld\n", columnSizeRes);
         LOG_MSG("decimalDigitsRes: %lld\n", decimalDigitsRes);
         LOG_MSG("nullableRes: %lld\n", nullableRes);
-        LOG_MSG("columnNameBuf: %s\n", columnNameBuf ? columnNameBuf : "<null>");
+        LOG_MSG("columnNameBuf: %s\n", columnNameBuf ? (const char*)columnNameBuf : "<null>");
         LOG_MSG("columnNameLen: %d\n", columnNameLen ? *columnNameLen : -1);
 
         if (dataType)


[28/40] ignite git commit: IGNITE-4034 Get rid of specialized methods in platform targets

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
index ceb3b05..960c930 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
@@ -21,8 +21,6 @@ namespace Apache.Ignite.Core.Impl.Cache
     using System.Diagnostics;
     using System.Threading;
     using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
     /// <summary>
     /// Cache lock implementation.
@@ -32,8 +30,8 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** Unique lock ID.*/
         private readonly long _id;
 
-        /** Cache. */
-        private readonly IUnmanagedTarget _cache;
+        /** Cache lock. */
+        private readonly ICacheLockInternal _lock;
 
         /** State (-1 for disposed, >=0 for number of currently executing methods). */
         private int _state;
@@ -45,13 +43,13 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// Initializes a new instance of the <see cref="CacheLock"/> class.
         /// </summary>
         /// <param name="id">Lock id.</param>
-        /// <param name="cache">Cache.</param>
-        public CacheLock(long id, IUnmanagedTarget cache)
+        /// <param name="cacheLock">Cache lock.</param>
+        public CacheLock(long id, ICacheLockInternal cacheLock)
         {
-            Debug.Assert(cache != null);
+            Debug.Assert(cacheLock != null);
 
             _id = id;
-            _cache = cache;
+            _lock = cacheLock;
         }
 
         /** <inheritDoc /> */
@@ -68,7 +66,7 @@ namespace Apache.Ignite.Core.Impl.Cache
 
             try
             {
-                UU.CacheEnterLock(_cache, _id);
+                _lock.Enter(_id);
 
                 res = true;
             }
@@ -104,7 +102,7 @@ namespace Apache.Ignite.Core.Impl.Cache
 
             try
             {
-                return res = UU.CacheTryEnterLock(_cache, _id, (long)timeout.TotalMilliseconds);
+                return res = _lock.TryEnter(_id, timeout);
             }
             finally 
             {
@@ -125,7 +123,7 @@ namespace Apache.Ignite.Core.Impl.Cache
             {
                 ThrowIfDisposed();
 
-                UU.CacheExitLock(_cache, _id);
+                _lock.Exit(_id);
 
                 _counter--;
             }
@@ -143,7 +141,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                         "The lock is being disposed while still being used. " +
                         "It either is being held by a thread and/or has active waiters waiting to acquire the lock.");
 
-                UU.CacheCloseLock(_cache, _id);
+                _lock.Close(_id);
 
                 _state = -1;
 
@@ -156,7 +154,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// </summary>
         ~CacheLock()
         {
-            UU.CacheCloseLock(_cache, _id);
+            _lock.Close(_id);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
index 4c42bf3..713ab42 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -61,6 +61,22 @@ namespace Apache.Ignite.Core.Impl.Cache
         Replace2 = 37,
         Replace3 = 38,
         GetConfig = 39,
-        LoadAll = 40
+        LoadAll = 40,
+        ClearCache = 41,
+        WithAsync = 42,
+        RemoveAll2 = 43,
+        WithKeepBinary = 44,
+        WithExpiryPolicy = 45,
+        WithNoRetries = 46,
+        WithSkipStore = 47,
+        Size = 48,
+        Iterator = 49,
+        LocIterator = 50,
+        EnterLock = 51,
+        ExitLock = 52,
+        TryEnterLock = 53,
+        CloseLock = 54,
+        Rebalance = 55,
+        SizeLoc = 56
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheLockInternal.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheLockInternal.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheLockInternal.cs
new file mode 100644
index 0000000..4329ed0
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/ICacheLockInternal.cs
@@ -0,0 +1,47 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Cache
+{
+    using System;
+
+    /// <summary>
+    /// Internal cache locking interface.
+    /// </summary>
+    internal interface ICacheLockInternal
+    {
+        /// <summary>
+        /// Enters the lock.
+        /// </summary>
+        void Enter(long id);
+
+        /// <summary>
+        /// Tries to enter the lock.
+        /// </summary>
+        bool TryEnter(long id, TimeSpan timeout);
+
+        /// <summary>
+        /// Exits the lock.
+        /// </summary>
+        void Exit(long id);
+
+        /// <summary>
+        /// Closes the lock.
+        /// </summary>
+        void Close(long id);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
index a22b247..e6092d7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
@@ -37,6 +37,12 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         /** */
         private const int OpGetBatch = 2;
 
+        /** */
+        private const int OpIterator = 4;
+
+        /** */
+        private const int OpIteratorClose = 5;
+
         /** Position before head. */
         private const int BatchPosBeforeHead = -1;
 
@@ -94,7 +100,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         {
             try
             {
-                UU.QueryCursorClose(Target);
+                DoOutOp(OpIteratorClose);
             }
             finally 
             {
@@ -119,7 +125,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
                 throw new InvalidOperationException("Failed to get enumerator entries because " + 
                     "GetAll() method has already been called.");
 
-            UU.QueryCursorIterator(Target);
+            DoOutOp(OpIterator);
 
             _iterCalled = true;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
index 6cfbe92..b66dc48 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
     /// <summary>
     /// Continuous query handle.
     /// </summary>
-    internal class ContinuousQueryHandleImpl<TK, TV> : IContinuousQueryHandleImpl, IContinuousQueryFilter, 
+    internal class ContinuousQueryHandleImpl<TK, TV> : IContinuousQueryHandleImpl, IContinuousQueryFilter,
         IContinuousQueryHandle<ICacheEntry<TK, TV>>
     {
         /** Marshaller. */
@@ -64,11 +64,11 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         private readonly ICacheEntryEventFilter<TK, TV> _filter;
 
         /** GC handle. */
-        private long _hnd;
+        private readonly long _hnd;
 
         /** Native query. */
-        private volatile IUnmanagedTarget _nativeQry;
-        
+        private readonly IUnmanagedTarget _nativeQry;
+
         /** Initial query cursor. */
         private volatile IQueryCursor<ICacheEntry<TK, TV>> _initialQueryCursor;
 
@@ -81,64 +81,81 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /// <param name="qry">Query.</param>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="keepBinary">Keep binary flag.</param>
-        public ContinuousQueryHandleImpl(ContinuousQuery<TK, TV> qry, Marshaller marsh, bool keepBinary)
+        /// <param name="createTargetCb">The initialization callback.</param>
+        /// <param name="initialQry">The initial query.</param>
+        public ContinuousQueryHandleImpl(ContinuousQuery<TK, TV> qry, Marshaller marsh, bool keepBinary,
+            Func<Action<BinaryWriter>, IUnmanagedTarget> createTargetCb, QueryBase initialQry)
         {
             _marsh = marsh;
             _keepBinary = keepBinary;
 
             _lsnr = qry.Listener;
             _filter = qry.Filter;
-        }
 
-        /// <summary>
-        /// Start execution.
-        /// </summary>
-        /// <param name="grid">Ignite instance.</param>
-        /// <param name="writer">Writer.</param>
-        /// <param name="cb">Callback invoked when all necessary data is written to stream.</param>
-        /// <param name="qry">Query.</param>
-        public void Start(Ignite grid, BinaryWriter writer, Func<IUnmanagedTarget> cb, 
-            ContinuousQuery<TK, TV> qry)
-        {
             // 1. Inject resources.
-            ResourceProcessor.Inject(_lsnr, grid);
-            ResourceProcessor.Inject(_filter, grid);
-
-            // 2. Allocate handle.
-            _hnd = grid.HandleRegistry.Allocate(this);
-
-            // 3. Write data to stream.
-            writer.WriteLong(_hnd);
-            writer.WriteBoolean(qry.Local);
-            writer.WriteBoolean(_filter != null);
-
-            var javaFilter = _filter as PlatformJavaObjectFactoryProxy;
+            ResourceProcessor.Inject(_lsnr, _marsh.Ignite);
+            ResourceProcessor.Inject(_filter, _marsh.Ignite);
 
-            if (javaFilter != null)
+            try
             {
-                writer.WriteObject(javaFilter.GetRawProxy());
-            }
-            else
-            {
-                var filterHolder = _filter == null || qry.Local
-                    ? null
-                    : new ContinuousQueryFilterHolder(_filter, _keepBinary);
+                // 2. Allocate handle.
+                _hnd = _marsh.Ignite.HandleRegistry.Allocate(this);
 
-                writer.WriteObject(filterHolder);
+                // 3. Call Java.
+                _nativeQry = createTargetCb(writer =>
+                {
+                    writer.WriteLong(_hnd);
+                    writer.WriteBoolean(qry.Local);
+                    writer.WriteBoolean(_filter != null);
+
+                    var javaFilter = _filter as PlatformJavaObjectFactoryProxy;
+
+                    if (javaFilter != null)
+                    {
+                        writer.WriteObject(javaFilter.GetRawProxy());
+                    }
+                    else
+                    {
+                        var filterHolder = _filter == null || qry.Local
+                            ? null
+                            : new ContinuousQueryFilterHolder(_filter, _keepBinary);
+
+                        writer.WriteObject(filterHolder);
+                    }
+
+                    writer.WriteInt(qry.BufferSize);
+                    writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);
+                    writer.WriteBoolean(qry.AutoUnsubscribe);
+
+                    if (initialQry != null)
+                    {
+                        writer.WriteInt((int)initialQry.OpId);
+
+                        initialQry.Write(writer, _keepBinary);
+                    }
+                    else
+                        writer.WriteInt(-1); // no initial query
+                });
+
+                // 4. Initial query.
+                var nativeInitialQryCur = UU.TargetOutObject(_nativeQry, 0);
+                _initialQueryCursor = nativeInitialQryCur == null
+                    ? null
+                    : new QueryCursor<TK, TV>(nativeInitialQryCur, _marsh, _keepBinary);
             }
+            catch (Exception)
+            {
+                if (_hnd > 0)
+                    _marsh.Ignite.HandleRegistry.Release(_hnd);
 
-            writer.WriteInt(qry.BufferSize);
-            writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);
-            writer.WriteBoolean(qry.AutoUnsubscribe);
-
-            // 4. Call Java.
-            _nativeQry = cb();
+                if (_nativeQry != null)
+                    _nativeQry.Dispose();
 
-            // 5. Initial query.
-            var nativeInitialQryCur = UU.ContinuousQueryGetInitialQueryCursor(_nativeQry);
-            _initialQueryCursor = nativeInitialQryCur == null
-                ? null
-                : new QueryCursor<TK, TV>(nativeInitialQryCur, _marsh, _keepBinary);
+                if (_initialQueryCursor != null)
+                    _initialQueryCursor.Dispose();
+                
+                throw;
+            }
         }
 
         /** <inheritdoc /> */
@@ -208,7 +225,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
 
                 try
                 {
-                    UU.ContinuousQueryClose(_nativeQry);
+                    UU.TargetOutLong(_nativeQry, 0);
                 }
                 finally
                 {
@@ -219,4 +236,4 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
             }
         }
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
index 7785280..b14b2a3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
 {
     using System.Collections;
     using System.Diagnostics;
+    using System.IO;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache.Store;
     using Apache.Ignite.Core.Common;
@@ -26,7 +27,6 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
     using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Handle;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Impl.Unmanaged;
 
     /// <summary>
     /// Interop cache store.
@@ -145,21 +145,20 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
         /// <summary>
         /// Invokes a store operation.
         /// </summary>
-        /// <param name="input">Input stream.</param>
-        /// <param name="cb">Callback.</param>
+        /// <param name="stream">Input stream.</param>
         /// <param name="grid">Grid.</param>
         /// <returns>Invocation result.</returns>
         /// <exception cref="IgniteException">Invalid operation type:  + opType</exception>
-        public int Invoke(IBinaryStream input, IUnmanagedTarget cb, Ignite grid)
+        public int Invoke(IBinaryStream stream, Ignite grid)
         {
-            IBinaryReader reader = grid.Marshaller.StartUnmarshal(input,
+            IBinaryReader reader = grid.Marshaller.StartUnmarshal(stream,
                 _convertBinary ? BinaryMode.Deserialize : BinaryMode.ForceBinary);
             
             IBinaryRawReader rawReader = reader.GetRawReader();
 
             int opType = rawReader.ReadByte();
 
-            // Setup cache sessoin for this invocation.
+            // Setup cache session for this invocation.
             long sesId = rawReader.ReadLong();
             
             CacheStoreSession ses = grid.HandleRegistry.Get<CacheStoreSession>(sesId, true);
@@ -174,27 +173,79 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
                 switch (opType)
                 {
                     case OpLoadCache:
-                        _store.LoadCache((k, v) => WriteObjects(cb, grid, k, v), rawReader.ReadArray<object>());
+                    {
+                        var args = rawReader.ReadArray<object>();
+
+                        stream.Seek(0, SeekOrigin.Begin);
+
+                        int cnt = 0;
+                        stream.WriteInt(cnt); // Reserve space for count.
+
+                        var writer = grid.Marshaller.StartMarshal(stream);
+
+                        _store.LoadCache((k, v) =>
+                        {
+                            lock (writer) // User-defined store can be multithreaded.
+                            {
+                                writer.WithDetach(w =>
+                                {
+                                    w.WriteObject(k);
+                                    w.WriteObject(v);
+                                });
+
+                                cnt++;
+                            }
+                        }, args);
+
+                        stream.WriteInt(0, cnt);
+
+                        grid.Marshaller.FinishMarshal(writer);
 
                         break;
+                    }
 
                     case OpLoad:
-                        object val = _store.Load(rawReader.ReadObject<object>());
+                    {
+                        var val = _store.Load(rawReader.ReadObject<object>());
+
+                        stream.Seek(0, SeekOrigin.Begin);
 
-                        if (val != null)
-                            WriteObjects(cb, grid, val);
+                        var writer = grid.Marshaller.StartMarshal(stream);
+
+                        writer.WriteObject(val);
+
+                        grid.Marshaller.FinishMarshal(writer);
 
                         break;
+                    }
 
                     case OpLoadAll:
+                    {
                         var keys = rawReader.ReadCollection();
 
                         var result = _store.LoadAll(keys);
 
+                        stream.Seek(0, SeekOrigin.Begin);
+
+                        stream.WriteInt(result.Count);
+
+                        var writer = grid.Marshaller.StartMarshal(stream);
+
                         foreach (DictionaryEntry entry in result)
-                            WriteObjects(cb, grid, entry.Key, entry.Value);
+                        {
+                            var entry0 = entry;  // Copy modified closure.
+
+                            writer.WithDetach(w =>
+                            {
+                                w.WriteObject(entry0.Key);
+                                w.WriteObject(entry0.Value);
+                            });
+                        }
+
+                        grid.Marshaller.FinishMarshal(writer);
 
                         break;
+                    }
 
                     case OpPut:
                         _store.Write(rawReader.ReadObject<object>(), rawReader.ReadObject<object>());
@@ -241,40 +292,5 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
                 _sesProxy.ClearSession();
             }
         }
-
-        /// <summary>
-        /// Writes objects to the marshaller.
-        /// </summary>
-        /// <param name="cb">Optional callback.</param>
-        /// <param name="grid">Grid.</param>
-        /// <param name="objects">Objects.</param>
-        private static void WriteObjects(IUnmanagedTarget cb, Ignite grid, params object[] objects)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().GetStream())
-            {
-                BinaryWriter writer = grid.Marshaller.StartMarshal(stream);
-
-                try
-                {
-                    foreach (var obj in objects)
-                    {
-                        var obj0 = obj;
-
-                        writer.WithDetach(w => w.WriteObject(obj0));
-                    }
-                }
-                finally
-                {
-                    grid.Marshaller.FinishMarshal(writer);
-                }
-
-                if (cb != null)
-                {
-                    stream.SynchronizeOutput();
-
-                    UnmanagedUtils.CacheStoreCallbackInvoke(cb, stream.MemoryPointer);
-                }
-            }
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index e6c0005..508bdc9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -99,6 +99,21 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /** */
         private const int OpSchema = 15;
 
+        /** */
+        private const int OpForRemotes = 17;
+        
+        /** */
+        private const int OpForRandom = 19;
+        
+        /** */
+        private const int OpForOldest = 20;
+        
+        /** */
+        private const int OpForYoungest = 21;
+        
+        /** */
+        public const int OpResetMetrics = 22;
+        
         /** Initial Ignite instance. */
         private readonly Ignite _ignite;
         
@@ -208,7 +223,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         {
             Debug.Assert(items != null);
 
-            IUnmanagedTarget prj = DoProjetionOutOp(OpForNodeIds, writer =>
+            IUnmanagedTarget prj = DoOutOpObject(OpForNodeIds, writer =>
             {
                 WriteEnumerable(writer, items, func);
             });
@@ -229,11 +244,12 @@ namespace Apache.Ignite.Core.Impl.Cluster
         {
             IgniteArgumentCheck.NotNull(name, "name");
 
-            IUnmanagedTarget prj = DoProjetionOutOp(OpForAttribute, writer =>
+            Action<BinaryWriter> action = writer =>
             {
                 writer.WriteString(name);
                 writer.WriteString(val);
-            });
+            };
+            IUnmanagedTarget prj = DoOutOpObject(OpForAttribute, action);
 
             return GetClusterGroup(prj);
         }
@@ -248,7 +264,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /// </returns>
         private IClusterGroup ForCacheNodes(string name, int op)
         {
-            IUnmanagedTarget prj = DoProjetionOutOp(op, writer =>
+            IUnmanagedTarget prj = DoOutOpObject(op, writer =>
             {
                 writer.WriteString(name);
             });
@@ -277,7 +293,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /** <inheritDoc /> */
         public IClusterGroup ForRemotes()
         {
-            return GetClusterGroup(UU.ProjectionForRemotes(Target));
+            return GetClusterGroup(DoOutOpObject(OpForRemotes));
         }
 
         /** <inheritDoc /> */
@@ -285,7 +301,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         {
             IgniteArgumentCheck.NotNull(node, "node");
 
-            IUnmanagedTarget prj = DoProjetionOutOp(OpForHost, writer =>
+            IUnmanagedTarget prj = DoOutOpObject(OpForHost, writer =>
             {
                 writer.WriteGuid(node.Id);
             });    
@@ -296,19 +312,19 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /** <inheritDoc /> */
         public IClusterGroup ForRandom()
         {
-            return GetClusterGroup(UU.ProjectionForRandom(Target));
+            return GetClusterGroup(DoOutOpObject(OpForRandom));
         }
 
         /** <inheritDoc /> */
         public IClusterGroup ForOldest()
         {
-            return GetClusterGroup(UU.ProjectionForOldest(Target));
+            return GetClusterGroup(DoOutOpObject(OpForOldest));
         }
 
         /** <inheritDoc /> */
         public IClusterGroup ForYoungest()
         {
-            return GetClusterGroup(UU.ProjectionForYoungest(Target));
+            return GetClusterGroup(DoOutOpObject(OpForYoungest));
         }
 
         /** <inheritDoc /> */
@@ -519,27 +535,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
 
             return _nodes;
         }
-        
-        /// <summary>
-        /// Perform synchronous out operation returning value.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="action">Action.</param>
-        /// <returns>Native projection.</returns>
-        private IUnmanagedTarget DoProjetionOutOp(int type, Action<BinaryWriter> action)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().GetStream())
-            {
-                var writer = Marshaller.StartMarshal(stream);
 
-                action(writer);
-
-                FinishMarshal(writer);
-
-                return UU.ProjectionOutOpRet(Target, type, stream.SynchronizeOutput());
-            }
-        }
-        
         /** <inheritDoc /> */
         public IBinaryType GetBinaryType(int typeId)
         {

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
index 746577a..68bd9d4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -62,7 +62,10 @@ namespace Apache.Ignite.Core.Impl.Common
             }
             catch (AggregateException ex)
             {
-                throw ex.InnerException;
+                if (ex.InnerException != null)
+                    throw ex.InnerException;
+
+                throw;
             }
         }
 
@@ -174,33 +177,12 @@ namespace Apache.Ignite.Core.Impl.Common
         }
 
         /// <summary>
-        /// Cancels this instance.
-        /// </summary>
-        internal bool Cancel()
-        {
-            if (_unmanagedTarget == null)
-                return false;
-
-            return UnmanagedUtils.ListenableCancel(_unmanagedTarget);
-        }
-
-        /// <summary>
-        /// Determines whether this instance is cancelled.
-        /// </summary>
-        internal bool IsCancelled()
-        {
-            if (_unmanagedTarget == null)
-                return false;
-
-            return UnmanagedUtils.ListenableIsCancelled(_unmanagedTarget);
-        }
-
-        /// <summary>
         /// Called when token cancellation occurs.
         /// </summary>
         private void OnTokenCancel()
         {
-            Cancel();
+            if (_unmanagedTarget != null)
+                UnmanagedUtils.ListenableCancel(_unmanagedTarget);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
index 86dee30..1b2e2aa 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
@@ -57,6 +57,15 @@ namespace Apache.Ignite.Core.Impl.Compute
         /** */
         private const int OpUnicast = 5;
 
+        /** */
+        private const int OpWithNoFailover = 6;
+
+        /** */
+        private const int OpWithTimeout = 7;
+
+        /** */
+        private const int OpExecNative = 8;
+
         /** Underlying projection. */
         private readonly ClusterGroupImpl _prj;
 
@@ -97,7 +106,7 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// </summary>
         public void WithNoFailover()
         {
-            UU.ComputeWithNoFailover(Target);
+            DoOutOp(OpWithNoFailover);
         }
 
         /// <summary>
@@ -107,7 +116,7 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// <param name="timeout">Computation timeout in milliseconds.</param>
         public void WithTimeout(long timeout)
         {
-            UU.ComputeWithTimeout(Target, timeout);
+            DoOutInOpLong(OpWithTimeout, timeout);
         }
 
         /// <summary>
@@ -193,7 +202,11 @@ namespace Apache.Ignite.Core.Impl.Compute
 
             long ptr = Marshaller.Ignite.HandleRegistry.Allocate(holder);
 
-            var futTarget = UU.ComputeExecuteNative(Target, ptr, _prj.TopologyVersion);
+            var futTarget = DoOutOpObject(OpExecNative, w =>
+            {
+                w.WriteLong(ptr);
+                w.WriteLong(_prj.TopologyVersion);
+            });
 
             var future = holder.Future;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs
index 6fefe3b..571e6fd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Impl.DataStructures
     using System.Diagnostics;
     using Apache.Ignite.Core.DataStructures;
     using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
 
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
@@ -32,6 +33,19 @@ namespace Apache.Ignite.Core.Impl.DataStructures
         /** */
         private readonly string _name;
 
+        /** Operation codes. */
+        private enum Op
+        {
+            AddAndGet = 1,
+            Close = 2,
+            CompareAndSetAndGet = 4,
+            DecrementAndGet = 5,
+            Get = 6,
+            GetAndSet = 10,
+            IncrementAndGet = 11,
+            IsClosed = 12
+        }
+
         /// <summary>
         /// Initializes a new instance of the <see cref="AtomicLong"/> class.
         /// </summary>
@@ -54,49 +68,53 @@ namespace Apache.Ignite.Core.Impl.DataStructures
         /** <inheritDoc /> */
         public long Read()
         {
-            return UU.AtomicLongGet(Target);
+            return DoOutOp((int) Op.Get);
         }
 
         /** <inheritDoc /> */
         public long Increment()
         {
-            return UU.AtomicLongIncrementAndGet(Target);
+            return DoOutOp((int) Op.IncrementAndGet);
         }
 
         /** <inheritDoc /> */
         public long Add(long value)
         {
-            return UU.AtomicLongAddAndGet(Target, value);
+            return DoOutInOpLong((int) Op.AddAndGet, value);
         }
 
         /** <inheritDoc /> */
         public long Decrement()
         {
-            return UU.AtomicLongDecrementAndGet(Target);
+            return DoOutOp((int) Op.DecrementAndGet);
         }
 
         /** <inheritDoc /> */
         public long Exchange(long value)
         {
-            return UU.AtomicLongGetAndSet(Target, value);
+            return DoOutInOpLong((int) Op.GetAndSet, value);
         }
 
         /** <inheritDoc /> */
         public long CompareExchange(long value, long comparand)
         {
-            return UU.AtomicLongCompareAndSetAndGet(Target, comparand, value);
+            return DoOutOp((int) Op.CompareAndSetAndGet, (IBinaryStream s) =>
+            {
+                s.WriteLong(comparand);
+                s.WriteLong(value);
+            });
         }
 
         /** <inheritDoc /> */
         public void Close()
         {
-            UU.AtomicLongClose(Target);
+            DoOutOp((int) Op.Close);
         }
 
         /** <inheritDoc /> */
         public bool IsClosed()
         {
-            return UU.AtomicLongIsClosed(Target);
+            return DoOutOp((int) Op.IsClosed) == True;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs
index d22afeb..75e36d1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs
@@ -32,7 +32,9 @@ namespace Apache.Ignite.Core.Impl.DataStructures
         {
             Get = 1,
             Set = 2,
-            CompareAndSetAndGet = 3
+            CompareAndSetAndGet = 3,
+            Close = 4,
+            IsClosed = 5
         }
 
         /** */
@@ -80,13 +82,13 @@ namespace Apache.Ignite.Core.Impl.DataStructures
         /** <inheritDoc /> */
         public bool IsClosed
         {
-            get { return UnmanagedUtils.AtomicReferenceIsClosed(Target); }
+            get { return DoOutOp((int) Op.IsClosed) == True; }
         }
 
         /** <inheritDoc /> */
         public void Close()
         {
-            UnmanagedUtils.AtomicReferenceClose(Target);
+            DoOutOp((int) Op.Close);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs
index 0835b9a..b7b924e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs
@@ -30,6 +30,18 @@ namespace Apache.Ignite.Core.Impl.DataStructures
         /** */
         private readonly string _name;
 
+        /** */
+        private enum Op
+        {
+            AddAndGet = 1,
+            Close = 2,
+            Get = 3,
+            GetBatchSize = 6,
+            IncrementAndGet = 7,
+            IsClosed = 8,
+            SetBatchSize = 9
+        }
+
         /// <summary>
         /// Initializes a new instance of the <see cref="Apache.Ignite.Core.Impl.DataStructures.AtomicLong"/> class.
         /// </summary>
@@ -53,38 +65,38 @@ namespace Apache.Ignite.Core.Impl.DataStructures
         /** <inheritDoc /> */
         public long Read()
         {
-            return UnmanagedUtils.AtomicSequenceGet(Target);
+            return DoOutOp((int) Op.Get);
         }
 
         /** <inheritDoc /> */
         public long Increment()
         {
-            return UnmanagedUtils.AtomicSequenceIncrementAndGet(Target);
+            return DoOutOp((int) Op.IncrementAndGet);
         }
 
         /** <inheritDoc /> */
         public long Add(long value)
         {
-            return UnmanagedUtils.AtomicSequenceAddAndGet(Target, value);
+            return DoOutInOpLong((int) Op.AddAndGet, value);
         }
 
         /** <inheritDoc /> */
         public int BatchSize
         {
-            get { return UnmanagedUtils.AtomicSequenceGetBatchSize(Target); }
-            set { UnmanagedUtils.AtomicSequenceSetBatchSize(Target, value); }
+            get { return (int) DoOutOp((int) Op.GetBatchSize); }
+            set { DoOutInOpLong((int) Op.SetBatchSize, value); }
         }
 
         /** <inheritDoc /> */
         public bool IsClosed
         {
-            get { return UnmanagedUtils.AtomicSequenceIsClosed(Target); }
+            get { return DoOutOp((int) Op.IsClosed) == True; }
         }
 
         /** <inheritDoc /> */
         public void Close()
         {
-            UnmanagedUtils.AtomicSequenceClose(Target);
+            DoOutOp((int) Op.Close);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
index 74261d3..8893fc5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
@@ -67,7 +67,34 @@ namespace Apache.Ignite.Core.Impl.Datastream
         
         /** Operation: set receiver. */
         private const int OpReceiver = 2;
-        
+
+        /** */
+        private const int OpAllowOverwrite = 3;
+
+        /** */
+        private const int OpSetAllowOverwrite = 4;
+
+        /** */
+        private const int OpSkipStore = 5;
+
+        /** */
+        private const int OpSetSkipStore = 6;
+
+        /** */
+        private const int OpPerNodeBufferSize = 7;
+
+        /** */
+        private const int OpSetPerNodeBufferSize = 8;
+
+        /** */
+        private const int OpPerNodeParallelOps = 9;
+
+        /** */
+        private const int OpSetPerNodeParallelOps = 10;
+
+        /** */
+        private const int OpListenTopology = 11;
+
         /** Cache name. */
         private readonly string _cacheName;
 
@@ -129,7 +156,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
             _hnd = marsh.Ignite.HandleRegistry.Allocate(thisRef);
 
             // Start topology listening. This call will ensure that buffer size member is updated.
-            UU.DataStreamerListenTopology(target, _hnd);
+            DoOutInOpLong(OpListenTopology, _hnd);
 
             // Membar to ensure fields initialization before leaving constructor.
             Thread.MemoryBarrier();
@@ -157,7 +184,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                 {
                     ThrowIfDisposed();
 
-                    return UU.DataStreamerAllowOverwriteGet(Target);
+                    return DoOutOp(OpAllowOverwrite) == True;
                 }
                 finally
                 {
@@ -172,7 +199,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                 {
                     ThrowIfDisposed();
 
-                    UU.DataStreamerAllowOverwriteSet(Target, value);
+                    DoOutInOpLong(OpSetAllowOverwrite, value ? True : False);
                 }
                 finally
                 {
@@ -192,7 +219,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                 {
                     ThrowIfDisposed();
 
-                    return UU.DataStreamerSkipStoreGet(Target);
+                    return DoOutOp(OpSkipStore) == True;
                 }
                 finally
                 {
@@ -207,7 +234,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                 {
                     ThrowIfDisposed();
 
-                    UU.DataStreamerSkipStoreSet(Target, value);
+                    DoOutInOpLong(OpSetSkipStore, value ? True : False);
                 }
                 finally
                 {
@@ -227,7 +254,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                 {
                     ThrowIfDisposed();
 
-                    return UU.DataStreamerPerNodeBufferSizeGet(Target);
+                    return (int) DoOutOp(OpPerNodeBufferSize);
                 }
                 finally
                 {
@@ -242,7 +269,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                 {
                     ThrowIfDisposed();
 
-                    UU.DataStreamerPerNodeBufferSizeSet(Target, value);
+                    DoOutInOpLong(OpSetPerNodeBufferSize, value);
 
                     _bufSndSize = _topSize * value;
                 }
@@ -264,7 +291,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                 {
                     ThrowIfDisposed();
 
-                    return UU.DataStreamerPerNodeParallelOperationsGet(Target);
+                    return (int) DoOutOp(OpPerNodeParallelOps);
                 }
                 finally
                 {
@@ -280,7 +307,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                 {
                     ThrowIfDisposed();
 
-                    UU.DataStreamerPerNodeParallelOperationsSet(Target, value);
+                    DoOutInOpLong(OpSetPerNodeParallelOps, value);
                 }
                 finally
                 {
@@ -571,7 +598,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
                     _topVer = topVer;
                     _topSize = topSize > 0 ? topSize : 1;  // Do not set to 0 to avoid 0 buffer size.
 
-                    _bufSndSize = _topSize * UU.DataStreamerPerNodeBufferSizeGet(Target);
+                    _bufSndSize = (int) (_topSize * DoOutOp(OpPerNodeBufferSize));
                 }
             }
             finally

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
index 783ba94..5d1add640 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -52,7 +52,11 @@ namespace Apache.Ignite.Core.Impl.Events
             RecordLocal = 6,
             EnableLocal = 8,
             DisableLocal = 9,
-            GetEnabledEvents = 10
+            GetEnabledEvents = 10,
+            WithAsync = 11,
+            IsEnabled = 12,
+            LocalListen = 13,
+            StopLocalListen = 14
         }
 
         /** Map from user func to local wrapper, needed for invoke/unsubscribe. */
@@ -85,7 +89,7 @@ namespace Apache.Ignite.Core.Impl.Events
         /// Initializes a new async instance.
         /// </summary>
         /// <param name="events">The events.</param>
-        private Events(Events events) : base(UU.EventsWithAsync(events.Target), events.Marshaller)
+        private Events(Events events) : base(UU.TargetOutObject(events.Target, (int) Op.WithAsync), events.Marshaller)
         {
             _clusterGroup = events.ClusterGroup;
         }
@@ -335,7 +339,7 @@ namespace Apache.Ignite.Core.Impl.Events
                 // Should do this inside lock to avoid race with subscription
                 // ToArray is required because we are going to modify underlying dictionary during enumeration
                 foreach (var filter in GetLocalFilters(listener, types).ToArray())
-                    success |= UU.EventsStopLocalListen(Target, filter.Handle);
+                    success |= (DoOutInOpLong((int) Op.StopLocalListen, filter.Handle) == True);
 
                 return success;
             }
@@ -384,7 +388,7 @@ namespace Apache.Ignite.Core.Impl.Events
         /** <inheritDoc /> */
         public bool IsEnabled(int type)
         {
-            return UU.EventsIsEnabled(Target, type);
+            return DoOutInOpLong((int) Op.IsEnabled, type) == True;
         }
 
         /// <summary>
@@ -508,7 +512,11 @@ namespace Apache.Ignite.Core.Impl.Events
                     filters[type] = localFilter;
                 }
 
-                UU.EventsLocalListen(Target, localFilter.Handle, type);
+                DoOutOp((int) Op.LocalListen, (IBinaryStream s) =>
+                {
+                    s.WriteLong(localFilter.Handle);
+                    s.WriteInt(type);
+                });
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 0706966..675af5e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -486,7 +486,7 @@ namespace Apache.Ignite.Core.Impl
         /** <inheritdoc /> */
         public void ResetMetrics()
         {
-            UU.ProjectionResetMetrics(_prj.Target);
+            UU.TargetOutLong(_prj.Target, ClusterGroupImpl.OpResetMetrics);
         }
 
         /** <inheritdoc /> */

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
index 5882495..2216d1a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
@@ -48,7 +48,8 @@ namespace Apache.Ignite.Core.Impl.Messaging
             SendMulti = 4,
             SendOrdered = 5,
             StopLocalListen = 6,
-            StopRemoteListen = 7
+            StopRemoteListen = 7,
+            WithAsync = 8
         }
 
         /** Map from user (func+topic) -> id, needed for unsubscription. */
@@ -89,7 +90,8 @@ namespace Apache.Ignite.Core.Impl.Messaging
         /// Initializes a new async instance.
         /// </summary>
         /// <param name="messaging">The messaging.</param>
-        private Messaging(Messaging messaging) : base(UU.MessagingWithASync(messaging.Target), messaging.Marshaller)
+        private Messaging(Messaging messaging) : base(
+            UU.TargetOutObject(messaging.Target, (int) Op.WithAsync), messaging.Marshaller)
         {
             _isAsync = true;
             _ignite = messaging._ignite;

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
index 26b6033..8c065bc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
@@ -40,6 +40,9 @@ namespace Apache.Ignite.Core.Impl
     internal abstract class PlatformTarget
     {
         /** */
+        protected const int False = 0;
+
+        /** */
         protected const int True = 1;
 
         /** */
@@ -256,6 +259,16 @@ namespace Apache.Ignite.Core.Impl
         /// Perform out operation.
         /// </summary>
         /// <param name="type">Operation type.</param>
+        /// <returns>Long result.</returns>
+        protected long DoOutOp(int type)
+        {
+            return UU.TargetOutLong(_target, type);
+        }
+
+        /// <summary>
+        /// Perform out operation.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
         /// <param name="action">Action to be performed on the stream.</param>
         /// <returns></returns>
         protected long DoOutOp(int type, Action<IBinaryStream> action)
@@ -309,6 +322,16 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /// <summary>
+        /// Perform out operation.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <returns>Resulting object.</returns>
+        protected IUnmanagedTarget DoOutOpObject(int type)
+        {
+            return UU.TargetOutObject(_target, type);
+        }
+
+        /// <summary>
         /// Perform simple output operation accepting single argument.
         /// </summary>
         /// <param name="type">Operation type.</param>
@@ -505,6 +528,66 @@ namespace Apache.Ignite.Core.Impl
         /// </summary>
         /// <param name="type">Operation type.</param>
         /// <param name="outAction">Out action.</param>
+        /// <param name="inAction">In action.</param>
+        /// <param name="arg">Argument.</param>
+        /// <returns>Result.</returns>
+        protected unsafe TR DoOutInOp<TR>(int type, Action<BinaryWriter> outAction,
+            Func<IBinaryStream, IUnmanagedTarget, TR> inAction, void* arg)
+        {
+            PlatformMemoryStream outStream = null;
+            long outPtr = 0;
+
+            PlatformMemoryStream inStream = null;
+            long inPtr = 0;
+
+            try
+            {
+                if (outAction != null)
+                {
+                    outStream = IgniteManager.Memory.Allocate().GetStream();
+                    var writer = _marsh.StartMarshal(outStream);
+                    outAction(writer);
+                    FinishMarshal(writer);
+                    outPtr = outStream.SynchronizeOutput();
+                }
+
+                if (inAction != null)
+                {
+                    inStream = IgniteManager.Memory.Allocate().GetStream();
+                    inPtr = inStream.MemoryPointer;
+                }
+
+                var res = UU.TargetInObjectStreamOutObjectStream(_target, type, arg, outPtr, inPtr);
+
+                if (inAction == null)
+                    return default(TR);
+
+                inStream.SynchronizeInput();
+
+                return inAction(inStream, res);
+
+            }
+            finally
+            {
+                try
+                {
+                    if (inStream != null)
+                        inStream.Dispose();
+
+                }
+                finally
+                {
+                    if (outStream != null)
+                        outStream.Dispose();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Perform out-in operation.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="outAction">Out action.</param>
         /// <returns>Result.</returns>
         protected TR DoOutInOp<TR>(int type, Action<BinaryWriter> outAction)
         {
@@ -583,6 +666,17 @@ namespace Apache.Ignite.Core.Impl
             }
         }
 
+        /// <summary>
+        /// Perform simple out-in operation accepting two arguments.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="val">Value.</param>
+        /// <returns>Result.</returns>
+        protected long DoOutInOpLong(int type, long val)
+        {
+            return UU.TargetInLongOutLong(_target, type, val);
+        }
+
         #endregion
 
         #region Miscelanneous

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
index 3d55f06..d6b1d05 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
@@ -51,6 +51,21 @@ namespace Apache.Ignite.Core.Impl.Services
         private const int OpDescriptors = 5;
 
         /** */
+        private const int OpWithAsync = 6;
+
+        /** */
+        private const int OpWithServerKeepBinary = 7;
+
+        /** */
+        private const int OpServiceProxy = 8;
+
+        /** */
+        private const int OpCancel = 9;
+
+        /** */
+        private const int OpCancelAll = 10;
+
+        /** */
         private readonly IClusterGroup _clusterGroup;
 
         /** Invoker binary flag. */
@@ -87,7 +102,8 @@ namespace Apache.Ignite.Core.Impl.Services
         /// Initializes a new async instance.
         /// </summary>
         /// <param name="services">The services.</param>
-        private Services(Services services) : base(UU.ServicesWithAsync(services.Target), services.Marshaller)
+        private Services(Services services) : base(UU.TargetOutObject(services.Target, OpWithAsync), 
+            services.Marshaller)
         {
             _clusterGroup = services.ClusterGroup;
             _keepBinary = services._keepBinary;
@@ -109,7 +125,7 @@ namespace Apache.Ignite.Core.Impl.Services
             if (_srvKeepBinary)
                 return this;
 
-            return new Services(UU.ServicesWithServerKeepBinary(Target), Marshaller, _clusterGroup, _keepBinary, true);
+            return new Services(DoOutOpObject(OpWithServerKeepBinary), Marshaller, _clusterGroup, _keepBinary, true);
         }
 
         /** <inheritDoc /> */
@@ -243,7 +259,7 @@ namespace Apache.Ignite.Core.Impl.Services
         {
             IgniteArgumentCheck.NotNullOrEmpty(name, "name");
 
-            UU.ServicesCancel(Target, name);
+            DoOutOp(OpCancel, w => w.WriteString(name));
         }
 
         /** <inheritDoc /> */
@@ -257,7 +273,7 @@ namespace Apache.Ignite.Core.Impl.Services
         /** <inheritDoc /> */
         public void CancelAll()
         {
-            UU.ServicesCancelAll(Target);
+            DoOutOp(OpCancelAll);
         }
 
         /** <inheritDoc /> */
@@ -347,7 +363,12 @@ namespace Apache.Ignite.Core.Impl.Services
             if (locInst != null)
                 return locInst;
 
-            var javaProxy = UU.ServicesGetServiceProxy(Target, name, sticky);
+            var javaProxy = DoOutOpObject(OpServiceProxy, w =>
+            {
+                w.WriteString(name);
+                w.WriteBoolean(sticky);
+            });
+
             var platform = GetServiceDescriptors().Cast<ServiceDescriptor>().Single(x => x.Name == name).Platform;
 
             return new ServiceProxy<T>((method, args) =>

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
index 51a49d0..796044d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
@@ -22,9 +22,9 @@ namespace Apache.Ignite.Core.Impl.Transactions
     using System.Threading.Tasks;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using Apache.Ignite.Core.Transactions;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
     /// <summary>
     /// Transactions facade.
@@ -36,7 +36,35 @@ namespace Apache.Ignite.Core.Impl.Transactions
 
         /** */
         private const int OpMetrics = 2;
-        
+
+        /** */
+        private const int OpStart = 3;
+
+        /** */
+        private const int OpCommit = 4;
+
+        /** */
+        private const int OpRollback = 5;
+
+        /** */
+        private const int OpClose = 6;
+
+        /** */
+        private const int OpState = 7;
+
+        /** */
+        private const int OpSetRollbackOnly = 8;
+
+        /** */
+        private const int OpCommitAsync = 9;
+
+        /** */
+        private const int OpRollbackAsync = 10;
+
+        /** */
+        private const int OpResetMetrics = 11;
+
+
         /** */
         private readonly TransactionConcurrency _dfltConcurrency;
 
@@ -95,8 +123,13 @@ namespace Apache.Ignite.Core.Impl.Transactions
         public ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation,
             TimeSpan timeout, int txSize)
         {
-            var id = UU.TransactionsStart(Target, (int)concurrency, (int)isolation, (long)timeout.TotalMilliseconds,
-                txSize);
+            var id = DoOutInOp(OpStart, w =>
+            {
+                w.WriteInt((int) concurrency);
+                w.WriteInt((int) isolation);
+                w.WriteTimeSpanAsLong(timeout);
+                w.WriteInt(txSize);
+            }, s => s.ReadLong());
 
             var innerTx = new TransactionImpl(id, this, concurrency, isolation, timeout, _localNodeId);
             
@@ -123,7 +156,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /** <inheritDoc /> */
         public void ResetMetrics()
         {
-            UU.TransactionsResetMetrics(Target);
+            DoOutOp(OpResetMetrics);
         }
 
         /// <summary>
@@ -133,7 +166,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// <returns>Final transaction state.</returns>
         internal TransactionState TxCommit(TransactionImpl tx)
         {
-            return (TransactionState) UU.TransactionsCommit(Target, tx.Id);
+            return (TransactionState) DoOutInOpLong(OpCommit, tx.Id);
         }
 
         /// <summary>
@@ -143,7 +176,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// <returns>Final transaction state.</returns>
         internal TransactionState TxRollback(TransactionImpl tx)
         {
-            return (TransactionState)UU.TransactionsRollback(Target, tx.Id);
+            return (TransactionState) DoOutInOpLong(OpRollback, tx.Id);
         }
 
         /// <summary>
@@ -153,7 +186,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// <returns>Final transaction state.</returns>
         internal int TxClose(TransactionImpl tx)
         {
-            return UU.TransactionsClose(Target, tx.Id);
+            return (int) DoOutInOpLong(OpClose, tx.Id);
         }
 
         /// <summary>
@@ -163,7 +196,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// <returns>Transaction current state.</returns>
         internal TransactionState TxState(TransactionImpl tx)
         {
-            return GetTransactionState(UU.TransactionsState(Target, tx.Id));
+            return (TransactionState) DoOutInOpLong(OpState, tx.Id);
         }
 
         /// <summary>
@@ -173,7 +206,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// <returns><c>true</c> if the flag was set.</returns>
         internal bool TxSetRollbackOnly(TransactionImpl tx)
         {
-            return UU.TransactionsSetRollbackOnly(Target, tx.Id);
+            return DoOutInOpLong(OpSetRollbackOnly, tx.Id) == True;
         }
 
         /// <summary>
@@ -181,7 +214,11 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// </summary>
         internal Task CommitAsync(TransactionImpl tx)
         {
-            return GetFuture<object>((futId, futTyp) => UU.TransactionsCommitAsync(Target, tx.Id, futId)).Task;
+            return GetFuture<object>((futId, futTyp) => DoOutOp(OpCommitAsync, (IBinaryStream s) =>
+            {
+                s.WriteLong(tx.Id);
+                s.WriteLong(futId);
+            })).Task;
         }
 
         /// <summary>
@@ -189,15 +226,11 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// </summary>
         internal Task RollbackAsync(TransactionImpl tx)
         {
-            return GetFuture<object>((futId, futTyp) => UU.TransactionsRollbackAsync(Target, tx.Id, futId)).Task;
-        }
- 
-        /// <summary>
-        /// Gets the state of the transaction from int.
-        /// </summary>
-        private static TransactionState GetTransactionState(int state)
-        {
-            return (TransactionState)state;
+            return GetFuture<object>((futId, futTyp) => DoOutOp(OpRollbackAsync, (IBinaryStream s) =>
+            {
+                s.WriteLong(tx.Id);
+                s.WriteLong(futId);
+            })).Task;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
index bb26382..8de82ee 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -113,6 +113,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetCacheNames")]
         public static extern void ProcessorGetCacheNames(void* ctx, void* obj, long memPtr);
 
+        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInLongOutLong")]
+        public static extern long TargetInLongOutLong(void* ctx, void* target, int opType, long val);
+
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInStreamOutLong")]
         public static extern long TargetInStreamOutLong(void* ctx, void* target, int opType, long memPtr);
 
@@ -127,6 +130,10 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         public static extern void TargetInObjectStreamOutStream(void* ctx, void* target, int opType,
             void* arg, long inMemPtr, long outMemPtr);
 
+        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInObjectStreamOutObjectStream")]
+        public static extern void* TargetInObjectStreamOutObjectStream(void* ctx, void* target, int opType,
+            void* arg, long inMemPtr, long outMemPtr);
+
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetOutLong")]
         public static extern long TargetOutLong(void* ctx, void* target, int opType);
 
@@ -148,178 +155,12 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetListenFutureForOperationAndGet")]
         public static extern void* TargetListenFutForOpAndGet(void* ctx, void* target, long futId, int typ, int opId);
 
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAffinityPartitions")]
-        public static extern int AffinityParts(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheWithSkipStore")]
-        public static extern void* CacheWithSkipStore(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheWithNoRetries")]
-        public static extern void* CacheWithNoRetries(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheWithExpiryPolicy")]
-        public static extern void* CacheWithExpiryPolicy(void* ctx, void* obj, long create, long update, long access);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheWithAsync")]
-        public static extern void* CacheWithAsync(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheWithKeepPortable")]
-        public static extern void* CacheWithKeepBinary(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheClear")]
-        public static extern void CacheClear(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheRemoveAll")]
-        public static extern void CacheRemoveAll(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheOutOpQueryCursor")]
-        public static extern void* CacheOutOpQueryCursor(void* ctx, void* obj, int type, long memPtr);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheOutOpContinuousQuery")]
-        public static extern void* CacheOutOpContinuousQuery(void* ctx, void* obj, int type, long memPtr);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheIterator")]
-        public static extern void* CacheIterator(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheLocalIterator")]
-        public static extern void* CacheLocalIterator(void* ctx, void* obj, int peekModes);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheEnterLock")]
-        public static extern void CacheEnterLock(void* ctx, void* obj, long id);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheExitLock")]
-        public static extern void CacheExitLock(void* ctx, void* obj, long id);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheTryEnterLock")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool CacheTryEnterLock(void* ctx, void* obj, long id, long timeout);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheCloseLock")]
-        public static extern void CacheCloseLock(void* ctx, void* obj, long id);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheRebalance")]
-        public static extern void CacheRebalance(void* ctx, void* obj, long futId);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheSize")]
-        public static extern int CacheSize(void* ctx, void* obj, int peekModes, [MarshalAs(UnmanagedType.U1)] bool loc);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteCacheStoreCallbackInvoke")]
-        public static extern void CacheStoreCallbackInvoke(void* ctx, void* obj, long memPtr);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteComputeWithNoFailover")]
-        public static extern void ComputeWithNoFailover(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteComputeWithTimeout")]
-        public static extern void ComputeWithTimeout(void* ctx, void* target, long timeout);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteComputeExecuteNative")]
-        public static extern void* ComputeExecuteNative(void* ctx, void* target, long taskPtr, long topVer);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteContinuousQueryClose")]
-        public static extern void ContinuousQryClose(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteContinuousQueryGetInitialQueryCursor")]
-        public static extern void* ContinuousQryGetInitialQueryCursor(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerListenTopology")]
-        public static extern void DataStreamerListenTop(void* ctx, void* obj, long ptr);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerAllowOverwriteGet")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool DataStreamerAllowOverwriteGet(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerAllowOverwriteSet")]
-        public static extern void DataStreamerAllowOverwriteSet(void* ctx, void* obj, 
-            [MarshalAs(UnmanagedType.U1)] bool val);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerSkipStoreGet")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool DataStreamerSkipStoreGet(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerSkipStoreSet")]
-        public static extern void DataStreamerSkipStoreSet(void* ctx, void* obj, 
-            [MarshalAs(UnmanagedType.U1)] bool val);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerPerNodeBufferSizeGet")]
-        public static extern int DataStreamerPerNodeBufferSizeGet(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerPerNodeBufferSizeSet")]
-        public static extern void DataStreamerPerNodeBufferSizeSet(void* ctx, void* obj, int val);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerPerNodeParallelOperationsGet")]
-        public static extern int DataStreamerPerNodeParallelOpsGet(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDataStreamerPerNodeParallelOperationsSet")]
-        public static extern void DataStreamerPerNodeParallelOpsSet(void* ctx, void* obj, int val);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteMessagingWithAsync")]
-        public static extern void* MessagingWithAsync(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionForOthers")]
-        public static extern void* ProjectionForOthers(void* ctx, void* obj, void* prj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionForRemotes")]
-        public static extern void* ProjectionForRemotes(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionForDaemons")]
-        public static extern void* ProjectionForDaemons(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionForRandom")]
-        public static extern void* ProjectionForRandom(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionForOldest")]
-        public static extern void* ProjectionForOldest(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionForYoungest")]
-        public static extern void* ProjectionForYoungest(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionResetMetrics")]
-        public static extern void ProjectionResetMetrics(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionOutOpRet")]
-        public static extern void* ProjectionOutOpRet(void* ctx, void* obj, int type, long memPtr);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteQueryCursorIterator")]
-        public static extern void QryCursorIterator(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteQueryCursorClose")]
-        public static extern void QryCursorClose(void* ctx, void* target);
-
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAcquire")]
         public static extern void* Acquire(void* ctx, void* target);
 
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteRelease")]
         public static extern void Release(void* target);
 
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsStart")]
-        public static extern long TxStart(void* ctx, void* target, int concurrency, int isolation, long timeout,
-            int txSize);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsCommit")]
-        public static extern int TxCommit(void* ctx, void* target, long id);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsCommitAsync")]
-        public static extern void TxCommitAsync(void* ctx, void* target, long id, long futId);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsRollback")]
-        public static extern int TxRollback(void* ctx, void* target, long id);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsRollbackAsync")]
-        public static extern void TxRollbackAsync(void* ctx, void* target, long id, long futId);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsClose")]
-        public static extern int TxClose(void* ctx, void* target, long id);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsState")]
-        public static extern int TxState(void* ctx, void* target, long id);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsSetRollbackOnly")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool TxSetRollbackOnly(void* ctx, void* target, long id);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTransactionsResetMetrics")]
-        public static extern void TxResetMetrics(void* ctx, void* target);
-
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteThrowToJava")]
         public static extern void ThrowToJava(void* ctx, char* msg);
 
@@ -335,96 +176,8 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteDestroyJvm")]
         public static extern void DestroyJvm(void* ctx);
 
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteEventsWithAsync")]
-        public static extern void* EventsWithAsync(void* ctx, void* obj);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteEventsStopLocalListen")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool EventsStopLocalListen(void* ctx, void* obj, long hnd);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteEventsLocalListen")]
-        public static extern void EventsLocalListen(void* ctx, void* obj, long hnd, int type);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteEventsIsEnabled")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool EventsIsEnabled(void* ctx, void* obj, int type);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteServicesWithAsync")]
-        public static extern void* ServicesWithAsync(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteServicesWithServerKeepPortable")]
-        public static extern void* ServicesWithServerKeepBinary(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteServicesCancel")]
-        public static extern long ServicesCancel(void* ctx, void* target, char* name);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteServicesCancelAll")]
-        public static extern long ServicesCancelAll(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteServicesGetServiceProxy")]
-        public static extern void* ServicesGetServiceProxy(void* ctx, void* target, char* name,
-            [MarshalAs(UnmanagedType.U1)] bool sticky);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongGet")]
-        public static extern long AtomicLongGet(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongIncrementAndGet")]
-        public static extern long AtomicLongIncrementAndGet(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongAddAndGet")]
-        public static extern long AtomicLongAddAndGet(void* ctx, void* target, long value);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongDecrementAndGet")]
-        public static extern long AtomicLongDecrementAndGet(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongGetAndSet")]
-        public static extern long AtomicLongGetAndSet(void* ctx, void* target, long value);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongCompareAndSetAndGet")]
-        public static extern long AtomicLongCompareAndSetAndGet(void* ctx, void* target, long expVal, long newVal);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongIsClosed")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool AtomicLongIsClosed(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongClose")]
-        public static extern void AtomicLongClose(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceGet")]
-        public static extern long AtomicSequenceGet(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceIncrementAndGet")]
-        public static extern long AtomicSequenceIncrementAndGet(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceAddAndGet")]
-        public static extern long AtomicSequenceAddAndGet(void* ctx, void* target, long value);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceGetBatchSize")]
-        public static extern int AtomicSequenceGetBatchSize(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceSetBatchSize")]
-        public static extern void AtomicSequenceSetBatchSize(void* ctx, void* target, int size);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceIsClosed")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool AtomicSequenceIsClosed(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceClose")]
-        public static extern void AtomicSequenceClose(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicReferenceIsClosed")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool AtomicReferenceIsClosed(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicReferenceClose")]
-        public static extern void AtomicReferenceClose(void* ctx, void* target);
-
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteListenableCancel")]
         [return: MarshalAs(UnmanagedType.U1)]
         public static extern bool ListenableCancel(void* ctx, void* target);
-
-        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteListenableIsCancelled")]
-        [return: MarshalAs(UnmanagedType.U1)]
-        public static extern bool ListenableIsCancelled(void* ctx, void* target);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index 5815b4d..be55ab1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -95,7 +95,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         private const int OpPrepareDotNet = 1;
 
         private delegate long CacheStoreCreateCallbackDelegate(void* target, long memPtr);
-        private delegate int CacheStoreInvokeCallbackDelegate(void* target, long objPtr, long memPtr, void* cb);
+        private delegate int CacheStoreInvokeCallbackDelegate(void* target, long objPtr, long memPtr);
         private delegate void CacheStoreDestroyCallbackDelegate(void* target, long objPtr);
         private delegate long CacheStoreSessionCreateCallbackDelegate(void* target, long storePtr);
 
@@ -305,20 +305,15 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         }
 
         [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
-        private int CacheStoreInvoke(void* target, long objPtr, long memPtr, void* cb)
+        private int CacheStoreInvoke(void* target, long objPtr, long memPtr)
         {
             return SafeCall(() =>
             {
                 var t = _handleRegistry.Get<CacheStore>(objPtr, true);
 
-                IUnmanagedTarget cb0 = null;
-
-                if ((long) cb != 0)
-                    cb0 = new UnmanagedNonReleaseableTarget(_ctx, cb);
-
                 using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).GetStream())
                 {
-                    return t.Invoke(stream, cb0, _ignite);
+                    return t.Invoke(stream, _ignite);
                 }
             });
         }


[07/40] ignite git commit: Fixed TcpDiscoverySnapshotHistoryTest intermittent failures caused by multicast IP finder.

Posted by av...@apache.org.
Fixed TcpDiscoverySnapshotHistoryTest intermittent failures caused by multicast IP finder.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: fa698d6fcfde0006423ef009337dbef58ac62515
Parents: 9f211e4
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Oct 3 13:33:12 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Oct 3 13:33:12 2016 +0300

----------------------------------------------------------------------
 .../tcp/TcpDiscoverySnapshotHistoryTest.java          | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fa698d6f/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java
index 9667fb8..47e9112 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java
@@ -22,24 +22,26 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.discovery.DiscoverySpi;
 import org.apache.ignite.spi.discovery.DiscoverySpiHistorySupport;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
+import java.util.Collections;
+
 import static org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_TOP_HISTORY_SIZE;
 
 /**
  * Tests for topology snapshots history.
  */
 public class TcpDiscoverySnapshotHistoryTest extends GridCommonAbstractTest {
-    /** */
-    public TcpDiscoverySnapshotHistoryTest() {
-        super(false);
-    }
-
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        cfg.setDiscoverySpi(new TcpDiscoverySpi());
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+        ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500"));
+
+        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
         cfg.setCacheConfiguration();
         cfg.setLocalHost("127.0.0.1");
         cfg.setConnectorConfiguration(null);


[37/40] ignite git commit: IGNITE-4054: Hadoop: added map-reduce plan debug output.

Posted by av...@apache.org.
IGNITE-4054: Hadoop: added map-reduce plan debug output.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 43ac3f5d5e8ab664e07f26d99be34f284f7941dd
Parents: 80abd1b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Oct 17 11:26:12 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Oct 17 11:26:12 2016 +0300

----------------------------------------------------------------------
 .../hadoop/HadoopMapReducePlanner.java          |  1 +
 .../processors/hadoop/HadoopExternalSplit.java  |  8 +++
 .../processors/hadoop/HadoopSplitWrapper.java   |  9 +++
 .../hadoop/jobtracker/HadoopJobTracker.java     | 61 ++++++++++++++++++++
 4 files changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/43ac3f5d/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReducePlanner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReducePlanner.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReducePlanner.java
index 185994f..0009c4a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReducePlanner.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReducePlanner.java
@@ -33,6 +33,7 @@ public interface HadoopMapReducePlanner {
      * @param top Topology.
      * @param oldPlan Old plan in case of partial failure.
      * @return Map reduce plan.
+     * @throws IgniteCheckedException If an error occurs.
      */
     public HadoopMapReducePlan preparePlan(HadoopJob job, Collection<ClusterNode> top,
         @Nullable HadoopMapReducePlan oldPlan) throws IgniteCheckedException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/43ac3f5d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopExternalSplit.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopExternalSplit.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopExternalSplit.java
index bd767b3..a9b4532 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopExternalSplit.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopExternalSplit.java
@@ -17,10 +17,13 @@
 
 package org.apache.ignite.internal.processors.hadoop;
 
+import org.apache.ignite.internal.util.typedef.internal.S;
+
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.Arrays;
 
 /**
  * Split serialized in external file.
@@ -85,4 +88,9 @@ public class HadoopExternalSplit extends HadoopInputSplit {
     @Override public int hashCode() {
         return (int)(off ^ (off >>> 32));
     }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(HadoopExternalSplit.class, this, "hosts", Arrays.toString(hosts));
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/43ac3f5d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSplitWrapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSplitWrapper.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSplitWrapper.java
index 511aa5a..fb6d0f3 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSplitWrapper.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSplitWrapper.java
@@ -20,7 +20,10 @@ package org.apache.ignite.internal.processors.hadoop;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.Arrays;
 
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
 /**
@@ -33,6 +36,7 @@ public class HadoopSplitWrapper extends HadoopInputSplit {
     private static final long serialVersionUID = 0L;
 
     /** Native hadoop input split. */
+    @GridToStringExclude
     private byte[] bytes;
 
     /** */
@@ -116,4 +120,9 @@ public class HadoopSplitWrapper extends HadoopInputSplit {
     @Override public int hashCode() {
         return id;
     }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(HadoopSplitWrapper.class, this, "hosts", Arrays.toString(hosts));
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/43ac3f5d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java
index bffb82b..36782bf 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java
@@ -75,6 +75,7 @@ import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteInClosure;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
@@ -313,6 +314,8 @@ public class HadoopJobTracker extends HadoopComponent {
 
             HadoopMapReducePlan mrPlan = mrPlanner.preparePlan(job, ctx.nodes(), null);
 
+            logPlan(info, mrPlan);
+
             HadoopJobMetadata meta = new HadoopJobMetadata(ctx.localNodeId(), jobId, info);
 
             meta.mapReducePlan(mrPlan);
@@ -354,6 +357,64 @@ public class HadoopJobTracker extends HadoopComponent {
     }
 
     /**
+     * Log map-reduce plan if needed.
+     *
+     * @param info Job info.
+     * @param plan Plan.
+     */
+    @SuppressWarnings("StringConcatenationInsideStringBufferAppend")
+    private void logPlan(HadoopJobInfo info, HadoopMapReducePlan plan) {
+        if (log.isDebugEnabled()) {
+            Map<UUID, IgniteBiTuple<Collection<HadoopInputSplit>, int[]>> map = new HashMap<>();
+
+            for (UUID nodeId : plan.mapperNodeIds())
+                map.put(nodeId, new IgniteBiTuple<Collection<HadoopInputSplit>, int[]>(plan.mappers(nodeId), null));
+
+            for (UUID nodeId : plan.reducerNodeIds()) {
+                int[] reducers = plan.reducers(nodeId);
+
+                IgniteBiTuple<Collection<HadoopInputSplit>, int[]> entry = map.get(nodeId);
+
+                if (entry == null)
+                    map.put(nodeId, new IgniteBiTuple<Collection<HadoopInputSplit>, int[]>(null, reducers));
+                else
+                    entry.set2(reducers);
+            }
+
+            StringBuilder details = new StringBuilder("[");
+
+            boolean first = true;
+
+            for (Map.Entry<UUID, IgniteBiTuple<Collection<HadoopInputSplit>, int[]>> entry : map.entrySet()) {
+                if (first)
+                    first = false;
+                else
+                    details.append(", ");
+
+                UUID nodeId = entry.getKey();
+
+                Collection<HadoopInputSplit> mappers = entry.getValue().get1();
+
+                if (mappers == null)
+                    mappers = Collections.emptyList();
+
+                int[] reducers = entry.getValue().get2();
+
+                if (reducers == null)
+                    reducers = new int[0];
+
+                details.append("[nodeId=" + nodeId + ", mappers=" + mappers.size() + ", reducers=" + reducers.length +
+                    ", mapperDetails=" + mappers + ", reducerDetails=" + Arrays.toString(reducers) + ']');
+            }
+
+            details.append(']');
+
+            log.debug("Prepared map-reduce plan [jobName=" + info.jobName() + ", mappers=" + plan.mappers() +
+                ", reducers=" + plan.reducers() + ", details=" + details + ']');
+        }
+    }
+
+    /**
      * Convert Hadoop job metadata to job status.
      *
      * @param meta Metadata.


[32/40] ignite git commit: IGNITE-4066 Fixed NPE.

Posted by av...@apache.org.
IGNITE-4066 Fixed NPE.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: b1ec58f716ece3a5866dd654ebc707bef67caf57
Parents: eaf8ae2
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Thu Oct 13 12:58:22 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Thu Oct 13 12:58:22 2016 +0700

----------------------------------------------------------------------
 .../visor/cache/VisorCacheTypeMetadata.java     | 70 +++++++++++---------
 1 file changed, 37 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b1ec58f7/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
index 870e033..f17e588 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
@@ -111,51 +111,55 @@ public class VisorCacheTypeMetadata implements Serializable, LessNamingBean {
         if (factory != null && factory instanceof CacheJdbcPojoStoreFactory) {
              CacheJdbcPojoStoreFactory jdbcFactory = (CacheJdbcPojoStoreFactory) factory;
 
-            for (JdbcType jdbcType : jdbcFactory.getTypes()) {
-                VisorCacheTypeMetadata meta = metaMap.get(jdbcType.getKeyType());
+            JdbcType[] jdbcTypes = jdbcFactory.getTypes();
 
-                boolean notFound = meta == null;
+            if (jdbcTypes != null && jdbcTypes.length > 0) {
+                for (JdbcType jdbcType : jdbcTypes) {
+                    VisorCacheTypeMetadata meta = metaMap.get(jdbcType.getKeyType());
 
-                if (notFound) {
-                    meta = new VisorCacheTypeMetadata();
+                    boolean notFound = meta == null;
 
-                    meta.keyType = jdbcType.getKeyType();
-                    meta.valType = jdbcType.getValueType();
+                    if (notFound) {
+                        meta = new VisorCacheTypeMetadata();
 
-                    meta.qryFlds = Collections.emptyMap();
-                    meta.ascFlds = Collections.emptyMap();
-                    meta.descFlds = Collections.emptyMap();
-                    meta.txtFlds = Collections.emptyList();
-                    meta.grps = Collections.emptyMap();
-                }
+                        meta.keyType = jdbcType.getKeyType();
+                        meta.valType = jdbcType.getValueType();
 
-                meta.dbSchema = jdbcType.getDatabaseSchema();
-                meta.dbTbl = jdbcType.getDatabaseTable();
+                        meta.qryFlds = Collections.emptyMap();
+                        meta.ascFlds = Collections.emptyMap();
+                        meta.descFlds = Collections.emptyMap();
+                        meta.txtFlds = Collections.emptyList();
+                        meta.grps = Collections.emptyMap();
+                    }
 
-                JdbcTypeField[] keyFields = jdbcType.getKeyFields();
+                    meta.dbSchema = jdbcType.getDatabaseSchema();
+                    meta.dbTbl = jdbcType.getDatabaseTable();
 
-                if (keyFields != null) {
-                    meta.keyFields = new ArrayList<>(keyFields.length);
+                    JdbcTypeField[] keyFields = jdbcType.getKeyFields();
 
-                    for (JdbcTypeField fld : keyFields)
-                        meta.keyFields.add(new VisorCacheTypeFieldMetadata(
-                            fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
-                            fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
-                }
+                    if (keyFields != null) {
+                        meta.keyFields = new ArrayList<>(keyFields.length);
 
-                JdbcTypeField[] valFields = jdbcType.getValueFields();
+                        for (JdbcTypeField fld : keyFields)
+                            meta.keyFields.add(new VisorCacheTypeFieldMetadata(
+                                fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
+                                fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
+                    }
 
-                if (valFields != null) {
-                    meta.valFields = new ArrayList<>(valFields.length);
+                    JdbcTypeField[] valFields = jdbcType.getValueFields();
 
-                    for (JdbcTypeField fld : valFields)
-                        meta.valFields.add(new VisorCacheTypeFieldMetadata(
-                            fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
-                            fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
-                }
+                    if (valFields != null) {
+                        meta.valFields = new ArrayList<>(valFields.length);
 
-                if (notFound)
-                    metas.add(meta);
+                        for (JdbcTypeField fld : valFields)
+                            meta.valFields.add(new VisorCacheTypeFieldMetadata(
+                                fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
+                                fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
+                    }
+
+                    if (notFound)
+                        metas.add(meta);
+                }
             }
         }
 


[08/40] ignite git commit: IGNITE-3980: Processed failing tests in query suites. This closes #1137.

Posted by av...@apache.org.
IGNITE-3980: Processed failing tests in query suites. This closes #1137.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: bba019fd5076412ca43c10a32fd300b6031ccd0b
Parents: fa698d6
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Oct 3 17:25:20 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Oct 3 17:25:20 2016 +0300

----------------------------------------------------------------------
 .../ignite/testframework/IgniteTestSuite.java   | 18 +++++++--
 modules/ignored-tests/pom.xml                   |  8 ++++
 ...gniteIgnoredBinarySimpleMapperTestSuite.java | 41 +++++++++++++++++++
 .../IgniteIgnoredBinaryTestSuite.java           | 42 ++++++++++++++++++++
 .../testsuites/IgniteIgnoredTestSuite.java      |  4 ++
 .../IgniteCacheReplicatedQuerySelfTest.java     |  4 +-
 .../query/IgniteSqlSplitterSelfTest.java        |  4 +-
 .../query/h2/sql/BaseH2CompareQueryTest.java    |  3 +-
 ...narySimpleNameMapperCacheQueryTestSuite.java |  2 -
 .../IgniteCacheQuerySelfTestSuite.java          |  3 +-
 .../IgniteCacheQuerySelfTestSuite2.java         |  3 +-
 11 files changed, 119 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/core/src/test/java/org/apache/ignite/testframework/IgniteTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/IgniteTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testframework/IgniteTestSuite.java
index 1cf69ae..157e1f5 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/IgniteTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/IgniteTestSuite.java
@@ -103,11 +103,21 @@ public class IgniteTestSuite extends TestSuite {
     }
 
     /** {@inheritDoc} */
-    @Override public void addTestSuite(Class<? extends TestCase> testClass) {
-        IgniteTestSuite suite = new IgniteTestSuite(testClass, ignoredOnly);
+    @Override public void addTest(Test test) {
+        // Ignore empty test suites.
+        if (test instanceof IgniteTestSuite) {
+            IgniteTestSuite suite = (IgniteTestSuite)test;
+
+            if (suite.testCount() == 0)
+                return;
+        }
 
-        if (suite.testCount() > 0)
-            addTest(suite);
+        super.addTest(test);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void addTestSuite(Class<? extends TestCase> testClass) {
+        addTest(new IgniteTestSuite(testClass, ignoredOnly));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/ignored-tests/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ignored-tests/pom.xml b/modules/ignored-tests/pom.xml
index 142754e..00c7d55 100644
--- a/modules/ignored-tests/pom.xml
+++ b/modules/ignored-tests/pom.xml
@@ -100,6 +100,14 @@
 
         <dependency>
             <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-indexing</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
             <artifactId>ignite-jta</artifactId>
             <version>${project.version}</version>
         </dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredBinarySimpleMapperTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredBinarySimpleMapperTestSuite.java b/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredBinarySimpleMapperTestSuite.java
new file mode 100644
index 0000000..aa2e219
--- /dev/null
+++ b/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredBinarySimpleMapperTestSuite.java
@@ -0,0 +1,41 @@
+/*
+ * 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.testframework.IgniteTestSuite;
+
+/**
+ * Special test suite with ignored tests for Binary mode.
+ */
+public class IgniteIgnoredBinarySimpleMapperTestSuite extends TestSuite {
+    /**
+     * @return IgniteCache test suite.
+     * @throws Exception Thrown in case of the failure.
+     */
+    public static TestSuite suite() throws Exception {
+        IgniteTestSuite.ignoreDefault(true);
+
+        IgniteTestSuite suite = new IgniteTestSuite(null, "Ignite Ignored Binary Simple Mapper Test Suite");
+
+        /* --- QUERY --- */
+        suite.addTest(IgniteBinarySimpleNameMapperCacheQueryTestSuite.suite());
+
+        return suite;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredBinaryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredBinaryTestSuite.java b/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredBinaryTestSuite.java
new file mode 100644
index 0000000..5116bd7
--- /dev/null
+++ b/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredBinaryTestSuite.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.testframework.IgniteTestSuite;
+
+/**
+ * Special test suite with ignored tests for Binary mode.
+ */
+public class IgniteIgnoredBinaryTestSuite extends TestSuite {
+    /**
+     * @return IgniteCache test suite.
+     * @throws Exception Thrown in case of the failure.
+     */
+    public static TestSuite suite() throws Exception {
+        IgniteTestSuite.ignoreDefault(true);
+
+        IgniteTestSuite suite = new IgniteTestSuite(null, "Ignite Ignored Binary Test Suite");
+
+        /* --- QUERY --- */
+        suite.addTest(IgniteBinaryCacheQueryTestSuite.suite());
+        suite.addTest(IgniteBinaryCacheQueryTestSuite2.suite());
+
+        return suite;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredTestSuite.java b/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredTestSuite.java
index fd92a35..414d166 100644
--- a/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredTestSuite.java
+++ b/modules/ignored-tests/src/test/java/org/apache/ignite/testsuites/IgniteIgnoredTestSuite.java
@@ -46,6 +46,10 @@ public class IgniteIgnoredTestSuite extends TestSuite {
         /* --- JTA --- */
         suite.addTest(IgniteJtaTestSuite.suite());
 
+        /* --- QUERIES --- */
+        suite.addTest(IgniteCacheQuerySelfTestSuite.suite());
+        suite.addTest(IgniteCacheQuerySelfTestSuite2.suite());
+
         /* --- SPRING --- */
         suite.addTest(IgniteSpringTestSuite.suite());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
index 06adb68..a673a73 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
@@ -53,6 +53,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testsuites.IgniteIgnore;
 import org.apache.ignite.transactions.Transaction;
 import org.springframework.util.ReflectionUtils;
 
@@ -354,9 +355,8 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
     /**
      * @throws Exception If failed.
      */
+    @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-613", forceFailure = true)
     public void testNodeLeft() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-613");
-
         Ignite g = startGrid("client");
 
         try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index fd52469..64be936 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -39,6 +39,7 @@ 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.apache.ignite.testsuites.IgniteIgnore;
 
 /**
  * Tests for correct distributed partitioned queries.
@@ -281,9 +282,8 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
     /**
      *
      */
+    @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-1886", forceFailure = true)
     public void testFunctionNpe() {
-        assert false : "https://issues.apache.org/jira/browse/IGNITE-1886";
-
         IgniteCache<Integer, User> userCache = ignite(0).createCache(
             cacheConfig("UserCache", true, Integer.class, User.class));
         IgniteCache<Integer, UserOrder> userOrderCache = ignite(0).createCache(

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
index 46076a9..7cae585 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
@@ -37,6 +37,7 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cache.query.annotations.QuerySqlFunction;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testsuites.IgniteIgnore;
 
 /**
  * Base set of queries to compare query results from h2 database instance and mixed ignite caches (replicated and partitioned)
@@ -204,8 +205,8 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest {
     /**
      * @throws Exception
      */
+    @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-705", forceFailure = true)
     public void testAllExamples() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-705");
 //        compareQueryRes0("select ? limit ? offset ?");
 
 //        compareQueryRes0("select cool1()");

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
index 3eed980..109e244 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.testframework.config.GridTestProperties;
 
 /**
@@ -30,7 +29,6 @@ public class IgniteBinarySimpleNameMapperCacheQueryTestSuite extends TestSuite {
      * @throws Exception In case of error.
      */
     public static TestSuite suite() throws Exception {
-        GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
         GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
 
         return IgniteBinaryCacheQueryTestSuite.suite();

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/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 2174147..d1f4c4a 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
@@ -65,6 +65,7 @@ import org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryTxSelfT
 import org.apache.ignite.internal.processors.query.IgniteSqlSchemaIndexingTest;
 import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest;
 import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest;
+import org.apache.ignite.testframework.IgniteTestSuite;
 
 /**
  * Test suite for cache queries.
@@ -75,7 +76,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
      * @throws Exception If failed.
      */
     public static TestSuite suite() throws Exception {
-        TestSuite suite = new TestSuite("Ignite Cache Queries Test Suite");
+        IgniteTestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite");
 
         // Parsing
         suite.addTestSuite(GridQueryParsingTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bba019fd/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
index e5f4027..40fc157 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceF
 import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest;
 import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryTest;
 import org.apache.ignite.spi.communication.tcp.GridOrderedMessageCancelSelfTest;
+import org.apache.ignite.testframework.IgniteTestSuite;
 
 /**
  * Test suite for cache queries.
@@ -57,7 +58,7 @@ public class IgniteCacheQuerySelfTestSuite2 extends TestSuite {
      * @throws Exception If failed.
      */
     public static TestSuite suite() throws Exception {
-        TestSuite suite = new TestSuite("Ignite Cache Queries Test Suite 2");
+        TestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite 2");
 
         // Scan queries.
         suite.addTestSuite(CacheScanPartitionQueryFallbackSelfTest.class);


[20/40] ignite git commit: IGNITE-3948: Fixed a bug causing TTL manager to continue tracking of evicted entries. This closes #1101.

Posted by av...@apache.org.
IGNITE-3948: Fixed a bug causing TTL manager to continue tracking of evicted entries. This closes #1101.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 1938a17b01fac1e08c30011180bbcc3ed7374d83
Parents: f9a0676
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Oct 11 14:50:18 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 11 14:50:18 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMapEntry.java     |  13 +-
 .../GridCacheTtlManagerEvictionSelfTest.java    | 160 +++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |   2 +
 3 files changed, 173 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1938a17b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index a9ac1e7..5996672 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -29,6 +29,7 @@ import javax.cache.Cache;
 import javax.cache.expiry.ExpiryPolicy;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.EntryProcessorResult;
+
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -4196,8 +4197,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                                 }
                             }
                         }
-                        else
+                        else {
+                            if (this.expireTimeUnlocked() > 0)
+                                cctx.ttl().removeTrackedEntry(this);
+
                             clearIndex(prev);
+                        }
 
                         // Nullify value after swap.
                         value(null);
@@ -4250,8 +4255,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                                     }
                                 }
                             }
-                            else
+                            else {
+                                if (this.expireTimeUnlocked() > 0)
+                                    cctx.ttl().removeTrackedEntry(this);
+
                                 clearIndex(prevVal);
+                            }
 
                             // Nullify value after swap.
                             value(null);

http://git-wip-us.apache.org/repos/asf/ignite/blob/1938a17b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java
new file mode 100644
index 0000000..4c7c1c0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+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.concurrent.TimeUnit;
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
+
+/**
+ * TTL manager eviction self test.
+ */
+public class GridCacheTtlManagerEvictionSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final int ENTRIES_TO_PUT = 10_100;
+
+    /** */
+    private static final int ENTRIES_LIMIT = 1_000;
+
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** Cache mode. */
+    private volatile CacheMode cacheMode;
+
+    /** Cache memory mode. */
+    private volatile CacheMemoryMode cacheMemoryMode;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setCacheMode(cacheMode);
+        ccfg.setMemoryMode(cacheMemoryMode);
+        ccfg.setEagerTtl(true);
+        ccfg.setSwapEnabled(false);
+        ccfg.setEvictionPolicy(new FifoEvictionPolicy(ENTRIES_LIMIT, 100));
+        ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12)));
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLocalEviction() throws Exception {
+        checkEviction(CacheMode.LOCAL, CacheMemoryMode.ONHEAP_TIERED);
+        checkEviction(CacheMode.LOCAL, CacheMemoryMode.OFFHEAP_TIERED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPartitionedEviction() throws Exception {
+        checkEviction(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED);
+        checkEviction(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testReplicatedEviction() throws Exception {
+        checkEviction(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED);
+        checkEviction(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED);
+    }
+
+    /**
+     * @param mode Cache mode.
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ConstantConditions")
+    private void checkEviction(CacheMode mode, CacheMemoryMode memoryMode) throws Exception {
+        cacheMode = mode;
+        cacheMemoryMode = memoryMode;
+
+        final IgniteKernal g = (IgniteKernal)startGrid(0);
+
+        try {
+            final IgniteCache<Object, Object> cache = g.cache(null);
+
+            final GridCacheContext<Object, Object> cctx = g.cachex(null).context();
+
+            for (int i = 1; i <= ENTRIES_TO_PUT; i++) {
+                String key = "Some test entry key#" + i;
+                String value = "Some test entry value#" + i;
+
+                cache.put(key, value);
+            }
+
+            GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                @Override public boolean apply() {
+                    return (cctx.isSwapOrOffheapEnabled()) ?
+                        ENTRIES_TO_PUT == cctx.ttl().pendingSize() :
+                        ENTRIES_LIMIT == cctx.ttl().pendingSize();
+                }
+            }, 3_000);
+
+            if (log.isTraceEnabled())
+                cctx.ttl().printMemoryStats();
+
+            final String firstKey = "Some test entry key#0";
+            final String lastKey = "Some test entry key#" + ENTRIES_TO_PUT;
+
+            if (cctx.isSwapOrOffheapEnabled()) {
+                assertTrue("last key should NOT be evicted", cache.containsKey(lastKey));
+
+                assertEquals(ENTRIES_TO_PUT, cctx.ttl().pendingSize());
+            }
+            else {
+                assertFalse("first key should be evicted", cache.containsKey(firstKey));
+
+                assertTrue("last key should NOT be evicted", cache.containsKey(lastKey));
+
+                assertEquals("Ttl Manager should NOT track evicted entries", ENTRIES_LIMIT, cctx.ttl().pendingSize());
+            }
+        }
+        finally {
+            Ignition.stopAll(true);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1938a17b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 5ad4cb8..d8231fc 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -83,6 +83,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheStorePutxSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheStoreValueBytesSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheSwapPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheSwapReloadSelfTest;
+import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerEvictionSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheTxPartitionedLocalStoreSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicInvokeTest;
@@ -268,6 +269,7 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheAsyncOperationsLimitSelfTest.class);
         suite.addTestSuite(IgniteCacheManyAsyncOperationsTest.class);
         suite.addTestSuite(GridCacheTtlManagerSelfTest.class);
+        suite.addTestSuite(GridCacheTtlManagerEvictionSelfTest.class);
         suite.addTestSuite(GridCacheLifecycleAwareSelfTest.class);
         suite.addTestSuite(IgniteCacheAtomicStopBusySelfTest.class);
         suite.addTestSuite(IgniteCacheTransactionalStopBusySelfTest.class);


[34/40] ignite git commit: IGNITE-4060: Fixed a bug in RoundRobinLoadBalancing API causing exception when running closures after client node reconnect. This closes #1157.

Posted by av...@apache.org.
IGNITE-4060: Fixed a bug in RoundRobinLoadBalancing API causing exception when running closures after client node reconnect. This closes #1157.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 7adfbcf1ee7bbe0beb95fa82749a2e04449de8fa
Parents: 447e07c
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Fri Oct 14 17:48:14 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Oct 14 17:48:14 2016 +0300

----------------------------------------------------------------------
 .../RoundRobinGlobalLoadBalancer.java           | 16 +++-
 ...RoundRobinErrorAfterClientReconnectTest.java | 99 ++++++++++++++++++++
 .../testsuites/IgniteComputeGridTestSuite.java  |  2 +
 3 files changed, 114 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7adfbcf1/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/roundrobin/RoundRobinGlobalLoadBalancer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/roundrobin/RoundRobinGlobalLoadBalancer.java b/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/roundrobin/RoundRobinGlobalLoadBalancer.java
index c48b819..9ce854f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/roundrobin/RoundRobinGlobalLoadBalancer.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/roundrobin/RoundRobinGlobalLoadBalancer.java
@@ -26,7 +26,6 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
@@ -38,6 +37,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.IgniteSpiContext;
 
+import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_RECONNECTED;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
@@ -101,6 +101,16 @@ class RoundRobinGlobalLoadBalancer {
                                 nodeList = new GridNodeList(0, newNodes);
                             }
                         }
+                        else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) {
+                            Collection<ClusterNode> nodes = ((DiscoveryEvent)evt).topologyNodes();
+
+                            List<UUID> newNodes = new ArrayList<>(nodes.size());
+
+                            for (ClusterNode node : nodes)
+                                newNodes.add(node.id());
+
+                            nodeList = new GridNodeList(0, newNodes);
+                        }
                         else {
                             assert evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED;
 
@@ -119,7 +129,7 @@ class RoundRobinGlobalLoadBalancer {
                     }
                 }
             },
-            EVT_NODE_FAILED, EVT_NODE_JOINED, EVT_NODE_LEFT
+            EVT_NODE_FAILED, EVT_NODE_JOINED, EVT_NODE_LEFT, EVT_CLIENT_NODE_RECONNECTED
         );
 
         synchronized (mux) {
@@ -147,7 +157,7 @@ class RoundRobinGlobalLoadBalancer {
      *
      * @param top Topology to pick from.
      * @return Best balanced node.
-     * @throws IgniteCheckedException Thrown in case of any error.
+     * @throws IgniteException Thrown in case of any error.
      */
     ClusterNode getBalancedNode(Collection<ClusterNode> top) throws IgniteException {
         assert !F.isEmpty(top);

http://git-wip-us.apache.org/repos/asf/ignite/blob/7adfbcf1/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java
new file mode 100644
index 0000000..0ec3b6b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test to reproduce IGNITE-4060.
+ */
+public class IgniteRoundRobinErrorAfterClientReconnectTest extends GridCommonAbstractTest {
+    /** Server index. */
+    private static final int SRV_IDX = 0;
+
+    /** Client index. */
+    private static final int CLI_IDX = 1;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        startGrid(SRV_IDX);
+        startGrid(CLI_IDX);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        if (gridName.endsWith("1"))
+            cfg.setClientMode(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 60000;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClientReconnect() throws Exception {
+        final Ignite cli = grid(CLI_IDX);
+
+        final GridFutureAdapter<Boolean> fut = new GridFutureAdapter<>();
+
+        cli.events().localListen(new IgnitePredicate<Event>() {
+            @Override public boolean apply(Event event) {
+                try {
+                    cli.compute().apply(new IgniteClosure<String, Void>() {
+                        @Override public Void apply(String arg) {
+                            return null;
+                        }
+                    }, "Hello!");
+
+                    fut.onDone(true);
+
+                    return true;
+                }
+                catch (Exception e) {
+                    fut.onDone(e);
+
+                    return false;
+                }
+            }
+        }, EventType.EVT_CLIENT_NODE_RECONNECTED);
+
+        stopGrid(SRV_IDX);
+        startGrid(SRV_IDX);
+
+        assert fut.get();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7adfbcf1/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
index 699ad0c..a1a75f8 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
@@ -66,6 +66,7 @@ import org.apache.ignite.internal.IgniteComputeEmptyClusterGroupTest;
 import org.apache.ignite.internal.IgniteComputeTopologyExceptionTest;
 import org.apache.ignite.internal.IgniteExecutorServiceTest;
 import org.apache.ignite.internal.IgniteExplicitImplicitDeploymentSelfTest;
+import org.apache.ignite.internal.IgniteRoundRobinErrorAfterClientReconnectTest;
 import org.apache.ignite.internal.TaskNodeRestartTest;
 import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManagerSelfTest;
 import org.apache.ignite.internal.managers.checkpoint.GridCheckpointTaskSelfTest;
@@ -148,6 +149,7 @@ public class IgniteComputeGridTestSuite {
         suite.addTestSuite(IgniteComputeTopologyExceptionTest.class);
         suite.addTestSuite(GridTaskFailoverAffinityRunTest.class);
         suite.addTestSuite(TaskNodeRestartTest.class);
+        suite.addTestSuite(IgniteRoundRobinErrorAfterClientReconnectTest.class);
 
         return suite;
     }


[05/40] ignite git commit: ignite-3601 Do not check version on commit for read-only serializable transactions.

Posted by av...@apache.org.
ignite-3601 Do not check version on commit for read-only serializable transactions.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 0b66d2d7b695cf370a4b8a717844ad67742c6090
Parents: 59b46d3
Author: sboikov <sb...@gridgain.com>
Authored: Mon Oct 3 12:04:03 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Oct 3 12:04:03 2016 +0300

----------------------------------------------------------------------
 .../colocated/GridDhtDetachedCacheEntry.java    |   5 +
 .../cache/distributed/near/GridNearTxLocal.java |   2 +-
 .../transactions/IgniteTxLocalAdapter.java      |  62 ++++---
 .../cache/CacheGetEntryAbstractTest.java        |  38 +++++
 .../processors/cache/CachePutIfAbsentTest.java  | 161 +++++++++++++++++++
 .../CacheSerializableTransactionsTest.java      |  70 +++-----
 .../processors/cache/CacheTxFastFinishTest.java |   2 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 8 files changed, 276 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0b66d2d7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java
index db91134..2e05560 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java
@@ -97,4 +97,9 @@ public class GridDhtDetachedCacheEntry extends GridDistributedCacheEntry {
         // No-op for detached cache entry.
         return true;
     }
+
+    /** {@inheritDoc} */
+    @Override public int partition() {
+        return cctx.affinity().partition(key);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b66d2d7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 410baf8..ed37059 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -953,7 +953,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
      * @return {@code True} if 'fast finish' path can be used for transaction completion.
      */
     private boolean fastFinish() {
-        return writeMap().isEmpty() && ((optimistic() && !serializable()) || readMap().isEmpty());
+        return writeMap().isEmpty() && (optimistic() || readMap().isEmpty());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b66d2d7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index fe69536..6d21dcf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -2269,7 +2269,16 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                             addInvokeResult(e, cacheVal, ret, ver);
                         }
                         else {
-                            boolean success = !hasFilters || isAll(e.context(), key, cacheVal, filter);
+                            boolean success;
+
+                            if (hasFilters) {
+                                success = isAll(e.context(), key, cacheVal, filter);
+
+                                if (!success)
+                                    e.value(cacheVal, false, false);
+                            }
+                            else
+                                success = true;
 
                             ret.set(cacheCtx, cacheVal, success, keepBinary);
                         }
@@ -2411,25 +2420,43 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                     else
                         old = retval ? entry.rawGetOrUnmarshal(false) : entry.rawGet();
 
+                    final GridCacheOperation op = lockOnly ? NOOP : rmv ? DELETE :
+                        entryProcessor != null ? TRANSFORM : old != null ? UPDATE : CREATE;
+
                     if (old != null && hasFilters && !filter(entry.context(), cacheKey, old, filter)) {
                         ret.set(cacheCtx, old, false, keepBinary);
 
                         if (!readCommitted()) {
-                            // Enlist failed filters as reads for non-read-committed mode,
-                            // so future ops will get the same values.
-                            txEntry = addEntry(READ,
-                                old,
-                                null,
-                                null,
-                                entry,
-                                null,
-                                CU.empty0(),
-                                false,
-                                -1L,
-                                -1L,
-                                null,
-                                skipStore,
-                                keepBinary);
+                            if (optimistic() && serializable()) {
+                                txEntry = addEntry(op,
+                                    old,
+                                    entryProcessor,
+                                    invokeArgs,
+                                    entry,
+                                    expiryPlc,
+                                    filter,
+                                    true,
+                                    drTtl,
+                                    drExpireTime,
+                                    drVer,
+                                    skipStore,
+                                    keepBinary);
+                            }
+                            else {
+                                txEntry = addEntry(READ,
+                                    old,
+                                    null,
+                                    null,
+                                    entry,
+                                    null,
+                                    CU.empty0(),
+                                    false,
+                                    -1L,
+                                    -1L,
+                                    null,
+                                    skipStore,
+                                    keepBinary);
+                            }
 
                             txEntry.markValid();
 
@@ -2446,9 +2473,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                         break; // While.
                     }
 
-                    final GridCacheOperation op = lockOnly ? NOOP : rmv ? DELETE :
-                        entryProcessor != null ? TRANSFORM : old != null ? UPDATE : CREATE;
-
                     txEntry = addEntry(op,
                         cacheCtx.toCacheObject(val),
                         entryProcessor,

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b66d2d7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
index 34480a2..2eab6d9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
@@ -40,6 +40,7 @@ import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.transactions.Transaction;
 import org.apache.ignite.transactions.TransactionConcurrency;
 import org.apache.ignite.transactions.TransactionIsolation;
+import org.apache.ignite.transactions.TransactionOptimisticException;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -52,6 +53,7 @@ import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
 import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
 import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
 import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
 
 /**
  * Test getEntry and getEntries methods.
@@ -247,6 +249,10 @@ public abstract class CacheGetEntryAbstractTest extends GridCacheAbstractSelfTes
 
                 testConcurrentTx(cache, PESSIMISTIC, REPEATABLE_READ, oneEntry);
                 testConcurrentTx(cache, PESSIMISTIC, READ_COMMITTED, oneEntry);
+
+                testConcurrentOptimisticTxGet(cache, REPEATABLE_READ);
+                testConcurrentOptimisticTxGet(cache, READ_COMMITTED);
+                testConcurrentOptimisticTxGet(cache, SERIALIZABLE);
             }
         }
         finally {
@@ -256,6 +262,38 @@ public abstract class CacheGetEntryAbstractTest extends GridCacheAbstractSelfTes
 
     /**
      * @param cache Cache.
+     * @param txIsolation Transaction isolation.
+     * @throws Exception If failed.
+     */
+    private void testConcurrentOptimisticTxGet(final IgniteCache<Integer, TestValue> cache,
+        final TransactionIsolation txIsolation) throws Exception {
+        GridTestUtils.runMultiThreaded(new Runnable() {
+            @Override public void run() {
+                final int key = 42;
+
+                IgniteTransactions txs = grid(0).transactions();
+
+                cache.put(key, new TestValue(key));
+
+                long stopTime = System.currentTimeMillis() + 3000;
+
+                while (System.currentTimeMillis() < stopTime) {
+                    try (Transaction tx = txs.txStart(OPTIMISTIC, txIsolation)) {
+                        cache.get(key);
+
+                        tx.commit();
+                    }
+                    catch (TransactionOptimisticException e) {
+                        assertTrue("Should not throw optimistic exception in only read TX. Tx isolation: "
+                            + txIsolation, false);
+                    }
+                }
+            }
+        }, 10, "tx-thread");
+    }
+
+    /**
+     * @param cache Cache.
      * @param txConcurrency Transaction concurrency.
      * @param txIsolation Transaction isolation.
      * @param oneEntry If {@code true} then single entry is tested.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b66d2d7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutIfAbsentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutIfAbsentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutIfAbsentTest.java
new file mode 100644
index 0000000..6ed9049
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutIfAbsentTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+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.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class CachePutIfAbsentTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final int SRVS = 4;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGridsMultiThreaded(SRVS);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 5 * 60_000;
+    }
+
+    /**
+     * @return Cache configurations.
+     */
+    private List<CacheConfiguration<Integer, Integer>> cacheConfigurations() {
+        List<CacheConfiguration<Integer, Integer>> ccfgs = new ArrayList<>();
+
+        ccfgs.add(cacheConfiguration(REPLICATED, FULL_SYNC, 0));
+
+        ccfgs.add(cacheConfiguration(PARTITIONED, FULL_SYNC, 0));
+        ccfgs.add(cacheConfiguration(PARTITIONED, FULL_SYNC, 1));
+        ccfgs.add(cacheConfiguration(PARTITIONED, FULL_SYNC, 2));
+
+        return ccfgs;
+    }
+
+    /**
+     * @param cacheMode Cache mode.
+     * @param syncMode Write synchronization mode.
+     * @param backups Number of backups.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration<Integer, Integer> cacheConfiguration(
+        CacheMode cacheMode,
+        CacheWriteSynchronizationMode syncMode,
+        int backups) {
+        CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>();
+
+        ccfg.setCacheMode(cacheMode);
+        ccfg.setAtomicityMode(TRANSACTIONAL);
+        ccfg.setWriteSynchronizationMode(syncMode);
+
+        if (cacheMode == PARTITIONED)
+            ccfg.setBackups(backups);
+
+        return ccfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxConflictGetAndPutIfAbsent() throws Exception {
+        Ignite ignite0 = ignite(0);
+
+        final IgniteTransactions txs = ignite0.transactions();
+
+        for (CacheConfiguration<Integer, Integer> ccfg : cacheConfigurations()) {
+            try {
+                IgniteCache<Integer, Integer> cache = ignite0.createCache(ccfg);
+
+                ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+                for (int i = 0; i < 10; i++) {
+                    Integer key = rnd.nextInt(10_000);
+
+                    cache.put(key, 2);
+
+                    for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+                        for (TransactionIsolation isolation : TransactionIsolation.values()) {
+                            try (Transaction tx = txs.txStart(concurrency, isolation)) {
+                                Object old = cache.getAndPutIfAbsent(key, 3);
+
+                                assertEquals(2, old);
+
+                                Object val = cache.get(key);
+
+                                assertEquals(2, val);
+
+                                tx.commit();
+                            }
+
+                            assertEquals((Integer)2, cache.get(key));
+                        }
+                    }
+                }
+            }
+            finally {
+                ignite0.destroyCache(ccfg.getName());
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b66d2d7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
index 3d4f850..6a73f79 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
@@ -709,6 +709,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
 
     /**
      * @param noVal If {@code true} there is no cache value when read in tx.
+     * @param needVer If {@code true} then gets entry, otherwise just value.
      * @throws Exception If failed.
      */
     private void txConflictRead(boolean noVal, boolean needVer) throws Exception {
@@ -735,28 +736,21 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
                         cache.put(key, expVal);
                     }
 
-                    try {
-                        try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                            if (needVer) {
-                                CacheEntry<Integer, Integer> val = cache.getEntry(key);
-
-                                assertEquals(expVal, val == null ? null : val.getValue());
-                            }
-                            else {
-                                Integer val = cache.get(key);
-
-                                assertEquals(expVal, val);
-                            }
+                    try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+                        if (needVer) {
+                            CacheEntry<Integer, Integer> val = cache.getEntry(key);
 
-                            updateKey(cache, key, 1);
+                            assertEquals(expVal, val == null ? null : val.getValue());
+                        }
+                        else {
+                            Integer val = cache.get(key);
 
-                            tx.commit();
+                            assertEquals(expVal, val);
                         }
 
-                        fail();
-                    }
-                    catch (TransactionOptimisticException e) {
-                        log.info("Expected exception: " + e);
+                        updateKey(cache, key, 1);
+
+                        tx.commit();
                     }
 
                     checkValue(key, 1, cache.getName());
@@ -2625,21 +2619,14 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
             cache0.put(key2, -1);
             cache0.put(key3, -1);
 
-            try {
-                try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                    cache.get(key1);
-                    cache.get(key2);
-                    cache.get(key3);
-
-                    updateKey(near ? cache : cache0, key2, -2);
+            try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+                cache.get(key1);
+                cache.get(key2);
+                cache.get(key3);
 
-                    tx.commit();
-                }
+                updateKey(near ? cache : cache0, key2, -2);
 
-                fail();
-            }
-            catch (TransactionOptimisticException e) {
-                log.info("Expected exception: " + e);
+                tx.commit();
             }
 
             checkValue(key1, -1, cacheName);
@@ -2890,23 +2877,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
                 checkValue(key1, newVal, CACHE1);
                 checkValue(key2, newVal, CACHE2);
 
-                try {
-                    try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                        Object val1 = cache1.get(key1);
-                        Object val2 = cache2.get(key2);
-
-                        assertEquals(newVal, val1);
-                        assertEquals(newVal, val2);
+                try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+                    Object val1 = cache1.get(key1);
+                    Object val2 = cache2.get(key2);
 
-                        updateKey(cache2, key2, newVal);
+                    assertEquals(newVal, val1);
+                    assertEquals(newVal, val2);
 
-                        tx.commit();
-                    }
+                    updateKey(cache2, key2, newVal);
 
-                    fail();
-                }
-                catch (TransactionOptimisticException e) {
-                    log.info("Expected exception: " + e);
+                    tx.commit();
                 }
 
                 try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b66d2d7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java
index 35b1405..f9c6683 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java
@@ -173,7 +173,7 @@ public class CacheTxFastFinishTest extends GridCommonAbstractTest {
                 try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
                     cache.get(i);
 
-                    checkNormalTxFinish(tx, commit);
+                    checkFastTxFinish(tx, commit);
                 }
 
                 try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b66d2d7/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index c494e73..2b446bb 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticReadC
 import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticRepeatableReadSeltTest;
 import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticSerializableSeltTest;
 import org.apache.ignite.internal.processors.cache.CacheOffheapMapEntrySelfTest;
+import org.apache.ignite.internal.processors.cache.CachePutIfAbsentTest;
 import org.apache.ignite.internal.processors.cache.CacheReadThroughAtomicRestartSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheReadThroughLocalAtomicRestartSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheReadThroughLocalRestartSelfTest;
@@ -326,6 +327,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteCachePrimarySyncTest.class);
         suite.addTestSuite(IgniteTxCachePrimarySyncTest.class);
         suite.addTestSuite(IgniteTxCacheWriteSynchronizationModesMultithreadedTest.class);
+        suite.addTestSuite(CachePutIfAbsentTest.class);
 
         suite.addTestSuite(MarshallerCacheJobRunNodeRestartTest.class);
 


[36/40] ignite git commit: GG-11360 - Implement SQL queries cancellation (#18)

Posted by av...@apache.org.
GG-11360 - Implement SQL queries cancellation (#18)

* GG-11360 Merged IGNITE-2680 to ignite-1.6.3.

* GG-11360 Test cleanup.

* GG-11360 Fixing broken tests.

* GG-11360 Fixing test.

* GG-11360 Fixing test.

* GG-11360 Fixing broken tests.

* GG-11360 Added test for forever-running query cancellation on node restart.

* GG-11360 Fixing race.

* GG-11360 Added test for forever-running query cancellation on node stop.

* GG-11360 Cleanup.

* GG-11360 Support for local query cancellation/timeout.

* GG-11360 Increase test duration.

* GG-11360 Remove redundant catch block.

* GG-11360 Fix formatting.

* GG-11360 Fix formatting.

* GG-11360 Fix formatting.

* GG-11360 Fix formatting.

* GG-11360 Fix formatting.

* GG-11360 Fix formatting.

* GG-11360 Fix formatting.

* GG-11360 Fix formatting.

* GG-11360 Simplify test.

* GG-11360 Simplify test.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* GG-11360 Fixing issues.

* Merge remote-tracking branch 'remotes/gg/ignite-1.6.10' into ignite-gg-11360

Conflicts:
	modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java

* GG-11360 Review fixes.

* GG-11360 Review fixes.

* GG-11360 Review fixes.

* GG-11360 Review fixes.

* GG-11360 Review fixes.

* GG-11360 Review fixes.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 80abd1b72e4fc7b0b95212e7f53c700c0fe21156
Parents: 7adfbcf
Author: Aleksei Scherbakov <al...@gmail.com>
Authored: Fri Oct 14 19:33:07 2016 +0300
Committer: Sergi Vladykin <sv...@users.noreply.github.com>
Committed: Fri Oct 14 19:33:07 2016 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteScheduler.java |  13 +
 .../cache/query/QueryCancelledException.java    |  35 +++
 .../apache/ignite/cache/query/QueryCursor.java  |   8 +-
 .../ignite/cache/query/SqlFieldsQuery.java      |  26 ++
 .../org/apache/ignite/cache/query/SqlQuery.java |  25 ++
 .../ignite/internal/IgniteSchedulerImpl.java    |  18 ++
 .../processors/cache/QueryCursorImpl.java       |  92 +++++--
 .../processors/query/GridQueryCancel.java       |  84 +++++++
 .../processors/query/GridQueryFieldsResult.java |   3 +-
 .../query/GridQueryFieldsResultAdapter.java     |   3 +-
 .../processors/query/GridQueryIndexing.java     |  26 +-
 .../processors/query/GridQueryProcessor.java    | 115 +++++----
 .../twostep/messages/GridQueryFailResponse.java |  34 ++-
 .../h2/twostep/messages/GridQueryRequest.java   |  31 ++-
 .../processors/query/h2/IgniteH2Indexing.java   | 177 ++++++++++---
 .../query/h2/twostep/GridMapQueryExecutor.java  |  42 +++-
 .../h2/twostep/GridReduceQueryExecutor.java     |  99 ++++++--
 ...niteCacheDistributedQueryCancelSelfTest.java | 176 +++++++++++++
 ...butedQueryStopOnCancelOrTimeoutSelfTest.java | 248 +++++++++++++++++++
 .../IgniteCacheQueryNodeRestartSelfTest2.java   | 125 ++++++----
 ...eCacheLocalQueryCancelOrTimeoutSelfTest.java | 158 ++++++++++++
 .../h2/GridIndexingSpiAbstractSelfTest.java     |   9 +-
 .../IgniteCacheQuerySelfTestSuite2.java         |   8 +
 23 files changed, 1341 insertions(+), 214 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/IgniteScheduler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteScheduler.java b/modules/core/src/main/java/org/apache/ignite/IgniteScheduler.java
index b0ea960..2e2553b 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteScheduler.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteScheduler.java
@@ -17,7 +17,9 @@
 
 package org.apache.ignite;
 
+import java.io.Closeable;
 import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgniteRunnable;
@@ -61,6 +63,17 @@ public interface IgniteScheduler {
     public IgniteFuture<?> runLocal(@Nullable Runnable r);
 
     /**
+     * Executes given closure after the delay.
+     * <p>
+     * Note that class {@link IgniteRunnable} implements {@link Runnable}
+     * @param r Runnable to execute.
+     * @param delay Initial delay.
+     * @param timeUnit Time granularity.
+     * @return java.io.Closeable which can be used to cancel execution.
+     */
+    public Closeable runLocal(@Nullable Runnable r, long delay, TimeUnit timeUnit);
+
+    /**
      * Executes given callable on internal system thread pool asynchronously.
      * <p>
      * Note that class {@link IgniteRunnable} implements {@link Runnable} and class {@link IgniteOutClosure}

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCancelledException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCancelledException.java b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCancelledException.java
new file mode 100644
index 0000000..5f5ffdc
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCancelledException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.query;
+
+import org.apache.ignite.IgniteCheckedException;
+
+/**
+ * The exception is thrown if a query was cancelled or timed out while executing.
+ */
+public class QueryCancelledException extends IgniteCheckedException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * Default constructor.
+     */
+    public QueryCancelledException() {
+        super("The query was cancelled while executing.");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCursor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCursor.java b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCursor.java
index 84b6862..1af47ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCursor.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryCursor.java
@@ -22,8 +22,6 @@ import java.util.List;
 /**
  * Query result cursor. Implements {@link Iterable} only for convenience, e.g. {@link #iterator()}
  * can be obtained only once. Also if iteration is started then {@link #getAll()} method calls are prohibited.
- * <p>
- * Not thread safe and must be used from single thread only.
  */
 public interface QueryCursor<T> extends Iterable<T>, AutoCloseable {
     /**
@@ -39,7 +37,11 @@ public interface QueryCursor<T> extends Iterable<T>, AutoCloseable {
     public List<T> getAll();
 
     /**
-     * Closes all resources related to this cursor.
+     * Closes all resources related to this cursor. If the query execution is in progress
+     * (which is possible in case of invoking from another thread), a cancel will be attempted.
+     * Sequential calls to this method have no effect.
+     * <p>
+     * Note: don't forget to close query cursors. Not doing so may lead to various resource leaks.
      */
     @Override public void close();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
index b2dd181..d1a5117 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
@@ -18,7 +18,9 @@
 package org.apache.ignite.cache.query;
 
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -56,6 +58,9 @@ public final class SqlFieldsQuery extends Query<List<?>> {
     /** Collocation flag. */
     private boolean collocated;
 
+    /** Query timeout in millis. */
+    private int timeout;
+
     /**
      * Constructs SQL fields query.
      *
@@ -121,6 +126,27 @@ public final class SqlFieldsQuery extends Query<List<?>> {
     }
 
     /**
+     * Gets the query execution timeout in milliseconds.
+     *
+     * @return Timeout value.
+     */
+    public int getTimeout() {
+        return timeout;
+    }
+
+    /**
+     * Sets the query execution timeout. Query will be automatically cancelled if the execution timeout is exceeded.
+     * @param timeout Timeout value. Zero value disables timeout.
+     * @param timeUnit Time unit.
+     * @return {@code this} For chaining.
+     */
+    public SqlFieldsQuery setTimeout(int timeout, TimeUnit timeUnit) {
+        this.timeout = GridQueryProcessor.validateTimeout(timeout, timeUnit);
+
+        return this;
+    }
+
+    /**
      * Checks if this query is collocated.
      *
      * @return {@code true} If the query is collocated.

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
index be3b390..51c6cb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.cache.query;
 
+import java.util.concurrent.TimeUnit;
 import javax.cache.Cache;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
@@ -43,6 +44,9 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
     @GridToStringInclude
     private Object[] args;
 
+    /** Timeout in millis. */
+    private int timeout;
+
     /**
      * Constructs query for the given type name and SQL query.
      *
@@ -130,6 +134,27 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
         return this;
     }
 
+    /**
+     * Gets the query execution timeout in milliseconds.
+     *
+     * @return Timeout value.
+     */
+    public int getTimeout() {
+        return timeout;
+    }
+
+    /**
+     * Sets the query execution timeout. Query will be automatically cancelled if the execution timeout is exceeded.
+     * @param timeout Timeout value. Zero value disables timeout.
+     * @param timeUnit Time granularity.
+     * @return {@code this} For chaining.
+     */
+    public SqlQuery<K, V> setTimeout(int timeout, TimeUnit timeUnit) {
+        this.timeout = GridQueryProcessor.validateTimeout(timeout, timeUnit);
+
+        return this;
+    }
+
     /** {@inheritDoc} */
     @Override public SqlQuery<K, V> setPageSize(int pageSize) {
         return (SqlQuery<K, V>)super.setPageSize(pageSize);

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/IgniteSchedulerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteSchedulerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteSchedulerImpl.java
index ed8d1a4..623b1f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteSchedulerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteSchedulerImpl.java
@@ -17,17 +17,20 @@
 
 package org.apache.ignite.internal;
 
+import java.io.Closeable;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamException;
 import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
 import org.apache.ignite.IgniteScheduler;
 import org.apache.ignite.internal.util.future.IgniteFutureImpl;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.scheduler.SchedulerFuture;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * {@link IgniteScheduler} implementation.
@@ -68,6 +71,21 @@ public class IgniteSchedulerImpl implements IgniteScheduler, Externalizable {
     }
 
     /** {@inheritDoc} */
+    @Override public Closeable runLocal(@Nullable Runnable r, long delay, TimeUnit timeUnit) {
+        A.notNull(r, "r");
+        A.ensure(delay > 0, "Illegal delay");
+
+        guard();
+
+        try {
+            return ctx.timeout().schedule(r, timeUnit.toMillis(delay), -1);
+        }
+        finally {
+            unguard();
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public <R> IgniteFuture<R> callLocal(Callable<R> c) {
         A.notNull(c, "c");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/QueryCursorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/QueryCursorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/QueryCursorImpl.java
index 672a37d..f68426e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/QueryCursorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/QueryCursorImpl.java
@@ -20,15 +20,28 @@ package org.apache.ignite.internal.processors.cache;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+import javax.cache.CacheException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.query.QueryCancelledException;
 import org.apache.ignite.internal.processors.cache.query.QueryCursorEx;
+import org.apache.ignite.internal.processors.query.GridQueryCancel;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
 
+import static org.apache.ignite.internal.processors.cache.QueryCursorImpl.State.CLOSED;
+import static org.apache.ignite.internal.processors.cache.QueryCursorImpl.State.EXECUTION;
+import static org.apache.ignite.internal.processors.cache.QueryCursorImpl.State.IDLE;
+import static org.apache.ignite.internal.processors.cache.QueryCursorImpl.State.RESULT_READY;
+
 /**
  * Query cursor implementation.
  */
 public class QueryCursorImpl<T> implements QueryCursorEx<T> {
+    /** */
+    private final static AtomicReferenceFieldUpdater<QueryCursorImpl, State> STATE_UPDATER =
+            AtomicReferenceFieldUpdater.newUpdater(QueryCursorImpl.class, State.class, "state");
+
     /** Query executor. */
     private Iterable<T> iterExec;
 
@@ -36,29 +49,43 @@ public class QueryCursorImpl<T> implements QueryCursorEx<T> {
     private Iterator<T> iter;
 
     /** */
-    private boolean iterTaken;
+    private volatile State state = IDLE;
 
     /** */
     private List<GridQueryFieldMetadata> fieldsMeta;
 
+    /** */
+    private final GridQueryCancel cancel;
+
     /**
      * @param iterExec Query executor.
+     * @param cancel Cancellation closure.
      */
-    public QueryCursorImpl(Iterable<T> iterExec) {
+    public QueryCursorImpl(Iterable<T> iterExec, GridQueryCancel cancel) {
         this.iterExec = iterExec;
+        this.cancel = cancel;
+    }
+
+    /**
+     * @param iterExec Query executor.
+     */
+    public QueryCursorImpl(Iterable<T> iterExec) {
+        this(iterExec, null);
     }
 
     /** {@inheritDoc} */
     @Override public Iterator<T> iterator() {
-        if (iter == null && iterTaken)
-            throw new IgniteException("Cursor is closed.");
+        if (!STATE_UPDATER.compareAndSet(this, IDLE, EXECUTION))
+            throw new IgniteException("Iterator is already fetched or query was cancelled.");
 
-        if (iterTaken)
-            throw new IgniteException("Iterator is already taken from this cursor.");
+        iter = iterExec.iterator();
 
-        iterTaken = true;
+        if (!STATE_UPDATER.compareAndSet(this, EXECUTION, RESULT_READY)) {
+            // Handle race with cancel and make sure the iterator resources are freed correctly.
+            closeIter();
 
-        iter = iterExec.iterator();
+            throw new CacheException(new QueryCancelledException());
+        }
 
         assert iter != null;
 
@@ -93,18 +120,35 @@ public class QueryCursorImpl<T> implements QueryCursorEx<T> {
 
     /** {@inheritDoc} */
     @Override public void close() {
-        Iterator<T> i;
-
-        if ((i = iter) != null) {
-            iter = null;
-
-            if (i instanceof AutoCloseable) {
-                try {
-                    ((AutoCloseable)i).close();
-                }
-                catch (Exception e) {
-                    throw new IgniteException(e);
-                }
+        while(state != CLOSED) {
+            if (STATE_UPDATER.compareAndSet(this, RESULT_READY, CLOSED)) {
+                closeIter();
+
+                return;
+            }
+
+            if (STATE_UPDATER.compareAndSet(this, EXECUTION, CLOSED)) {
+                if (cancel != null)
+                    cancel.cancel();
+
+                return;
+            }
+
+            if (STATE_UPDATER.compareAndSet(this, IDLE, CLOSED))
+                return;
+        }
+    }
+
+    /**
+     * Closes iterator.
+     */
+    private void closeIter() {
+        if (iter instanceof AutoCloseable) {
+            try {
+                ((AutoCloseable)iter).close();
+            }
+            catch (Exception e) {
+                throw new IgniteException(e);
             }
         }
     }
@@ -122,4 +166,12 @@ public class QueryCursorImpl<T> implements QueryCursorEx<T> {
     @Override public List<GridQueryFieldMetadata> fieldsMeta() {
         return fieldsMeta;
     }
+
+    /** Query cursor state */
+    protected enum State {
+        /** Idle. */IDLE,
+        /** Executing. */EXECUTION,
+        /** Result ready. */RESULT_READY,
+        /** Closed. */CLOSED,
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCancel.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCancel.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCancel.java
new file mode 100644
index 0000000..47f1208
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCancel.java
@@ -0,0 +1,84 @@
+/*
+ * 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.query;
+
+import org.apache.ignite.cache.query.QueryCancelledException;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ * Holds query cancel state.
+ */
+public class GridQueryCancel {
+    /** */
+    private volatile boolean cancelled;
+
+    /** */
+    private volatile boolean completed;
+
+    /** */
+    private volatile Runnable clo;
+
+    /**
+     * Sets a cancel closure. The closure must be idempotent to multiple invocations.
+     *
+     * @param clo Clo.
+     */
+    public void set(Runnable clo) throws QueryCancelledException{
+        checkCancelled();
+
+        this.clo = clo;
+    }
+
+    /**
+     * Spins until a query is completed.
+     * Only one thread can enter this method.
+     * This is guaranteed by {@link org.apache.ignite.internal.processors.cache.QueryCursorImpl}
+     */
+    public void cancel() {
+        cancelled = true;
+
+        int attempt = 0;
+
+        while (!completed) {
+            if (clo != null) clo.run();
+
+            try {
+                U.sleep(++attempt * 10);
+            } catch (IgniteInterruptedCheckedException ignored) {
+                return;
+            }
+        }
+    }
+
+    /**
+     * Stops query execution if a user requested cancel.
+     */
+    public void checkCancelled() throws QueryCancelledException{
+        if (cancelled)
+            throw new QueryCancelledException();
+    }
+
+    /**
+     * Sets completed state.
+     * The method must be called then a query is completed by any reason, typically in final block.
+     */
+    public void setCompleted() {
+        completed = true;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResult.java
index 25c8caba..e32a687 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResult.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.query;
 
 import java.util.List;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.spi.IgniteSpiCloseableIterator;
 
 /**
@@ -37,5 +38,5 @@ public interface GridQueryFieldsResult {
      *
      * @return Iterator over queried fields.
      */
-    IgniteSpiCloseableIterator<List<?>> iterator();
+    IgniteSpiCloseableIterator<List<?>> iterator() throws IgniteCheckedException;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResultAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResultAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResultAdapter.java
index fc01d2d..7f1d175 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResultAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryFieldsResultAdapter.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.query;
 
 import java.util.Collections;
 import java.util.List;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.jetbrains.annotations.Nullable;
 
@@ -51,7 +52,7 @@ public class GridQueryFieldsResultAdapter implements GridQueryFieldsResult {
     }
 
     /** {@inheritDoc} */
-    @Override public GridCloseableIterator<List<?>> iterator() {
+    @Override public GridCloseableIterator<List<?>> iterator() throws IgniteCheckedException{
         return it;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 7697a12..b1b3c68 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -29,7 +29,6 @@ import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
 import org.apache.ignite.internal.util.GridSpinBusyLock;
 import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.lang.IgniteBiTuple;
@@ -58,17 +57,6 @@ public interface GridQueryIndexing {
     public void stop() throws IgniteCheckedException;
 
     /**
-     * Runs two step query.
-     *
-     * @param cctx Cache context.
-     * @param qry Query.
-     * @param keepCacheObjects If {@code true}, cache objects representation will be preserved.
-     * @return Cursor.
-     */
-    public Iterable<List<?>> queryTwoStep(GridCacheContext<?,?> cctx, GridCacheTwoStepQuery qry,
-        boolean keepCacheObjects);
-
-    /**
      * Parses SQL query into two step query and executes it.
      *
      * @param cctx Cache context.
@@ -93,11 +81,14 @@ public interface GridQueryIndexing {
      * @param qry Query.
      * @param params Query parameters.
      * @param filters Space name and key filters.
+     * @param timeout Query timeout in milliseconds.
+     * @param cancel Query cancel.
      * @return Query result.
      * @throws IgniteCheckedException If failed.
      */
-    public GridQueryFieldsResult queryFields(@Nullable String spaceName, String qry,
-        Collection<Object> params, IndexingQueryFilter filters) throws IgniteCheckedException;
+    public GridQueryFieldsResult execute(@Nullable String spaceName, String qry,
+        Collection<Object> params, IndexingQueryFilter filters, int timeout, GridQueryCancel cancel)
+        throws IgniteCheckedException;
 
     /**
      * Executes regular query.
@@ -241,4 +232,9 @@ public interface GridQueryIndexing {
      * @param reconnectFut Reconnect future.
      */
     public void onDisconnected(IgniteFuture<?> reconnectFut);
-}
+
+    /**
+     * Cancels all executing queries.
+     */
+    public void cancelAllQueries();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 1605188..3d185c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -39,6 +39,7 @@ import java.util.TreeSet;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
 import javax.cache.Cache;
 import javax.cache.CacheException;
 import org.apache.ignite.IgniteCheckedException;
@@ -71,7 +72,6 @@ import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryType;
-import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
 import org.apache.ignite.internal.util.GridSpinBusyLock;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -82,6 +82,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.A;
 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;
@@ -434,6 +435,19 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     @Override public void onKernalStop(boolean cancel) {
         super.onKernalStop(cancel);
 
+        if (cancel && idx != null)
+            try {
+                while (!busyLock.tryBlock(500))
+                    idx.cancelAllQueries();
+
+                return;
+            }
+            catch (InterruptedException e) {
+                U.warn(log, "Interrupted while waiting for active queries cancellation.");
+
+                Thread.currentThread().interrupt();
+            }
+
         busyLock.block();
     }
 
@@ -763,37 +777,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     }
 
     /**
-     * @param space Space name.
-     * @param qry Query.
-     * @return Cursor.
-     */
-    public Iterable<List<?>> queryTwoStep(String space, final GridCacheTwoStepQuery qry) {
-        checkxEnabled();
-
-        if (!busyLock.enterBusy())
-            throw new IllegalStateException("Failed to execute query (grid is stopping).");
-
-        try {
-            final GridCacheContext<Object, Object> cctx = ctx.cache().internalCache(space).context();
-
-            return executeQuery(cctx, new IgniteOutClosureX<Iterable<List<?>>>() {
-                @Override public Iterable<List<?>> applyx() throws IgniteCheckedException {
-                    return idx.queryTwoStep(
-                        cctx,
-                        qry,
-                        cctx.keepBinary());
-                }
-            }, false);
-        }
-        catch (IgniteCheckedException e) {
-            throw new IgniteException(e);
-        }
-        finally {
-            busyLock.leaveBusy();
-        }
-    }
-
-    /**
      * @param cctx Cache context.
      * @param qry Query.
      * @return Cursor.
@@ -806,7 +789,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
         try {
             return executeQuery(cctx, new IgniteOutClosureX<QueryCursor<List<?>>>() {
-                @Override public QueryCursor<List<?>> applyx() throws IgniteCheckedException {
+                @Override public QueryCursor<List<?>> applyx() {
                     return idx.queryTwoStep(cctx, qry);
                 }
             }, true);
@@ -942,6 +925,24 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * @param timeout Timeout.
+     * @param timeUnit Time unit.
+     * @return Converted time.
+     */
+    public static int validateTimeout(int timeout, TimeUnit timeUnit) {
+        A.ensure(timeUnit != TimeUnit.MICROSECONDS && timeUnit != TimeUnit.NANOSECONDS,
+                "timeUnit minimal resolution is millisecond.");
+
+        A.ensure(timeout >= 0, "timeout value should be non-negative.");
+
+        long tmp = TimeUnit.MILLISECONDS.convert(timeout, timeUnit);
+
+        A.ensure(timeout <= Integer.MAX_VALUE, "timeout value too large.");
+
+        return (int) tmp;
+    }
+
+    /**
      * Closeable iterator.
      */
     private interface ClIter<X> extends AutoCloseable, Iterator<X> {
@@ -962,20 +963,26 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
             return executeQuery(cctx, new IgniteOutClosureX<QueryCursor<List<?>>>() {
                 @Override public QueryCursor<List<?>> applyx() throws IgniteCheckedException {
-                    String space = cctx.name();
-                    String sql = qry.getSql();
-                    Object[] args = qry.getArgs();
-
-                    final GridQueryFieldsResult res = idx.queryFields(space, sql, F.asList(args),
-                        idx.backupFilter(null, requestTopVer.get(), null));
+                    final String space = cctx.name();
+                    final String sql = qry.getSql();
+                    final Object[] args = qry.getArgs();
+                    final GridQueryCancel cancel = new GridQueryCancel();
 
-                    sendQueryExecutedEvent(sql, args);
+                    final GridQueryFieldsResult res = idx.execute(space, sql, F.asList(args),
+                        idx.backupFilter(null, requestTopVer.get(), null), qry.getTimeout(), cancel);
 
                     QueryCursorImpl<List<?>> cursor = new QueryCursorImpl<>(new Iterable<List<?>>() {
                         @Override public Iterator<List<?>> iterator() {
-                            return new GridQueryCacheObjectsIterator(res.iterator(), cctx, keepBinary);
+                            try {
+                                sendQueryExecutedEvent(sql, args);
+
+                                return new GridQueryCacheObjectsIterator(res.iterator(), cctx, keepBinary);
+                            }
+                            catch (IgniteCheckedException e) {
+                                throw new IgniteException(e);
+                            }
                         }
-                    });
+                    }, cancel);
 
                     cursor.fieldsMeta(res.metaData());
 
@@ -1076,14 +1083,13 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @return Type name.
      */
     public static String typeName(String clsName) {
-        int packageEnd = clsName.lastIndexOf('.');
+        int pkgEnd = clsName.lastIndexOf('.');
 
-        if (packageEnd >= 0 && packageEnd < clsName.length() - 1)
-            clsName = clsName.substring(packageEnd + 1);
+        if (pkgEnd >= 0 && pkgEnd < clsName.length() - 1)
+            clsName = clsName.substring(pkgEnd + 1);
 
-        if (clsName.endsWith("[]")) {
+        if (clsName.endsWith("[]"))
             clsName = clsName.substring(0, clsName.length() - 2) + "_array";
-        }
 
         int parentEnd = clsName.lastIndexOf('$');
 
@@ -1154,7 +1160,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
             return executeQuery(cctx, new IgniteOutClosureX<GridQueryFieldsResult>() {
                 @Override public GridQueryFieldsResult applyx() throws IgniteCheckedException {
-                    return idx.queryFields(space, clause, params, filters);
+                    return idx.execute(space, clause, params, filters, 0, null);
                 }
             }, false);
         }
@@ -1519,13 +1525,12 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
         for (Map.Entry<String, String> entry : qryEntity.getFields().entrySet()) {
             ClassProperty prop = buildClassProperty(
-                d.keyClass(),
-                d.valueClass(),
-                entry.getKey(),
-                U.classForName(entry.getValue(), Object.class),
-                aliases,
-                coCtx);
-
+                    d.keyClass(),
+                    d.valueClass(),
+                    entry.getKey(),
+                    U.classForName(entry.getValue(), Object.class),
+                    aliases,
+                    coCtx);
 
             d.addProperty(prop, false);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
index 499438d..0baf6ea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryFailResponse.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.query.h2.twostep.messages;
 
 import java.nio.ByteBuffer;
+import org.apache.ignite.cache.query.QueryCancelledException;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -27,6 +28,12 @@ import org.apache.ignite.plugin.extensions.communication.MessageWriter;
  * Error message.
  */
 public class GridQueryFailResponse implements Message {
+    /** General error failure type. */
+    public static final byte GENERAL_ERROR = 0;
+
+    /** Cancelled by originator failure type. */
+    public static final byte CANCELLED_BY_ORIGINATOR = 1;
+
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -36,6 +43,9 @@ public class GridQueryFailResponse implements Message {
     /** */
     private String errMsg;
 
+    /** */
+    private byte failCode;
+
     /**
      * Default constructor.
      */
@@ -50,6 +60,7 @@ public class GridQueryFailResponse implements Message {
     public GridQueryFailResponse(long qryReqId, Throwable err) {
         this.qryReqId = qryReqId;
         this.errMsg = err.getClass() + ":" + err.getMessage();
+        this.failCode = err instanceof QueryCancelledException ? CANCELLED_BY_ORIGINATOR : GENERAL_ERROR;
     }
 
     /**
@@ -66,6 +77,13 @@ public class GridQueryFailResponse implements Message {
         return errMsg;
     }
 
+    /**
+     * @return Fail code.
+     */
+    public byte failCode() {
+        return failCode;
+    }
+
     /** {@inheritDoc} */
     @Override public void onAckReceived() {
         // No-op.
@@ -100,6 +118,12 @@ public class GridQueryFailResponse implements Message {
 
                 writer.incrementState();
 
+            case 2:
+                if (!writer.writeByte("failCode", failCode))
+                    return false;
+
+                writer.incrementState();
+
         }
 
         return true;
@@ -129,6 +153,14 @@ public class GridQueryFailResponse implements Message {
 
                 reader.incrementState();
 
+            case 2:
+                failCode = reader.readByte("failCode");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
         }
 
         return reader.afterMessageRead(GridQueryFailResponse.class);
@@ -141,6 +173,6 @@ public class GridQueryFailResponse implements Message {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 2;
+        return 3;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java
index 60d348b..550cf9b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryRequest.java
@@ -66,6 +66,9 @@ public class GridQueryRequest implements Message {
     @GridToStringInclude
     private int[] parts;
 
+    /** */
+    private int timeout;
+
     /**
      * Default constructor.
      */
@@ -81,6 +84,7 @@ public class GridQueryRequest implements Message {
      * @param topVer Topology version.
      * @param extraSpaces All space names participating in query other than {@code space}.
      * @param parts Optional partitions for unstable topology.
+     * @param timeout Timeout in millis.
      */
     public GridQueryRequest(
         long reqId,
@@ -89,7 +93,8 @@ public class GridQueryRequest implements Message {
         Collection<GridCacheSqlQuery> qrys,
         AffinityTopologyVersion topVer,
         List<String> extraSpaces,
-        int[] parts) {
+        int[] parts,
+        int timeout) {
         this.reqId = reqId;
         this.pageSize = pageSize;
         this.space = space;
@@ -98,6 +103,7 @@ public class GridQueryRequest implements Message {
         this.topVer = topVer;
         this.extraSpaces = extraSpaces;
         this.parts = parts;
+        this.timeout = timeout;
     }
 
     /**
@@ -163,6 +169,13 @@ public class GridQueryRequest implements Message {
     }
 
     /**
+     * @return Timeout.
+     */
+    public int timeout() {
+        return this.timeout;
+    }
+
+    /**
      * @return Queries.
      */
     public Collection<GridCacheSqlQuery> queries() throws IgniteCheckedException {
@@ -233,6 +246,12 @@ public class GridQueryRequest implements Message {
 
                 writer.incrementState();
 
+            case 7:
+                if (!writer.writeInt("timeout", timeout))
+                    return false;
+
+                writer.incrementState();
+
         }
 
         return true;
@@ -302,6 +321,14 @@ public class GridQueryRequest implements Message {
 
                 reader.incrementState();
 
+            case 7:
+                timeout = reader.readInt("timeout");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
         }
 
         return reader.afterMessageRead(GridQueryRequest.class);
@@ -314,6 +341,6 @@ public class GridQueryRequest implements Message {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 7;
+        return 8;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index a5f283e..ab332c1 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -51,12 +51,14 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 import javax.cache.Cache;
 import javax.cache.CacheException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.query.QueryCancelledException;
 import org.apache.ignite.cache.query.QueryCursor;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.SqlQuery;
@@ -75,6 +77,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
 import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
+import org.apache.ignite.internal.processors.query.GridQueryCancel;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
 import org.apache.ignite.internal.processors.query.GridQueryFieldsResult;
 import org.apache.ignite.internal.processors.query.GridQueryFieldsResultAdapter;
@@ -120,9 +123,12 @@ import org.h2.api.JavaObjectSerializer;
 import org.h2.command.CommandInterface;
 import org.h2.constant.ErrorCode;
 import org.h2.constant.SysProperties;
+import org.h2.engine.Session;
 import org.h2.index.Index;
 import org.h2.index.SpatialIndex;
+import org.h2.jdbc.JdbcConnection;
 import org.h2.jdbc.JdbcPreparedStatement;
+import org.h2.jdbc.JdbcStatement;
 import org.h2.message.DbException;
 import org.h2.mvstore.cache.CacheLongKeyLIRS;
 import org.h2.server.web.WebServer;
@@ -350,7 +356,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             PreparedStatement stmt = cache.get(sql);
 
-            if (stmt != null && !stmt.isClosed()) {
+            if (stmt != null && !((JdbcStatement)stmt).wasCancelled()) {
                 assert stmt.getConnection() == c;
 
                 return stmt;
@@ -727,28 +733,33 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public GridQueryFieldsResult queryFields(@Nullable final String spaceName, final String qry,
-        @Nullable final Collection<Object> params, final IndexingQueryFilter filters)
+    @Override public GridQueryFieldsResult execute(@Nullable final String spaceName, final String qry,
+        @Nullable final Collection<Object> params, final IndexingQueryFilter filters,
+        final int timeout, final GridQueryCancel cancel)
         throws IgniteCheckedException {
         setFilters(filters);
 
         try {
-            Connection conn = connectionForThread(schema(spaceName));
+            final Connection conn = connectionForThread(schema(spaceName));
 
-            ResultSet rs = executeSqlQueryWithTimer(spaceName, conn, qry, params, true);
+            final PreparedStatement stmt = preparedStatementWithParams(conn, qry, params, true);
 
-            List<GridQueryFieldMetadata> meta = null;
+            List<GridQueryFieldMetadata> meta;
 
-            if (rs != null) {
-                try {
-                    meta = meta(rs.getMetaData());
-                }
-                catch (SQLException e) {
-                    throw new IgniteCheckedException("Failed to get meta data.", e);
-                }
+            try {
+                meta = meta(stmt.getMetaData());
+            }
+            catch (SQLException e) {
+                throw new IgniteCheckedException("Cannot prepare query metadata", e);
             }
 
-            return new GridQueryFieldsResultAdapter(meta, new FieldsIterator(rs));
+            return new GridQueryFieldsResultAdapter(meta, null) {
+                @Override public GridCloseableIterator<List<?>> iterator() throws IgniteCheckedException{
+                    ResultSet rs = executeSqlQueryWithTimer(spaceName, stmt, conn, qry, params, timeout, cancel);
+
+                    return new FieldsIterator(rs);
+                }
+            };
         }
         finally {
             setFilters(null);
@@ -808,18 +819,18 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
-     * Executes sql query.
+     * Prepares sql statement.
      *
-     * @param conn Connection,.
-     * @param sql Sql query.
-     * @param params Parameters.
-     * @param useStmtCache If {@code true} uses statement cache.
-     * @return Result.
+     * @param conn Connection.
+     * @param sql Sql.
+     * @param params Params.
+     * @param useStmtCache If {@code true} use stmt cache.
+     * @return Prepared statement with set parameters.
      * @throws IgniteCheckedException If failed.
      */
-    private ResultSet executeSqlQuery(Connection conn, String sql, Collection<Object> params, boolean useStmtCache)
-        throws IgniteCheckedException {
-        PreparedStatement stmt;
+    private PreparedStatement preparedStatementWithParams(Connection conn, String sql, Collection<Object> params,
+        boolean useStmtCache) throws IgniteCheckedException {
+        final PreparedStatement stmt;
 
         try {
             stmt = prepareStatement(conn, sql, useStmtCache);
@@ -840,12 +851,54 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         bindParameters(stmt, params);
 
+        return stmt;
+    }
+
+    /**
+     * Executes sql query statement.
+     *
+     * @param conn Connection,.
+     * @param stmt Statement.
+     * @param cancel Query cancel.
+     * @return Result.
+     * @throws IgniteCheckedException If failed.
+     */
+    private ResultSet executeSqlQuery(final Connection conn, final PreparedStatement stmt,
+        int timeoutMillis, @Nullable GridQueryCancel cancel)
+        throws IgniteCheckedException {
+
+        if (timeoutMillis > 0)
+            ((Session)((JdbcConnection)conn).getSession()).setQueryTimeout(timeoutMillis);
+
+        if (cancel != null) {
+            cancel.set(new Runnable() {
+                @Override public void run() {
+                    try {
+                        stmt.cancel();
+                    } catch (SQLException ignored) {
+                        // No-op.
+                    }
+                }
+            });
+        }
+
         try {
             return stmt.executeQuery();
         }
         catch (SQLException e) {
+            // Throw special exception.
+            if (e.getErrorCode() == ErrorCode.STATEMENT_WAS_CANCELED)
+                throw new QueryCancelledException();
+
             throw new IgniteCheckedException("Failed to execute SQL query.", e);
         }
+        finally {
+            if(cancel != null)
+                cancel.setCompleted();
+
+            if (timeoutMillis > 0)
+                ((Session)((JdbcConnection)conn).getSession()).setQueryTimeout(0);
+        }
     }
 
     /**
@@ -855,7 +908,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
      * @param conn Connection,.
      * @param sql Sql query.
      * @param params Parameters.
-     * @param useStmtCache If {@code true} uses statement cache.
+     * @param useStmtCache If {@code true} uses stmt cache.
+     * @param cancel Query cancel.
      * @return Result.
      * @throws IgniteCheckedException If failed.
      */
@@ -863,11 +917,35 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         Connection conn,
         String sql,
         @Nullable Collection<Object> params,
-        boolean useStmtCache) throws IgniteCheckedException {
+        boolean useStmtCache,
+        int timeoutMillis,
+        @Nullable GridQueryCancel cancel) throws IgniteCheckedException {
+        return executeSqlQueryWithTimer(space, preparedStatementWithParams(conn, sql, params, useStmtCache),
+            conn, sql, params, timeoutMillis, cancel);
+    }
+
+    /**
+     * Executes sql query and prints warning if query is too slow.
+     *
+     * @param space Space name.
+     * @param stmt Prepared statement for query.
+     * @param conn Connection.
+     * @param sql Sql query.
+     * @param params Parameters.
+     * @param cancel Query cancel.
+     * @return Result.
+     * @throws IgniteCheckedException If failed.
+     */
+    private ResultSet executeSqlQueryWithTimer(String space, PreparedStatement stmt,
+        Connection conn,
+        String sql,
+        @Nullable Collection<Object> params,
+        int timeoutMillis,
+        @Nullable GridQueryCancel cancel) throws IgniteCheckedException {
         long start = U.currentTimeMillis();
 
         try {
-            ResultSet rs = executeSqlQuery(conn, sql, params, useStmtCache);
+            ResultSet rs = executeSqlQuery(conn, stmt, timeoutMillis, cancel);
 
             long time = U.currentTimeMillis() - start;
 
@@ -876,7 +954,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             if (time > longQryExecTimeout) {
                 String msg = "Query execution is too long (" + time + " ms): " + sql;
 
-                ResultSet plan = executeSqlQuery(conn, "EXPLAIN " + sql, params, false);
+                ResultSet plan = executeSqlQuery(conn, preparedStatementWithParams(conn, "EXPLAIN " + sql,
+                    params, false), 0, null);
 
                 plan.next();
 
@@ -903,16 +982,20 @@ public class IgniteH2Indexing implements GridQueryIndexing {
      * @param qry Query.
      * @param params Query parameters.
      * @param tbl Target table of query to generate select.
+     * @param cancel Query cancel.
      * @return Result set.
      * @throws IgniteCheckedException If failed.
      */
-    private ResultSet executeQuery(String space, String qry, @Nullable Collection<Object> params, TableDescriptor tbl)
+    private ResultSet executeQuery(String space, String qry, @Nullable Collection<Object> params, TableDescriptor tbl,
+        @Nullable GridQueryCancel cancel)
             throws IgniteCheckedException {
         Connection conn = connectionForThread(tbl.schemaName());
 
         String sql = generateQuery(qry, tbl);
 
-        return executeSqlQueryWithTimer(space, conn, sql, params, true);
+        return executeSqlQueryWithTimer(space,
+            preparedStatementWithParams(conn, sql, params, true),
+            conn, sql, params, 0, cancel);
     }
 
     /**
@@ -954,7 +1037,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         setFilters(filters);
 
         try {
-            ResultSet rs = executeQuery(spaceName, qry, params, tbl);
+            ResultSet rs = executeQuery(spaceName, qry, params, tbl, null);
 
             return new KeyValIterator(rs);
         }
@@ -964,11 +1047,19 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /** {@inheritDoc} */
-    @Override public Iterable<List<?>> queryTwoStep(final GridCacheContext<?,?> cctx, final GridCacheTwoStepQuery qry,
-        final boolean keepCacheObj) {
+    private Iterable<List<?>> doQueryTwoStep(final GridCacheContext<?, ?> cctx, final GridCacheTwoStepQuery qry,
+        final boolean keepCacheObj,
+        final int timeoutMillis,
+        final GridQueryCancel cancel) {
         return new Iterable<List<?>>() {
             @Override public Iterator<List<?>> iterator() {
-                return rdcQryExec.query(cctx, qry, keepCacheObj);
+                try {
+                    return rdcQryExec.query(cctx, qry, keepCacheObj, timeoutMillis, cancel);
+                }
+                finally {
+                    if (cancel != null)
+                        cancel.setCompleted();
+                }
             }
         };
     }
@@ -998,6 +1089,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         fqry.setArgs(qry.getArgs());
         fqry.setPageSize(qry.getPageSize());
 
+        if(qry.getTimeout() > 0)
+            fqry.setTimeout(qry.getTimeout(), TimeUnit.MILLISECONDS);
+
         final QueryCursor<List<?>> res = queryTwoStep(cctx, fqry);
 
         final Iterable<Cache.Entry<K, V>> converted = new Iterable<Cache.Entry<K, V>>() {
@@ -1064,7 +1158,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                         try {
                             ctx.cache().createMissingCaches();
                         }
-                        catch (IgniteCheckedException e1) {
+                        catch (IgniteCheckedException ignored) {
                             throw new CacheException("Failed to create missing caches.", e);
                         }
 
@@ -1104,7 +1198,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         twoStepQry.pageSize(qry.getPageSize());
 
-        QueryCursorImpl<List<?>> cursor = new QueryCursorImpl<>(queryTwoStep(cctx, twoStepQry, cctx.keepBinary()));
+        GridQueryCancel cancel = new GridQueryCancel();
+
+        QueryCursorImpl<List<?>> cursor = new QueryCursorImpl<>(
+            doQueryTwoStep(cctx, twoStepQry, cctx.keepBinary(), qry.getTimeout(), cancel), cancel);
 
         cursor.fieldsMeta(meta);
 
@@ -1455,8 +1552,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         if (tbl == null)
             return -1;
 
-        IgniteSpiCloseableIterator<List<?>> iter = queryFields(spaceName,
-            "SELECT COUNT(*) FROM " + tbl.fullTableName(), null, null).iterator();
+        IgniteSpiCloseableIterator<List<?>> iter = execute(spaceName,
+                "SELECT COUNT(*) FROM " + tbl.fullTableName(), null, null, 0, null).iterator();
 
         return ((Number)iter.next().get(0)).longValue();
     }
@@ -2618,4 +2715,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             lastUsage = U.currentTimeMillis();
         }
     }
+
+    /** {@inheritDoc} */
+    @Override public void cancelAllQueries() {
+        for (Connection conn : conns)
+            U.close(conn, log);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 580058c..1f05bf7 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -19,8 +19,6 @@ package org.apache.ignite.internal.processors.query.h2.twostep;
 
 import java.lang.reflect.Field;
 import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.AbstractCollection;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -52,6 +50,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartit
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridReservable;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryType;
 import org.apache.ignite.internal.processors.cache.query.GridCacheSqlQuery;
+import org.apache.ignite.internal.processors.query.GridQueryCancel;
 import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse;
@@ -452,10 +451,12 @@ public class GridMapQueryExecutor {
 
             for (GridCacheSqlQuery qry : qrys) {
                 ResultSet rs = h2.executeSqlQueryWithTimer(req.space(),
-                    h2.connectionForSpace(req.space()),
-                    qry.query(),
-                    F.asList(qry.parameters()),
-                    true);
+                        h2.connectionForSpace(req.space()),
+                        qry.query(),
+                        F.asList(qry.parameters()),
+                        true,
+                        req.timeout(),
+                        qr.cancels[i]);
 
                 if (ctx.event().isRecordable(EVT_CACHE_QUERY_EXECUTED)) {
                     ctx.event().record(new CacheQueryExecutedEvent<>(
@@ -509,6 +510,15 @@ public class GridMapQueryExecutor {
             // Release reserved partitions.
             for (GridReservable r : reserved)
                 r.release();
+
+            // Ensure all cancels state is correct.
+            if (qr != null)
+                for (int i = 0; i < qr.cancels.length; i++) {
+                    GridQueryCancel cancel = qr.cancels[i];
+
+                    if (cancel != null)
+                        cancel.setCompleted();
+                }
         }
     }
 
@@ -637,6 +647,9 @@ public class GridMapQueryExecutor {
         private final AtomicReferenceArray<QueryResult> results;
 
         /** */
+        private final GridQueryCancel[] cancels;
+
+        /** */
         private final GridCacheContext<?,?> cctx;
 
         /** */
@@ -652,6 +665,10 @@ public class GridMapQueryExecutor {
             this.cctx = cctx;
 
             results = new AtomicReferenceArray<>(qrys);
+            cancels = new GridQueryCancel[qrys];
+
+            for (int i = 0; i < cancels.length; i++)
+                cancels[i] = new GridQueryCancel();
         }
 
         /**
@@ -687,6 +704,9 @@ public class GridMapQueryExecutor {
             return true;
         }
 
+        /**
+         * Cancels the query.
+         */
         void cancel() {
             if (canceled)
                 return;
@@ -696,8 +716,16 @@ public class GridMapQueryExecutor {
             for (int i = 0; i < results.length(); i++) {
                 QueryResult res = results.get(i);
 
-                if (res != null)
+                if (res != null) {
                     res.close();
+
+                    continue;
+                }
+
+                GridQueryCancel cancel = cancels[i];
+
+                if (cancel != null)
+                    cancel.cancel();
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 6a079f0..3fdbf42 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -62,8 +62,10 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Gri
 import org.apache.ignite.internal.processors.cache.query.GridCacheSqlQuery;
 import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
 import org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator;
+import org.apache.ignite.internal.processors.query.GridQueryCancel;
 import org.apache.ignite.internal.processors.query.h2.GridH2ResultSetIterator;
 import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
+import org.apache.ignite.cache.query.QueryCancelledException;
 import org.apache.ignite.internal.processors.query.h2.sql.GridSqlQuerySplitter;
 import org.apache.ignite.internal.processors.query.h2.sql.GridSqlType;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest;
@@ -244,7 +246,7 @@ public class GridReduceQueryExecutor {
     private void onFail(ClusterNode node, GridQueryFailResponse msg) {
         QueryRun r = runs.get(msg.queryRequestId());
 
-        fail(r, node.id(), msg.error());
+        fail(r, node.id(), msg.error(), msg.failCode());
     }
 
     /**
@@ -252,9 +254,15 @@ public class GridReduceQueryExecutor {
      * @param nodeId Failed node ID.
      * @param msg Error message.
      */
-    private void fail(QueryRun r, UUID nodeId, String msg) {
-        if (r != null)
-            r.state(new CacheException("Failed to execute map query on the node: " + nodeId + ", " + msg), nodeId);
+    private void fail(QueryRun r, UUID nodeId, String msg, byte failCode) {
+        if (r != null) {
+            CacheException e = new CacheException("Failed to execute map query on the node: " + nodeId + ", " + msg);
+
+            if (failCode == GridQueryFailResponse.CANCELLED_BY_ORIGINATOR)
+                e.addSuppressed(new QueryCancelledException());
+
+            r.state(e, nodeId);
+        }
     }
 
     /**
@@ -312,7 +320,7 @@ public class GridReduceQueryExecutor {
         catch (Exception e) {
             U.error(log, "Error in message.", e);
 
-            fail(r, node.id(), "Error in message.");
+            fail(r, node.id(), "Error in message.", GridQueryFailResponse.GENERAL_ERROR);
 
             return;
         }
@@ -449,9 +457,12 @@ public class GridReduceQueryExecutor {
      * @param cctx Cache context.
      * @param qry Query.
      * @param keepBinary Keep binary.
-     * @return Cursor.
+     * @param timeoutMillis Timeout in milliseconds.
+     * @param cancel Query cancel.
+     * @return Rows iterator.
      */
-    public Iterator<List<?>> query(GridCacheContext<?,?> cctx, GridCacheTwoStepQuery qry, boolean keepBinary) {
+    public Iterator<List<?>> query(GridCacheContext<?,?> cctx, GridCacheTwoStepQuery qry, boolean keepBinary,
+        int timeoutMillis, GridQueryCancel cancel) {
         for (int attempt = 0;; attempt++) {
             if (attempt != 0) {
                 try {
@@ -464,7 +475,7 @@ public class GridReduceQueryExecutor {
                 }
             }
 
-            long qryReqId = reqIdGen.incrementAndGet();
+            final long qryReqId = reqIdGen.incrementAndGet();
 
             QueryRun r = new QueryRun();
 
@@ -510,6 +521,8 @@ public class GridReduceQueryExecutor {
                 nodes = Collections.singleton(F.rand(nodes));
             }
 
+            final Collection<ClusterNode> finalNodes = nodes;
+
             int tblIdx = 0;
 
             final boolean skipMergeTbl = !qry.explain() && qry.skipMergeTable();
@@ -545,6 +558,8 @@ public class GridReduceQueryExecutor {
             runs.put(qryReqId, r);
 
             try {
+                cancel.checkCancelled();
+
                 if (ctx.clientDisconnected()) {
                     throw new CacheException("Query was cancelled, client node disconnected.",
                         new IgniteClientDisconnectedException(ctx.cluster().clientReconnectFuture(),
@@ -567,12 +582,20 @@ public class GridReduceQueryExecutor {
                         mapQry.marshallParams(m);
                 }
 
+                cancel.set(new Runnable() {
+                    @Override public void run() {
+                        send(finalNodes, new GridQueryCancelRequest(qryReqId), null);
+                    }
+                });
+
                 boolean retry = false;
 
                 if (send(nodes,
-                    new GridQueryRequest(qryReqId, r.pageSize, space, mapQrys, topVer, extraSpaces, null), partsMap)) {
+                    new GridQueryRequest(qryReqId, r.pageSize, space, mapQrys, topVer, extraSpaces, null, timeoutMillis), partsMap)) {
                     awaitAllReplies(r, nodes);
 
+                    cancel.checkCancelled();
+
                     Object state = r.state.get();
 
                     if (state != null) {
@@ -582,6 +605,9 @@ public class GridReduceQueryExecutor {
                             if (err.getCause() instanceof IgniteClientDisconnectedException)
                                 throw err;
 
+                            if (wasCancelled(err))
+                                throw new QueryCancelledException(); // Throw correct exception.
+
                             throw new CacheException("Failed to run map query remotely.", err);
                         }
 
@@ -627,6 +653,8 @@ public class GridReduceQueryExecutor {
                         resIter = res.iterator();
                     }
                     else {
+                        cancel.checkCancelled();
+
                         GridCacheSqlQuery rdc = qry.reduceQuery();
 
                         // Statement caching is prohibited here because we can't guarantee correct merge index reuse.
@@ -634,17 +662,14 @@ public class GridReduceQueryExecutor {
                             r.conn,
                             rdc.query(),
                             F.asList(rdc.parameters()),
-                            false);
+                            false,
+                            timeoutMillis,
+                            cancel);
 
                         resIter = new Iter(res);
                     }
                 }
 
-                for (GridMergeIndex idx : r.idxs) {
-                    if (!idx.fetchedAll()) // We have to explicitly cancel queries on remote nodes.
-                        send(nodes, new GridQueryCancelRequest(qryReqId), null);
-                }
-
                 if (retry) {
                     if (Thread.currentThread().isInterrupted())
                         throw new IgniteInterruptedCheckedException("Query was interrupted.");
@@ -657,8 +682,12 @@ public class GridReduceQueryExecutor {
             catch (IgniteCheckedException | RuntimeException e) {
                 U.closeQuiet(r.conn);
 
-                if (e instanceof CacheException)
+                if (e instanceof CacheException) {
+                    if (wasCancelled((CacheException)e))
+                        throw new CacheException("Failed to run reduce query locally.", new QueryCancelledException());
+
                     throw (CacheException)e;
+                }
 
                 Throwable cause = e;
 
@@ -673,6 +702,9 @@ public class GridReduceQueryExecutor {
                 throw new CacheException("Failed to run reduce query locally.", cause);
             }
             finally {
+                // Make sure any activity related to current attempt is cancelled.
+                cancelRemoteQueriesIfNeeded(nodes, r, qryReqId);
+
                 if (!runs.remove(qryReqId, r))
                     U.warn(log, "Query run was already removed: " + qryReqId);
 
@@ -685,6 +717,33 @@ public class GridReduceQueryExecutor {
     }
 
     /**
+     * Returns true if the exception is triggered by query cancel.
+     *
+     * @param e Exception.
+     * @return {@code true} if exception is caused by cancel.
+     */
+    private boolean wasCancelled(CacheException e) {
+        return e.getSuppressed() != null && e.getSuppressed().length > 0 &&
+            e.getSuppressed()[0] instanceof QueryCancelledException;
+    }
+
+    /**
+     * Explicitly cancels remote queries.
+     * @param nodes Nodes.
+     * @param r Query run.
+     * @param qryReqId Query id.
+     */
+    private void cancelRemoteQueriesIfNeeded(Collection<ClusterNode> nodes, QueryRun r, long qryReqId) {
+        for (GridMergeIndex idx : r.idxs) {
+            if (!idx.fetchedAll()) {
+                send(nodes, new GridQueryCancelRequest(qryReqId), null);
+
+                break;
+            }
+        }
+    }
+
+    /**
      * @param r Query run.
      * @param nodes Nodes to check periodically if they alive.
      * @throws IgniteInterruptedCheckedException If interrupted.
@@ -986,7 +1045,7 @@ public class GridReduceQueryExecutor {
         List<List<?>> lists = new ArrayList<>();
 
         for (int i = 0, mapQrys = qry.mapQueries().size(); i < mapQrys; i++) {
-            ResultSet rs = h2.executeSqlQueryWithTimer(space, c, "SELECT PLAN FROM " + table(i), null, false);
+            ResultSet rs = h2.executeSqlQueryWithTimer(space, c, "SELECT PLAN FROM " + table(i), null, false, 0, null);
 
             lists.add(F.asList(getPlan(rs)));
         }
@@ -1005,7 +1064,9 @@ public class GridReduceQueryExecutor {
             c,
             "EXPLAIN " + rdc.query(),
             F.asList(rdc.parameters()),
-            false);
+            false,
+            0,
+            null);
 
         lists.add(F.asList(getPlan(rs)));
 
@@ -1240,4 +1301,4 @@ public class GridReduceQueryExecutor {
             return res;
         }
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/80abd1b7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryCancelSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryCancelSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryCancelSelfTest.java
new file mode 100644
index 0000000..3fec966
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryCancelSelfTest.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.near;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.query.QueryCancelledException;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.G;
+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;
+
+/**
+ * Tests distributed SQL query cancel related scenarios.
+ */
+public class IgniteCacheDistributedQueryCancelSelfTest extends GridCommonAbstractTest {
+    /** Grids count. */
+    private static final int GRIDS_COUNT = 3;
+
+    /** IP finder. */
+    private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** Cache size. */
+    public static final int CACHE_SIZE = 10_000;
+
+    /** Value size. */
+    public static final int VAL_SIZE = 16;
+
+    /** */
+    private static final String QUERY = "select a._val, b._val from String a, String b";
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        startGridsMultiThreaded(GRIDS_COUNT);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+        TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
+        spi.setIpFinder(IP_FINDER);
+
+        CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<>();
+        ccfg.setIndexedTypes(Integer.class, String.class);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        if ("client".equals(gridName))
+            cfg.setClientMode(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /** */
+    public void testQueryCancelsOnGridShutdown() throws Exception {
+        try (Ignite client = startGrid("client")) {
+
+            IgniteCache<Object, Object> cache = client.cache(null);
+
+            assertEquals(0, cache.localSize());
+
+            int p = 1;
+            for (int i = 1; i <= CACHE_SIZE; i++) {
+                char[] tmp = new char[VAL_SIZE];
+                Arrays.fill(tmp, ' ');
+                cache.put(i, new String(tmp));
+
+                if (i / (float)CACHE_SIZE >= p / 10f) {
+                    log().info("Loaded " + i + " of " + CACHE_SIZE);
+
+                    p++;
+                }
+            }
+
+            SqlFieldsQuery qry = new SqlFieldsQuery(QUERY);
+
+            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+                @Override public void run() {
+                    try {
+                        Thread.sleep(1_500);
+                    }
+                    catch (InterruptedException e) {
+                        throw new IgniteException(e);
+                    }
+
+                    for (Ignite g : G.allGrids())
+                        if (!g.configuration().getDiscoverySpi().isClientMode())
+                            stopGrid(g.name(), true);
+                }
+            }, 1);
+
+            try {
+                final QueryCursor<List<?>> cursor = cache.query(qry);
+
+                cursor.iterator();
+            }
+            catch (CacheException ignored) {
+                // No-op.
+            }
+
+            fut.get();
+
+            // Test must exit gracefully.
+        }
+    }
+
+    /** */
+    public void testQueryResponseFailCode() throws Exception {
+        try (Ignite client = startGrid("client")) {
+
+            CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>();
+            cfg.setSqlFunctionClasses(Functions.class);
+            cfg.setIndexedTypes(Integer.class, Integer.class);
+            cfg.setName("test");
+
+            IgniteCache<Integer, Integer> cache = client.getOrCreateCache(cfg);
+
+            cache.put(1, 1);
+
+            QueryCursor<List<?>> qry = cache.query(new SqlFieldsQuery("select fail() from Integer"));
+
+            try {
+                qry.getAll();
+
+                fail();
+            }
+            catch (Exception e) {
+                assertTrue(e.getCause() instanceof CacheException);
+            }
+        }
+    }
+
+    /** */
+    public static class Functions {
+        /** */
+        @QuerySqlFunction
+        public static int fail() {
+            throw new IllegalArgumentException();
+        }
+    }
+}
\ No newline at end of file


[10/40] ignite git commit: IGNITE-3597: Removed static work directory.

Posted by av...@apache.org.
IGNITE-3597: Removed static work directory.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: a92f20b5cc75e6b80b2731da0192723526b0c1dc
Parents: bba019f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Oct 4 14:10:26 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 4 14:10:26 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/GridKernalContextImpl.java  |   4 +-
 .../org/apache/ignite/internal/IgnitionEx.java  |  15 +-
 .../ignite/internal/MarshallerContextImpl.java  |   5 +-
 .../processors/hadoop/HadoopHelper.java         |   7 +
 .../internal/processors/hadoop/HadoopJob.java   |   5 +
 .../processors/hadoop/HadoopNoopHelper.java     |   5 +
 .../internal/processors/igfs/IgfsServer.java    |   5 +-
 .../cpp/PlatformCppConfigurationClosure.java    |  13 +-
 .../PlatformDotNetConfigurationClosure.java     |  13 +-
 .../platform/utils/PlatformUtils.java           |   8 +-
 .../ignite/internal/util/IgniteUtils.java       |  92 +++++-----
 .../shmem/IpcSharedMemoryServerEndpoint.java    |  15 +-
 .../apache/ignite/logger/java/JavaLogger.java   |  14 +-
 .../logger/java/JavaLoggerFileHandler.java      |  10 +-
 .../sharedfs/SharedFsCheckpointSpi.java         |   3 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   4 +-
 .../sharedfs/TcpDiscoverySharedFsIpFinder.java  |   2 +-
 .../spi/swapspace/file/FileSwapSpaceSpi.java    |   2 +-
 .../MarshallerContextLockingSelfTest.java       |   2 +-
 .../MarshallerCacheJobRunNodeRestartTest.java   |   2 +-
 .../handlers/log/GridLogCommandHandlerTest.java |   5 +-
 ...artupWithSpecifiedWorkDirectorySelfTest.java | 166 -------------------
 .../ipc/shmem/IgfsSharedMemoryTestServer.java   |   4 +-
 .../IpcSharedMemoryCrashDetectionSelfTest.java  |   9 +-
 .../IpcSharedMemoryBenchmarkReader.java         |   2 +-
 .../ignite/logger/java/JavaLoggerTest.java      |   3 +-
 .../OptimizedMarshallerNodeFailoverTest.java    |   4 -
 ...heckpointSpiMultipleDirectoriesSelfTest.java |   6 +-
 .../GridAbstractCommunicationSelfTest.java      |   2 -
 ...cpCommunicationSpiMultithreadedSelfTest.java |   2 -
 .../GridSwapSpaceSpiAbstractSelfTest.java       |   2 -
 .../testframework/junits/GridAbstractTest.java  |   2 +-
 .../ignite/testframework/junits/IgniteMock.java |  10 ++
 .../junits/IgniteTestResources.java             |   2 -
 .../junits/spi/GridSpiAbstractTest.java         |   2 -
 .../testsuites/IgniteBinaryBasicTestSuite.java  |   2 -
 .../testsuites/IgniteKernalSelfTestSuite.java   |   2 -
 .../CacheNoValueClassOnServerTestClient.java    |   2 -
 .../CacheConfigurationP2PTestClient.java        |   2 -
 .../processors/hadoop/HadoopHelperImpl.java     |  13 ++
 .../processors/hadoop/impl/HadoopUtils.java     |  11 +-
 .../processors/hadoop/impl/v2/HadoopV2Job.java  |  13 +-
 .../hadoop/impl/v2/HadoopV2TaskContext.java     |   4 +-
 .../external/HadoopExternalTaskExecutor.java    |  13 +-
 .../child/HadoopExternalProcessStarter.java     |  10 +-
 .../HadoopExternalCommunication.java            |  10 +-
 .../hadoop/impl/HadoopPlannerMockJob.java       |   7 +
 .../HadoopExternalCommunicationSelfTest.java    |   2 +-
 .../cache/CacheConfigurationP2PTestServer.java  |   2 -
 .../IgniteConfigurationTest.cs                  |   2 +-
 .../spi/deployment/uri/UriDeploymentSpi.java    |   2 +-
 .../scala/org/apache/ignite/visor/visor.scala   |   2 +-
 52 files changed, 209 insertions(+), 337 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index eb214e8..c7e26e9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -408,7 +408,9 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         this.restExecSvc = restExecSvc;
         this.callbackExecSvc = callbackExecSvc;
 
-        marshCtx = new MarshallerContextImpl(plugins);
+        String workDir = U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome());
+
+        marshCtx = new MarshallerContextImpl(workDir, plugins);
 
         try {
             spring = SPRING.create(false);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index aad96fb..2914c7c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1823,7 +1823,10 @@ public class IgnitionEx {
                 // If user provided IGNITE_HOME - set it as a system property.
                 U.setIgniteHome(ggHome);
 
-            U.setWorkDirectory(cfg.getWorkDirectory(), ggHome);
+            // Correctly resolve work directory and set it back to configuration.
+            String workDir = U.workDirectory(cfg.getWorkDirectory(), ggHome);
+
+            myCfg.setWorkDirectory(workDir);
 
             // Ensure invariant.
             // It's a bit dirty - but this is a result of late refactoring
@@ -1834,7 +1837,7 @@ public class IgnitionEx {
 
             myCfg.setNodeId(nodeId);
 
-            IgniteLogger cfgLog = initLogger(cfg.getGridLogger(), nodeId);
+            IgniteLogger cfgLog = initLogger(cfg.getGridLogger(), nodeId, workDir);
 
             assert cfgLog != null;
 
@@ -2095,11 +2098,13 @@ public class IgnitionEx {
         /**
          * @param cfgLog Configured logger.
          * @param nodeId Local node ID.
+         * @param workDir Work directory.
          * @return Initialized logger.
          * @throws IgniteCheckedException If failed.
          */
         @SuppressWarnings("ErrorNotRethrown")
-        private IgniteLogger initLogger(@Nullable IgniteLogger cfgLog, UUID nodeId) throws IgniteCheckedException {
+        private IgniteLogger initLogger(@Nullable IgniteLogger cfgLog, UUID nodeId, String workDir)
+            throws IgniteCheckedException {
             try {
                 Exception log4jInitErr = null;
 
@@ -2157,6 +2162,10 @@ public class IgnitionEx {
                         cfgLog = new JavaLogger();
                 }
 
+                // Special handling for Java logger which requires work directory.
+                if (cfgLog instanceof JavaLogger)
+                    ((JavaLogger)cfgLog).setWorkDirectory(workDir);
+
                 // Set node IDs for all file appenders.
                 if (cfgLog instanceof LoggerNodeIdAware)
                     ((LoggerNodeIdAware)cfgLog).setNodeId(nodeId);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
index 0420e18..e501d27 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
@@ -72,13 +72,14 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     private ContinuousQueryListener lsnr;
 
     /**
+     * @param igniteWorkDir Ignite work directory.
      * @param plugins Plugins.
      * @throws IgniteCheckedException In case of error.
      */
-    public MarshallerContextImpl(List<PluginProvider> plugins) throws IgniteCheckedException {
+    public MarshallerContextImpl(String igniteWorkDir, List<PluginProvider> plugins) throws IgniteCheckedException {
         super(plugins);
 
-        workDir = U.resolveWorkDirectory("marshaller", false);
+        workDir = U.resolveWorkDirectory(igniteWorkDir, "marshaller", false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java
index a8fee79..7936fef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelper.java
@@ -52,4 +52,11 @@ public interface HadoopHelper {
      * @return Input stream.
      */
     @Nullable public InputStream loadClassBytes(ClassLoader ldr, String clsName);
+
+    /**
+     * Get work directory.
+     *
+     * @return Work directory.
+     */
+    public String workDirectory();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java
index 2f6f6a7..a77c744 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopJob.java
@@ -99,4 +99,9 @@ public interface HadoopJob {
      * Cleans up the job staging directory.
      */
     public void cleanupStagingDirectory();
+
+    /**
+     * @return Ignite work directory.
+     */
+    public String igniteWorkDirectory();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java
index d3348ca..f8f870f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopNoopHelper.java
@@ -57,6 +57,11 @@ public class HadoopNoopHelper implements HadoopHelper {
         throw unsupported();
     }
 
+    /** {@inheritDoc} */
+    @Override public String workDirectory() {
+        throw unsupported();
+    }
+
     /**
      * @return Exception.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
index aa4b115..b2c3c83 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
@@ -153,7 +153,7 @@ public class IgfsServer {
      * @return Server endpoint.
      * @throws IgniteCheckedException If failed.
      */
-    private static IpcServerEndpoint createEndpoint(IgfsIpcEndpointConfiguration endpointCfg, boolean mgmt)
+    private IpcServerEndpoint createEndpoint(IgfsIpcEndpointConfiguration endpointCfg, boolean mgmt)
         throws IgniteCheckedException {
         A.notNull(endpointCfg, "endpointCfg");
 
@@ -164,7 +164,8 @@ public class IgfsServer {
 
         switch (typ) {
             case SHMEM: {
-                IpcSharedMemoryServerEndpoint endpoint = new IpcSharedMemoryServerEndpoint();
+                IpcSharedMemoryServerEndpoint endpoint =
+                    new IpcSharedMemoryServerEndpoint(igfsCtx.kernalContext().config().getWorkDirectory());
 
                 endpoint.setPort(endpointCfg.getPort());
                 endpoint.setSize(endpointCfg.getMemorySize());

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
index 2e60025..f6711d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.platform.cpp;
 
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryBasicIdMapper;
@@ -130,17 +129,7 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
         // Set Ignite home so that marshaller context works.
         String ggHome = igniteCfg.getIgniteHome();
 
-        if (ggHome == null)
-            ggHome = U.getIgniteHome();
-        else
-            // If user provided IGNITE_HOME - set it as a system property.
+        if (ggHome != null)
             U.setIgniteHome(ggHome);
-
-        try {
-            U.setWorkDirectory(igniteCfg.getWorkDirectory(), ggHome);
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index 5a7d15d..ed40be5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.platform.dotnet;
 
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.binary.BinaryBasicIdMapper;
 import org.apache.ignite.binary.BinaryBasicNameMapper;
@@ -151,19 +150,9 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
         // Set Ignite home so that marshaller context works.
         String ggHome = igniteCfg.getIgniteHome();
 
-        if (ggHome == null)
-            ggHome = U.getIgniteHome();
-        else
-            // If user provided IGNITE_HOME - set it as a system property.
+        if (ggHome != null)
             U.setIgniteHome(ggHome);
 
-        try {
-            U.setWorkDirectory(igniteCfg.getWorkDirectory(), ggHome);
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
-
         // 4. Callback to .Net.
         prepare(igniteCfg, dotNetCfg0);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index b31bbd3..ec025c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -786,12 +786,16 @@ public class PlatformUtils {
     @SuppressWarnings("deprecation")
     public static GridBinaryMarshaller marshaller() {
         try {
+            IgniteConfiguration cfg = new IgniteConfiguration();
+
             BinaryContext ctx =
-                new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
+                new BinaryContext(BinaryNoopMetadataHandler.instance(), cfg, new NullLogger());
 
             BinaryMarshaller marsh = new BinaryMarshaller();
 
-            marsh.setContext(new MarshallerContextImpl(null));
+            String workDir = U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome());
+
+            marsh.setContext(new MarshallerContextImpl(workDir, null));
 
             ctx.configure(marsh, new IgniteConfiguration());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 501cdb2..f07266b 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
@@ -305,9 +305,6 @@ public abstract class IgniteUtils {
     /** Project home directory. */
     private static volatile GridTuple<String> ggHome;
 
-    /** Project work directory. */
-    private static volatile String igniteWork;
-
     /** OS JDK string. */
     private static String osJdkStr;
 
@@ -8826,54 +8823,56 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * Get default work directory.
+     *
+     * @return Default work directory.
+     */
+    public static String defaultWorkDirectory() throws IgniteCheckedException {
+        return workDirectory(null, null);
+    }
+
+    /**
+     * Get work directory for the given user-provided work directory and Ignite home.
+     *
      * @param userWorkDir Ignite work folder provided by user.
      * @param userIgniteHome Ignite home folder provided by user.
      */
-    public static void setWorkDirectory(@Nullable String userWorkDir, @Nullable String userIgniteHome)
+    public static String workDirectory(@Nullable String userWorkDir, @Nullable String userIgniteHome)
         throws IgniteCheckedException {
-        String igniteWork0 = igniteWork;
-
-        if (igniteWork0 == null) {
-            synchronized (IgniteUtils.class) {
-                // Double check.
-                igniteWork0 = igniteWork;
-
-                if (igniteWork0 != null)
-                    return;
+        if (userIgniteHome == null)
+            userIgniteHome = getIgniteHome();
 
-                File workDir;
+        File workDir;
 
-                if (!F.isEmpty(userWorkDir))
-                    workDir = new File(userWorkDir);
-                else if (!F.isEmpty(IGNITE_WORK_DIR))
-                    workDir = new File(IGNITE_WORK_DIR);
-                else if (!F.isEmpty(userIgniteHome))
-                    workDir = new File(userIgniteHome, "work");
-                else {
-                    String tmpDirPath = System.getProperty("java.io.tmpdir");
+        if (!F.isEmpty(userWorkDir))
+            workDir = new File(userWorkDir);
+        else if (!F.isEmpty(IGNITE_WORK_DIR))
+            workDir = new File(IGNITE_WORK_DIR);
+        else if (!F.isEmpty(userIgniteHome))
+            workDir = new File(userIgniteHome, "work");
+        else {
+            String tmpDirPath = System.getProperty("java.io.tmpdir");
 
-                    if (tmpDirPath == null)
-                        throw new IgniteCheckedException("Failed to create work directory in OS temp " +
-                            "(property 'java.io.tmpdir' is null).");
+            if (tmpDirPath == null)
+                throw new IgniteCheckedException("Failed to create work directory in OS temp " +
+                    "(property 'java.io.tmpdir' is null).");
 
-                    workDir = new File(tmpDirPath, "ignite" + File.separator + "work");
-                }
+            workDir = new File(tmpDirPath, "ignite" + File.separator + "work");
+        }
 
-                if (!workDir.isAbsolute())
-                    throw new IgniteCheckedException("Work directory path must be absolute: " + workDir);
+        if (!workDir.isAbsolute())
+            throw new IgniteCheckedException("Work directory path must be absolute: " + workDir);
 
-                if (!mkdirs(workDir))
-                    throw new IgniteCheckedException("Work directory does not exist and cannot be created: " + workDir);
+        if (!mkdirs(workDir))
+            throw new IgniteCheckedException("Work directory does not exist and cannot be created: " + workDir);
 
-                if (!workDir.canRead())
-                    throw new IgniteCheckedException("Cannot read from work directory: " + workDir);
+        if (!workDir.canRead())
+            throw new IgniteCheckedException("Cannot read from work directory: " + workDir);
 
-                if (!workDir.canWrite())
-                    throw new IgniteCheckedException("Cannot write to work directory: " + workDir);
+        if (!workDir.canWrite())
+            throw new IgniteCheckedException("Cannot write to work directory: " + workDir);
 
-                igniteWork = workDir.getAbsolutePath();
-            }
-        }
+        return workDir.getAbsolutePath();
     }
 
     /**
@@ -8884,30 +8883,23 @@ public abstract class IgniteUtils {
     }
 
     /**
-     * Nullifies work directory. For test purposes only.
-     */
-    public static void nullifyWorkDirectory() {
-        igniteWork = null;
-    }
-
-    /**
      * Resolves work directory.
      *
+     * @param workDir Work directory.
      * @param path Path to resolve.
      * @param delIfExist Flag indicating whether to delete the specify directory or not.
      * @return Resolved work directory.
      * @throws IgniteCheckedException If failed.
      */
-    public static File resolveWorkDirectory(String path, boolean delIfExist) throws IgniteCheckedException {
+    public static File resolveWorkDirectory(String workDir, String path, boolean delIfExist)
+        throws IgniteCheckedException {
         File dir = new File(path);
 
         if (!dir.isAbsolute()) {
-            String ggWork0 = igniteWork;
-
-            if (F.isEmpty(ggWork0))
+            if (F.isEmpty(workDir))
                 throw new IgniteCheckedException("Failed to resolve path (work directory has not been set): " + path);
 
-            dir = new File(ggWork0, dir.getPath());
+            dir = new File(workDir, dir.getPath());
         }
 
         if (delIfExist && dir.exists()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
index 6fd6482..94c3820 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryServerEndpoint.java
@@ -120,6 +120,9 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
     /** Grid name. */
     private String gridName;
 
+    /** Work directory. */
+    private final String workDir;
+
     /** Flag allowing not to print out of resources warning. */
     private boolean omitOutOfResourcesWarn;
 
@@ -139,9 +142,11 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
     /**
      * Use this constructor when dependencies could be injected
      * with {@link GridResourceProcessor#injectGeneric(Object)}.
+     *
+     * @param workDir Work directory.
      */
-    public IpcSharedMemoryServerEndpoint() {
-        // No-op.
+    public IpcSharedMemoryServerEndpoint(String workDir) {
+        this.workDir = workDir;
     }
 
     /**
@@ -150,11 +155,13 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
      * @param log Log.
      * @param locNodeId Node id.
      * @param gridName Grid name.
+     * @param workDir Work directory.
      */
-    public IpcSharedMemoryServerEndpoint(IgniteLogger log, UUID locNodeId, String gridName) {
+    public IpcSharedMemoryServerEndpoint(IgniteLogger log, UUID locNodeId, String gridName, String workDir) {
         this.log = log;
         this.locNodeId = locNodeId;
         this.gridName = gridName;
+        this.workDir = workDir;
     }
 
     /** @param omitOutOfResourcesWarn If {@code true}, out of resources warning will not be printed by server. */
@@ -181,7 +188,7 @@ public class IpcSharedMemoryServerEndpoint implements IpcServerEndpoint {
 
         tokDirPath = tokDirPath + '/' + locNodeId.toString() + '-' + IpcSharedMemoryUtils.pid();
 
-        tokDir = U.resolveWorkDirectory(tokDirPath, false);
+        tokDir = U.resolveWorkDirectory(workDir, tokDirPath, false);
 
         if (port <= 0 || port >= 0xffff)
             throw new IpcEndpointBindException("Port value is illegal: " + port);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java b/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java
index 4214b5b..d5ff5e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java
+++ b/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java
@@ -113,6 +113,9 @@ public class JavaLogger implements IgniteLogger, LoggerNodeIdAware {
     /** Quiet flag. */
     private final boolean quiet;
 
+    /** Work directory. */
+    private volatile String workDir;
+
     /** Node ID. */
     private volatile UUID nodeId;
 
@@ -340,6 +343,15 @@ public class JavaLogger implements IgniteLogger, LoggerNodeIdAware {
         }
     }
 
+    /**
+     * Set work directory.
+     *
+     * @param workDir Work directory.
+     */
+    public void setWorkDirectory(String workDir) {
+        this.workDir = workDir;
+    }
+
     /** {@inheritDoc} */
     @Override public void setNodeId(UUID nodeId) {
         A.notNull(nodeId, "nodeId");
@@ -361,7 +373,7 @@ public class JavaLogger implements IgniteLogger, LoggerNodeIdAware {
             return;
 
         try {
-            fileHnd.nodeId(nodeId);
+            fileHnd.nodeId(nodeId, workDir);
         }
         catch (IgniteCheckedException | IOException e) {
             throw new RuntimeException("Failed to enable file handler.", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java b/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java
index 5acdc08..7d1fa08 100644
--- a/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/logger/java/JavaLoggerFileHandler.java
@@ -80,7 +80,7 @@ public final class JavaLoggerFileHandler extends StreamHandler {
      *
      * @param nodeId Node id.
      */
-    public void nodeId(UUID nodeId) throws IgniteCheckedException, IOException {
+    public void nodeId(UUID nodeId, String workDir) throws IgniteCheckedException, IOException {
         if (delegate != null)
             return;
 
@@ -91,7 +91,7 @@ public final class JavaLoggerFileHandler extends StreamHandler {
         if (ptrn == null)
             ptrn = "ignite-%{id8}.%g.log";
 
-        ptrn = new File(logDirectory(), ptrn.replace("%{id8}", U.id8(nodeId))).getAbsolutePath();
+        ptrn = new File(logDirectory(workDir), ptrn.replace("%{id8}", U.id8(nodeId))).getAbsolutePath();
 
         int limit = getIntProperty(clsName + ".limit", 0);
 
@@ -133,10 +133,12 @@ public final class JavaLoggerFileHandler extends StreamHandler {
     /**
      * Resolves logging directory.
      *
+     * @param workDir Work directory.
      * @return Logging directory.
      */
-    private static File logDirectory() throws IgniteCheckedException {
-        return !F.isEmpty(U.IGNITE_LOG_DIR) ? new File(U.IGNITE_LOG_DIR) : U.resolveWorkDirectory("log", false);
+    private static File logDirectory(String workDir) throws IgniteCheckedException {
+        return !F.isEmpty(U.IGNITE_LOG_DIR) ? new File(U.IGNITE_LOG_DIR) :
+            U.resolveWorkDirectory(workDir, "log", false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
index 092c864..21011a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
@@ -36,7 +36,6 @@ import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.MarshallerUtils;
-import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.resources.LoggerResource;
 import org.apache.ignite.spi.IgniteSpiAdapter;
@@ -291,7 +290,7 @@ public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements Checkpoin
                 folder = new File(curDirPath);
             else {
                 try {
-                    folder = U.resolveWorkDirectory(curDirPath, false);
+                    folder = U.resolveWorkDirectory(ignite.configuration().getWorkDirectory(), curDirPath, false);
                 }
                 catch (IgniteCheckedException e) {
                     if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index d81b9f3..d61cee6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -1779,8 +1779,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
         // If configured TCP port is busy, find first available in range.
         for (int port = shmemPort; port < shmemPort + locPortRange; port++) {
             try {
+                IgniteConfiguration cfg = ignite.configuration();
+
                 IpcSharedMemoryServerEndpoint srv =
-                    new IpcSharedMemoryServerEndpoint(log, ignite.configuration().getNodeId(), gridName);
+                    new IpcSharedMemoryServerEndpoint(log, cfg.getNodeId(), gridName, cfg.getWorkDirectory());
 
                 srv.setPort(port);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
index bcd9513..d4e93d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
@@ -140,7 +140,7 @@ public class TcpDiscoverySharedFsIpFinder extends TcpDiscoveryIpFinderAdapter {
                     tmp = new File(path);
                 else {
                     try {
-                        tmp = U.resolveWorkDirectory(path, false);
+                        tmp = U.resolveWorkDirectory(ignite.configuration().getWorkDirectory(), path, false);
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteSpiException("Failed to resolve directory [path=" + path +

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
index 9be5b93..222f463 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
@@ -299,7 +299,7 @@ public class FileSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi,
         String path = baseDir + File.separator + gridName + File.separator + ignite.configuration().getNodeId();
 
         try {
-            dir = U.resolveWorkDirectory(path, true);
+            dir = U.resolveWorkDirectory(ignite.configuration().getWorkDirectory(), path, true);
         }
         catch (IgniteCheckedException e) {
             throw new IgniteSpiException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java
index e549336..bf0adf8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java
@@ -90,7 +90,7 @@ public class MarshallerContextLockingSelfTest extends GridCommonAbstractTest {
         public void executeTest(GridTestLog4jLogger log) throws Exception {
             counter.incrementAndGet();
 
-            File workDir = U.resolveWorkDirectory("marshaller", false);
+            File workDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", false);
 
             final MarshallerContextImpl.ContinuousQueryListener queryListener = new MarshallerContextImpl.ContinuousQueryListener(log, workDir);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
index c7aecb4..2b7922e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
@@ -57,7 +57,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest
      */
     public void testJobRun() throws Exception {
         for (int i = 0; i < 5; i++) {
-            U.resolveWorkDirectory("marshaller", true);
+            U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", true);
 
             log.info("Iteration: " + i);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
index 7b0e950..1fb093a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
@@ -61,12 +61,9 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected void afterTestsStopped() throws Exception {
-        Path file = Paths.get(igniteHome + "/work/log/" + "test.log");
-        Files.delete(file);
-
+        Files.delete(Paths.get(igniteHome + "/work/log/" + "test.log"));
         Files.delete(Paths.get(igniteHome + "/work/log/" + "ignite.log"));
         Files.delete(Paths.get(igniteHome + "/work/log/"));
-        Files.delete(Paths.get(igniteHome + "/work/"));
 
         super.afterTestsStopped();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithSpecifiedWorkDirectorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithSpecifiedWorkDirectorySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithSpecifiedWorkDirectorySelfTest.java
deleted file mode 100644
index 3eb0eba..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithSpecifiedWorkDirectorySelfTest.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.internal.util;
-
-import java.io.File;
-import java.util.UUID;
-import junit.framework.TestCase;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.logger.java.JavaLogger;
-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 static org.apache.ignite.IgniteSystemProperties.IGNITE_HOME;
-import static org.apache.ignite.internal.util.IgniteUtils.nullifyHomeDirectory;
-import static org.apache.ignite.internal.util.IgniteUtils.nullifyWorkDirectory;
-
-/**
- * Checks creation of work folder.
- */
-public class GridStartupWithSpecifiedWorkDirectorySelfTest extends TestCase {
-    /** */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /** */
-    private static final int GRID_COUNT = 2;
-
-    /** System temp directory. */
-    private static final String TMP_DIR = System.getProperty("java.io.tmpdir");
-
-    /** {@inheritDoc} */
-    @Override protected void setUp() throws Exception {
-        // Protection against previously cached values.
-        nullifyHomeDirectory();
-        nullifyWorkDirectory();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void tearDown() throws Exception {
-        // Next grid in the same VM shouldn't use cached values produced by these tests.
-        nullifyHomeDirectory();
-        nullifyWorkDirectory();
-
-        U.setWorkDirectory(null, U.getIgniteHome());
-    }
-
-    /**
-     * @param log Grid logger.
-     * @return Grid configuration.
-     */
-    private IgniteConfiguration getConfiguration(IgniteLogger log) {
-        // We can't use U.getIgniteHome() here because
-        // it will initialize cached value which is forbidden to override.
-        String ggHome = IgniteSystemProperties.getString(IGNITE_HOME);
-
-        assert ggHome != null;
-
-        U.setIgniteHome(null);
-
-        String ggHome0 = U.getIgniteHome();
-
-        assert ggHome0 == null;
-
-        TcpDiscoverySpi disc = new TcpDiscoverySpi();
-
-        disc.setIpFinder(IP_FINDER);
-
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setGridLogger(log);
-        cfg.setDiscoverySpi(disc);
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testStartStopWithUndefinedHomeAndWorkDirs() throws Exception {
-        IgniteLogger log = new JavaLogger();
-
-        log.info(">>> Test started: " + getName());
-        log.info("Grid start-stop test count: " + GRID_COUNT);
-
-        File testWorkDir = null;
-
-        try {
-            for (int i = 0; i < GRID_COUNT; i++) {
-                try (Ignite g = G.start(getConfiguration(log))) {
-                    assert g != null;
-
-                    testWorkDir = U.resolveWorkDirectory(getName(), true);
-
-                    assertTrue("Work directory wasn't created", testWorkDir.exists());
-
-                    assertTrue("Work directory must be located in OS temp directory",
-                        testWorkDir.getAbsolutePath().startsWith(TMP_DIR));
-
-                    System.out.println(testWorkDir);
-
-                    X.println("Stopping grid " + g.cluster().localNode().id());
-                }
-            }
-        }
-        finally {
-            if (testWorkDir != null && testWorkDir.getAbsolutePath().startsWith(TMP_DIR))
-                U.delete(testWorkDir);
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testStartStopWithUndefinedHomeAndConfiguredWorkDirs() throws Exception {
-        IgniteLogger log = new JavaLogger();
-
-        log.info(">>> Test started: " + getName());
-        log.info("Grid start-stop test count: " + GRID_COUNT);
-
-        String tmpWorkDir = new File(TMP_DIR, getName() + "_" + UUID.randomUUID()).getAbsolutePath();
-
-        try {
-            for (int i = 0; i < GRID_COUNT; i++) {
-                IgniteConfiguration cfg = getConfiguration(log);
-
-                cfg.setWorkDirectory(tmpWorkDir);
-
-                try (Ignite g = G.start(cfg)) {
-                    assert g != null;
-
-                    File testWorkDir = U.resolveWorkDirectory(getName(), true);
-
-                    assertTrue("Work directory wasn't created", testWorkDir.exists());
-
-                    assertTrue("Work directory must be located in configured directory",
-                        testWorkDir.getAbsolutePath().startsWith(tmpWorkDir));
-
-                    X.println("Stopping grid " + g.cluster().localNode().id());
-                }
-            }
-        } finally {
-            U.delete(new File(tmpWorkDir));
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java
index 2873708..a983f82 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IgfsSharedMemoryTestServer.java
@@ -35,15 +35,13 @@ public class IgfsSharedMemoryTestServer {
     public static void main(String[] args) throws IgniteCheckedException {
         System.out.println("Starting server ...");
 
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         // Tell our process PID to the wrapper.
         X.println(GridJavaProcess.PID_MSG_PREFIX + U.jvmPid());
 
         InputStream is = null;
 
         try {
-            IpcServerEndpoint srv = new IpcSharedMemoryServerEndpoint();
+            IpcServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory());
 
             new IgniteTestResources().inject(srv);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
index 1aae999..0c5f564 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java
@@ -55,10 +55,7 @@ public class IpcSharedMemoryCrashDetectionSelfTest extends GridCommonAbstractTes
     @Override protected void afterTestsStopped() throws Exception {
         // Start and stop server endpoint to let GC worker
         // make a run and cleanup resources.
-
-        U.setWorkDirectory(null, U.getIgniteHome());
-
-        IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint();
+        IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory());
 
         new IgniteTestResources().inject(srv);
 
@@ -74,10 +71,8 @@ public class IpcSharedMemoryCrashDetectionSelfTest extends GridCommonAbstractTes
      * @throws Exception If failed.
      */
     public void testIgfsServerClientInteractionsUponClientKilling() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         // Run server endpoint.
-        IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint();
+        IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory());
 
         new IgniteTestResources().inject(srv);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java
index 90c74f9..d86f127 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/benchmark/IpcSharedMemoryBenchmarkReader.java
@@ -76,7 +76,7 @@ public class IpcSharedMemoryBenchmarkReader implements IpcSharedMemoryBenchmarkP
             }
         });
 
-        try (IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint()) {
+        try (IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory())) {
             new IgniteTestResources().inject(srv);
 
             srv.start();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java b/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java
index 5b0251d..5fd5b5e 100644
--- a/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java
@@ -37,10 +37,9 @@ public class JavaLoggerTest extends TestCase {
      * @throws Exception If failed.
      */
     public void testLogInitialize() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         log = new JavaLogger();
 
+        ((JavaLogger)log).setWorkDirectory(U.defaultWorkDirectory());
         ((LoggerNodeIdAware)log).setNodeId(UUID.fromString("00000000-1111-2222-3333-444444444444"));
 
         if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java
index eddc4de..ebbd8ac 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java
@@ -160,8 +160,6 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest
             for (int i = 0; i < workDirs.length; i++) {
                 workDir = workDirs[i];
 
-                U.nullifyWorkDirectory();
-
                 startGrid(i);
             }
 
@@ -178,8 +176,6 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest
             for (int i = 0; i < workDirs.length; i++) {
                 workDir = workDirs[i];
 
-                U.nullifyWorkDirectory();
-
                 startGrid(i);
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java
index ce89302..2eea7c1 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java
@@ -70,7 +70,7 @@ public class GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest extends
 
         String curSpiPath1 = getSpi().getCurrentDirectoryPath();
 
-        File folder1 = U.resolveWorkDirectory(curSpiPath1, false);
+        File folder1 = U.resolveWorkDirectory(U.defaultWorkDirectory(), curSpiPath1, false);
 
         assert folder1.exists() : "Checkpoint folder doesn't exist.";
 
@@ -83,7 +83,7 @@ public class GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest extends
 
         String curSpiPath2 = getSpi().getCurrentDirectoryPath();
 
-        File folder2 = U.resolveWorkDirectory(curSpiPath2, false);
+        File folder2 = U.resolveWorkDirectory(U.defaultWorkDirectory(), curSpiPath2, false);
 
         assert folder2.exists() : "Check point folder doesn't exist.";
 
@@ -97,7 +97,7 @@ public class GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest extends
 
         String newCurSpiPath = getSpi().getCurrentDirectoryPath();
 
-        File changedFolder = U.resolveWorkDirectory(newCurSpiPath, false);
+        File changedFolder = U.resolveWorkDirectory(U.defaultWorkDirectory(), newCurSpiPath, false);
 
         assert changedFolder.exists() : "Check point folder doesn't exist.";
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
index fc9cf0f..93339ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
@@ -283,8 +283,6 @@ public abstract class GridAbstractCommunicationSelfTest<T extends CommunicationS
      * @throws Exception If failed.
      */
     private void startSpis() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         spis.clear();
         nodes.clear();
         spiRsrcs.clear();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
index 7bbf531..a74a07a 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
@@ -468,8 +468,6 @@ public class GridTcpCommunicationSpiMultithreadedSelfTest extends GridSpiAbstrac
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         spis.clear();
         nodes.clear();
         spiRsrcs.clear();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java
index da1bc26..9e927dd 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java
@@ -65,8 +65,6 @@ public abstract class GridSwapSpaceSpiAbstractSelfTest extends GridCommonAbstrac
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         spi = spi();
 
         getTestResources().inject(spi);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 aa90af0..9f507e6 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
@@ -497,7 +497,7 @@ public abstract class GridAbstractTest extends TestCase {
      */
     protected void beforeTestsStarted() throws Exception {
         // Will clean and re-create marshaller directory from scratch.
-        U.resolveWorkDirectory("marshaller", true);
+        U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index c9859fc..b559897 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -27,9 +27,11 @@ import org.apache.ignite.IgniteAtomicReference;
 import org.apache.ignite.IgniteAtomicSequence;
 import org.apache.ignite.IgniteAtomicStamped;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteCluster;
 import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteCountDownLatch;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLock;
 import org.apache.ignite.IgniteSemaphore;
 import org.apache.ignite.IgniteDataStreamer;
@@ -55,6 +57,7 @@ import org.apache.ignite.internal.binary.BinaryCachingMetadataHandler;
 import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
 import org.apache.ignite.internal.processors.cacheobject.NoOpBinary;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.logger.NullLogger;
 import org.apache.ignite.marshaller.Marshaller;
@@ -136,6 +139,13 @@ public class IgniteMock implements Ignite {
         cfg.setIgniteHome(home);
         cfg.setLocalHost(locHost);
 
+        try {
+            cfg.setWorkDirectory(U.defaultWorkDirectory());
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException("Failed to get default work directory.", e);
+        }
+
         return cfg;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/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 13d5fbd..4d861d0 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
@@ -83,8 +83,6 @@ public class IgniteTestResources {
         home = U.getIgniteHome();
         locHost = localHost();
 
-        U.setWorkDirectory(null, null);
-
         GridTestKernalContext ctx = new GridTestKernalContext(log);
 
         rsrcProc = new GridResourceProcessor(ctx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
index 591753b..20b3cf2 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
@@ -429,8 +429,6 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi> extends GridAbstr
      * @throws Exception If failed.
      */
     protected void spiStart(IgniteSpi spi) throws Exception {
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         // Start SPI with unique grid name.
         spi.spiStart(getTestGridName());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
index 734e199..2e3d8b5 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
@@ -31,7 +31,6 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingRe
 import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingTxErrorTest;
 import org.apache.ignite.internal.processors.cache.IgniteDaemonNodeMarshallerCacheTest;
 import org.apache.ignite.internal.util.GridHandleTableSelfTest;
-import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
 import org.apache.ignite.internal.util.IgniteUtilsSelfTest;
 import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest;
 import org.apache.ignite.internal.util.nio.GridNioSelfTest;
@@ -80,7 +79,6 @@ public class IgniteBinaryBasicTestSuite extends TestSuite {
         ignoredTests.add(IgniteCacheP2pUnmarshallingNearErrorTest.class);
         ignoredTests.add(IgniteCacheP2pUnmarshallingRebalanceErrorTest.class);
         ignoredTests.add(GridReleaseTypeSelfTest.class);
-        ignoredTests.add(GridStartupWithSpecifiedWorkDirectorySelfTest.class);
         ignoredTests.add(IgniteUtilsSelfTest.class);
         ignoredTests.add(ClusterGroupSelfTest.class);
         ignoredTests.add(GridMessagingNoPeerClassLoadingSelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index b91fff4..d9cc8c0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -68,7 +68,6 @@ import org.apache.ignite.internal.processors.service.IgniteServiceDeploymentClas
 import org.apache.ignite.internal.processors.service.IgniteServiceDeploymentClassLoadingOptimizedMarshallerTest;
 import org.apache.ignite.internal.processors.service.IgniteServiceReassignmentTest;
 import org.apache.ignite.internal.processors.service.ServicePredicateAccessCacheTest;
-import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
 import org.apache.ignite.internal.util.GridStartupWithUndefinedIgniteHomeSelfTest;
 import org.apache.ignite.spi.communication.GridCacheMessageSelfTest;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -115,7 +114,6 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
         suite.addTestSuite(GridDiscoveryEventSelfTest.class);
         suite.addTestSuite(GridPortProcessorSelfTest.class);
         suite.addTestSuite(GridHomePathSelfTest.class);
-        GridTestUtils.addTestIfNeeded(suite, GridStartupWithSpecifiedWorkDirectorySelfTest.class, ignoredTests);
         suite.addTestSuite(GridStartupWithUndefinedIgniteHomeSelfTest.class);
         GridTestUtils.addTestIfNeeded(suite, GridVersionSelfTest.class, ignoredTests);
         suite.addTestSuite(GridListenActorSelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
index c845593..5c82469 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
@@ -55,8 +55,6 @@ public class CacheNoValueClassOnServerTestClient {
 
         cfg.setDiscoverySpi(disco);
 
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         try (Ignite ignite = Ignition.start(cfg)) {
             System.out.println("Test external node started");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
index 1134ab3..e0406c2 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigurationP2PTestClient.java
@@ -55,8 +55,6 @@ public class CacheConfigurationP2PTestClient {
 
         cfg.setDiscoverySpi(disco);
 
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         try (Ignite ignite = Ignition.start(cfg)) {
             System.out.println("Test external node started");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java
index 71bb8a4..0e86529 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopHelperImpl.java
@@ -16,7 +16,10 @@
  */
 package org.apache.ignite.internal.processors.hadoop;
 
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jetbrains.annotations.Nullable;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassWriter;
@@ -117,4 +120,14 @@ public class HadoopHelperImpl implements HadoopHelper {
     @Override @Nullable public InputStream loadClassBytes(ClassLoader ldr, String clsName) {
         return ldr.getResourceAsStream(clsName.replace('.', '/') + ".class");
     }
+
+    /** {@inheritDoc} */
+    @Override public String workDirectory() {
+        try {
+            return ctx != null ? ctx.config().getWorkDirectory() : U.defaultWorkDirectory();
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException("Failed to resolve Ignite work directory.", e);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
index 347bfae..a34388d 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
@@ -287,25 +287,28 @@ public class HadoopUtils {
     /**
      * Returns work directory for job execution.
      *
+     * @param workDir Work directory.
      * @param locNodeId Local node ID.
      * @param jobId Job ID.
      * @return Working directory for job.
      * @throws IgniteCheckedException If Failed.
      */
-    public static File jobLocalDir(UUID locNodeId, HadoopJobId jobId) throws IgniteCheckedException {
-        return new File(new File(U.resolveWorkDirectory("hadoop", false), "node-" + locNodeId), "job_" + jobId);
+    public static File jobLocalDir(String workDir, UUID locNodeId, HadoopJobId jobId) throws IgniteCheckedException {
+        return new File(new File(U.resolveWorkDirectory(workDir, "hadoop", false),
+            "node-" + locNodeId), "job_" + jobId);
     }
 
     /**
      * Returns subdirectory of job working directory for task execution.
      *
+     * @param workDir Work directory.
      * @param locNodeId Local node ID.
      * @param info Task info.
      * @return Working directory for task.
      * @throws IgniteCheckedException If Failed.
      */
-    public static File taskLocalDir(UUID locNodeId, HadoopTaskInfo info) throws IgniteCheckedException {
-        File jobLocDir = jobLocalDir(locNodeId, info.jobId());
+    public static File taskLocalDir(String workDir, UUID locNodeId, HadoopTaskInfo info) throws IgniteCheckedException {
+        File jobLocDir = jobLocalDir(workDir, locNodeId, info.jobId());
 
         return new File(jobLocDir, info.type() + "_" + info.taskNumber() + "_" + info.attempt());
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java
index 3731b2c..36da410 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2Job.java
@@ -311,7 +311,7 @@ public class HadoopV2Job implements HadoopJob {
         ClassLoader oldLdr = HadoopCommonUtils.setContextClassLoader(getClass().getClassLoader());
 
         try {
-            rsrcMgr.prepareJobEnvironment(!external, jobLocalDir(locNodeId, jobId));
+            rsrcMgr.prepareJobEnvironment(!external, jobLocalDir(igniteWorkDirectory(), locNodeId, jobId));
         }
         finally {
             HadoopCommonUtils.restoreContextClassLoader(oldLdr);
@@ -323,7 +323,7 @@ public class HadoopV2Job implements HadoopJob {
     @Override public void dispose(boolean external) throws IgniteCheckedException {
         try {
             if (rsrcMgr != null && !external) {
-                File jobLocDir = jobLocalDir(locNodeId, jobId);
+                File jobLocDir = jobLocalDir(igniteWorkDirectory(), locNodeId, jobId);
 
                 if (jobLocDir.exists())
                     U.delete(jobLocDir);
@@ -411,7 +411,7 @@ public class HadoopV2Job implements HadoopJob {
 
     /** {@inheritDoc} */
     @Override public void prepareTaskEnvironment(HadoopTaskInfo info) throws IgniteCheckedException {
-        rsrcMgr.prepareTaskWorkDir(taskLocalDir(locNodeId, info));
+        rsrcMgr.prepareTaskWorkDir(taskLocalDir(igniteWorkDirectory(), locNodeId, info));
     }
 
     /** {@inheritDoc} */
@@ -420,7 +420,7 @@ public class HadoopV2Job implements HadoopJob {
 
         taskCtxClsPool.add(ctx.getClass());
 
-        File locDir = taskLocalDir(locNodeId, info);
+        File locDir = taskLocalDir(igniteWorkDirectory(), locNodeId, info);
 
         if (locDir.exists())
             U.delete(locDir);
@@ -431,6 +431,11 @@ public class HadoopV2Job implements HadoopJob {
         rsrcMgr.cleanupStagingDirectory();
     }
 
+    /** {@inheritDoc} */
+    @Override public String igniteWorkDirectory() {
+        return helper.workDirectory();
+    }
+
     /**
      * Getter for job configuration.
      * @return The job configuration.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
index 96fa892..d444f2b 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
@@ -285,12 +285,12 @@ public class HadoopV2TaskContext extends HadoopTaskContext {
             case REDUCE:
                 job().prepareTaskEnvironment(taskInfo());
 
-                locDir = taskLocalDir(locNodeId, taskInfo());
+                locDir = taskLocalDir(job.igniteWorkDirectory(), locNodeId, taskInfo());
 
                 break;
 
             default:
-                locDir = jobLocalDir(locNodeId, taskInfo().jobId());
+                locDir = jobLocalDir(job.igniteWorkDirectory(), locNodeId, taskInfo().jobId());
         }
 
         ClassLoader oldLdr = HadoopCommonUtils.setContextClassLoader(jobConf().getClassLoader());

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java
index dc5874d..2c560bc 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/HadoopExternalTaskExecutor.java
@@ -106,7 +106,7 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
 
         log = ctx.kernalContext().log(HadoopExternalTaskExecutor.class);
 
-        outputBase = U.resolveWorkDirectory("hadoop", false);
+        outputBase = U.resolveWorkDirectory(ctx.kernalContext().config().getWorkDirectory(), "hadoop", false);
 
         pathSep = System.getProperty("path.separator", U.isWindows() ? ";" : ":");
 
@@ -118,7 +118,8 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
             ctx.kernalContext().config().getMarshaller(),
             log,
             ctx.kernalContext().getSystemExecutorService(),
-            ctx.kernalContext().gridName());
+            ctx.kernalContext().gridName(),
+            ctx.kernalContext().config().getWorkDirectory());
 
         comm.setListener(new MessageListener());
 
@@ -380,7 +381,8 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
                         log.debug("Created hadoop child process metadata for job [job=" + job +
                             ", childProcId=" + childProcId + ", taskMeta=" + startMeta + ']');
 
-                    Process proc = startJavaProcess(childProcId, startMeta, job);
+                    Process proc = startJavaProcess(childProcId, startMeta, job,
+                        ctx.kernalContext().config().getWorkDirectory());
 
                     BufferedReader rdr = new BufferedReader(new InputStreamReader(proc.getInputStream()));
 
@@ -517,10 +519,11 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
      * @param childProcId Child process ID.
      * @param startMeta Metadata.
      * @param job Job.
+     * @param igniteWorkDir Work directory.
      * @return Started process.
      */
     private Process startJavaProcess(UUID childProcId, HadoopExternalTaskMetadata startMeta,
-        HadoopJob job) throws Exception {
+        HadoopJob job, String igniteWorkDir) throws Exception {
         String outFldr = jobWorkFolder(job.id()) + File.separator + childProcId;
 
         if (log.isDebugEnabled())
@@ -528,7 +531,7 @@ public class HadoopExternalTaskExecutor extends HadoopTaskExecutorAdapter {
 
         List<String> cmd = new ArrayList<>();
 
-        File workDir = U.resolveWorkDirectory("", false);
+        File workDir = U.resolveWorkDirectory(igniteWorkDir, "", false);
 
         cmd.add(javaCmd);
         cmd.addAll(startMeta.jvmOptions());

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java
index 32880e4..90012fb 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/child/HadoopExternalProcessStarter.java
@@ -77,12 +77,11 @@ public class HadoopExternalProcessStarter {
     }
 
     /**
+     * Run the process.
      *
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void run() throws Exception {
-        U.setWorkDirectory(args.workDir, U.getIgniteHome());
-
         File outputDir = outputDirectory();
 
         initializeStreams(outputDir);
@@ -98,7 +97,8 @@ public class HadoopExternalProcessStarter {
             new JdkMarshaller(),
             log,
             msgExecSvc,
-            "external"
+            "external",
+            args.workDir
         );
 
         comm.start();
@@ -121,7 +121,7 @@ public class HadoopExternalProcessStarter {
 
     /**
      * @param outputDir Directory for process output.
-     * @throws Exception
+     * @throws Exception If failed.
      */
     private void initializeStreams(File outputDir) throws Exception {
         out = new FileOutputStream(new File(outputDir, args.childProcId + ".out"));

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
index 1d59a95..6d903d8 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/taskexecutor/external/communication/HadoopExternalCommunication.java
@@ -177,6 +177,9 @@ public class HadoopExternalCommunication {
     /** Grid name. */
     private String gridName;
 
+    /** Work directory. */
+    private String workDir;
+
     /** Complex variable that represents this node IP address. */
     private volatile InetAddress locHost;
 
@@ -254,6 +257,7 @@ public class HadoopExternalCommunication {
      * @param log Logger.
      * @param execSvc Executor service for message notification.
      * @param gridName Grid name.
+     * @param workDir Work directory.
      */
     public HadoopExternalCommunication(
         UUID parentNodeId,
@@ -261,7 +265,8 @@ public class HadoopExternalCommunication {
         Marshaller marsh,
         IgniteLogger log,
         ExecutorService execSvc,
-        String gridName
+        String gridName,
+        String workDir
     ) {
         locProcDesc = new HadoopProcessDescriptor(parentNodeId, procId);
 
@@ -269,6 +274,7 @@ public class HadoopExternalCommunication {
         this.log = log.getLogger(HadoopExternalCommunication.class);
         this.execSvc = execSvc;
         this.gridName = gridName;
+        this.workDir = workDir;
     }
 
     /**
@@ -685,7 +691,7 @@ public class HadoopExternalCommunication {
             try {
                 IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(
                     log.getLogger(IpcSharedMemoryServerEndpoint.class),
-                    locProcDesc.processId(), gridName);
+                    locProcDesc.processId(), gridName, workDir);
 
                 srv.setPort(port);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java
index 220614c..7e6fa9c 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopPlannerMockJob.java
@@ -101,6 +101,13 @@ public class HadoopPlannerMockJob implements HadoopJob {
         throwUnsupported();
     }
 
+    /** {@inheritDoc} */
+    @Override public String igniteWorkDirectory() {
+        throwUnsupported();
+
+        return null;
+    }
+
     /**
      * Throw {@link UnsupportedOperationException}.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java
index a40c531..38ff318 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/communication/HadoopExternalCommunicationSelfTest.java
@@ -81,7 +81,7 @@ public class HadoopExternalCommunicationSelfTest extends GridCommonAbstractTest
 
             for (int i = 0; i < comms.length; i++) {
                 comms[i] = new HadoopExternalCommunication(parentNodeId, UUID.randomUUID(), marsh, log,
-                    Executors.newFixedThreadPool(1), name + i);
+                    Executors.newFixedThreadPool(1), name + i, U.defaultWorkDirectory());
 
                 if (useShmem)
                     comms[i].setSharedMemoryPort(14000);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java
index 05a314b..500811f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTestServer.java
@@ -35,8 +35,6 @@ public class CacheConfigurationP2PTestServer {
 
         IgniteConfiguration cfg = CacheConfigurationP2PTest.createConfiguration();
 
-        U.setWorkDirectory(null, U.getIgniteHome());
-
         try (Ignite ignite = Ignition.start(cfg)) {
             System.out.println(CacheConfigurationP2PTest.NODE_START_MSG);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a92f20b5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 9d11ad3..47575e1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -116,7 +116,7 @@ namespace Apache.Ignite.Core.Tests
                 Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount);
                 Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout);
                 Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay);
-                Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory);
+                Assert.AreEqual(cfg.WorkDirectory.Trim('\\'), resCfg.WorkDirectory.Trim('\\'));
                 Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath);
                 Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions);
                 Assert.IsTrue(File.Exists(resCfg.JvmDllPath));


[14/40] ignite git commit: Squashed commit of the following:

Posted by av...@apache.org.
Squashed commit of the following:

commit 566881b695b8bc00e618fe9a9b4c86a8fd563cc1
Author: sboikov <sb...@gridgain.com>
Date:   Fri Oct 7 13:08:38 2016 +0300

    minor

commit 7fe88a1cb21f794ee55a176ab36d895cbf916528
Author: Dmitriy Govorukhin <dm...@gmail.com>
Date:   Thu Oct 6 11:11:24 2016 +0300

    ignite-update-notifier fix after review

    (cherry picked from commit a10d2ff)

commit f2de749f958a3b18dc479f8a5517d7bf9362b933
Author: Dmitriy Govorukhin <dm...@gmail.com>
Date:   Tue Oct 4 12:12:08 2016 +0300

    ignite-2079-2 optimize import and change url path

    (cherry picked from commit 830a3cf)

commit 0d1be85ad55b0aa91224690d6c112ae92e8bc0a9
Author: Dmitriy Govorukhin <dm...@gmail.com>
Date:   Thu Sep 29 19:54:54 2016 +0300

    update-notifier remove parse xml, now parse like properties

    (cherry picked from commit 9ecaa29)

commit e43bca6fb4528a7fc0dcb804a74fca1c59d7468b
Author: Dmitriy Govorukhin <dm...@gmail.com>
Date:   Tue Sep 27 17:07:21 2016 +0300

    remove dom parser

    (cherry picked from commit d1653b2)


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 952be8b995050b34379006dd6e739da3fe3b49e3
Parents: e6317e0
Author: Dmitriy Govorukhin <dm...@gmail.com>
Authored: Fri Oct 7 15:00:09 2016 +0300
Committer: Dmitriy Govorukhin <dm...@gmail.com>
Committed: Fri Oct 7 15:00:09 2016 +0300

----------------------------------------------------------------------
 .../processors/cluster/GridUpdateNotifier.java  | 108 ++++---------------
 1 file changed, 21 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/952be8b9/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
index b41bf28..592fdd1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
@@ -18,13 +18,11 @@
 package org.apache.ignite.internal.processors.cluster;
 
 import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.URL;
@@ -32,9 +30,6 @@ import java.net.URLConnection;
 import java.util.Collection;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.atomic.AtomicReference;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteSystemProperties;
@@ -47,12 +42,6 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.worker.GridWorker;
 import org.apache.ignite.plugin.PluginProvider;
 import org.jetbrains.annotations.Nullable;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
 
 import static java.net.URLEncoder.encode;
 
@@ -73,23 +62,20 @@ class GridUpdateNotifier {
     private static final long THROTTLE_PERIOD = 24 * 60 * 60 * 1000; // 1 day.
 
     /** Sleep milliseconds time for worker thread. */
-    public static final int WORKER_THREAD_SLEEP_TIME = 5000;
+    private static final int WORKER_THREAD_SLEEP_TIME = 5000;
+
+    /** Url for request version. */
+    private final static String UPDATE_NOTIFIER_URL = "https://ignite.run/update_status_ignite-plain-text.php";
 
     /** Grid version. */
     private final String ver;
 
-    /** Site. */
-    private final String url;
-
     /** Latest version. */
     private volatile String latestVer;
 
     /** Download url for latest version. */
     private volatile String downloadUrl;
 
-    /** HTML parsing helper. */
-    private final DocumentBuilder documentBuilder;
-
     /** Grid name. */
     private final String gridName;
 
@@ -130,23 +116,7 @@ class GridUpdateNotifier {
     GridUpdateNotifier(String gridName, String ver, GridKernalGateway gw, Collection<PluginProvider> pluginProviders,
         boolean reportOnlyNew) throws IgniteCheckedException {
         try {
-            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
-            documentBuilder = factory.newDocumentBuilder();
-
-            documentBuilder.setEntityResolver(new EntityResolver() {
-                @Override public InputSource resolveEntity(String publicId, String sysId) {
-                    if (sysId.endsWith(".dtd"))
-                        return new InputSource(new StringReader(""));
-
-                    return null;
-                }
-            });
-
             this.ver = ver;
-
-            url = "http://ignite.run/update_status_ignite.php";
-
             this.gridName = gridName == null ? "null" : gridName;
             this.gw = gw;
 
@@ -184,9 +154,6 @@ class GridUpdateNotifier {
 
             workerThread.start();
         }
-        catch (ParserConfigurationException e) {
-            throw new IgniteCheckedException("Failed to create xml parser.", e);
-        }
         catch (UnsupportedEncodingException e) {
             throw new IgniteCheckedException("Failed to encode.", e);
         }
@@ -346,7 +313,7 @@ class GridUpdateNotifier {
                     (!F.isEmpty(vmProps) ? "&vmProps=" + encode(vmProps, CHARSET) : "") +
                         pluginsVers;
 
-                URLConnection conn = new URL(url).openConnection();
+                URLConnection conn = new URL(UPDATE_NOTIFIER_URL).openConnection();
 
                 if (!isCancelled()) {
                     conn.setDoOutput(true);
@@ -356,8 +323,6 @@ class GridUpdateNotifier {
                     conn.setConnectTimeout(3000);
                     conn.setReadTimeout(3000);
 
-                    Document dom = null;
-
                     try {
                         try (OutputStream os = conn.getOutputStream()) {
                             os.write(postParams.getBytes(CHARSET));
@@ -369,30 +334,19 @@ class GridUpdateNotifier {
 
                             BufferedReader reader = new BufferedReader(new InputStreamReader(in, CHARSET));
 
-                            StringBuilder xml = new StringBuilder();
-
-                            String line;
-
-                            while ((line = reader.readLine()) != null) {
-                                if (line.contains("<meta") && !line.contains("/>"))
-                                    line = line.replace(">", "/>");
-
-                                xml.append(line).append('\n');
+                            for (String line; (line = reader.readLine()) != null; ) {
+                                if (line.contains("version"))
+                                    latestVer = obtainVersionFrom(line);
+                                else if (line.contains("downloadUrl"))
+                                    downloadUrl = obtainDownloadUrlFrom(line);
                             }
 
-                            dom = documentBuilder.parse(new ByteArrayInputStream(xml.toString().getBytes(CHARSET)));
                         }
                     }
                     catch (IOException e) {
                         if (log.isDebugEnabled())
                             log.debug("Failed to connect to Ignite update server. " + e.getMessage());
                     }
-
-                    if (dom != null) {
-                        latestVer = obtainVersionFrom(dom);
-
-                        downloadUrl = obtainDownloadUrlFrom(dom);
-                    }
                 }
             }
             catch (Exception e) {
@@ -404,55 +358,35 @@ class GridUpdateNotifier {
         /**
          * Gets the version from the current {@code node}, if one exists.
          *
-         * @param node W3C DOM node.
+         * @param  line Line which contains value for extract.
+         * @param  metaName Name for extract.
          * @return Version or {@code null} if one's not found.
          */
-        @Nullable private String obtainMeta(String metaName, Node node) {
-            assert node != null;
-
-            if (node instanceof Element && "meta".equals(node.getNodeName().toLowerCase())) {
-                Element meta = (Element)node;
-
-                String name = meta.getAttribute("name");
-
-                if (metaName.equals(name)) {
-                    String content = meta.getAttribute("content");
+        @Nullable private String obtainMeta(String metaName, String line) {
+            assert line.contains(metaName);
 
-                    if (content != null && !content.isEmpty())
-                        return content;
-                }
-            }
-
-            NodeList childNodes = node.getChildNodes();
-
-            for (int i = 0; i < childNodes.getLength(); i++) {
-                String ver = obtainMeta(metaName, childNodes.item(i));
+            return line.substring(line.indexOf(metaName) + metaName.length()).trim();
 
-                if (ver != null)
-                    return ver;
-            }
-
-            return null;
         }
 
         /**
          * Gets the version from the current {@code node}, if one exists.
          *
-         * @param node W3C DOM node.
+         * @param  line Line which contains value for extract.
          * @return Version or {@code null} if one's not found.
          */
-        @Nullable private String obtainVersionFrom(Node node) {
-            return obtainMeta("version", node);
+        @Nullable private String obtainVersionFrom(String line) {
+            return obtainMeta("version=", line);
         }
 
         /**
          * Gets the download url from the current {@code node}, if one exists.
          *
-         * @param node W3C DOM node.
+         * @param line Which contains value for extract.
          * @return download url or {@code null} if one's not found.
          */
-        @Nullable private String obtainDownloadUrlFrom(Node node) {
-            return obtainMeta("downloadUrl", node);
+        @Nullable private String obtainDownloadUrlFrom(String line) {
+            return obtainMeta("downloadUrl=", line);
         }
     }
 }


[24/40] ignite git commit: IGNITE-3972: Fixed a bug causing continuous queries to be lost for ATOMIC cache when key's primary node leaves topology. This closes #1133.

Posted by av...@apache.org.
IGNITE-3972: Fixed a bug causing continuous queries to be lost for ATOMIC cache when key's primary node leaves topology. This closes #1133.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 0659bebe04dc9c0b0a163bc95061519c553e678c
Parents: 01ca6db
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Wed Oct 12 14:49:36 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Oct 12 14:49:36 2016 +0300

----------------------------------------------------------------------
 .../continuous/CacheContinuousQueryHandler.java |   8 +-
 .../continuous/GridContinuousProcessor.java     |   6 +
 ...eContinuousQueryAsyncFailoverTxSelfTest.java |   5 +
 ...ContinuousQueryFailoverAbstractSelfTest.java | 225 ++++++++++++++++++-
 .../CacheContinuousQueryFailoverTxSelfTest.java |   5 +
 5 files changed, 237 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0659bebe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 4b5074c..304d031 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -595,12 +595,12 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
         assert objs != null;
         assert ctx != null;
 
-        final List<CacheContinuousQueryEntry> entries = (List<CacheContinuousQueryEntry>)objs;
-
-        if (entries.isEmpty())
+        if (objs.isEmpty())
             return;
 
         if (asyncCallback) {
+            final List<CacheContinuousQueryEntry> entries = objs instanceof List ? (List)objs : new ArrayList(objs);
+
             IgniteStripedThreadPoolExecutor asyncPool = ctx.asyncCallbackPool();
 
             int threadId = asyncPool.threadId(entries.get(0).partition());
@@ -639,7 +639,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
             }, threadId);
         }
         else
-            notifyCallback0(nodeId, ctx, entries);
+            notifyCallback0(nodeId, ctx, (Collection)objs);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0659bebe/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index f078b1b..3a559e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -820,6 +820,12 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
             if (!toSnd.isEmpty())
                 sendNotification(nodeId, routineId, null, toSnd, orderedTopic, true, null);
         }
+        else {
+            LocalRoutineInfo localRoutineInfo = locInfos.get(routineId);
+
+            if (localRoutineInfo != null)
+                localRoutineInfo.handler().notifyCallback(nodeId, routineId, objs, ctx);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0659bebe/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java
index 8f0bd0e..900abc8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java
@@ -41,4 +41,9 @@ public class CacheContinuousQueryAsyncFailoverTxSelfTest extends CacheContinuous
     @Override protected boolean asyncCallback() {
         return true;
     }
+
+    /** {@inheritDoc} */
+    public void testNoEventLossOnTopologyChange() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-4015");
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0659bebe/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
index 1376be1..1b7fe2b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
@@ -35,6 +35,7 @@ import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.cache.Cache;
 import javax.cache.CacheException;
@@ -51,6 +52,7 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
@@ -69,6 +71,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 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.managers.communication.GridIoMessage;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -84,9 +87,11 @@ import org.apache.ignite.internal.util.typedef.PA;
 import org.apache.ignite.internal.util.typedef.PAX;
 import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.T3;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteAsyncCallback;
 import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgniteOutClosure;
+import org.apache.ignite.logger.NullLogger;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.resources.LoggerResource;
 import org.apache.ignite.spi.IgniteSpiException;
@@ -141,10 +146,10 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
 
         cfg.setCommunicationSpi(commSpi);
 
-        MemoryEventStorageSpi eventSpi = new MemoryEventStorageSpi();
-        eventSpi.setExpireCount(50);
+        MemoryEventStorageSpi evtSpi = new MemoryEventStorageSpi();
+        evtSpi.setExpireCount(50);
 
-        cfg.setEventStorageSpi(eventSpi);
+        cfg.setEventStorageSpi(evtSpi);
 
         CacheConfiguration ccfg = new CacheConfiguration();
 
@@ -1180,7 +1185,7 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
                     CacheEntryEvent<?, ?> e = iter.next();
 
                     if ((exp.get2() != null && e.getValue() != null && exp.get2().equals(e.getValue()))
-                            && equalOldValue(e, exp)) {
+                        && equalOldValue(e, exp)) {
                         found = true;
 
                         iter.remove();
@@ -1254,12 +1259,12 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
      * @param e Event
      * @param expVals expected value
      * @return {@code True} if entries has the same key, value and oldValue. If cache start without backups
-     *          than oldValue ignoring in comparison.
+     * than oldValue ignoring in comparison.
      */
     private boolean equalOldValue(CacheEntryEvent<?, ?> e, T3<Object, Object, Object> expVals) {
         return (e.getOldValue() == null && expVals.get3() == null) // Both null
             || (e.getOldValue() != null && expVals.get3() != null  // Equals
-                && e.getOldValue().equals(expVals.get3()))
+            && e.getOldValue().equals(expVals.get3()))
             || (backups == 0); // If we start without backup than oldValue might be lose.
     }
 
@@ -2040,7 +2045,7 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
                             bar.await(1, MINUTES);
                     }
                 }
-                catch (Exception e){
+                catch (Exception e) {
                     log.error("Failed.", e);
 
                     err = true;
@@ -2251,6 +2256,164 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
     }
 
     /**
+     * This is failover test detecting CQ event loss while topology changing.
+     *
+     * @throws Exception If failed.
+     */
+    public void testNoEventLossOnTopologyChange() throws Exception {
+        final int stableNodeCnt = 1;
+
+        final int batchLoadSize = 2000;
+
+        final int restartCycles = 5;
+
+        Ignite qryClient = startGridsMultiThreaded(stableNodeCnt);
+
+        final CacheEventListener4 lsnr = new CacheEventListener4(atomicityMode() == CacheAtomicityMode.ATOMIC);
+
+        ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
+
+        qry.setLocalListener(lsnr);
+
+        IgniteCache<Integer, Integer> cache = qryClient.cache(null);
+
+        QueryCursor<?> cur = cache.query(qry);
+
+        int iteration = 0;
+
+        int putCnt = 0;
+
+        int ignoredDupEvts = 0;
+
+        Thread nodeRestartThread = nodeRestartThread(restartCycles, 2_000, 1_000);
+
+        try {
+            nodeRestartThread.start();
+
+            while (!Thread.interrupted() && nodeRestartThread.isAlive()) {
+                iteration++;
+
+                for (int i = 0; i < batchLoadSize; i++)
+                    cache.put(i, iteration);
+
+                putCnt += batchLoadSize;
+
+                log.info("Batch loaded. Iteration: " + iteration);
+
+                final long cnt = lsnr.count();
+
+                final long expCnt = putCnt * stableNodeCnt + ignoredDupEvts;
+
+                GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                    @Override public boolean apply() {
+                        return cnt == expCnt;
+                    }
+                }, 6_000);
+
+                if (cnt != expCnt) {
+                    StringBuilder sb = new StringBuilder();
+
+                    for (int i = 0; i < batchLoadSize; i++) {
+                        Integer key = i;
+                        Integer val = cache.get(key);
+
+                        if (!F.eq(val, iteration))
+                            sb.append("\n\t").append(">>> WRONG CACHE VALUE (lost data?) [key=").append(key)
+                                .append(", val=").append(val).append(']');
+                    }
+
+                    for (Map.Entry<Integer, Integer> entry : lsnr.eventMap().entrySet()) {
+                        Integer key = entry.getKey();
+                        Integer val = entry.getValue();
+
+                        if (!F.eq(val, iteration))
+                            sb.append("\n\t").append(">>> WRONG LISTENER VALUE (lost event?) [key=").append(key)
+                                .append(", val=").append(val).append(']');
+                    }
+
+                    String msg = sb.toString();
+
+                    // In atomic mode CQ can receive duplicate update events if update retried after fails.
+                    // E.g. topology change
+                    if (atomicityMode() == CacheAtomicityMode.ATOMIC && msg.isEmpty() && cnt > expCnt)
+                        ignoredDupEvts += cnt - expCnt;
+                    else
+                        fail("Unexpected event updates count: EXPECTED=" + expCnt + ", ACTUAL=" + cnt + ", " +
+                            "ITERATION=" + iteration + msg);
+                }
+
+                sleep(500);
+            }
+        }
+        finally {
+            nodeRestartThread.interrupt();
+
+            cur.close();
+
+            nodeRestartThread.join(3_000);
+        }
+    }
+
+    /**
+     * Starts thread which restarts a node over and over again.
+     */
+    private Thread nodeRestartThread(final int restartCycles, final long initDelay, final long restartDelay) {
+        Thread t = new Thread(new Runnable() {
+            public void run() {
+                sleep(initDelay);
+
+                try {
+                    for (int i = 1; i <= restartCycles && !Thread.interrupted(); i++) {
+
+                        IgniteConfiguration cfg = optimize(getConfiguration("restartNode")).
+                            setGridLogger(new NullLogger());
+
+                        log.info("Node restart cycle started: " + i);
+
+                        try (Ignite ignored = Ignition.start(cfg)) {
+                            awaitPartitionMapExchange();
+
+                            sleep(restartDelay);
+                        }
+
+                        log.info("Node restart cycle finished: " + i);
+
+                        awaitPartitionMapExchange();
+
+                        sleep(restartDelay);
+                    }
+                }
+                catch (Exception e) {
+                    log.error("Unexpected error.", e);
+                }
+            }
+        });
+
+        t.setName("flapping-node-thread");
+
+        t.setDaemon(true);
+
+        return t;
+    }
+
+    /**
+     * Sleep quietly
+     *
+     * @param sleepTime Sleep time.
+     */
+    private void sleep(long sleepTime) {
+        try {
+            if (Thread.currentThread().isInterrupted())
+                return;
+
+            U.sleep(sleepTime);
+        }
+        catch (IgniteInterruptedCheckedException e) {
+            Thread.interrupted();
+        }
+    }
+
+    /**
      *
      */
     @IgniteAsyncCallback
@@ -2363,7 +2526,7 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
 
         /** {@inheritDoc} */
         @Override public synchronized void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts)
-            throws CacheEntryListenerException  {
+            throws CacheEntryListenerException {
             try {
                 for (CacheEntryEvent<?, ?> evt : evts) {
                     Integer key = (Integer)evt.getKey();
@@ -2439,6 +2602,52 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
     }
 
     /**
+     * Listener.
+     */
+    private static class CacheEventListener4 implements CacheEntryUpdatedListener<Integer, Integer> {
+        /** Listener count. */
+        private final AtomicLong cntr = new AtomicLong();
+
+        /** Listener map. */
+        private final Map<Integer, Integer> evtMap = new ConcurrentHashMap<>();
+
+        /** Atomicity mode flag. */
+        private final boolean atomicModeFlag;
+
+        /** Constructor */
+        public CacheEventListener4(boolean atomicModeFlag) {
+            this.atomicModeFlag = atomicModeFlag;
+        }
+
+        /** {@inheritDoc} */
+        @SuppressWarnings("EqualsBetweenInconvertibleTypes")
+        @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts)
+            throws CacheEntryListenerException {
+            for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts) {
+                Integer prev = evtMap.put(evt.getKey(), evt.getValue());
+
+                //Atomic cache allows duplicate events if cache update operation fails, e.g. due to topology change.
+                if (!atomicModeFlag || prev == null || !prev.equals(evt))
+                    cntr.incrementAndGet();
+            }
+        }
+
+        /**
+         * @return Events count.
+         */
+        public long count() {
+            return cntr.get();
+        }
+
+        /**
+         * @return Event map.
+         */
+        Map<Integer, Integer> eventMap() {
+            return evtMap;
+        }
+    }
+
+    /**
      *
      */
     @IgniteAsyncCallback

http://git-wip-us.apache.org/repos/asf/ignite/blob/0659bebe/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java
index 789a105..c5240da 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java
@@ -36,4 +36,9 @@ public class CacheContinuousQueryFailoverTxSelfTest extends CacheContinuousQuery
     @Override protected CacheAtomicityMode atomicityMode() {
         return TRANSACTIONAL;
     }
+
+    /** {@inheritDoc} */
+    public void testNoEventLossOnTopologyChange() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-4015");
+    }
 }


[03/40] ignite git commit: Merge branch 'ignite-1.6.9' into ignite-1.6.10

Posted by av...@apache.org.
Merge branch 'ignite-1.6.9' into ignite-1.6.10


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 5e7ef8644ad824b87d4797e59133eb783ff8b098
Parents: a12298c de50287
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Oct 3 10:37:25 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Oct 3 10:37:25 2016 +0300

----------------------------------------------------------------------
 .../internal/binary/BinaryClassDescriptor.java  |  16 ++-
 .../binary/builder/BinaryObjectBuilderImpl.java |  24 ++--
 .../query/GridCacheQueryMetricsAdapter.java     |  12 +-
 .../cache/VisorCacheResetQueryMetricsTask.java  |  69 +++++++++++
 .../binary/BinaryFieldOrderSelfTest.java        | 115 -------------------
 .../IgniteBinaryObjectsTestSuite.java           |   2 -
 .../CacheAbstractQueryMetricsSelfTest.java      |   6 +-
 7 files changed, 99 insertions(+), 145 deletions(-)
----------------------------------------------------------------------



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

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


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 01ca6db70933fb7f50f161a80cde9647e68a3710
Parents: 359a392 60d2754
Author: dkarachentsev <dk...@gridgain.com>
Authored: Tue Oct 11 16:18:40 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Tue Oct 11 16:18:40 2016 +0300

----------------------------------------------------------------------
 .../internal/jdbc2/JdbcResultSetSelfTest.java   |  91 ++-
 .../rendezvous/RendezvousAffinityFunction.java  |   2 +-
 .../cache/store/jdbc/CacheJdbcBlobStore.java    |   4 +-
 .../configuration/CacheConfiguration.java       |  13 +-
 .../configuration/IgniteConfiguration.java      |  18 +-
 .../internal/GridEventConsumeHandler.java       |   8 +-
 .../internal/GridJobSiblingsResponse.java       |   3 +-
 .../ignite/internal/GridKernalContext.java      |  15 +
 .../ignite/internal/GridKernalContextImpl.java  |  28 +-
 .../internal/GridMessageListenHandler.java      |   8 +-
 .../apache/ignite/internal/IgniteKernal.java    |   6 +
 .../org/apache/ignite/internal/IgnitionEx.java  | 105 ++--
 .../ignite/internal/MarshallerContextImpl.java  |   5 +-
 .../internal/binary/BinaryEnumObjectImpl.java   |   3 +-
 .../internal/binary/BinaryMarshaller.java       |   2 +-
 .../internal/binary/BinaryWriterExImpl.java     |   3 +-
 .../GridClientOptimizedMarshaller.java          |   5 +-
 .../GridClientZipOptimizedMarshaller.java       |   5 +-
 .../apache/ignite/internal/jdbc/JdbcUtils.java  |   4 +-
 .../checkpoint/GridCheckpointManager.java       |   6 +-
 .../managers/communication/GridIoManager.java   | 173 +-----
 .../deployment/GridDeploymentCommunication.java |   4 +-
 .../eventstorage/GridEventStorageManager.java   |  16 +-
 .../swapspace/GridSwapSpaceManager.java         |  13 +-
 .../processors/affinity/GridAffinityUtils.java  |   4 +-
 .../cache/CacheEntrySerializablePredicate.java  |   4 +-
 .../cache/CacheInvokeDirectResult.java          |   4 +-
 .../processors/cache/GridCacheMapEntry.java     |  13 +-
 .../processors/cache/GridCacheMessage.java      |   4 +-
 .../processors/cache/GridCacheProcessor.java    |  13 +-
 .../processors/cache/GridCacheUtils.java        |   2 +-
 .../GridDistributedLockResponse.java            |   4 +-
 .../GridDistributedTxPrepareRequest.java        |   4 +-
 .../GridDistributedTxPrepareResponse.java       |   4 +-
 .../dht/GridDhtAffinityAssignmentResponse.java  |  12 +-
 .../dht/GridDhtTxFinishResponse.java            |   4 +-
 .../dht/atomic/GridDhtAtomicUpdateResponse.java |   4 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java |   2 +-
 .../atomic/GridNearAtomicUpdateResponse.java    |   4 +-
 .../dht/preloader/GridDhtForceKeysResponse.java |   4 +-
 .../GridDhtPartitionDemandMessage.java          |   4 +-
 .../preloader/GridDhtPartitionsFullMessage.java |   8 +-
 .../GridDhtPartitionsSingleMessage.java         |   8 +-
 .../distributed/near/GridNearGetResponse.java   |   4 +-
 .../near/GridNearSingleGetResponse.java         |   4 +-
 .../near/GridNearTxFinishResponse.java          |   4 +-
 .../cache/query/GridCacheLocalQueryFuture.java  |   4 +-
 .../cache/query/GridCacheQueryRequest.java      |  12 +-
 .../cache/query/GridCacheQueryResponse.java     |   4 +-
 .../cache/query/GridCacheSqlQuery.java          |   4 +-
 .../continuous/CacheContinuousQueryHandler.java |   4 +-
 .../jdbc/GridCacheQueryJdbcMetadataTask.java    |   4 +-
 .../query/jdbc/GridCacheQueryJdbcTask.java      |   6 +-
 .../cache/transactions/IgniteTxEntry.java       |   5 +-
 .../version/GridCacheRawVersionedEntry.java     |   8 +-
 .../IgniteCacheObjectProcessorImpl.java         |   3 +-
 .../processors/closure/GridClosurePolicy.java   |  51 --
 .../closure/GridClosureProcessor.java           |  96 +--
 .../processors/cluster/GridUpdateNotifier.java  | 108 +---
 .../continuous/GridContinuousProcessor.java     |   6 +-
 .../processors/continuous/StartRequestData.java |   4 +-
 .../datastreamer/DataStreamProcessor.java       |   8 +-
 .../datastreamer/DataStreamerImpl.java          |   6 +-
 .../processors/hadoop/HadoopHelper.java         |   7 +
 .../internal/processors/hadoop/HadoopJob.java   |   5 +
 .../processors/hadoop/HadoopNoopHelper.java     |   5 +
 .../processors/igfs/IgfsAckMessage.java         |   5 +-
 .../processors/igfs/IgfsDeleteMessage.java      |   5 +-
 .../internal/processors/igfs/IgfsPaths.java     |   4 +-
 .../internal/processors/igfs/IgfsServer.java    |   5 +-
 .../processors/igfs/IgfsThreadFactory.java      |  61 ++
 .../processors/job/GridJobProcessor.java        |  18 +-
 .../internal/processors/job/GridJobWorker.java  |   8 +-
 .../offheap/GridOffHeapProcessor.java           |   4 +-
 .../cpp/PlatformCppConfigurationClosure.java    |  13 +-
 .../PlatformDotNetConfigurationClosure.java     |  13 +-
 .../platform/utils/PlatformUtils.java           |   8 +-
 .../internal/processors/pool/PoolProcessor.java | 149 +++++
 .../processors/query/GridQueryProcessor.java    |  71 ++-
 .../handlers/task/GridTaskCommandHandler.java   |  10 +-
 .../rest/protocols/tcp/GridTcpRestParser.java   |   4 +-
 .../service/GridServiceProcessor.java           |   9 +-
 .../processors/task/GridTaskProcessor.java      |   8 +-
 .../processors/task/GridTaskWorker.java         |  14 +-
 .../ignite/internal/util/IgniteUtils.java       | 291 +++++++--
 .../shmem/IpcSharedMemoryServerEndpoint.java    |  15 +-
 .../apache/ignite/logger/java/JavaLogger.java   |  14 +-
 .../logger/java/JavaLoggerFileHandler.java      |  10 +-
 .../ignite/marshaller/jdk/JdkMarshaller.java    |   8 +-
 .../optimized/OptimizedMarshaller.java          |  14 +-
 .../sharedfs/SharedFsCheckpointSpi.java         |   3 +-
 .../spi/checkpoint/sharedfs/SharedFsUtils.java  |   4 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   4 +-
 .../ignite/spi/discovery/tcp/ClientImpl.java    |   8 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  24 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   8 +-
 .../TcpDiscoveryMulticastIpFinder.java          |   4 +-
 .../sharedfs/TcpDiscoverySharedFsIpFinder.java  |   2 +-
 .../TcpDiscoveryCustomEventMessage.java         |   3 +-
 .../spi/swapspace/file/FileSwapSpaceSpi.java    |   4 +-
 .../ignite/stream/socket/SocketStreamer.java    |   3 +-
 .../resources/META-INF/classnames.properties    |   1 -
 .../MarshallerContextLockingSelfTest.java       |   2 +-
 .../managers/GridManagerStopSelfTest.java       |   2 +
 .../GridCacheTtlManagerEvictionSelfTest.java    | 160 +++++
 .../MarshallerCacheJobRunNodeRestartTest.java   |   2 +-
 ...eEntryProcessorExternalizableFailedTest.java | 588 +++++++++++++++++++
 .../handlers/log/GridLogCommandHandlerTest.java |   5 +-
 ...artupWithSpecifiedWorkDirectorySelfTest.java | 166 ------
 .../util/future/GridFutureAdapterSelfTest.java  |   3 +
 .../ipc/shmem/IgfsSharedMemoryTestServer.java   |   4 +-
 .../IpcSharedMemoryCrashDetectionSelfTest.java  |   9 +-
 .../IpcSharedMemoryBenchmarkReader.java         |   2 +-
 .../ignite/logger/java/JavaLoggerTest.java      |   3 +-
 .../OptimizedMarshallerNodeFailoverTest.java    |   4 -
 ...heckpointSpiMultipleDirectoriesSelfTest.java |   6 +-
 .../GridAbstractCommunicationSelfTest.java      |   2 -
 ...cpCommunicationSpiMultithreadedSelfTest.java |   2 -
 .../GridSwapSpaceSpiAbstractSelfTest.java       |   2 -
 .../testframework/junits/GridAbstractTest.java  |   2 +-
 .../junits/GridTestKernalContext.java           |   1 +
 .../ignite/testframework/junits/IgniteMock.java |  10 +
 .../junits/IgniteTestResources.java             |   2 -
 .../junits/spi/GridSpiAbstractTest.java         |   2 -
 .../testsuites/IgniteBinaryBasicTestSuite.java  |   2 -
 .../ignite/testsuites/IgniteCacheTestSuite.java |   4 +
 .../testsuites/IgniteKernalSelfTestSuite.java   |   2 -
 .../CacheNoValueClassOnServerTestClient.java    |   2 -
 .../CacheConfigurationP2PTestClient.java        |   2 -
 .../processors/hadoop/HadoopHelperImpl.java     |  13 +
 .../processors/hadoop/impl/HadoopUtils.java     |  11 +-
 .../HadoopBasicFileSystemFactoryDelegate.java   |  16 +-
 ...HadoopKerberosFileSystemFactoryDelegate.java |   7 +-
 .../processors/hadoop/impl/v2/HadoopV2Job.java  |  13 +-
 .../hadoop/impl/v2/HadoopV2TaskContext.java     |   4 +-
 .../external/HadoopExternalTaskExecutor.java    |  13 +-
 .../child/HadoopExternalProcessStarter.java     |  10 +-
 .../HadoopExternalCommunication.java            |  10 +-
 .../communication/HadoopMarshallerFilter.java   |  13 +-
 .../hadoop/impl/HadoopPlannerMockJob.java       |   7 +
 .../impl/igfs/Hadoop1DualAbstractTest.java      |  12 +-
 ...oopSecondaryFileSystemConfigurationTest.java |  12 +
 .../HadoopExternalCommunicationSelfTest.java    |   2 +-
 .../hibernate/CacheHibernateBlobStore.java      |   4 +-
 .../processors/query/h2/IgniteH2Indexing.java   |   4 +-
 .../cache/CacheConfigurationP2PTestServer.java  |   2 -
 .../serialization/CacheEventDeserializer.java   |   3 +-
 .../serialization/CacheEventSerializer.java     |   3 +-
 .../IgniteConfigurationTest.cs                  |  24 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |   2 +-
 .../spi/deployment/uri/UriDeploymentSpi.java    |   2 +-
 .../scala/org/apache/ignite/visor/visor.scala   |   2 +-
 .../ignite/cache/websession/WebSessionV2.java   |  20 +-
 153 files changed, 2012 insertions(+), 1025 deletions(-)
----------------------------------------------------------------------


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


[40/40] ignite git commit: IGNITE-1924 Incomplete marshaller cache rebalancing causes Grid hangs under SSL (HOTFIX)

Posted by av...@apache.org.
IGNITE-1924 Incomplete marshaller cache rebalancing causes Grid hangs under SSL (HOTFIX)


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: b43bb6f6d6c8942b31e5144f32d6187907733e1a
Parents: 59de231
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Oct 17 20:56:28 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Oct 17 20:56:28 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java    | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b43bb6f6/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
index 273df5d..b3e8201 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
@@ -472,8 +472,6 @@ public class BlockingSslHandler {
      */
     private void readFromNet() throws IgniteCheckedException {
         try {
-            inNetBuf.clear();
-
             int read = ch.read(inNetBuf);
 
             if (read == -1)


[21/40] ignite git commit: Merge remote-tracking branch 'upstream/ignite-1.6.10' into ignite-1.6.10

Posted by av...@apache.org.
Merge remote-tracking branch 'upstream/ignite-1.6.10' into ignite-1.6.10


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 60d27547dfc6bd27c6d39cbcc523d0d1e872a821
Parents: 1938a17 9a6cfce
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Oct 11 14:51:00 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 11 14:51:00 2016 +0300

----------------------------------------------------------------------
 .../rendezvous/RendezvousAffinityFunction.java  |   2 +-
 .../cache/store/jdbc/CacheJdbcBlobStore.java    |   4 +-
 .../internal/GridEventConsumeHandler.java       |   8 +-
 .../internal/GridJobSiblingsResponse.java       |   3 +-
 .../internal/GridMessageListenHandler.java      |   8 +-
 .../internal/binary/BinaryEnumObjectImpl.java   |   3 +-
 .../internal/binary/BinaryMarshaller.java       |   2 +-
 .../internal/binary/BinaryWriterExImpl.java     |   3 +-
 .../GridClientOptimizedMarshaller.java          |   5 +-
 .../GridClientZipOptimizedMarshaller.java       |   5 +-
 .../apache/ignite/internal/jdbc/JdbcUtils.java  |   4 +-
 .../checkpoint/GridCheckpointManager.java       |   6 +-
 .../managers/communication/GridIoManager.java   |  12 +-
 .../deployment/GridDeploymentCommunication.java |   4 +-
 .../eventstorage/GridEventStorageManager.java   |  16 +-
 .../swapspace/GridSwapSpaceManager.java         |  13 +-
 .../processors/affinity/GridAffinityUtils.java  |   4 +-
 .../cache/CacheEntrySerializablePredicate.java  |   4 +-
 .../cache/CacheInvokeDirectResult.java          |   4 +-
 .../processors/cache/GridCacheMessage.java      |   4 +-
 .../processors/cache/GridCacheProcessor.java    |  13 +-
 .../processors/cache/GridCacheUtils.java        |   2 +-
 .../GridDistributedLockResponse.java            |   4 +-
 .../GridDistributedTxPrepareRequest.java        |   4 +-
 .../GridDistributedTxPrepareResponse.java       |   4 +-
 .../dht/GridDhtAffinityAssignmentResponse.java  |  12 +-
 .../dht/GridDhtTxFinishResponse.java            |   4 +-
 .../dht/atomic/GridDhtAtomicUpdateResponse.java |   4 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java |   2 +-
 .../atomic/GridNearAtomicUpdateResponse.java    |   4 +-
 .../dht/preloader/GridDhtForceKeysResponse.java |   4 +-
 .../GridDhtPartitionDemandMessage.java          |   4 +-
 .../preloader/GridDhtPartitionsFullMessage.java |   8 +-
 .../GridDhtPartitionsSingleMessage.java         |   8 +-
 .../distributed/near/GridNearGetResponse.java   |   4 +-
 .../near/GridNearSingleGetResponse.java         |   4 +-
 .../near/GridNearTxFinishResponse.java          |   4 +-
 .../cache/query/GridCacheLocalQueryFuture.java  |   4 +-
 .../cache/query/GridCacheQueryRequest.java      |  12 +-
 .../cache/query/GridCacheQueryResponse.java     |   4 +-
 .../cache/query/GridCacheSqlQuery.java          |   4 +-
 .../continuous/CacheContinuousQueryHandler.java |   4 +-
 .../jdbc/GridCacheQueryJdbcMetadataTask.java    |   4 +-
 .../query/jdbc/GridCacheQueryJdbcTask.java      |   6 +-
 .../cache/transactions/IgniteTxEntry.java       |   5 +-
 .../version/GridCacheRawVersionedEntry.java     |   8 +-
 .../IgniteCacheObjectProcessorImpl.java         |   3 +-
 .../closure/GridClosureProcessor.java           |   8 +-
 .../continuous/GridContinuousProcessor.java     |   6 +-
 .../processors/continuous/StartRequestData.java |   4 +-
 .../datastreamer/DataStreamProcessor.java       |   8 +-
 .../datastreamer/DataStreamerImpl.java          |   6 +-
 .../processors/igfs/IgfsAckMessage.java         |   5 +-
 .../processors/igfs/IgfsDeleteMessage.java      |   5 +-
 .../internal/processors/igfs/IgfsPaths.java     |   4 +-
 .../processors/job/GridJobProcessor.java        |  18 +-
 .../internal/processors/job/GridJobWorker.java  |   8 +-
 .../offheap/GridOffHeapProcessor.java           |   4 +-
 .../handlers/task/GridTaskCommandHandler.java   |  10 +-
 .../rest/protocols/tcp/GridTcpRestParser.java   |   4 +-
 .../service/GridServiceProcessor.java           |   9 +-
 .../processors/task/GridTaskProcessor.java      |   8 +-
 .../processors/task/GridTaskWorker.java         |  14 +-
 .../ignite/internal/util/IgniteUtils.java       | 199 +++++++
 .../ignite/marshaller/jdk/JdkMarshaller.java    |   8 +-
 .../optimized/OptimizedMarshaller.java          |  14 +-
 .../spi/checkpoint/sharedfs/SharedFsUtils.java  |   4 +-
 .../ignite/spi/discovery/tcp/ClientImpl.java    |   8 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  24 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   8 +-
 .../TcpDiscoveryMulticastIpFinder.java          |   4 +-
 .../TcpDiscoveryCustomEventMessage.java         |   3 +-
 .../spi/swapspace/file/FileSwapSpaceSpi.java    |   2 +-
 .../ignite/stream/socket/SocketStreamer.java    |   3 +-
 ...eEntryProcessorExternalizableFailedTest.java | 588 +++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |   2 +
 .../communication/HadoopMarshallerFilter.java   |  13 +-
 .../hibernate/CacheHibernateBlobStore.java      |   4 +-
 .../processors/query/h2/IgniteH2Indexing.java   |   4 +-
 .../serialization/CacheEventDeserializer.java   |   3 +-
 .../serialization/CacheEventSerializer.java     |   3 +-
 .../ignite/cache/websession/WebSessionV2.java   |  20 +-
 82 files changed, 1040 insertions(+), 252 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/60d27547/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------


[13/40] ignite git commit: IGNITE-3593 .NET: IgniteConfiguration.WorkDirectory has no effect. This closes #903. This closes #1145.

Posted by av...@apache.org.
IGNITE-3593 .NET: IgniteConfiguration.WorkDirectory has no effect. This closes #903. This closes #1145.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: e6317e01fa8a0de03e15dcdd84a575c6b06ce701
Parents: b94b0ae
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 6 12:03:48 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 6 12:03:48 2016 +0300

----------------------------------------------------------------------
 .../IgniteConfigurationTest.cs                  | 22 ++++++++++++++++++++
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |  2 +-
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e6317e01/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 47575e1..1773900 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -30,6 +30,7 @@ namespace Apache.Ignite.Core.Tests
     using Apache.Ignite.Core.Discovery.Tcp.Multicast;
     using Apache.Ignite.Core.Discovery.Tcp.Static;
     using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl;
     using Apache.Ignite.Core.Transactions;
     using NUnit.Framework;
 
@@ -301,6 +302,27 @@ namespace Apache.Ignite.Core.Tests
         }
 
         /// <summary>
+        /// Tests the work directory.
+        /// </summary>
+        [Test]
+        public void TestWorkDirectory()
+        {
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                WorkDirectory = IgniteUtils.GetTempDirectoryName()
+            };
+
+            using (Ignition.Start(cfg))
+            {
+                var marshDir = Path.Combine(cfg.WorkDirectory, "marshaller");
+
+                Assert.IsTrue(Directory.Exists(marshDir));
+            }
+
+            Directory.Delete(cfg.WorkDirectory, true);
+        }
+
+        /// <summary>
         /// Tests the ip finders.
         /// </summary>
         /// <param name="ipFinder">The ip finder.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/e6317e01/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index e43e332..57fb017 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -361,7 +361,7 @@ namespace Apache.Ignite.Core.Impl
         /// Creates a uniquely named, empty temporary directory on disk and returns the full path of that directory.
         /// </summary>
         /// <returns>The full path of the temporary directory.</returns>
-        private static string GetTempDirectoryName()
+        internal static string GetTempDirectoryName()
         {
             while (true)
             {


[27/40] ignite git commit: IGNITE-4034 Get rid of specialized methods in platform targets

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index a0abfaa..4722d0b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -365,6 +365,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
 
         #region NATIVE METHODS: TARGET
 
+        internal static long TargetInLongOutLong(IUnmanagedTarget target, int opType, long memPtr)
+        {
+            return JNI.TargetInLongOutLong(target.Context, target.Target, opType, memPtr);
+        }
+
         internal static long TargetInStreamOutLong(IUnmanagedTarget target, int opType, long memPtr)
         {
             return JNI.TargetInStreamOutLong(target.Context, target.Target, opType, memPtr);
@@ -387,6 +392,16 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             JNI.TargetInObjectStreamOutStream(target.Context, target.Target, opType, arg, inMemPtr, outMemPtr);
         }
 
+        internal static IUnmanagedTarget TargetInObjectStreamOutObjectStream(IUnmanagedTarget target, int opType, void* arg, long inMemPtr, long outMemPtr)
+        {
+            void* res = JNI.TargetInObjectStreamOutObjectStream(target.Context, target.Target, opType, arg, inMemPtr, outMemPtr);
+
+            if (res == null)
+                return null;
+
+            return target.ChangeTarget(res);
+        }
+
         internal static long TargetOutLong(IUnmanagedTarget target, int opType)
         {
             return JNI.TargetOutLong(target.Context, target.Target, opType);
@@ -431,345 +446,6 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
 
         #endregion
 
-        #region NATIVE METHODS: AFFINITY
-
-        internal static int AffinityPartitions(IUnmanagedTarget target)
-        {
-            return JNI.AffinityParts(target.Context, target.Target);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: CACHE
-
-        internal static IUnmanagedTarget CacheWithSkipStore(IUnmanagedTarget target)
-        {
-            void* res = JNI.CacheWithSkipStore(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheWithNoRetries(IUnmanagedTarget target)
-        {
-            void* res = JNI.CacheWithNoRetries(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheWithExpiryPolicy(IUnmanagedTarget target, long create, long update, long access)
-        {
-            void* res = JNI.CacheWithExpiryPolicy(target.Context, target.Target, create, update, access);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheWithAsync(IUnmanagedTarget target)
-        {
-            void* res = JNI.CacheWithAsync(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheWithKeepBinary(IUnmanagedTarget target)
-        {
-            void* res = JNI.CacheWithKeepBinary(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static void CacheClear(IUnmanagedTarget target)
-        {
-            JNI.CacheClear(target.Context, target.Target);
-        }
-
-        internal static void CacheRemoveAll(IUnmanagedTarget target)
-        {
-            JNI.CacheRemoveAll(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget CacheOutOpQueryCursor(IUnmanagedTarget target, int type, long memPtr)
-        {
-            void* res = JNI.CacheOutOpQueryCursor(target.Context, target.Target, type, memPtr);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheOutOpContinuousQuery(IUnmanagedTarget target, int type, long memPtr)
-        {
-            void* res = JNI.CacheOutOpContinuousQuery(target.Context, target.Target, type, memPtr);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheIterator(IUnmanagedTarget target)
-        {
-            void* res = JNI.CacheIterator(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheLocalIterator(IUnmanagedTarget target, int peekModes)
-        {
-            void* res = JNI.CacheLocalIterator(target.Context, target.Target, peekModes);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static void CacheEnterLock(IUnmanagedTarget target, long id)
-        {
-            JNI.CacheEnterLock(target.Context, target.Target, id);
-        }
-
-        internal static void CacheExitLock(IUnmanagedTarget target, long id)
-        {
-            JNI.CacheExitLock(target.Context, target.Target, id);
-        }
-
-        internal static bool CacheTryEnterLock(IUnmanagedTarget target, long id, long timeout)
-        {
-            return JNI.CacheTryEnterLock(target.Context, target.Target, id, timeout);
-        }
-
-        internal static void CacheCloseLock(IUnmanagedTarget target, long id)
-        {
-            JNI.CacheCloseLock(target.Context, target.Target, id);
-        }
-
-        internal static void CacheRebalance(IUnmanagedTarget target, long futId)
-        {
-            JNI.CacheRebalance(target.Context, target.Target, futId);
-        }
-
-        internal static void CacheStoreCallbackInvoke(IUnmanagedTarget target, long memPtr)
-        {
-            JNI.CacheStoreCallbackInvoke(target.Context, target.Target, memPtr);
-        }
-
-        internal static int CacheSize(IUnmanagedTarget target, int modes, bool loc)
-        {
-            return JNI.CacheSize(target.Context, target.Target, modes, loc);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: COMPUTE
-
-        internal static void ComputeWithNoFailover(IUnmanagedTarget target)
-        {
-            JNI.ComputeWithNoFailover(target.Context, target.Target);
-        }
-
-        internal static void ComputeWithTimeout(IUnmanagedTarget target, long timeout)
-        {
-            JNI.ComputeWithTimeout(target.Context, target.Target, timeout);
-        }
-
-        internal static IUnmanagedTarget ComputeExecuteNative(IUnmanagedTarget target, long taskPtr, long topVer)
-        {
-            void* res = JNI.ComputeExecuteNative(target.Context, target.Target, taskPtr, topVer);
-
-            return target.ChangeTarget(res);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: CONTINUOUS QUERY
-
-        internal static void ContinuousQueryClose(IUnmanagedTarget target)
-        {
-            JNI.ContinuousQryClose(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget ContinuousQueryGetInitialQueryCursor(IUnmanagedTarget target)
-        {
-            void* res = JNI.ContinuousQryGetInitialQueryCursor(target.Context, target.Target);
-
-            return res == null ? null : target.ChangeTarget(res);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: DATA STREAMER
-
-        internal static void DataStreamerListenTopology(IUnmanagedTarget target, long ptr)
-        {
-            JNI.DataStreamerListenTop(target.Context, target.Target, ptr);
-        }
-
-        internal static bool DataStreamerAllowOverwriteGet(IUnmanagedTarget target)
-        {
-            return JNI.DataStreamerAllowOverwriteGet(target.Context, target.Target);
-        }
-
-        internal static void DataStreamerAllowOverwriteSet(IUnmanagedTarget target, bool val)
-        {
-            JNI.DataStreamerAllowOverwriteSet(target.Context, target.Target, val);
-        }
-
-        internal static bool DataStreamerSkipStoreGet(IUnmanagedTarget target)
-        {
-            return JNI.DataStreamerSkipStoreGet(target.Context, target.Target);
-        }
-
-        internal static void DataStreamerSkipStoreSet(IUnmanagedTarget target, bool val)
-        {
-            JNI.DataStreamerSkipStoreSet(target.Context, target.Target, val);
-        }
-
-        internal static int DataStreamerPerNodeBufferSizeGet(IUnmanagedTarget target)
-        {
-            return JNI.DataStreamerPerNodeBufferSizeGet(target.Context, target.Target);
-        }
-
-        internal static void DataStreamerPerNodeBufferSizeSet(IUnmanagedTarget target, int val)
-        {
-            JNI.DataStreamerPerNodeBufferSizeSet(target.Context, target.Target, val);
-        }
-
-        internal static int DataStreamerPerNodeParallelOperationsGet(IUnmanagedTarget target)
-        {
-            return JNI.DataStreamerPerNodeParallelOpsGet(target.Context, target.Target);
-        }
-
-        internal static void DataStreamerPerNodeParallelOperationsSet(IUnmanagedTarget target, int val)
-        {
-            JNI.DataStreamerPerNodeParallelOpsSet(target.Context, target.Target, val);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: MESSAGING
-
-        internal static IUnmanagedTarget MessagingWithASync(IUnmanagedTarget target)
-        {
-            void* res = JNI.MessagingWithAsync(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: PROJECTION
-
-        internal static IUnmanagedTarget ProjectionForOthers(IUnmanagedTarget target, IUnmanagedTarget prj)
-        {
-            void* res = JNI.ProjectionForOthers(target.Context, target.Target, prj.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForRemotes(IUnmanagedTarget target)
-        {
-            void* res = JNI.ProjectionForRemotes(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForDaemons(IUnmanagedTarget target)
-        {
-            void* res = JNI.ProjectionForDaemons(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForRandom(IUnmanagedTarget target)
-        {
-            void* res = JNI.ProjectionForRandom(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForOldest(IUnmanagedTarget target)
-        {
-            void* res = JNI.ProjectionForOldest(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForYoungest(IUnmanagedTarget target)
-        {
-            void* res = JNI.ProjectionForYoungest(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-        
-        internal static void ProjectionResetMetrics(IUnmanagedTarget target)
-        {
-            JNI.ProjectionResetMetrics(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget ProjectionOutOpRet(IUnmanagedTarget target, int type, long memPtr)
-        {
-            void* res = JNI.ProjectionOutOpRet(target.Context, target.Target, type, memPtr);
-
-            return target.ChangeTarget(res);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: QUERY CURSOR
-
-        internal static void QueryCursorIterator(IUnmanagedTarget target)
-        {
-            JNI.QryCursorIterator(target.Context, target.Target);
-        }
-
-        internal static void QueryCursorClose(IUnmanagedTarget target)
-        {
-            JNI.QryCursorClose(target.Context, target.Target);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: TRANSACTIONS
-
-        internal static long TransactionsStart(IUnmanagedTarget target, int concurrency, int isolation, long timeout, int txSize)
-        {
-            return JNI.TxStart(target.Context, target.Target, concurrency, isolation, timeout, txSize);
-        }
-
-        internal static int TransactionsCommit(IUnmanagedTarget target, long id)
-        {
-            return JNI.TxCommit(target.Context, target.Target, id);
-        }
-
-        internal static void TransactionsCommitAsync(IUnmanagedTarget target, long id, long futId)
-        {
-            JNI.TxCommitAsync(target.Context, target.Target, id, futId);
-        }
-
-        internal static int TransactionsRollback(IUnmanagedTarget target, long id)
-        {
-            return JNI.TxRollback(target.Context, target.Target, id);
-        }
-
-        internal static void TransactionsRollbackAsync(IUnmanagedTarget target, long id, long futId)
-        {
-            JNI.TxRollbackAsync(target.Context, target.Target, id, futId);
-        }
-
-        internal static int TransactionsClose(IUnmanagedTarget target, long id)
-        {
-            return JNI.TxClose(target.Context, target.Target, id);
-        }
-
-        internal static int TransactionsState(IUnmanagedTarget target, long id)
-        {
-            return JNI.TxState(target.Context, target.Target, id);
-        }
-
-        internal static bool TransactionsSetRollbackOnly(IUnmanagedTarget target, long id)
-        {
-            return JNI.TxSetRollbackOnly(target.Context, target.Target, id);
-        }
-
-        internal static void TransactionsResetMetrics(IUnmanagedTarget target)
-        {
-            JNI.TxResetMetrics(target.Context, target.Target);
-        }
-
-        #endregion
-
         #region NATIVE METHODS: MISCELANNEOUS
 
         internal static void Reallocate(long memPtr, int cap)
@@ -827,176 +503,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             JNI.DestroyJvm(ctx);
         }
 
-        #endregion
-
-        #region NATIVE METHODS: EVENTS
-
-        internal static IUnmanagedTarget EventsWithAsync(IUnmanagedTarget target)
-        {
-            return target.ChangeTarget(JNI.EventsWithAsync(target.Context, target.Target));
-        }
-
-        internal static bool EventsStopLocalListen(IUnmanagedTarget target, long handle)
-        {
-            return JNI.EventsStopLocalListen(target.Context, target.Target, handle);
-        }
-
-        internal static bool EventsIsEnabled(IUnmanagedTarget target, int type)
-        {
-            return JNI.EventsIsEnabled(target.Context, target.Target, type);
-        }
-
-        internal static void EventsLocalListen(IUnmanagedTarget target, long handle, int type)
-        {
-            JNI.EventsLocalListen(target.Context, target.Target, handle, type);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: SERVICES
-
-        internal static IUnmanagedTarget ServicesWithAsync(IUnmanagedTarget target)
-        {
-            return target.ChangeTarget(JNI.ServicesWithAsync(target.Context, target.Target));
-        }
-
-        internal static IUnmanagedTarget ServicesWithServerKeepBinary(IUnmanagedTarget target)
-        {
-            return target.ChangeTarget(JNI.ServicesWithServerKeepBinary(target.Context, target.Target));
-        }
-
-        internal static void ServicesCancel(IUnmanagedTarget target, string name)
-        {
-            var nameChars = (char*)IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                JNI.ServicesCancel(target.Context, target.Target, nameChars);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(nameChars));
-            }
-        }
-
-        internal static void ServicesCancelAll(IUnmanagedTarget target)
-        {
-            JNI.ServicesCancelAll(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget ServicesGetServiceProxy(IUnmanagedTarget target, string name, bool sticky)
-        {
-            var nameChars = (char*)IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                return target.ChangeTarget(JNI.ServicesGetServiceProxy(target.Context, target.Target, nameChars, sticky));
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(nameChars));
-            }
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: DATA STRUCTURES
-
-        internal static long AtomicLongGet(IUnmanagedTarget target)
-        {
-            return JNI.AtomicLongGet(target.Context, target.Target);
-        }
-
-        internal static long AtomicLongIncrementAndGet(IUnmanagedTarget target)
-        {
-            return JNI.AtomicLongIncrementAndGet(target.Context, target.Target);
-        }
-
-        internal static long AtomicLongAddAndGet(IUnmanagedTarget target, long value)
-        {
-            return JNI.AtomicLongAddAndGet(target.Context, target.Target, value);
-        }
-
-        internal static long AtomicLongDecrementAndGet(IUnmanagedTarget target)
-        {
-            return JNI.AtomicLongDecrementAndGet(target.Context, target.Target);
-        }
-
-        internal static long AtomicLongGetAndSet(IUnmanagedTarget target, long value)
-        {
-            return JNI.AtomicLongGetAndSet(target.Context, target.Target, value);
-        }
-
-        internal static long AtomicLongCompareAndSetAndGet(IUnmanagedTarget target, long expVal, long newVal)
-        {
-            return JNI.AtomicLongCompareAndSetAndGet(target.Context, target.Target, expVal, newVal);
-        }
-
-        internal static bool AtomicLongIsClosed(IUnmanagedTarget target)
-        {
-            return JNI.AtomicLongIsClosed(target.Context, target.Target);
-        }
-
-        internal static void AtomicLongClose(IUnmanagedTarget target)
-        {
-            JNI.AtomicLongClose(target.Context, target.Target);
-        }
-
-        internal static long AtomicSequenceGet(IUnmanagedTarget target)
-        {
-            return JNI.AtomicSequenceGet(target.Context, target.Target);
-        }
-
-        internal static long AtomicSequenceIncrementAndGet(IUnmanagedTarget target)
-        {
-            return JNI.AtomicSequenceIncrementAndGet(target.Context, target.Target);
-        }
-
-        internal static long AtomicSequenceAddAndGet(IUnmanagedTarget target, long value)
-        {
-            return JNI.AtomicSequenceAddAndGet(target.Context, target.Target, value);
-        }
-
-        internal static int AtomicSequenceGetBatchSize(IUnmanagedTarget target)
-        {
-            return JNI.AtomicSequenceGetBatchSize(target.Context, target.Target);
-        }
-
-        internal static void AtomicSequenceSetBatchSize(IUnmanagedTarget target, int size)
-        {
-            JNI.AtomicSequenceSetBatchSize(target.Context, target.Target, size);
-        }
-
-        internal static bool AtomicSequenceIsClosed(IUnmanagedTarget target)
-        {
-            return JNI.AtomicSequenceIsClosed(target.Context, target.Target);
-        }
-
-        internal static void AtomicSequenceClose(IUnmanagedTarget target)
-        {
-            JNI.AtomicSequenceClose(target.Context, target.Target);
-        }
-
-        internal static bool AtomicReferenceIsClosed(IUnmanagedTarget target)
-        {
-            return JNI.AtomicReferenceIsClosed(target.Context, target.Target);
-        }
-
-        internal static void AtomicReferenceClose(IUnmanagedTarget target)
-        {
-            JNI.AtomicReferenceClose(target.Context, target.Target);
-        }
-
         internal static bool ListenableCancel(IUnmanagedTarget target)
         {
             return JNI.ListenableCancel(target.Context, target.Target);
         }
 
-        internal static bool ListenableIsCancelled(IUnmanagedTarget target)
-        {
-            return JNI.ListenableIsCancelled(target.Context, target.Target);
-        }
-
         #endregion
     }
 }


[06/40] ignite git commit: IGNITE-3645: IGFS: Local secondary: Implemented update() operation. This closes #1003.

Posted by av...@apache.org.
IGNITE-3645: IGFS: Local secondary: Implemented update() operation. This closes #1003.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 9f211e413332931f0fb1190744ddd7c7f38fd213
Parents: 0b66d2d
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Mon Oct 3 12:26:12 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Oct 3 12:26:12 2016 +0300

----------------------------------------------------------------------
 .../local/LocalIgfsSecondaryFileSystem.java     |  90 ++-
 .../internal/processors/igfs/IgfsImpl.java      |  11 +-
 .../processors/igfs/IgfsMetaManager.java        |   1 -
 .../local/LocalFileSystemIgfsFile.java          |   9 +-
 .../secondary/local/LocalFileSystemUtils.java   | 142 +++++
 .../igfs/IgfsAbstractBaseSelfTest.java          |  19 +
 .../processors/igfs/IgfsAbstractSelfTest.java   |   5 +-
 .../igfs/IgfsDualAbstractSelfTest.java          |  42 +-
 ...SecondaryFileSystemDualAbstractSelfTest.java |  26 +-
 ...fsLocalSecondaryFileSystemProxySelfTest.java |   5 -
 ...IgfsLocalSecondaryFileSystemTestAdapter.java |  27 +-
 .../igfs/benchmark/IgfsBenchmark.java           | 561 +++++++++++++++++++
 ...doopIgfsSecondaryFileSystemDelegateImpl.java |   3 +-
 .../hadoop/impl/igfs/HadoopIgfsProperties.java  |   3 +
 14 files changed, 900 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
index 1775db6..ef00bea 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
@@ -26,8 +26,10 @@ import org.apache.ignite.igfs.IgfsPathIsNotDirectoryException;
 import org.apache.ignite.igfs.IgfsPathNotFoundException;
 import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
 import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
 import org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemIgfsFile;
 import org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemSizeVisitor;
+import org.apache.ignite.internal.processors.igfs.secondary.local.LocalFileSystemUtils;
 import org.apache.ignite.internal.processors.igfs.secondary.local.LocalIgfsSecondaryFileSystemPositionedReadable;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -44,6 +46,7 @@ import java.nio.file.Files;
 import java.nio.file.LinkOption;
 import java.nio.file.Path;
 import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.PosixFileAttributes;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
@@ -76,7 +79,14 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, Li
 
     /** {@inheritDoc} */
     @Nullable @Override public IgfsFile update(IgfsPath path, Map<String, String> props) {
-        throw new UnsupportedOperationException("Update operation is not yet supported.");
+        File f = fileForPath(path);
+
+        if (!f.exists())
+            return null;
+
+        updatePropertiesIfNeeded(path, props);
+
+        return info(path);
     }
 
     /** {@inheritDoc} */
@@ -157,6 +167,8 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, Li
     /** {@inheritDoc} */
     @Override public void mkdirs(IgfsPath path, @Nullable Map<String, String> props) {
         mkdirs(path);
+
+        updatePropertiesIfNeeded(path, props);
     }
 
     /**
@@ -258,7 +270,23 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, Li
     /** {@inheritDoc} */
     @Override public OutputStream create(IgfsPath path, int bufSize, boolean overwrite, int replication,
         long blockSize, @Nullable Map<String, String> props) {
-        return create0(path, overwrite);
+        OutputStream os = create0(path, overwrite);
+
+        try {
+            updatePropertiesIfNeeded(path, props);
+
+            return os;
+        }
+        catch (Exception err) {
+            try {
+                os.close();
+            }
+            catch (IOException closeErr) {
+                err.addSuppressed(closeErr);
+            }
+
+            throw err;
+        }
     }
 
     /** {@inheritDoc} */
@@ -269,11 +297,30 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, Li
 
             boolean exists = file.exists();
 
-            if (exists)
-                return new FileOutputStream(file, true);
+            if (exists) {
+                OutputStream os = new FileOutputStream(file, true);
+
+                try {
+                    updatePropertiesIfNeeded(path, props);
+
+                    return os;
+                }
+                catch (Exception err) {
+                    try {
+                        os.close();
+
+                        throw err;
+                    }
+                    catch (IOException closeErr) {
+                        err.addSuppressed(closeErr);
+
+                        throw err;
+                    }
+                }
+            }
             else {
                 if (create)
-                    return create0(path, false);
+                    return create(path, bufSize, false, 0, 0, props);
                 else
                     throw new IgfsPathNotFoundException("Failed to append to file because it doesn't exist: " + path);
             }
@@ -285,17 +332,21 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, Li
 
     /** {@inheritDoc} */
     @Override public IgfsFile info(final IgfsPath path) {
-        File f = fileForPath(path);
+        File file = fileForPath(path);
 
-        if (!f.exists())
+        if (!file.exists())
             return null;
 
-        boolean isDir = f.isDirectory();
+        boolean isDir = file.isDirectory();
+
+        PosixFileAttributes attrs = LocalFileSystemUtils.posixAttributes(file);
+
+        Map<String, String> props = LocalFileSystemUtils.posixAttributesToMap(attrs);
 
         if (isDir)
-            return new LocalFileSystemIgfsFile(path, false, true, 0, f.lastModified(), 0, null);
+            return new LocalFileSystemIgfsFile(path, false, true, 0, file.lastModified(), 0, props);
         else
-            return new LocalFileSystemIgfsFile(path, f.isFile(), false, 0, f.lastModified(), f.length(), null);
+            return new LocalFileSystemIgfsFile(path, file.isFile(), false, 0, file.lastModified(), file.length(), props);
     }
 
     /** {@inheritDoc} */
@@ -412,4 +463,23 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, Li
             throw handleSecondaryFsError(e, "Failed to create file [path=" + path + ", overwrite=" + overwrite + ']');
         }
     }
+
+    /**
+     * Update path properties if needed.
+     *
+     * @param path IGFS path
+     * @param props Properties map.
+     */
+    private void updatePropertiesIfNeeded(IgfsPath path, Map<String, String> props) {
+        if (props == null || props.isEmpty())
+            return;
+
+        File file = fileForPath(path);
+
+        if (!file.exists())
+            throw new IgfsPathNotFoundException("Failed to update properties for path: " + path);
+
+        LocalFileSystemUtils.updateProperties(file, props.get(IgfsUtils.PROP_GROUP_NAME),
+            props.get(IgfsUtils.PROP_PERMISSION));
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/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 1dd12d9..1c985c0 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
@@ -152,9 +152,6 @@ public final class IgfsImpl implements IgfsEx {
     /** Writers map. */
     private final ConcurrentHashMap8<IgfsPath, IgfsFileWorkerBatch> workerMap = new ConcurrentHashMap8<>();
 
-    /** Local metrics holder. */
-    private final IgfsLocalMetrics metrics = new IgfsLocalMetrics();
-
     /** Client log directory. */
     private volatile String logDir;
 
@@ -765,13 +762,11 @@ public final class IgfsImpl implements IgfsEx {
                 if (log.isDebugEnabled())
                     log.debug("Make directories: " + path);
 
-                final Map<String, String> props0 = props == null ? DFLT_DIR_META : new HashMap<>(props);
-
                 IgfsMode mode = resolveMode(path);
 
                 switch (mode) {
                     case PRIMARY:
-                        meta.mkdirs(path, props0);
+                        meta.mkdirs(path, props == null ? DFLT_DIR_META : new HashMap<>(props));
 
                         break;
 
@@ -779,12 +774,12 @@ public final class IgfsImpl implements IgfsEx {
                     case DUAL_SYNC:
                         await(path);
 
-                        meta.mkdirsDual(secondaryFs, path, props0);
+                        meta.mkdirsDual(secondaryFs, path, props);
 
                         break;
 
                     case PROXY:
-                        secondaryFs.mkdirs(path, props0);
+                        secondaryFs.mkdirs(path, props);
 
                         break;
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/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 89cadce..ffa502b 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
@@ -2226,7 +2226,6 @@ public class IgfsMetaManager extends IgfsManager {
             try {
                 assert fs != null;
                 assert path != null;
-                assert props != null;
 
                 if (path.parent() == null)
                     return true; // No additional handling for root directory is needed.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java
index 5abe4eb..400ac34 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemIgfsFile.java
@@ -17,14 +17,13 @@
 
 package org.apache.ignite.internal.processors.igfs.secondary.local;
 
+import java.util.Collections;
+import java.util.Map;
 import org.apache.ignite.igfs.IgfsFile;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.processors.igfs.IgfsUtils;
 import org.jetbrains.annotations.Nullable;
 
-import java.util.Collections;
-import java.util.Map;
-
 /**
  * Implementation of the IgfsFile interface for the local filesystem.
  */
@@ -45,7 +44,7 @@ public class LocalFileSystemIgfsFile implements IgfsFile {
     private final long len;
 
     /** Properties. */
-    private final Map<String, String> props;
+    private Map<String, String> props;
 
     /**
      * @param path IGFS path.
@@ -63,7 +62,7 @@ public class LocalFileSystemIgfsFile implements IgfsFile {
         assert !isDir || len == 0 : "length must be 0 for dirs. [length=" + len + ']';
 
         this.path = path;
-        this.flags = IgfsUtils.flags(isDir, isFile);
+        flags = IgfsUtils.flags(isDir, isFile);
         this.blockSize = blockSize;
         this.modTime = modTime;
         this.len = len;

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemUtils.java
new file mode 100644
index 0000000..59383c5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/secondary/local/LocalFileSystemUtils.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs.secondary.local;
+
+import org.apache.ignite.igfs.IgfsException;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.attribute.GroupPrincipal;
+import java.nio.file.attribute.PosixFileAttributeView;
+import java.nio.file.attribute.PosixFileAttributes;
+import java.nio.file.attribute.PosixFilePermission;
+import java.nio.file.attribute.UserPrincipalLookupService;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Various utility methods for local file system.
+ */
+public class LocalFileSystemUtils {
+    /** Posix file permissions. */
+    public static final PosixFilePermission[] POSIX_PERMISSIONS = PosixFilePermission.values();
+
+    /**
+     * Update file properties.
+     *
+     * @param file File.
+     * @param grp Group.
+     * @param perm Permissions.
+     */
+    public static void updateProperties(File file, String grp, String perm) {
+        PosixFileAttributeView attrs = Files.getFileAttributeView(file.toPath(), PosixFileAttributeView.class);
+
+        if (attrs == null)
+            throw new UnsupportedOperationException("Posix file attributes not available");
+
+        if (grp != null) {
+            try {
+                UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService();
+
+                GroupPrincipal grp0 = lookupService.lookupPrincipalByGroupName(grp);
+
+                attrs.setGroup(grp0);
+            }
+            catch (IOException e) {
+                throw new IgfsException("Update the '" + IgfsUtils.PROP_GROUP_NAME + "' property is failed.", e);
+            }
+        }
+
+        if (perm != null) {
+            int perm0 = Integer.parseInt(perm, 8);
+
+            Set<PosixFilePermission> permSet = new HashSet<>(9);
+
+            for (int i = 0; i < LocalFileSystemUtils.POSIX_PERMISSIONS.length; ++i) {
+                if ((perm0 & (1 << i)) != 0)
+                    permSet.add(LocalFileSystemUtils.POSIX_PERMISSIONS[i]);
+            }
+
+            try {
+                attrs.setPermissions(permSet);
+            }
+            catch (IOException e) {
+                throw new IgfsException("Update the '" + IgfsUtils.PROP_PERMISSION + "' property is failed.", e);
+            }
+        }
+    }
+
+    /**
+     * Get POSIX attributes for file.
+     *
+     * @param file File.
+     */
+    @Nullable public static PosixFileAttributes posixAttributes(File file) {
+        PosixFileAttributes attrs = null;
+
+        try {
+            PosixFileAttributeView view = Files.getFileAttributeView(file.toPath(), PosixFileAttributeView.class);
+
+            if (view != null)
+                attrs = view.readAttributes();
+        }
+        catch (IOException e) {
+            throw new IgfsException("Failed to read POSIX attributes: " + file.getAbsolutePath(), e);
+        }
+
+        return attrs;
+    }
+
+    /**
+     * Convert POSIX attributes to property map.
+     *
+     * @param attrs Attributes view.
+     * @return IGFS properties map.
+     */
+    public static Map<String, String> posixAttributesToMap(PosixFileAttributes attrs) {
+        if (attrs == null)
+            return null;
+
+        Map<String, String> props = U.newHashMap(3);
+
+        props.put(IgfsUtils.PROP_USER_NAME, attrs.owner().getName());
+        props.put(IgfsUtils.PROP_GROUP_NAME, attrs.group().getName());
+
+        int perm = 0;
+
+        for(PosixFilePermission p : attrs.permissions())
+            perm |= (1 << 8 - p.ordinal());
+
+        props.put(IgfsUtils.PROP_PERMISSION, '0' + Integer.toOctalString(perm));
+
+        return props;
+    }
+
+    /**
+     * Private constructor.
+     */
+    private LocalFileSystemUtils() {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java
index 79dc57b..374d3d3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java
@@ -871,6 +871,25 @@ public abstract class IgfsAbstractBaseSelfTest extends IgfsCommonAbstractTest {
     /**
      * Create map with properties.
      *
+     * @param grpName Group name.
+     * @param perm Permission.
+     * @return Map with properties.
+     */
+    protected Map<String, String> properties(@Nullable String grpName, @Nullable String perm) {
+        Map<String, String> props = new HashMap<>();
+
+        if (grpName != null)
+            props.put(IgfsUtils.PROP_GROUP_NAME, grpName);
+
+        if (perm != null)
+            props.put(IgfsUtils.PROP_PERMISSION, perm);
+
+        return props;
+    }
+
+    /**
+     * Create map with properties.
+     *
      * @param username User name.
      * @param grpName Group name.
      * @param perm Permission.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/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 7058954..128239d 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
@@ -532,7 +532,10 @@ public abstract class IgfsAbstractSelfTest extends IgfsAbstractBaseSelfTest {
      */
     @SuppressWarnings("ConstantConditions")
     public void testMkdirsParentRoot() throws Exception {
-        Map<String, String> props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info.
+        Map<String, String> props = null;
+
+        if (permissionsSupported())
+            props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info.
 
         igfs.mkdirs(DIR, props);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
index 742d20c..1d6010d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
@@ -970,7 +970,10 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
      * @throws Exception If failed.
      */
     public void testMkdirsParentPathMissingPartially() throws Exception {
-        Map<String, String> props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info.
+        Map<String, String> props = null;
+
+        if (permissionsSupported())
+            props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info.
 
         create(igfsSecondary, paths(DIR, SUBDIR), null);
         create(igfs, paths(DIR), null);
@@ -997,7 +1000,10 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
      * @throws Exception If failed.
      */
     public void testMkdrisParentPathMissing() throws Exception {
-        Map<String, String> props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info.
+        Map<String, String> props = null;
+
+        if (permissionsSupported())
+            props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info.
 
         create(igfsSecondary, paths(DIR, SUBDIR), null);
         create(igfs, null, null);
@@ -1131,11 +1137,19 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
      * @throws Exception If failed.
      */
     public void testUpdateParentRootPathMissing() throws Exception {
+        doUpdateParentRootPathMissing(properties("owner", "group", "0555"));
+    }
+
+    /**
+     * Test update when parent is the root and the path being updated is missing locally.
+     *
+     * @param props Properties.
+     * @throws Exception If failed.
+     */
+    protected void doUpdateParentRootPathMissing(Map<String, String> props) throws Exception {
         if (!propertiesSupported())
             return;
 
-        Map<String, String> props = properties("owner", "group", "0555");
-
         create(igfsSecondary, paths(DIR), null);
         create(igfs, null, null);
 
@@ -1143,8 +1157,8 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
 
         checkExist(igfs, DIR);
 
-        assertEquals(props, igfsSecondary.properties(DIR.toString()));
-        assertEquals(props, igfs.info(DIR).properties());
+        assertTrue(propertiesContains(igfsSecondary.properties(DIR.toString()), props));
+        assertTrue(propertiesContains(igfs.info(DIR).properties(), props));
     }
 
     /**
@@ -1613,4 +1627,20 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
         assertEquals(chunk.length, igfs.size(FILE));
         assertEquals(chunk.length * 2, igfs.size(SUBDIR));
     }
+
+    /**
+     * @param allProps All properties.
+     * @param checkedProps Checked properies
+     * @return {@code true} If allchecked properties are contained in the #propsAll.
+     */
+    public static boolean propertiesContains(Map<String, String> allProps, Map<String, String> checkedProps) {
+        for (String name : checkedProps.keySet())
+            if (!checkedProps.get(name).equals(allProps.get(name))) {
+                System.err.println("All properties: " + allProps);
+                System.err.println("Checked properties: " + checkedProps);
+                return false;
+            }
+
+        return true;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
index 0e6fc48..8a23954 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.igfs;
 
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.igfs.IgfsFile;
 import org.apache.ignite.igfs.IgfsMode;
 import org.apache.ignite.igfs.IgfsPath;
@@ -60,6 +61,13 @@ public abstract class IgfsLocalSecondaryFileSystemDualAbstractSelfTest extends I
     /** */
     private final File fileLinkSrc = new File(FS_WORK_DIR + File.separatorChar + "file");
 
+    /** */
+    private final String TEST_GROUP = System.getProperty("IGFS_LOCAL_FS_TEST_GROUP", "igfs_grp_0");
+
+    /** */
+    private final Boolean PROPERTIES_SUPPORT =
+        IgniteSystemProperties.getBoolean("IGFS_LOCAL_FS_PROPERTIES_SUPPORT", false);
+
 
     /**
      * Constructor.
@@ -103,13 +111,13 @@ public abstract class IgfsLocalSecondaryFileSystemDualAbstractSelfTest extends I
     }
 
     /** {@inheritDoc} */
-    @Override protected boolean permissionsSupported() {
-        return false;
+    @Override protected boolean propertiesSupported() {
+        return !U.isWindows() && PROPERTIES_SUPPORT;
     }
 
     /** {@inheritDoc} */
-    @Override protected boolean propertiesSupported() {
-        return false;
+    @Override protected boolean permissionsSupported() {
+        return !U.isWindows();
     }
 
     /** {@inheritDoc} */
@@ -170,6 +178,16 @@ public abstract class IgfsLocalSecondaryFileSystemDualAbstractSelfTest extends I
     }
 
     /**
+     * Test update when parent is the root and the path being updated is missing locally.
+     *
+     * @throws Exception If failed.
+     */
+    public void testUpdateParentRootPathMissing() throws Exception {
+        doUpdateParentRootPathMissing(properties(TEST_GROUP, "0555"));
+    }
+
+
+    /**
      *
      * @throws Exception If failed.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemProxySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemProxySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemProxySelfTest.java
index 848abe2..e7f9bbb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemProxySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemProxySelfTest.java
@@ -105,11 +105,6 @@ public class IgfsLocalSecondaryFileSystemProxySelfTest extends IgfsProxySelfTest
         return false;
     }
 
-    /** {@inheritDoc} */
-    @Override public void testUpdatePathDoesNotExist() throws Exception {
-        fail("IGNITE-3645");
-    }
-
     /**
      *
      * @throws Exception If failed.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java
index 12714c4..8f6af83 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemTestAdapter.java
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.internal.processors.igfs;
 
+import java.nio.file.attribute.PosixFileAttributeView;
+import java.nio.file.attribute.PosixFileAttributes;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.HashMap;
 import org.apache.ignite.internal.util.typedef.T2;
 
 import java.io.File;
@@ -77,12 +81,30 @@ public class IgfsLocalSecondaryFileSystemTestAdapter implements IgfsSecondaryFil
 
     /** {@inheritDoc} */
     @Override public Map<String, String> properties(final String path) throws IOException {
-        throw new UnsupportedOperationException("properties");
+        Path p = path(path);
+        PosixFileAttributes attrs = Files.getFileAttributeView(p, PosixFileAttributeView.class).readAttributes();
+
+        Map<String, String> props = new HashMap<>();
+        props.put(IgfsUtils.PROP_USER_NAME, attrs.owner().getName());
+        props.put(IgfsUtils.PROP_GROUP_NAME, attrs.group().getName());
+        props.put(IgfsUtils.PROP_PERMISSION, permissions(path));
+
+        return props;
     }
 
     /** {@inheritDoc} */
     @Override public String permissions(String path) throws IOException {
-        throw new UnsupportedOperationException("permissions");
+        Path p = path(path);
+        PosixFileAttributeView attrView = Files.getFileAttributeView(p, PosixFileAttributeView.class);
+
+        if (attrView == null)
+            throw new UnsupportedOperationException("Posix file attributes not available");
+
+        int perm = 0;
+        for(PosixFilePermission pfp : attrView.readAttributes().permissions())
+            perm |= (1 << 8 - pfp.ordinal());
+
+        return '0' + Integer.toOctalString(perm);
     }
 
     /** {@inheritDoc} */
@@ -123,6 +145,7 @@ public class IgfsLocalSecondaryFileSystemTestAdapter implements IgfsSecondaryFil
      *
      * @param path Path.
      * @throws IOException If failed.
+     * @return {@code true} if the file is deleted successfully. {@code false} otherwise.
      */
     private boolean deleteRecursively(Path path) throws IOException {
         if (Files.isDirectory(path)) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/benchmark/IgfsBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/benchmark/IgfsBenchmark.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/benchmark/IgfsBenchmark.java
new file mode 100644
index 0000000..9cf6e8f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/benchmark/IgfsBenchmark.java
@@ -0,0 +1,561 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs.benchmark;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.igfs.IgfsFile;
+import org.apache.ignite.igfs.IgfsInputStream;
+import org.apache.ignite.igfs.IgfsOutputStream;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.igfs.IgfsPathNotFoundException;
+
+/**
+ *
+ */
+class FileOperation {
+    /** Buff size. */
+    public static final int BUFF_SIZE = 8192;
+
+    /** Data bufer. */
+    ByteBuffer dataBufer = ByteBuffer.allocate(BUFF_SIZE);
+
+    /** Filesystem. */
+    protected final IgniteFileSystem fs;
+
+    /**
+     * @param fs Ignite filesystem to benchmark.
+     */
+    public FileOperation(IgniteFileSystem fs) {
+        this.fs = fs;
+    }
+
+    /**
+     * @param path Path to do operation.
+     * @throws Exception If failed.
+     */
+    public void handleFile(String path) throws Exception {
+        // No-op.
+    }
+
+    /**
+     * @param path Path to do operation.
+     * @throws Exception If failed.
+     */
+    public void preHandleDir(String path) throws Exception {
+        // No-op.
+    }
+
+    /**
+     * @param path Path to do operation.
+     * @throws Exception If failed.
+     */
+    public void postHandleDir(String path) throws Exception {
+        // No-op.
+    }
+}
+
+/**
+ *
+ */
+class WriteFileOperation extends FileOperation {
+    /** Size. */
+    private int size;
+
+    /**
+     * @param fs Filesystem/
+     * @param size Size to write.
+     */
+    public WriteFileOperation(IgniteFileSystem fs, int size) {
+        super(fs);
+        this.size = size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void handleFile(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+        IgfsOutputStream out = null;
+
+        try {
+            out = fs.create(path, false);
+        }
+        catch (IgniteException ex) {
+            System.out.println("create file " + path.toString() + " failed: " + ex);
+            throw ex;
+        }
+
+        try {
+            for (int i = 0; i < size / dataBufer.capacity(); i++)
+                out.write(dataBufer.array());
+        }
+        catch (IOException ex) {
+            System.out.println("write file " + path.toString() + " failed: " + ex);
+            throw ex;
+        }
+        finally {
+            out.close();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void preHandleDir(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+
+        if (fs.exists(path))
+            throw new IgniteException("path " + path.toString() + " already exists");
+
+        try {
+            fs.mkdirs(path);
+        }
+        catch (IgniteException ex) {
+            throw ex;
+        }
+    }
+}
+
+/**
+ *
+ */
+class ReadFileOperation extends FileOperation {
+    /** Size. */
+    private int size;
+
+    /**
+     * @param fs Filesystem
+     * @param size Size to read.
+     */
+    public ReadFileOperation(IgniteFileSystem fs, int size) {
+        super(fs);
+        this.size = size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void handleFile(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+        IgfsInputStream in = null;
+
+        try {
+            in = fs.open(path);
+        }
+        catch (IgfsPathNotFoundException ex) {
+            System.out.println("file " + path.toString() + " not exist: " + ex);
+            throw ex;
+        }
+        catch (IgniteException ex) {
+            System.out.println("open file " + path.toString() + " failed: " + ex);
+            throw ex;
+        }
+
+        try {
+            for (int i = 0; i < size / dataBufer.capacity(); i++)
+                in.read(dataBufer.array());
+        }
+        catch (IOException ex) {
+            System.out.println("read file " + path.toString() + " failed: " + ex);
+            throw ex;
+        }
+        finally {
+            in.close();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void preHandleDir(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+
+        if (!fs.exists(path)) {
+            System.out.println("path " + path.toString() + " not exist");
+            throw new IgniteException("path " + path.toString() + " not exist");
+        }
+    }
+}
+
+/**
+ *
+ */
+class DeleteFileOperation extends FileOperation {
+    /** Size. */
+    private int size;
+
+    /**
+     * @param fs Filesystem.
+     * @param size Size.
+     */
+    public DeleteFileOperation(IgniteFileSystem fs, int size) {
+        super(fs);
+        this.size = size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void handleFile(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+        fs.delete(path, false);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void postHandleDir(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+        fs.delete(path, false);
+    }
+}
+
+/**
+ *
+ */
+class InfoFileOperation extends FileOperation {
+    /**
+     * @param fs Filesystem.
+     */
+    public InfoFileOperation(IgniteFileSystem fs) {
+        super(fs);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void handleFile(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+        IgfsFile info = fs.info(path);
+
+        assert info != null : "Info must be not null for exists file. All files must be exists for benchmark";
+    }
+
+    /** {@inheritDoc} */
+    @Override public void postHandleDir(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+        IgfsFile info = fs.info(path);
+
+        assert info != null : "Info must be not null for exists dir. All dirs must be exists for benchmark";
+    }
+}
+
+/**
+ *
+ */
+class ListPathFileOperation extends FileOperation {
+    /**
+     * @param fs Filesystem.
+     */
+    public ListPathFileOperation(IgniteFileSystem fs) {
+        super(fs);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void postHandleDir(String strPath) throws Exception {
+        IgfsPath path = new IgfsPath(strPath);
+
+        Collection<IgfsPath> lst = fs.listPaths(path);
+
+        assert lst != null : "List of paths must not be null";
+    }
+}
+
+/**
+ *
+ */
+public class IgfsBenchmark {
+    /** Path. */
+    private final String path;
+
+    /** Depth. */
+    private final int depth;
+
+    /** Width. */
+    private final int subDirsCount;
+
+    /** Count. */
+    private final int filesCount;
+
+    /** Size. */
+    private final int size;
+
+    /**
+     * @param path Root test path.
+     * @param depth Directory depth.
+     * @param subDirsCount Count of subdirectories.
+     * @param filesCount Count of files.
+     * @param size Size of file.
+     */
+    public IgfsBenchmark(String path,
+        int depth,
+        int subDirsCount,
+        int filesCount,
+        int size) {
+        this.path = path;
+        this.depth = depth;
+        this.subDirsCount = subDirsCount;
+        this.filesCount = filesCount;
+        this.size = (size > FileOperation.BUFF_SIZE) ? size : FileOperation.BUFF_SIZE;
+    }
+
+    /**
+     * @param lst List of measurement results.
+     * @return Average value.
+     */
+    public static long avg(List<Long> lst) {
+        if (lst.isEmpty())
+            throw new IllegalArgumentException("List must be not empty");
+
+        long sum = 0;
+        for (long l : lst)
+            sum += l;
+
+        return sum / lst.size();
+    }
+
+    /**
+     * @param lst List of measurement results.
+     * @param avg Average value.
+     * @return THe value of the standard derivation.
+     */
+    public static long stdDev(List<Long> lst, long avg) {
+        if (lst.isEmpty())
+            throw new IllegalArgumentException("List must be not empty");
+
+        long sum = 0;
+        for (long l : lst)
+            sum += (l - avg) * (l - avg);
+
+        return (long)Math.sqrt((double)sum / (double)lst.size());
+    }
+
+    /**
+     * @param args Commandline arguments
+     */
+    public static void main(String[] args) {
+        Ignition.setClientMode(Boolean.getBoolean("clientMode"));
+
+        Ignite ignite = Ignition.start(System.getProperty("cfg", "default-config.xml"));
+
+        int wormUpCount = Integer.getInteger("wormup", 2);
+        int cycles = Integer.getInteger("cycles", 10);
+
+        final IgfsBenchmark fsTest = new IgfsBenchmark(
+            System.getProperty("testDir", "/test"),
+            Integer.getInteger("depth", 3),
+            Integer.getInteger("subDirs", 10),
+            Integer.getInteger("files", 10),
+            Integer.getInteger("fileSize", 8) * 1024);
+
+        final IgniteFileSystem fs = ignite.fileSystem("igfs");
+
+        try {
+            for (int i = 0; i < wormUpCount; ++i) {
+                System.out.println("Wormup #" + i + " / " + wormUpCount);
+                fsTest.testWriteFile(fs);
+                fsTest.testReadFile(fs);
+                fsTest.testDeleteFile(fs);
+            }
+        }
+        catch (Exception ex) {
+            System.err.println("Wormup error");
+            ex.printStackTrace(System.err);
+            Ignition.stop(false);
+            return;
+        }
+
+        List<Long> writeRes = new ArrayList<>(cycles);
+        List<Long> readRes = new ArrayList<>(cycles);
+        List<Long> infoRes = new ArrayList<>(cycles);
+        List<Long> listRes = new ArrayList<>(cycles);
+        List<Long> delRes = new ArrayList<>(cycles);
+
+        try {
+            for (int i = 0; i < cycles; ++i) {
+                System.out.println("Benchmark cycle #" + i + " / " + cycles);
+
+                writeRes.add(bench(new Runnable() {
+                    @Override public void run() {
+                        fsTest.testWriteFile(fs);
+                    }
+                }));
+
+                readRes.add(bench(new Runnable() {
+                    @Override public void run() {
+                        fsTest.testReadFile(fs);
+                    }
+                }));
+
+                infoRes.add(bench(new Runnable() {
+                    @Override public void run() {
+                        fsTest.testInfoFile(fs);
+                    }
+                }));
+
+                listRes.add(bench(new Runnable() {
+                    @Override public void run() {
+                        fsTest.testListPathFile(fs);
+                    }
+                }));
+
+                delRes.add(bench(new Runnable() {
+                    @Override public void run() {
+                        fsTest.testDeleteFile(fs);
+                    }
+                }));
+            }
+
+            System.out.println("\n");
+            System.out.println("Write " + avg(writeRes) + " +/- " + stdDev(writeRes, avg(writeRes)));
+            System.out.println("Read " + avg(readRes) + " +/- " + stdDev(readRes, avg(readRes)));
+            System.out.println("Info " + avg(infoRes) + " +/- " + stdDev(infoRes, avg(infoRes)));
+            System.out.println("List " + avg(listRes) + " +/- " + stdDev(listRes, avg(listRes)));
+            System.out.println("Delete " + avg(delRes) + " +/- " + stdDev(delRes, avg(delRes)));
+        }
+        catch (Exception ex) {
+            System.err.println("Benchmark error");
+            ex.printStackTrace(System.err);
+        }
+        finally {
+            Ignition.stop(false);
+        }
+    }
+
+    /**
+     * @param parentPath Begin path.
+     * @param depth Current deep.
+     * @return List of subdirs.
+     */
+    private String[] buildPath(String parentPath, int depth) {
+        String curPath[] = new String[subDirsCount];
+
+        for (int i = 1; i <= curPath.length; i++)
+            curPath[i - 1] = parentPath + "/vdb." + depth + "_" + i + ".dir";
+
+        return curPath;
+    }
+
+    /**
+     * @param parentPath Begin path.
+     * @param operation Test operation to do.
+     * @throws Exception If failed.
+     */
+    private void recurseFile(String parentPath, FileOperation operation) throws Exception {
+        for (int i = 1; i <= filesCount; i++) {
+            String filePath = parentPath + "/vdb_f" + String.format("%0" + String.valueOf(this.filesCount).length() + "d", i) + ".file";
+            operation.handleFile(filePath);
+        }
+    }
+
+    /**
+     * @param parentPath Begin path.
+     * @param depth depth of recurse.
+     * @param operation Test operation to do.
+     * @throws Exception If failed.
+     */
+    private void recursePath(String parentPath, int depth, FileOperation operation) throws Exception {
+        if (depth == this.depth + 1)
+            recurseFile(parentPath, operation);
+        else {
+            String curPath[] = buildPath(parentPath, depth);
+
+            for (String path : curPath) {
+                operation.preHandleDir(path);
+                recursePath(path, depth + 1, operation);
+                operation.postHandleDir(path);
+            }
+        }
+    }
+
+    /**
+     * Do read file operations. Files must be exist.
+     *
+     * @param fs Filesystem.
+     */
+    public void testReadFile(IgniteFileSystem fs) {
+        try {
+            recursePath(path, 1, new ReadFileOperation(fs, size));
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Do write file operations.
+     *
+     * @param fs Filesystem.
+     */
+    public void testWriteFile(IgniteFileSystem fs) {
+        try {
+            recursePath(path, 1, new WriteFileOperation(fs, size));
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Do delete file operations. Files must be exist.
+     *
+     * @param fs Filesystem.
+     */
+    public void testDeleteFile(IgniteFileSystem fs) {
+        try {
+            recursePath(path, 1, new DeleteFileOperation(fs, 0));
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Do info file operations. Files must be exist.
+     *
+     * @param fs Filesystem.
+     */
+    public void testInfoFile(IgniteFileSystem fs) {
+        try {
+            recursePath(path, 1, new InfoFileOperation(fs));
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Do info file operations. Files must be exist.
+     *
+     * @param fs Filesystem.
+     */
+    public void testListPathFile(IgniteFileSystem fs) {
+        try {
+            recursePath(path, 1, new ListPathFileOperation(fs));
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * @param r Runnable.
+     * @return Time of execution in millis.
+     */
+    public static long bench(Runnable r) {
+        long t0 = System.currentTimeMillis();
+
+        r.run();
+
+        return System.currentTimeMillis() - t0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopIgfsSecondaryFileSystemDelegateImpl.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopIgfsSecondaryFileSystemDelegateImpl.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopIgfsSecondaryFileSystemDelegateImpl.java
index fcad674..203965c 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopIgfsSecondaryFileSystemDelegateImpl.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopIgfsSecondaryFileSystemDelegateImpl.java
@@ -250,8 +250,7 @@ public class HadoopIgfsSecondaryFileSystemDelegateImpl implements HadoopIgfsSeco
     /** {@inheritDoc} */
     @Override public OutputStream create(IgfsPath path, int bufSize, boolean overwrite, int replication,
         long blockSize, @Nullable Map<String, String> props) {
-        HadoopIgfsProperties props0 =
-            new HadoopIgfsProperties(props != null ? props : Collections.<String, String>emptyMap());
+        HadoopIgfsProperties props0 = new HadoopIgfsProperties(props);
 
         try {
             return fileSystemForUser().create(convert(path), props0.permission(), overwrite, bufSize,

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f211e41/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsProperties.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsProperties.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsProperties.java
index 5427bf1..a322a99 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsProperties.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsProperties.java
@@ -43,6 +43,9 @@ public class HadoopIgfsProperties {
      * @throws IgniteException In case of error.
      */
     public HadoopIgfsProperties(Map<String, String> props) throws IgniteException {
+        if (props == null)
+            return;
+
         usrName = props.get(IgfsUtils.PROP_USER_NAME);
         grpName = props.get(IgfsUtils.PROP_GROUP_NAME);
 


[17/40] ignite git commit: IGNITE-4014 Fixed "Transaction hangs if entry processor failed during serialization". This closes #1148.

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
index b1c269b..c87f08f 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
@@ -506,7 +506,7 @@ public class CacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
      * @throws IgniteCheckedException If failed to convert.
      */
     protected byte[] toBytes(Object obj) throws IgniteCheckedException {
-        return marsh.marshal(obj);
+        return U.marshal(marsh, obj);
     }
 
     /**
@@ -521,7 +521,7 @@ public class CacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
         if (bytes == null || bytes.length == 0)
             return null;
 
-        return marsh.unmarshal(bytes, getClass().getClassLoader());
+        return U.unmarshal(marsh, bytes, getClass().getClassLoader());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 0b0fe85..a5f283e 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1553,13 +1553,13 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     protected JavaObjectSerializer h2Serializer() {
         return new JavaObjectSerializer() {
                 @Override public byte[] serialize(Object obj) throws Exception {
-                    return marshaller.marshal(obj);
+                    return U.marshal(marshaller, obj);
                 }
 
                 @Override public Object deserialize(byte[] bytes) throws Exception {
                     ClassLoader clsLdr = ctx != null ? U.resolveClassLoader(ctx.config()) : null;
 
-                    return marshaller.unmarshal(bytes, clsLdr);
+                    return U.unmarshal(marshaller, bytes, clsLdr);
                 }
             };
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventDeserializer.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventDeserializer.java b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventDeserializer.java
index 47ce1ca..3bcf5fb 100644
--- a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventDeserializer.java
+++ b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventDeserializer.java
@@ -20,6 +20,7 @@ package org.apache.ignite.stream.kafka.connect.serialization;
 import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.events.CacheEvent;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.kafka.common.errors.SerializationException;
@@ -40,7 +41,7 @@ public class CacheEventDeserializer implements Deserializer<CacheEvent> {
     /** {@inheritDoc} */
     @Override public CacheEvent deserialize(String topic, byte[] bytes) {
         try {
-            return marsh.unmarshal(bytes, getClass().getClassLoader());
+            return U.unmarshal(marsh, bytes, getClass().getClassLoader());
         }
         catch (IgniteCheckedException e) {
             throw new SerializationException("Failed to deserialize cache event!", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventSerializer.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventSerializer.java b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventSerializer.java
index 2f2d668..bc09256 100644
--- a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventSerializer.java
+++ b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/serialization/CacheEventSerializer.java
@@ -20,6 +20,7 @@ package org.apache.ignite.stream.kafka.connect.serialization;
 import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.events.CacheEvent;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.kafka.common.errors.SerializationException;
@@ -40,7 +41,7 @@ public class CacheEventSerializer implements Serializer<CacheEvent> {
     /** {@inheritDoc} */
     @Override public byte[] serialize(String topic, CacheEvent event) {
         try {
-            return marsh.marshal(event);
+            return U.marshal(marsh, event);
         }
         catch (IgniteCheckedException e) {
             throw new SerializationException("Failed to serialize cache event!", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a6cfce6/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
index b6540b2..83ad186 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
@@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.websession.WebSessionEntity;
 import org.apache.ignite.marshaller.Marshaller;
 import org.jetbrains.annotations.Nullable;
@@ -82,7 +83,7 @@ class WebSessionV2 implements HttpSession {
     private boolean invalidated;
 
     /** Grid marshaller. */
-    private final Marshaller marshaller;
+    private final Marshaller marsh;
 
     /** Original session to delegate invalidation. */
     private final HttpSession genuineSes;
@@ -91,15 +92,18 @@ class WebSessionV2 implements HttpSession {
      * @param id Session ID.
      * @param ses Session.
      * @param isNew Is new flag.
+     * @param ctx Servlet context.
+     * @param entity Entity.
+     * @param marsh Marshaller.
      */
     WebSessionV2(final String id, final @Nullable HttpSession ses, final boolean isNew, final ServletContext ctx,
-        @Nullable WebSessionEntity entity, final Marshaller marshaller) {
+        @Nullable WebSessionEntity entity, final Marshaller marsh) {
         assert id != null;
-        assert marshaller != null;
+        assert marsh != null;
         assert ctx != null;
         assert ses != null || entity != null;
 
-        this.marshaller = marshaller;
+        this.marsh = marsh;
         this.ctx = ctx;
         this.isNew = isNew;
         this.genuineSes = ses;
@@ -331,9 +335,9 @@ class WebSessionV2 implements HttpSession {
      * @throws IOException If unarshaling failed.
      */
     @Nullable private <T> T unmarshal(final byte[] bytes) throws IOException {
-        if (marshaller != null) {
+        if (marsh != null) {
             try {
-                return marshaller.unmarshal(bytes, getClass().getClassLoader());
+                return U.unmarshal(marsh, bytes, getClass().getClassLoader());
             }
             catch (IgniteCheckedException e) {
                 throw new IOException(e);
@@ -351,9 +355,9 @@ class WebSessionV2 implements HttpSession {
      * @throws IOException If marshaling failed.
      */
     @Nullable private byte[] marshal(final Object obj) throws IOException {
-        if (marshaller != null) {
+        if (marsh != null) {
             try {
-                return marshaller.marshal(obj);
+                return U.marshal(marsh, obj);
             }
             catch (IgniteCheckedException e) {
                 throw new IOException(e);


[30/40] ignite git commit: IGNITE-4034 Get rid of specialized methods in platform targets

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
index 8afabac..339937c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteTransactions;
 import org.apache.ignite.configuration.TransactionConfiguration;
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
 import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
@@ -47,6 +48,33 @@ public class PlatformTransactions extends PlatformAbstractTarget {
     public static final int OP_METRICS = 2;
 
     /** */
+    public static final int OP_START = 3;
+
+    /** */
+    public static final int OP_COMMIT = 4;
+
+    /** */
+    public static final int OP_ROLLBACK = 5;
+
+    /** */
+    public static final int OP_CLOSE = 6;
+
+    /** */
+    public static final int OP_STATE = 7;
+
+    /** */
+    public static final int OP_SET_ROLLBACK_ONLY = 8;
+
+    /** */
+    public static final int OP_COMMIT_ASYNC = 9;
+
+    /** */
+    public static final int OP_ROLLBACK_ASYNC = 10;
+
+    /** */
+    public static final int OP_RESET_METRICS = 11;
+
+    /** */
     private final IgniteTransactions txs;
 
     /** Map with currently active transactions. */
@@ -67,44 +95,45 @@ public class PlatformTransactions extends PlatformAbstractTarget {
     }
 
     /**
-     * @param concurrency Concurrency.
-     * @param isolation Isolation.
-     * @param timeout Timeout
-     * @param txSize Number of entries participating in transaction.
-     * @return Transaction thread ID.
+     * Listens to the transaction future and notifies .NET int future.
      */
-    public long txStart(int concurrency, int isolation, long timeout, int txSize) {
-        TransactionConcurrency txConcurrency = TransactionConcurrency.fromOrdinal(concurrency);
-
-        assert txConcurrency != null;
-
-        TransactionIsolation txIsolation = TransactionIsolation.fromOrdinal(isolation);
-
-        assert txIsolation != null;
+    private void listenAndNotifyIntFuture(final long futId, final Transaction asyncTx) {
+        IgniteFuture fut = asyncTx.future().chain(new C1<IgniteFuture, Object>() {
+            private static final long serialVersionUID = 0L;
 
-        Transaction tx = txs.txStart(txConcurrency, txIsolation);
+            @Override public Object apply(IgniteFuture fut) {
+                return null;
+            }
+        });
 
-        return registerTx(tx);
+        PlatformFutureUtils.listen(platformCtx, fut, futId, PlatformFutureUtils.TYP_OBJ, this);
     }
 
     /**
-     * @param id Transaction ID.
-     * @throws org.apache.ignite.IgniteCheckedException In case of error.
+     * Register transaction.
+     *
+     * @param tx Transaction.
+     * @return Transaction ID.
      */
-    public int txCommit(long id) throws IgniteCheckedException {
-        tx(id).commit();
+    private long registerTx(Transaction tx) {
+        long id = TX_ID_GEN.incrementAndGet();
 
-        return txClose(id);
+        Transaction old = txMap.put(id, tx);
+
+        assert old == null : "Duplicate TX ids: " + old;
+
+        return id;
     }
 
     /**
+     * Unregister transaction.
+     *
      * @param id Transaction ID.
-     * @throws org.apache.ignite.IgniteCheckedException In case of error.
      */
-    public int txRollback(long id) throws IgniteCheckedException {
-        tx(id).rollback();
+    private void unregisterTx(long id) {
+        Transaction tx = txMap.remove(id);
 
-        return txClose(id);
+        assert tx != null : "Failed to unregister transaction: " + id;
     }
 
     /**
@@ -112,7 +141,7 @@ public class PlatformTransactions extends PlatformAbstractTarget {
      * @throws org.apache.ignite.IgniteCheckedException In case of error.
      * @return Transaction state.
      */
-    public int txClose(long id) throws IgniteCheckedException {
+    private int txClose(long id) throws IgniteCheckedException {
         Transaction tx = tx(id);
 
         try {
@@ -126,108 +155,108 @@ public class PlatformTransactions extends PlatformAbstractTarget {
     }
 
     /**
-     * @param id Transaction ID.
-     * @return Transaction state.
+     * Get transaction by ID.
+     *
+     * @param id ID.
+     * @return Transaction.
      */
-    public int txState(long id) {
-        Transaction tx = tx(id);
+    private Transaction tx(long id) {
+        Transaction tx = txMap.get(id);
 
-        return tx.state().ordinal();
+        assert tx != null : "Transaction not found for ID: " + id;
+
+        return tx;
     }
 
-    /**
-     * @param id Transaction ID.
-     * @return {@code True} if rollback only flag was set.
-     */
-    public boolean txSetRollbackOnly(long id) {
-        Transaction tx = tx(id);
+    /** {@inheritDoc} */
+    @Override protected long processOutLong(int type) throws IgniteCheckedException {
+        switch (type) {
+            case OP_RESET_METRICS:
+                txs.resetMetrics();
 
-        return tx.setRollbackOnly();
+                return TRUE;
+        }
+        
+        return super.processOutLong(type);
     }
 
-    /**
-     * Commits tx in async mode.
-     */
-    public void txCommitAsync(final long txId, final long futId) {
-        final Transaction asyncTx = (Transaction)tx(txId).withAsync();
+    /** {@inheritDoc} */
+    @Override protected long processInLongOutLong(int type, long val) throws IgniteCheckedException {
+        switch (type) {
+            case OP_COMMIT:
+                tx(val).commit();
 
-        asyncTx.commit();
+                return txClose(val);
 
-        listenAndNotifyIntFuture(futId, asyncTx);
+            case OP_ROLLBACK:
+                tx(val).rollback();
+
+                return txClose(val);
+
+            case OP_CLOSE:
+                return txClose(val);
+
+            case OP_SET_ROLLBACK_ONLY:
+                return tx(val).setRollbackOnly() ? TRUE : FALSE;
+
+            case OP_STATE:
+                return tx(val).state().ordinal();
+        }
+
+        return super.processInLongOutLong(type, val);
     }
 
-    /**
-     * Rolls back tx in async mode.
-     */
-    public void txRollbackAsync(final long txId, final long futId) {
+    /** {@inheritDoc} */
+    @Override protected long processInStreamOutLong(int type, BinaryRawReaderEx reader) throws IgniteCheckedException {
+        long txId = reader.readLong();
+        long futId = reader.readLong();
+
         final Transaction asyncTx = (Transaction)tx(txId).withAsync();
 
-        asyncTx.rollback();
+        switch (type) {
+            case OP_COMMIT_ASYNC:
+                asyncTx.commit();
 
-        listenAndNotifyIntFuture(futId, asyncTx);
-    }
+                break;
 
-    /**
-     * Listens to the transaction future and notifies .NET int future.
-     */
-    private void listenAndNotifyIntFuture(final long futId, final Transaction asyncTx) {
-        IgniteFuture fut = asyncTx.future().chain(new C1<IgniteFuture, Object>() {
-            private static final long serialVersionUID = 0L;
 
-            @Override public Object apply(IgniteFuture fut) {
-                return null;
-            }
-        });
+            case OP_ROLLBACK_ASYNC:
+                asyncTx.rollback();
 
-        PlatformFutureUtils.listen(platformCtx, fut, futId, PlatformFutureUtils.TYP_OBJ, this);
-    }
+                break;
 
-    /**
-     * Resets transaction metrics.
-     */
-    public void resetMetrics() {
-       txs.resetMetrics();
+            default:
+                return super.processInStreamOutLong(type, reader);
+        }
+
+        listenAndNotifyIntFuture(futId, asyncTx);
+
+        return TRUE;
     }
 
-    /**
-     * Register transaction.
-     *
-     * @param tx Transaction.
-     * @return Transaction ID.
-     */
-    private long registerTx(Transaction tx) {
-        long id = TX_ID_GEN.incrementAndGet();
+    /** {@inheritDoc} */
+    @Override protected void processInStreamOutStream(int type, BinaryRawReaderEx reader, BinaryRawWriterEx writer) throws IgniteCheckedException {
+        switch (type) {
+            case OP_START: {
+                TransactionConcurrency txConcurrency = TransactionConcurrency.fromOrdinal(reader.readInt());
 
-        Transaction old = txMap.put(id, tx);
+                assert txConcurrency != null;
 
-        assert old == null : "Duplicate TX ids: " + old;
+                TransactionIsolation txIsolation = TransactionIsolation.fromOrdinal(reader.readInt());
 
-        return id;
-    }
+                assert txIsolation != null;
 
-    /**
-     * Unregister transaction.
-     *
-     * @param id Transaction ID.
-     */
-    private void unregisterTx(long id) {
-        Transaction tx = txMap.remove(id);
+                Transaction tx = txs.txStart(txConcurrency, txIsolation, reader.readLong(), reader.readInt());
 
-        assert tx != null : "Failed to unregister transaction: " + id;
-    }
+                long id = registerTx(tx);
 
-    /**
-     * Get transaction by ID.
-     *
-     * @param id ID.
-     * @return Transaction.
-     */
-    private Transaction tx(long id) {
-        Transaction tx = txMap.get(id);
+                writer.writeLong(id);
 
-        assert tx != null : "Transaction not found for ID: " + id;
+                return;
+            }
+        }
 
-        return tx;
+        super.processInStreamOutStream(type, reader, writer);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/core/include/ignite/cache/cache.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/cache.h b/modules/platforms/cpp/core/include/ignite/cache/cache.h
index 59b7a6a..a975be3 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/cache.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/cache.h
@@ -115,7 +115,7 @@ namespace ignite
              */
             bool IsEmpty(IgniteError& err)
             {
-                return impl.Get()->IsEmpty(&err);
+                return Size(err) == 0;
             }
 
             /**
@@ -1054,7 +1054,6 @@ namespace ignite
              *
              * This method should only be used on the valid instance.
              *
-             * @param err Error.
              */
             void RemoveAll()
             {
@@ -1109,7 +1108,7 @@ namespace ignite
              *
              * This method should only be used on the valid instance.
              *
-             * @param Peek modes.
+             * @param peekModes Peek modes.
              * @return Cache size on this node.
              */
             int32_t LocalSize(int32_t peekModes)
@@ -1128,13 +1127,13 @@ namespace ignite
              *
              * This method should only be used on the valid instance.
              *
-             * @param Peek modes.
+             * @param peekModes Peek modes.
              * @param err Error.
              * @return Cache size on this node.
              */
             int32_t LocalSize(int32_t peekModes, IgniteError& err)
             {
-                return impl.Get()->LocalSize(peekModes, &err);
+                return impl.Get()->Size(peekModes, true, &err);
             }
 
             /**
@@ -1170,7 +1169,7 @@ namespace ignite
              *
              * This method should only be used on the valid instance.
              *
-             * @param Peek modes.
+             * @param peekModes Peek modes.
              * @return Cache size across all nodes.
              */
             int32_t Size(int32_t peekModes)
@@ -1190,13 +1189,13 @@ namespace ignite
              *
              * This method should only be used on the valid instance.
              *
-             * @param Peek modes.
+             * @param peekModes Peek modes.
              * @param err Error.
              * @return Cache size across all nodes.
              */
             int32_t Size(int32_t peekModes, IgniteError& err)
             {
-                return impl.Get()->Size(peekModes, &err);
+                return impl.Get()->Size(peekModes, false, &err);
             }
 
             /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h b/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h
index e5f8ab8..3e0f177 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h
@@ -60,14 +60,6 @@ namespace ignite
                 const char* GetName() const;
 
                 /**
-                 * Perform IsEmpty.
-                 *
-                 * @param err Error.
-                 * @return Result.
-                 */
-                bool IsEmpty(IgniteError* err);
-
-                /**
                  * Perform ContainsKey.
                  *
                  * @param inOp Input.
@@ -274,22 +266,13 @@ namespace ignite
                 void RemoveAll(IgniteError* err);
 
                 /**
-                 * Perform Size.
-                 *
-                 * @param peekModes Peek modes.
-                 * @param err Error.
-                 * @return Result.
-                 */
-                int32_t Size(const int32_t peekModes, IgniteError* err);
-
-                /**
-                 * Perform LocalSize.
-                 * 
-                 * @param peekModes Peek modes.
-                 * @param err Error.
-                 * @return Result.
-                 */
-                int32_t LocalSize(const int32_t peekModes, IgniteError* err);
+                * Perform Size.
+                *
+                * @param peekModes Peek modes.
+                * @param local Local flag.
+                * @param err Error.
+                */
+                int32_t Size(int32_t peekModes, bool local, IgniteError* err);
 
                 /**
                  * Invoke query.
@@ -334,16 +317,6 @@ namespace ignite
                 IGNITE_NO_COPY_ASSIGNMENT(CacheImpl)
 
                 /**
-                 * Internal cache size routine.
-                 *
-                 * @param peekModes Peek modes.
-                 * @param loc Local flag.
-                 * @param err Error.
-                 * @return Size.
-                 */
-                int SizeInternal(const int32_t peekModes, const bool loc, IgniteError* err);
-
-                /**
                  * Internal query execution routine.
                  *
                  * @param qry Query.

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/core/include/ignite/impl/interop/interop_target.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_target.h b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_target.h
index 8b6ebb9..1c91a35 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_target.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_target.h
@@ -60,6 +60,15 @@ namespace ignite
                  * Internal out operation.
                  *
                  * @param opType Operation type.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool OutOp(int32_t opType, IgniteError* err);
+
+                /**
+                 * Internal out operation.
+                 *
+                 * @param opType Operation type.
                  * @param inOp Input.
                  * @param err Error.
                  * @return Result.
@@ -78,6 +87,15 @@ namespace ignite
                     IgniteError* err);
 
                 /**
+                * Internal out-in operation.
+                *
+                * @param opType Operation type.
+                * @param val Value.
+                * @param err Error.
+                */
+                int64_t OutInOpLong(int32_t opType, int64_t val, IgniteError* err);
+
+                /**
                  * Get environment shared pointer.
                  *
                  * @return Environment shared pointer.

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp b/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
index e728f55..d02759d 100644
--- a/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
@@ -17,12 +17,8 @@
 
 #include <ignite/common/utils.h>
 
-#include "ignite/cache/cache_peek_mode.h"
 #include "ignite/impl/cache/cache_impl.h"
-#include "ignite/impl/interop/interop.h"
-#include "ignite/impl/binary/binary_reader_impl.h"
 #include "ignite/impl/binary/binary_type_updater_impl.h"
-#include "ignite/binary/binary.h"
 
 using namespace ignite::common::concurrent;
 using namespace ignite::jni::java;
@@ -120,6 +116,18 @@ namespace ignite
             /** Operation: Replace(K, V, V). */
             const int32_t OP_REPLACE_3 = 38;
 
+            /** Operation: Clear(). */
+            const int32_t OP_CLEAR_CACHE = 41;
+
+            /** Operation: RemoveAll(). */
+            const int32_t OP_REMOVE_ALL2 = 43;
+
+            /** Operation: Size(peekModes). */
+            const int32_t OP_SIZE = 48;
+
+            /** Operation: SizeLoc(peekModes). */
+            const int32_t OP_SIZE_LOC = 48;
+
             CacheImpl::CacheImpl(char* name, SharedPointer<IgniteEnvironment> env, jobject javaRef) :
                 InteropTarget(env, javaRef),
                 name(name)
@@ -139,11 +147,6 @@ namespace ignite
                 return name;
             }
 
-            bool CacheImpl::IsEmpty(IgniteError* err)
-            {
-                return Size(IGNITE_PEEK_MODE_ALL, err) == 0;
-            }
-
             bool CacheImpl::ContainsKey(InputOperation& inOp, IgniteError* err)
             {
                 return OutOp(OP_CONTAINS_KEY, inOp, err);
@@ -223,7 +226,7 @@ namespace ignite
             {
                 JniErrorInfo jniErr;
 
-                GetEnvironment().Context()->CacheClear(GetTarget(), &jniErr);
+                OutOp(OP_CLEAR_CACHE, err);
 
                 IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
             }
@@ -267,19 +270,16 @@ namespace ignite
             {
                 JniErrorInfo jniErr;
 
-                GetEnvironment().Context()->CacheRemoveAll(GetTarget(), &jniErr);
+                OutOp(OP_REMOVE_ALL2, err);
 
                 IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
             }
 
-            int32_t CacheImpl::Size(const int32_t peekModes, IgniteError* err)
+            int32_t CacheImpl::Size(int32_t peekModes, bool local, IgniteError* err)
             {
-                return SizeInternal(peekModes, false, err);
-            }
+                int32_t op = local ? OP_SIZE_LOC : OP_SIZE;
 
-            int32_t CacheImpl::LocalSize(const int32_t peekModes, IgniteError* err)
-            {
-                return SizeInternal(peekModes, true, err);
+                return static_cast<int32_t>(OutInOpLong(op, peekModes, err));
             }
 
             QueryCursorImpl* CacheImpl::QuerySql(const SqlQuery& qry, IgniteError* err)
@@ -301,20 +301,6 @@ namespace ignite
             {
                 return QueryInternal(qry, OP_QRY_SQL_FIELDS, err);
             }
-
-            int CacheImpl::SizeInternal(const int32_t peekModes, const bool loc, IgniteError* err)
-            {
-                JniErrorInfo jniErr;
-
-                int res = GetEnvironment().Context()->CacheSize(GetTarget(), peekModes, loc, &jniErr);
-
-                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
-
-                if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
-                    return res;
-                else
-                    return -1;
-            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp b/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp
index 73d9924..c65e1e8 100644
--- a/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp
@@ -41,6 +41,15 @@ namespace ignite
                 /** Operation: get single entry. */
                 const int32_t OP_GET_SINGLE = 3;
 
+                /** Operation: start iterator. */
+                const int32_t OP_ITERATOR = 4;
+
+                /** Operation: close iterator. */
+                const int32_t OP_ITERATOR_CLOSE = 5;
+
+                /** Operation: close iterator. */
+                const int32_t OP_ITERATOR_HAS_NEXT = 6;
+
                 QueryCursorImpl::QueryCursorImpl(SharedPointer<IgniteEnvironment> env, jobject javaRef) :
                     env(env),
                     javaRef(javaRef),
@@ -58,7 +67,7 @@ namespace ignite
                     delete batch;
 
                     // 2. Close the cursor.
-                    env.Get()->Context()->QueryCursorClose(javaRef);
+                    env.Get()->Context()->TargetOutLong(javaRef, OP_ITERATOR_CLOSE);
 
                     // 3. Release Java reference.
                     JniContext::Release(javaRef);
@@ -190,7 +199,7 @@ namespace ignite
 
                     JniErrorInfo jniErr;
 
-                    env.Get()->Context()->QueryCursorIterator(javaRef, &jniErr);
+                    env.Get()->Context()->TargetOutLong(javaRef, OP_ITERATOR, &jniErr);
 
                     IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, &err);
 
@@ -240,7 +249,7 @@ namespace ignite
                 {
                     JniErrorInfo jniErr;
 
-                    bool res = env.Get()->Context()->QueryCursorIteratorHasNext(javaRef, &jniErr);
+                    bool res = env.Get()->Context()->TargetOutLong(javaRef, OP_ITERATOR_HAS_NEXT, &jniErr) == 1;
 
                     IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, &err);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/core/src/impl/interop/interop_target.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/interop/interop_target.cpp b/modules/platforms/cpp/core/src/impl/interop/interop_target.cpp
index 05764c7..592c1ba 100644
--- a/modules/platforms/cpp/core/src/impl/interop/interop_target.cpp
+++ b/modules/platforms/cpp/core/src/impl/interop/interop_target.cpp
@@ -96,6 +96,20 @@ namespace ignite
                 return false;
             }
 
+            bool InteropTarget::OutOp(int32_t opType, IgniteError* err)
+            {
+                JniErrorInfo jniErr;
+
+                long long res = env.Get()->Context()->TargetOutLong(javaRef, opType, &jniErr);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+                    return res == 1;
+
+                return false;
+            }
+
             bool InteropTarget::InOp(int32_t opType, OutputOperation& outOp, IgniteError* err)
             {
                 JniErrorInfo jniErr;
@@ -137,6 +151,17 @@ namespace ignite
                         ReadFrom(inMem.Get(), outOp);
                 }
             }
+
+            int64_t InteropTarget::OutInOpLong(int32_t opType, int64_t val, IgniteError* err)
+            {
+                JniErrorInfo jniErr;
+
+                long long res = env.Get()->Context()->TargetInLongOutLong(javaRef, opType, val, &jniErr);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+                    
+                return res;
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/core/src/impl/transactions/transactions_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/transactions/transactions_impl.cpp b/modules/platforms/cpp/core/src/impl/transactions/transactions_impl.cpp
index 6c01332..58f3018 100644
--- a/modules/platforms/cpp/core/src/impl/transactions/transactions_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/transactions/transactions_impl.cpp
@@ -32,8 +32,22 @@ namespace ignite
              */
             enum Operation
             {
-                /** Get metrics operation. */
-                OP_METRICS = 2
+                /** Get metrics. */
+                OP_METRICS = 2,
+                /** Start tx. */
+                OP_START = 3,
+                /** Commit. */
+                OP_COMMIT = 4,
+                /** Rollback. */
+                OP_ROLLBACK = 5,
+                /** Close tx. */
+                OP_CLOSE = 6,
+                /** Get tx state. */
+                OP_STATE = 7,
+                /** Set rollback-only mode. */
+                OP_SET_ROLLBACK_ONLY = 8,
+                /** Reset metrics. */
+                OP_RESET_METRICS = 11,
             };
 
             TransactionsImpl::TransactionsImpl(SP_IgniteEnvironment env, jobject javaRef) :
@@ -47,28 +61,98 @@ namespace ignite
                 // No-op.
             }
 
+            /*
+             * Input operation for starting a transaction.
+             */
+            class InTransactionStartOperation : public InputOperation
+            {
+            public:
+                /**
+                * Constructor.
+                *
+                * @param concurrency Concurrency.
+                * @param isolation Isolation.
+                * @param timeout Timeout in milliseconds. Zero if for infinite timeout.
+                * @param txSize Number of entries participating in transaction (may be approximate).
+                */
+                InTransactionStartOperation(int concurrency, int isolation, int64_t timeout, int32_t txSize) :
+                    concurrency(concurrency), isolation(isolation), timeout(timeout), txSize(txSize)
+                {
+                    // No-op.
+                }
+
+                virtual void ProcessInput(binary::BinaryWriterImpl& writer)
+                {                        
+                    writer.WriteInt32(concurrency);
+                    writer.WriteInt32(isolation);
+                    writer.WriteInt64(timeout);
+                    writer.WriteInt32(txSize);
+                }
+            private:
+                int concurrency; 
+                
+                int isolation;
+                    
+                int64_t timeout;
+                
+                int32_t txSize;
+
+                IGNITE_NO_COPY_ASSIGNMENT(InTransactionStartOperation)
+            };
+
+            /**
+            * Output operation for starting a transaction.
+            */
+            class OutTransactionStartOperation : public OutputOperation
+            {
+            public:
+                /**
+                * Constructor.
+                */
+                OutTransactionStartOperation(): val(0)
+                {
+                    // No-op.
+                }
+
+                virtual void ProcessOutput(binary::BinaryReaderImpl& reader) 
+                {
+                    val = reader.ReadInt64();
+                }
+
+                /**
+                * Get value.
+                *
+                * @return Value.
+                */
+                int64_t Get()
+                {
+                    return val;
+                }
+
+            private:
+                /** Value */
+                int64_t val;
+
+                IGNITE_NO_COPY_ASSIGNMENT(OutTransactionStartOperation)
+            };
+
+
             int64_t TransactionsImpl::TxStart(int concurrency, int isolation,
                 int64_t timeout, int32_t txSize, IgniteError& err)
             {
-                JniErrorInfo jniErr;
-
-                int64_t id = GetEnvironment().Context()->TransactionsStart(GetTarget(),
-                    concurrency, isolation, timeout, txSize, &jniErr);
+                InTransactionStartOperation inOp(concurrency, isolation, timeout, txSize);
+                OutTransactionStartOperation outOp;
 
-                if (jniErr.code != IGNITE_JNI_ERR_SUCCESS)
-                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, &err);
+                OutInOp(OP_START, inOp, outOp, &err);
 
-                return id;
+                return outOp.Get();
             }
 
             TransactionsImpl::TransactionState TransactionsImpl::TxCommit(int64_t id, IgniteError& err)
             {
                 JniErrorInfo jniErr;
 
-                int state = GetEnvironment().Context()->TransactionsCommit(GetTarget(), id, &jniErr);
-
-                if (jniErr.code != IGNITE_JNI_ERR_SUCCESS)
-                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, &err);
+                int state = static_cast<int>(OutInOpLong(OP_COMMIT, id, &err));
 
                 return ToTransactionState(state);
             }
@@ -77,10 +161,7 @@ namespace ignite
             {
                 JniErrorInfo jniErr;
 
-                int state = GetEnvironment().Context()->TransactionsRollback(GetTarget(), id, &jniErr);
-
-                if (jniErr.code != IGNITE_JNI_ERR_SUCCESS)
-                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, &err);
+                int state = static_cast<int>(OutInOpLong(OP_ROLLBACK, id, &err));
 
                 return ToTransactionState(state);
             }
@@ -89,10 +170,7 @@ namespace ignite
             {
                 JniErrorInfo jniErr;
 
-                int state = GetEnvironment().Context()->TransactionsClose(GetTarget(), id, &jniErr);
-
-                if (jniErr.code != IGNITE_JNI_ERR_SUCCESS)
-                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, &err);
+                int state = static_cast<int>(OutInOpLong(OP_CLOSE, id, &err));
 
                 return ToTransactionState(state);
             }
@@ -101,10 +179,7 @@ namespace ignite
             {
                 JniErrorInfo jniErr;
 
-                bool rollbackOnly = GetEnvironment().Context()->TransactionsSetRollbackOnly(GetTarget(), id, &jniErr);
-
-                if (jniErr.code != IGNITE_JNI_ERR_SUCCESS)
-                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, &err);
+                bool rollbackOnly = OutInOpLong(OP_SET_ROLLBACK_ONLY, id, &err) == 1;
 
                 return rollbackOnly;
             }
@@ -113,10 +188,7 @@ namespace ignite
             {
                 JniErrorInfo jniErr;
 
-                int state = GetEnvironment().Context()->TransactionsState(GetTarget(), id, &jniErr);
-
-                if (jniErr.code != IGNITE_JNI_ERR_SUCCESS)
-                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, &err);
+                int state = static_cast<int>(OutInOpLong(OP_STATE, id, &err));
 
                 return ToTransactionState(state);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/jni/include/ignite/jni/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/include/ignite/jni/exports.h b/modules/platforms/cpp/jni/include/ignite/jni/exports.h
index bcfc213..84f5a29f 100644
--- a/modules/platforms/cpp/jni/include/ignite/jni/exports.h
+++ b/modules/platforms/cpp/jni/include/ignite/jni/exports.h
@@ -55,10 +55,12 @@ extern "C" {
     void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long long memPtr);
     void IGNITE_CALL IgniteProcessorGetCacheNames(gcj::JniContext* ctx, void* obj, long long memPtr);
     
+    long long IGNITE_CALL IgniteTargetInLongOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
     long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
     void IGNITE_CALL IgniteTargetInStreamOutStream(gcj::JniContext* ctx, void* obj, int opType, long long inMemPtr, long long outMemPtr);
     void* IGNITE_CALL IgniteTargetInStreamOutObject(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
     void IGNITE_CALL IgniteTargetInObjectStreamOutStream(gcj::JniContext* ctx, void* obj, int opType, void* arg, long long inMemPtr, long long outMemPtr);
+    void* IGNITE_CALL IgniteTargetInObjectStreamOutObjectStream(gcj::JniContext* ctx, void* obj, int opType, void* arg, long long inMemPtr, long long outMemPtr);
     long long IGNITE_CALL IgniteTargetOutLong(gcj::JniContext* ctx, void* obj, int opType);
     void IGNITE_CALL IgniteTargetOutStream(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
     void* IGNITE_CALL IgniteTargetOutObject(gcj::JniContext* ctx, void* obj, int opType);
@@ -67,69 +69,6 @@ extern "C" {
     void* IGNITE_CALL IgniteTargetListenFutureAndGet(gcj::JniContext* ctx, void* obj, long long futId, int typ);
     void* IGNITE_CALL IgniteTargetListenFutureForOperationAndGet(gcj::JniContext* ctx, void* obj, long long futId, int typ, int opId);
 
-    int IGNITE_CALL IgniteAffinityPartitions(gcj::JniContext* ctx, void* obj);
-
-    void* IGNITE_CALL IgniteCacheWithSkipStore(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteCacheWithNoRetries(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteCacheWithExpiryPolicy(gcj::JniContext* ctx, void* obj, long long create, long long update, long long access);
-    void* IGNITE_CALL IgniteCacheWithAsync(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteCacheWithKeepPortable(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteCacheClear(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteCacheRemoveAll(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteCacheOutOpQueryCursor(gcj::JniContext* ctx, void* obj, int type, long long memPtr);
-    void* IGNITE_CALL IgniteCacheOutOpContinuousQuery(gcj::JniContext* ctx, void* obj, int type, long long memPtr);
-    void* IGNITE_CALL IgniteCacheIterator(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteCacheLocalIterator(gcj::JniContext* ctx, void* obj, int peekModes);
-    void IGNITE_CALL IgniteCacheEnterLock(gcj::JniContext* ctx, void* obj, long long id);
-    void IGNITE_CALL IgniteCacheExitLock(gcj::JniContext* ctx, void* obj, long long id);
-    bool IGNITE_CALL IgniteCacheTryEnterLock(gcj::JniContext* ctx, void* obj, long long id, long long timeout);
-    void IGNITE_CALL IgniteCacheCloseLock(gcj::JniContext* ctx, void* obj, long long id);
-    void IGNITE_CALL IgniteCacheRebalance(gcj::JniContext* ctx, void* obj, long long futId);
-    int IGNITE_CALL IgniteCacheSize(gcj::JniContext* ctx, void* obj, int peekModes, bool loc);
-
-    void IGNITE_CALL IgniteCacheStoreCallbackInvoke(gcj::JniContext* ctx, void* obj, long long memPtr);
-
-    void IGNITE_CALL IgniteComputeWithNoFailover(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteComputeWithTimeout(gcj::JniContext* ctx, void* obj, long long timeout);
-    void* IGNITE_CALL IgniteComputeExecuteNative(gcj::JniContext* ctx, void* obj, long long taskPtr, long long topVer);
-
-    void IGNITE_CALL IgniteContinuousQueryClose(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteContinuousQueryGetInitialQueryCursor(gcj::JniContext* ctx, void* obj);
-
-    void IGNITE_CALL IgniteDataStreamerListenTopology(gcj::JniContext* ctx, void* obj, long long ptr);
-    bool IGNITE_CALL IgniteDataStreamerAllowOverwriteGet(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteDataStreamerAllowOverwriteSet(gcj::JniContext* ctx, void* obj, bool val);
-    bool IGNITE_CALL IgniteDataStreamerSkipStoreGet(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteDataStreamerSkipStoreSet(gcj::JniContext* ctx, void* obj, bool val);
-    int IGNITE_CALL IgniteDataStreamerPerNodeBufferSizeGet(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteDataStreamerPerNodeBufferSizeSet(gcj::JniContext* ctx, void* obj, int val);
-    int IGNITE_CALL IgniteDataStreamerPerNodeParallelOperationsGet(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteDataStreamerPerNodeParallelOperationsSet(gcj::JniContext* ctx, void* obj, int val);
-
-    void* IGNITE_CALL IgniteMessagingWithAsync(gcj::JniContext* ctx, void* obj);
-
-    void* IGNITE_CALL IgniteProjectionForOthers(gcj::JniContext* ctx, void* obj, void* prj);
-    void* IGNITE_CALL IgniteProjectionForRemotes(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteProjectionForDaemons(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteProjectionForRandom(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteProjectionForOldest(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteProjectionForYoungest(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteProjectionResetMetrics(gcj::JniContext* ctx, void* obj);
-    void* IGNITE_CALL IgniteProjectionOutOpRet(gcj::JniContext* ctx, void* obj, int type, long long memPtr);
-
-    void IGNITE_CALL IgniteQueryCursorIterator(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteQueryCursorClose(gcj::JniContext* ctx, void* obj);
-
-    long long IGNITE_CALL IgniteTransactionsStart(gcj::JniContext* ctx, void* obj, int concurrency, int isolation, long long timeout, int txSize);
-    int IGNITE_CALL IgniteTransactionsCommit(gcj::JniContext* ctx, void* obj, long long id);
-    void IGNITE_CALL IgniteTransactionsCommitAsync(gcj::JniContext* ctx, void* obj, long long id, long long futId);
-    int IGNITE_CALL IgniteTransactionsRollback(gcj::JniContext* ctx, void* obj, long long id);
-    void IGNITE_CALL IgniteTransactionsRollbackAsync(gcj::JniContext* ctx, void* obj, long long id, long long futId);
-    int IGNITE_CALL IgniteTransactionsClose(gcj::JniContext* ctx, void* obj, long long id);
-    int IGNITE_CALL IgniteTransactionsState(gcj::JniContext* ctx, void* obj, long long id);
-    bool IGNITE_CALL IgniteTransactionsSetRollbackOnly(gcj::JniContext* ctx, void* obj, long long id);
-    void IGNITE_CALL IgniteTransactionsResetMetrics(gcj::JniContext* ctx, void* obj);
-
     void* IGNITE_CALL IgniteAcquire(gcj::JniContext* ctx, void* obj);
     void IGNITE_CALL IgniteRelease(void* obj);
 
@@ -142,42 +81,6 @@ extern "C" {
 
     void IGNITE_CALL IgniteDestroyJvm(gcj::JniContext* ctx);
 
-    void* IGNITE_CALL IgniteEventsWithAsync(gcj::JniContext* ctx, void* obj);
-    bool IGNITE_CALL IgniteEventsStopLocalListen(gcj::JniContext* ctx, void* obj, long long hnd);
-    void IGNITE_CALL IgniteEventsLocalListen(gcj::JniContext* ctx, void* obj, long long hnd, int type);
-    bool IGNITE_CALL IgniteEventsIsEnabled(gcj::JniContext* ctx, void* obj, int type);
-        
-	void* IGNITE_CALL IgniteServicesWithAsync(gcj::JniContext* ctx, void* obj);
-	void* IGNITE_CALL IgniteServicesWithServerKeepPortable(gcj::JniContext* ctx, void* obj);
-	void IGNITE_CALL IgniteServicesCancel(gcj::JniContext* ctx, void* obj, char* name);
-	void IGNITE_CALL IgniteServicesCancelAll(gcj::JniContext* ctx, void* obj);
-	void* IGNITE_CALL IgniteServicesGetServiceProxy(gcj::JniContext* ctx, void* obj, char* name, bool sticky);
-
-    long long IGNITE_CALL IgniteAtomicLongGet(gcj::JniContext* ctx, void* obj);
-    long long IGNITE_CALL IgniteAtomicLongIncrementAndGet(gcj::JniContext* ctx, void* obj);
-    long long IGNITE_CALL IgniteAtomicLongGetAndIncrement(gcj::JniContext* ctx, void* obj);
-    long long IGNITE_CALL IgniteAtomicLongAddAndGet(gcj::JniContext* ctx, void* obj, long long value);
-    long long IGNITE_CALL IgniteAtomicLongGetAndAdd(gcj::JniContext* ctx, void* obj, long long value);
-    long long IGNITE_CALL IgniteAtomicLongDecrementAndGet(gcj::JniContext* ctx, void* obj);
-    long long IGNITE_CALL IgniteAtomicLongGetAndDecrement(gcj::JniContext* ctx, void* obj);
-    long long IGNITE_CALL IgniteAtomicLongGetAndSet(gcj::JniContext* ctx, void* obj, long long value);
-    long long IGNITE_CALL IgniteAtomicLongCompareAndSetAndGet(gcj::JniContext* ctx, void* obj, long long expVal, long long newVal);
-    bool IGNITE_CALL IgniteAtomicLongIsClosed(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteAtomicLongClose(gcj::JniContext* ctx, void* obj);
-
-    long long IGNITE_CALL IgniteAtomicSequenceGet(gcj::JniContext* ctx, void* obj);
-    long long IGNITE_CALL IgniteAtomicSequenceIncrementAndGet(gcj::JniContext* ctx, void* obj);
-    long long IGNITE_CALL IgniteAtomicSequenceGetAndIncrement(gcj::JniContext* ctx, void* obj);
-    long long IGNITE_CALL IgniteAtomicSequenceAddAndGet(gcj::JniContext* ctx, void* obj, long long l);
-    long long IGNITE_CALL IgniteAtomicSequenceGetAndAdd(gcj::JniContext* ctx, void* obj, long long l);
-    int IGNITE_CALL IgniteAtomicSequenceGetBatchSize(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteAtomicSequenceSetBatchSize(gcj::JniContext* ctx, void* obj, int size);
-    bool IGNITE_CALL IgniteAtomicSequenceIsClosed(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteAtomicSequenceClose(gcj::JniContext* ctx, void* obj);
-
-    bool IGNITE_CALL IgniteAtomicReferenceIsClosed(gcj::JniContext* ctx, void* obj);
-    void IGNITE_CALL IgniteAtomicReferenceClose(gcj::JniContext* ctx, void* obj);
-
     bool IGNITE_CALL IgniteListenableCancel(gcj::JniContext* ctx, void* obj);
     bool IGNITE_CALL IgniteListenableIsCancelled(gcj::JniContext* ctx, void* obj);
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/jni/include/ignite/jni/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/include/ignite/jni/java.h b/modules/platforms/cpp/jni/include/ignite/jni/java.h
index 18a15e2..96daba8 100644
--- a/modules/platforms/cpp/jni/include/ignite/jni/java.h
+++ b/modules/platforms/cpp/jni/include/ignite/jni/java.h
@@ -31,7 +31,7 @@ namespace ignite
         {
             /* Handlers for callbacks from Java. */
             typedef long long(JNICALL *CacheStoreCreateHandler)(void* target, long long memPtr);
-            typedef int(JNICALL *CacheStoreInvokeHandler)(void* target, long long objPtr, long long memPtr, void* cb);
+            typedef int(JNICALL *CacheStoreInvokeHandler)(void* target, long long objPtr, long long memPtr);
             typedef void(JNICALL *CacheStoreDestroyHandler)(void* target, long long objPtr);
             typedef long long(JNICALL *CacheStoreSessionCreateHandler)(void* target, long long storePtr);
 
@@ -223,78 +223,8 @@ namespace ignite
              * JNI members.
              */
             struct JniMembers {
-                jclass c_PlatformAbstractQryCursor;
-                jmethodID m_PlatformAbstractQryCursor_iter;
-                jmethodID m_PlatformAbstractQryCursor_iterHasNext;
-                jmethodID m_PlatformAbstractQryCursor_close;
-
-                jclass c_PlatformAffinity;
-                jmethodID m_PlatformAffinity_partitions;
-
-                jclass c_PlatformCache;
-                jmethodID m_PlatformCache_withSkipStore;
-                jmethodID m_PlatformCache_withNoRetries;
-                jmethodID m_PlatformCache_withExpiryPolicy;
-                jmethodID m_PlatformCache_withAsync;
-                jmethodID m_PlatformCache_withKeepPortable;
-                jmethodID m_PlatformCache_clear;
-                jmethodID m_PlatformCache_removeAll;
-                jmethodID m_PlatformCache_iterator;
-                jmethodID m_PlatformCache_localIterator;
-                jmethodID m_PlatformCache_enterLock;
-                jmethodID m_PlatformCache_exitLock;
-                jmethodID m_PlatformCache_tryEnterLock;
-                jmethodID m_PlatformCache_closeLock;
-                jmethodID m_PlatformCache_rebalance;
-                jmethodID m_PlatformCache_size;
-
-                jclass c_PlatformCacheStoreCallback;
-                jmethodID m_PlatformCacheStoreCallback_invoke;
-
                 jclass c_IgniteException;
 
-                jclass c_PlatformClusterGroup;
-                jmethodID m_PlatformClusterGroup_forOthers;
-                jmethodID m_PlatformClusterGroup_forRemotes;
-                jmethodID m_PlatformClusterGroup_forDaemons;
-                jmethodID m_PlatformClusterGroup_forRandom;
-                jmethodID m_PlatformClusterGroup_forOldest;
-                jmethodID m_PlatformClusterGroup_forYoungest;
-                jmethodID m_PlatformClusterGroup_resetMetrics;
-
-                jclass c_PlatformCompute;
-                jmethodID m_PlatformCompute_withNoFailover;
-                jmethodID m_PlatformCompute_withTimeout;
-                jmethodID m_PlatformCompute_executeNative;
-
-                jclass c_PlatformContinuousQuery;
-                jmethodID m_PlatformContinuousQuery_close;
-                jmethodID m_PlatformContinuousQuery_getInitialQueryCursor;
-
-                jclass c_PlatformDataStreamer;
-                jmethodID m_PlatformDataStreamer_listenTopology;
-                jmethodID m_PlatformDataStreamer_getAllowOverwrite;
-                jmethodID m_PlatformDataStreamer_setAllowOverwrite;
-                jmethodID m_PlatformDataStreamer_getSkipStore;
-                jmethodID m_PlatformDataStreamer_setSkipStore;
-                jmethodID m_PlatformDataStreamer_getPerNodeBufSize;
-                jmethodID m_PlatformDataStreamer_setPerNodeBufSize;
-                jmethodID m_PlatformDataStreamer_getPerNodeParallelOps;
-                jmethodID m_PlatformDataStreamer_setPerNodeParallelOps;
-
-                jclass c_PlatformEvents;
-                jmethodID m_PlatformEvents_withAsync;
-                jmethodID m_PlatformEvents_stopLocalListen;
-                jmethodID m_PlatformEvents_localListen;
-                jmethodID m_PlatformEvents_isEnabled;
-
-                jclass c_PlatformServices;
-                jmethodID m_PlatformServices_withAsync;
-                jmethodID m_PlatformServices_withServerKeepPortable;
-                jmethodID m_PlatformServices_cancel;
-                jmethodID m_PlatformServices_cancelAll;
-                jmethodID m_PlatformServices_serviceProxy;
-
                 jclass c_PlatformIgnition;
                 jmethodID m_PlatformIgnition_start;
                 jmethodID m_PlatformIgnition_instance;
@@ -302,9 +232,6 @@ namespace ignite
                 jmethodID m_PlatformIgnition_stop;
                 jmethodID m_PlatformIgnition_stopAll;
 
-                jclass c_PlatformMessaging;
-                jmethodID m_PlatformMessaging_withAsync;
-
                 jclass c_PlatformProcessor;
                 jmethodID m_PlatformProcessor_releaseStart;
                 jmethodID m_PlatformProcessor_cache;
@@ -331,6 +258,7 @@ namespace ignite
                 jmethodID m_PlatformProcessor_atomicReference;
 
                 jclass c_PlatformTarget;
+                jmethodID m_PlatformTarget_inLongOutLong;
                 jmethodID m_PlatformTarget_inStreamOutLong;
                 jmethodID m_PlatformTarget_inStreamOutObject;
                 jmethodID m_PlatformTarget_outLong;
@@ -338,54 +266,16 @@ namespace ignite
                 jmethodID m_PlatformTarget_outObject;
                 jmethodID m_PlatformTarget_inStreamOutStream;
                 jmethodID m_PlatformTarget_inObjectStreamOutStream;
+                jmethodID m_PlatformTarget_inObjectStreamOutObjectStream;
                 jmethodID m_PlatformTarget_listenFuture;
                 jmethodID m_PlatformTarget_listenFutureForOperation;
                 jmethodID m_PlatformTarget_listenFutureAndGet;
                 jmethodID m_PlatformTarget_listenFutureForOperationAndGet;
 
-                jclass c_PlatformTransactions;
-                jmethodID m_PlatformTransactions_txStart;
-                jmethodID m_PlatformTransactions_txCommit;
-                jmethodID m_PlatformTransactions_txCommitAsync;
-                jmethodID m_PlatformTransactions_txRollback;
-                jmethodID m_PlatformTransactions_txRollbackAsync;
-                jmethodID m_PlatformTransactions_txState;
-                jmethodID m_PlatformTransactions_txSetRollbackOnly;
-                jmethodID m_PlatformTransactions_txClose;
-                jmethodID m_PlatformTransactions_resetMetrics;
-
                 jclass c_PlatformUtils;
                 jmethodID m_PlatformUtils_reallocate;
                 jmethodID m_PlatformUtils_errData;
 
-                jclass c_PlatformAtomicLong;
-                jmethodID m_PlatformAtomicLong_get;
-                jmethodID m_PlatformAtomicLong_incrementAndGet;
-                jmethodID m_PlatformAtomicLong_getAndIncrement;
-                jmethodID m_PlatformAtomicLong_addAndGet;
-                jmethodID m_PlatformAtomicLong_getAndAdd;
-                jmethodID m_PlatformAtomicLong_decrementAndGet;
-                jmethodID m_PlatformAtomicLong_getAndDecrement;
-                jmethodID m_PlatformAtomicLong_getAndSet;
-                jmethodID m_PlatformAtomicLong_compareAndSetAndGet;
-                jmethodID m_PlatformAtomicLong_isClosed;
-                jmethodID m_PlatformAtomicLong_close;
-
-                jclass c_PlatformAtomicSequence;
-                jmethodID m_PlatformAtomicSequence_get;
-                jmethodID m_PlatformAtomicSequence_incrementAndGet;
-                jmethodID m_PlatformAtomicSequence_getAndIncrement;
-                jmethodID m_PlatformAtomicSequence_addAndGet;
-                jmethodID m_PlatformAtomicSequence_getAndAdd;
-                jmethodID m_PlatformAtomicSequence_getBatchSize;
-                jmethodID m_PlatformAtomicSequence_setBatchSize;
-                jmethodID m_PlatformAtomicSequence_isClosed;
-                jmethodID m_PlatformAtomicSequence_close;
-
-                jclass c_PlatformAtomicReference;
-                jmethodID m_PlatformAtomicReference_isClosed;
-                jmethodID m_PlatformAtomicReference_close;
-
                 jclass c_PlatformListenable;
                 jmethodID m_PlatformListenable_cancel;
                 jmethodID m_PlatformListenable_isCancelled;
@@ -547,10 +437,12 @@ namespace ignite
 				void ProcessorGetIgniteConfiguration(jobject obj, long long memPtr);
 				void ProcessorGetCacheNames(jobject obj, long long memPtr);
 
+                long long TargetInLongOutLong(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
                 long long TargetInStreamOutLong(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
                 void TargetInStreamOutStream(jobject obj, int opType, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
                 jobject TargetInStreamOutObject(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
                 void TargetInObjectStreamOutStream(jobject obj, int opType, void* arg, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
+                jobject TargetInObjectStreamOutObjectStream(jobject obj, int opType, void* arg, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
                 long long TargetOutLong(jobject obj, int opType, JniErrorInfo* errInfo = NULL);
                 void TargetOutStream(jobject obj, int opType, long long memPtr, JniErrorInfo* errInfo = NULL);
                 jobject TargetOutObject(jobject obj, int opType, JniErrorInfo* errInfo = NULL);
@@ -559,105 +451,8 @@ namespace ignite
                 void* TargetListenFutureAndGet(jobject obj, long long futId, int typ);
                 void* TargetListenFutureForOperationAndGet(jobject obj, long long futId, int typ, int opId);
                 
-                int AffinityPartitions(jobject obj);
-
-                jobject CacheWithSkipStore(jobject obj);
-                jobject CacheWithNoRetries(jobject obj);
-                jobject CacheWithExpiryPolicy(jobject obj, long long create, long long update, long long access);
-                jobject CacheWithAsync(jobject obj);
-                jobject CacheWithKeepPortable(jobject obj);
-                void CacheClear(jobject obj, JniErrorInfo* errInfo = NULL);
-                void CacheRemoveAll(jobject obj, JniErrorInfo* errInfo = NULL);
                 jobject CacheOutOpQueryCursor(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
                 jobject CacheOutOpContinuousQuery(jobject obj, int type, long long memPtr);
-                jobject CacheIterator(jobject obj);
-                jobject CacheLocalIterator(jobject obj, int peekModes);
-                void CacheEnterLock(jobject obj, long long id);
-                void CacheExitLock(jobject obj, long long id);
-                bool CacheTryEnterLock(jobject obj, long long id, long long timeout);
-                void CacheCloseLock(jobject obj, long long id);
-                void CacheRebalance(jobject obj, long long futId);
-                int CacheSize(jobject obj, int peekModes, bool loc, JniErrorInfo* errInfo = NULL);
-
-                void CacheStoreCallbackInvoke(jobject obj, long long memPtr);
-
-                void ComputeWithNoFailover(jobject obj);
-                void ComputeWithTimeout(jobject obj, long long timeout);
-                void* ComputeExecuteNative(jobject obj, long long taskPtr, long long topVer);
-
-                void ContinuousQueryClose(jobject obj);
-                jobject ContinuousQueryGetInitialQueryCursor(jobject obj);
-
-                void DataStreamerListenTopology(jobject obj, long long ptr);
-                bool DataStreamerAllowOverwriteGet(jobject obj);
-                void DataStreamerAllowOverwriteSet(jobject obj, bool val);
-                bool DataStreamerSkipStoreGet(jobject obj);
-                void DataStreamerSkipStoreSet(jobject obj, bool val);
-                int DataStreamerPerNodeBufferSizeGet(jobject obj);
-                void DataStreamerPerNodeBufferSizeSet(jobject obj, int val);
-                int DataStreamerPerNodeParallelOperationsGet(jobject obj);
-                void DataStreamerPerNodeParallelOperationsSet(jobject obj, int val);
-
-                jobject MessagingWithAsync(jobject obj);
-
-                jobject ProjectionForOthers(jobject obj, jobject prj);
-                jobject ProjectionForRemotes(jobject obj);
-                jobject ProjectionForDaemons(jobject obj);
-                jobject ProjectionForRandom(jobject obj);
-                jobject ProjectionForOldest(jobject obj);
-                jobject ProjectionForYoungest(jobject obj);
-                void ProjectionResetMetrics(jobject obj);
-                jobject ProjectionOutOpRet(jobject obj, int type, long long memPtr);
-
-                void QueryCursorIterator(jobject obj, JniErrorInfo* errInfo = NULL);
-                bool QueryCursorIteratorHasNext(jobject obj, JniErrorInfo* errInfo = NULL);
-                void QueryCursorClose(jobject obj, JniErrorInfo* errInfo = NULL);
-
-                long long TransactionsStart(jobject obj, int concurrency, int isolation, long long timeout, int txSize, JniErrorInfo* errInfo = NULL);
-                int TransactionsCommit(jobject obj, long long id, JniErrorInfo* errInfo = NULL);
-                void TransactionsCommitAsync(jobject obj, long long id, long long futId);
-                int TransactionsRollback(jobject obj, long long id, JniErrorInfo* errInfo = NULL);
-                void TransactionsRollbackAsync(jobject obj, long long id, long long futId);
-                int TransactionsClose(jobject obj, long long id, JniErrorInfo* errInfo = NULL);
-                int TransactionsState(jobject obj, long long id, JniErrorInfo* errInfo = NULL);
-                bool TransactionsSetRollbackOnly(jobject obj, long long id, JniErrorInfo* errInfo = NULL);
-                void TransactionsResetMetrics(jobject obj);
-
-                jobject EventsWithAsync(jobject obj);
-                bool EventsStopLocalListen(jobject obj, long long hnd);
-                void EventsLocalListen(jobject obj, long long hnd, int type);
-                bool EventsIsEnabled(jobject obj, int type);
-                
-                jobject ServicesWithAsync(jobject obj);
-                jobject ServicesWithServerKeepPortable(jobject obj);
-                void ServicesCancel(jobject obj, char* name);
-                void ServicesCancelAll(jobject obj);
-                void* ServicesGetServiceProxy(jobject obj, char* name, bool sticky);
-
-                long long AtomicLongGet(jobject obj);
-                long long AtomicLongIncrementAndGet(jobject obj);
-                long long AtomicLongGetAndIncrement(jobject obj);
-                long long AtomicLongAddAndGet(jobject obj, long long value);
-                long long AtomicLongGetAndAdd(jobject obj, long long value);
-                long long AtomicLongDecrementAndGet(jobject obj);
-                long long AtomicLongGetAndDecrement(jobject obj);
-                long long AtomicLongGetAndSet(jobject obj, long long value);
-                long long AtomicLongCompareAndSetAndGet(jobject obj, long long expVal, long long newVal);
-                bool AtomicLongIsClosed(jobject obj);
-                void AtomicLongClose(jobject obj);
-
-                long long AtomicSequenceGet(jobject obj);
-                long long AtomicSequenceIncrementAndGet(jobject obj);
-                long long AtomicSequenceGetAndIncrement(jobject obj);
-                long long AtomicSequenceAddAndGet(jobject obj, long long l);
-                long long AtomicSequenceGetAndAdd(jobject obj, long long l);
-                int AtomicSequenceGetBatchSize(jobject obj);
-                void AtomicSequenceSetBatchSize(jobject obj, int size);
-                bool AtomicSequenceIsClosed(jobject obj);
-                void AtomicSequenceClose(jobject obj);
-
-                bool AtomicReferenceIsClosed(jobject obj);
-                void AtomicReferenceClose(jobject obj);
 
                 bool ListenableCancel(jobject obj);
                 bool ListenableIsCancelled(jobject obj);
@@ -682,7 +477,7 @@ namespace ignite
             };
 
             JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
-            JNIEXPORT jint JNICALL JniCacheStoreInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr, jlong memPtr, jobject cb);
+            JNIEXPORT jint JNICALL JniCacheStoreInvoke(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr, jlong memPtr);
             JNIEXPORT void JNICALL JniCacheStoreDestroy(JNIEnv *env, jclass cls, jlong envPtr, jlong objPtr);
             JNIEXPORT jlong JNICALL JniCacheStoreSessionCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong storePtr);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/jni/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/project/vs/module.def b/modules/platforms/cpp/jni/project/vs/module.def
index dc4af3d..c2069b6 100644
--- a/modules/platforms/cpp/jni/project/vs/module.def
+++ b/modules/platforms/cpp/jni/project/vs/module.def
@@ -23,62 +23,10 @@ IgniteTargetInStreamOutStream @20
 IgniteTargetInObjectStreamOutStream @21 
 IgniteTargetListenFuture @22 
 IgniteTargetListenFutureForOperation @23 
-IgniteAffinityPartitions @24 
-IgniteCacheWithSkipStore @25 
-IgniteCacheWithNoRetries @26 
-IgniteCacheWithExpiryPolicy @27 
-IgniteCacheWithAsync @28 
-IgniteCacheWithKeepPortable @29 
-IgniteCacheClear @30 
-IgniteCacheRemoveAll @31 
-IgniteCacheOutOpQueryCursor @32 
-IgniteCacheOutOpContinuousQuery @33 
-IgniteCacheIterator @34 
-IgniteCacheLocalIterator @35 
-IgniteCacheEnterLock @36 
-IgniteCacheExitLock @37 
-IgniteCacheTryEnterLock @38 
-IgniteCacheCloseLock @39 
-IgniteCacheRebalance @40 
-IgniteCacheSize @41 
-IgniteCacheStoreCallbackInvoke @42 
-IgniteComputeWithNoFailover @43 
-IgniteComputeWithTimeout @44 
-IgniteComputeExecuteNative @45 
-IgniteContinuousQueryClose @46 
-IgniteContinuousQueryGetInitialQueryCursor @47 
-IgniteDataStreamerListenTopology @48 
-IgniteDataStreamerAllowOverwriteGet @49 
-IgniteDataStreamerAllowOverwriteSet @50 
-IgniteDataStreamerSkipStoreGet @51 
-IgniteDataStreamerSkipStoreSet @52 
-IgniteDataStreamerPerNodeBufferSizeGet @53 
-IgniteDataStreamerPerNodeBufferSizeSet @54 
-IgniteDataStreamerPerNodeParallelOperationsGet @55 
-IgniteDataStreamerPerNodeParallelOperationsSet @56 
-IgniteMessagingWithAsync @57 
-IgniteProjectionForOthers @58 
-IgniteProjectionForRemotes @59 
-IgniteProjectionForDaemons @60 
-IgniteProjectionForRandom @61 
-IgniteProjectionForOldest @62 
-IgniteProjectionForYoungest @63 
+IgniteTargetInLongOutLong @24
 IgniteProcessorCompute @64 
 IgniteProcessorMessage @65 
 IgniteProcessorEvents @66 
-IgniteProjectionResetMetrics @67 
-IgniteProjectionOutOpRet @68 
-IgniteQueryCursorIterator @69 
-IgniteQueryCursorClose @70 
-IgniteTransactionsStart @71 
-IgniteTransactionsCommit @72 
-IgniteTransactionsCommitAsync @73 
-IgniteTransactionsRollback @74 
-IgniteTransactionsRollbackAsync @75 
-IgniteTransactionsClose @76 
-IgniteTransactionsState @77 
-IgniteTransactionsSetRollbackOnly @78 
-IgniteTransactionsResetMetrics @79 
 IgniteAcquire @80 
 IgniteRelease @81 
 IgniteThrowToJava @82 
@@ -86,29 +34,9 @@ IgniteHandlersSize @83
 IgniteCreateContext @84 
 IgniteDeleteContext @85 
 IgniteDestroyJvm @86 
-IgniteEventsWithAsync @87 
-IgniteEventsStopLocalListen @88 
-IgniteEventsLocalListen @89 
-IgniteEventsIsEnabled @90 
 IgniteTargetOutObject @91 
-IgniteServicesWithAsync @92
-IgniteServicesWithServerKeepPortable @93
-IgniteServicesCancel @94
-IgniteServicesCancelAll @95
-IgniteServicesGetServiceProxy @96
 IgniteProcessorExtensions @97
 IgniteProcessorAtomicLong @98
-IgniteAtomicLongGet @99 
-IgniteAtomicLongIncrementAndGet @100 
-IgniteAtomicLongGetAndIncrement @101
-IgniteAtomicLongAddAndGet @102
-IgniteAtomicLongGetAndAdd @103
-IgniteAtomicLongDecrementAndGet @104
-IgniteAtomicLongGetAndDecrement @105
-IgniteAtomicLongGetAndSet @106
-IgniteAtomicLongCompareAndSetAndGet @107
-IgniteAtomicLongIsClosed @108
-IgniteAtomicLongClose @109
 IgniteListenableCancel @110
 IgniteListenableIsCancelled @111
 IgniteTargetListenFutureAndGet @112
@@ -118,18 +46,7 @@ IgniteProcessorGetOrCreateCacheFromConfig @115
 IgniteProcessorGetIgniteConfiguration @116
 IgniteProcessorDestroyCache @117
 IgniteProcessorAtomicSequence @118
-IgniteAtomicSequenceGet @119
-IgniteAtomicSequenceIncrementAndGet @120
-IgniteAtomicSequenceGetAndIncrement @121
-IgniteAtomicSequenceAddAndGet @122
-IgniteAtomicSequenceGetAndAdd @123
-IgniteAtomicSequenceGetBatchSize @124
-IgniteAtomicSequenceSetBatchSize @125
-IgniteAtomicSequenceIsClosed @126
-IgniteAtomicSequenceClose @127
 IgniteProcessorAtomicReference @128
-IgniteAtomicReferenceIsClosed @129
-IgniteAtomicReferenceClose @130
 IgniteProcessorCreateNearCache @131
 IgniteProcessorGetOrCreateNearCache @132
 IgniteProcessorGetCacheNames @133

http://git-wip-us.apache.org/repos/asf/ignite/blob/eaf8ae24/modules/platforms/cpp/jni/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/src/exports.cpp b/modules/platforms/cpp/jni/src/exports.cpp
index 89878d4..ca332be 100644
--- a/modules/platforms/cpp/jni/src/exports.cpp
+++ b/modules/platforms/cpp/jni/src/exports.cpp
@@ -138,6 +138,10 @@ extern "C" {
         return ctx->ProcessorGetCacheNames(static_cast<jobject>(obj), memPtr);
     }
 
+    long long IGNITE_CALL IgniteTargetInLongOutLong(gcj::JniContext* ctx, void* obj, int opType, long long val) {
+        return ctx->TargetInLongOutLong(static_cast<jobject>(obj), opType, val);
+    }
+
     long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr) {
         return ctx->TargetInStreamOutLong(static_cast<jobject>(obj), opType, memPtr);
     }
@@ -154,6 +158,10 @@ extern "C" {
         ctx->TargetInObjectStreamOutStream(static_cast<jobject>(obj), opType, arg, inMemPtr, outMemPtr);
     }
     
+    void* IGNITE_CALL IgniteTargetInObjectStreamOutObjectStream(gcj::JniContext* ctx, void* obj, int opType, void* arg, long long inMemPtr, long long outMemPtr) {
+        return ctx->TargetInObjectStreamOutObjectStream(static_cast<jobject>(obj), opType, arg, inMemPtr, outMemPtr);
+    }
+
     long long IGNITE_CALL IgniteTargetOutLong(gcj::JniContext* ctx, void* obj, int opType) {
         return ctx->TargetOutLong(static_cast<jobject>(obj), opType);
     }
@@ -182,219 +190,6 @@ extern "C" {
         return ctx->TargetListenFutureForOperationAndGet(static_cast<jobject>(obj), futId, typ, opId);
     }
 
-    int IGNITE_CALL IgniteAffinityPartitions(gcj::JniContext* ctx, void* obj) {
-        return ctx->AffinityPartitions(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteCacheWithSkipStore(gcj::JniContext* ctx, void* obj) {
-        return ctx->CacheWithSkipStore(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteCacheWithNoRetries(gcj::JniContext* ctx, void* obj) {
-        return ctx->CacheWithNoRetries(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteCacheWithExpiryPolicy(gcj::JniContext* ctx, void* obj, long long create, long long update, long long access) {
-        return ctx->CacheWithExpiryPolicy(static_cast<jobject>(obj), create, update, access);
-    }
-
-    void* IGNITE_CALL IgniteCacheWithAsync(gcj::JniContext* ctx, void* obj) {
-        return ctx->CacheWithAsync(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteCacheWithKeepPortable(gcj::JniContext* ctx, void* obj)
-    {
-        return ctx->CacheWithKeepPortable(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteCacheClear(gcj::JniContext* ctx, void* obj) {
-        ctx->CacheClear(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteCacheRemoveAll(gcj::JniContext* ctx, void* obj) {
-        ctx->CacheRemoveAll(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteCacheOutOpQueryCursor(gcj::JniContext* ctx, void* obj, int type, long long memPtr) {
-        return ctx->CacheOutOpQueryCursor(static_cast<jobject>(obj), type, memPtr);
-    }
-
-    void* IGNITE_CALL IgniteCacheOutOpContinuousQuery(gcj::JniContext* ctx, void* obj, int type, long long memPtr) {
-        return ctx->CacheOutOpContinuousQuery(static_cast<jobject>(obj), type, memPtr);
-    }
-
-    void* IGNITE_CALL IgniteCacheIterator(gcj::JniContext* ctx, void* obj) {
-        return ctx->CacheIterator(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteCacheLocalIterator(gcj::JniContext* ctx, void* obj, int peekModes) {
-        return ctx->CacheLocalIterator(static_cast<jobject>(obj), peekModes);
-    }
-
-    void IGNITE_CALL IgniteCacheEnterLock(gcj::JniContext* ctx, void* obj, long long id) {
-        ctx->CacheEnterLock(static_cast<jobject>(obj), id);
-    }
-
-    void IGNITE_CALL IgniteCacheExitLock(gcj::JniContext* ctx, void* obj, long long id) {
-        ctx->CacheExitLock(static_cast<jobject>(obj), id);
-    }
-
-    bool IGNITE_CALL IgniteCacheTryEnterLock(gcj::JniContext* ctx, void* obj, long long id, long long timeout) {
-        return ctx->CacheTryEnterLock(static_cast<jobject>(obj), id, timeout);
-    }
-
-    void IGNITE_CALL IgniteCacheCloseLock(gcj::JniContext* ctx, void* obj, long long id) {
-        ctx->CacheCloseLock(static_cast<jobject>(obj), id);
-    }
-
-    void IGNITE_CALL IgniteCacheRebalance(gcj::JniContext* ctx, void* obj, long long futId) {
-        ctx->CacheRebalance(static_cast<jobject>(obj), futId);
-    }
-
-    int IGNITE_CALL IgniteCacheSize(gcj::JniContext* ctx, void* obj, int peekModes, bool loc) {
-        return ctx->CacheSize(static_cast<jobject>(obj), peekModes, loc);
-    }
-
-    void IGNITE_CALL IgniteComputeWithNoFailover(gcj::JniContext* ctx, void* obj) {
-        ctx->ComputeWithNoFailover(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteComputeWithTimeout(gcj::JniContext* ctx, void* obj, long long timeout) {
-        ctx->ComputeWithTimeout(static_cast<jobject>(obj), timeout);
-    }
-
-    void* IGNITE_CALL IgniteComputeExecuteNative(gcj::JniContext* ctx, void* obj, long long taskPtr, long long topVer) {
-        return ctx->ComputeExecuteNative(static_cast<jobject>(obj), taskPtr, topVer);
-    }
-
-    void IGNITE_CALL IgniteContinuousQueryClose(gcj::JniContext* ctx, void* obj) {
-        ctx->ContinuousQueryClose(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteContinuousQueryGetInitialQueryCursor(gcj::JniContext* ctx, void* obj) {
-        return ctx->ContinuousQueryGetInitialQueryCursor(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteCacheStoreCallbackInvoke(gcj::JniContext* ctx, void* obj, long long memPtr) {
-        ctx->CacheStoreCallbackInvoke(static_cast<jobject>(obj), memPtr);
-    }
-
-    void IGNITE_CALL IgniteDataStreamerListenTopology(gcj::JniContext* ctx, void* obj, long long ptr) {
-        ctx->DataStreamerListenTopology(static_cast<jobject>(obj), ptr);
-    }
-
-    bool IGNITE_CALL IgniteDataStreamerAllowOverwriteGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->DataStreamerAllowOverwriteGet(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteDataStreamerAllowOverwriteSet(gcj::JniContext* ctx, void* obj, bool val) {
-        ctx->DataStreamerAllowOverwriteSet(static_cast<jobject>(obj), val);
-    }
-
-    bool IGNITE_CALL IgniteDataStreamerSkipStoreGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->DataStreamerSkipStoreGet(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteDataStreamerSkipStoreSet(gcj::JniContext* ctx, void* obj, bool val) {
-        ctx->DataStreamerSkipStoreSet(static_cast<jobject>(obj), val);
-    }
-
-    int IGNITE_CALL IgniteDataStreamerPerNodeBufferSizeGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->DataStreamerPerNodeBufferSizeGet(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteDataStreamerPerNodeBufferSizeSet(gcj::JniContext* ctx, void* obj, int val) {
-        ctx->DataStreamerPerNodeBufferSizeSet(static_cast<jobject>(obj), val);
-    }
-
-    int IGNITE_CALL IgniteDataStreamerPerNodeParallelOperationsGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->DataStreamerPerNodeParallelOperationsGet(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteDataStreamerPerNodeParallelOperationsSet(gcj::JniContext* ctx, void* obj, int val) {
-        ctx->DataStreamerPerNodeParallelOperationsSet(static_cast<jobject>(obj), val);
-    }
-
-    void* IGNITE_CALL IgniteMessagingWithAsync(gcj::JniContext* ctx, void* obj) {
-        return ctx->MessagingWithAsync(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteProjectionForOthers(gcj::JniContext* ctx, void* obj, void* prj) {
-        return ctx->ProjectionForOthers(static_cast<jobject>(obj), static_cast<jobject>(prj));
-    }
-
-    void* IGNITE_CALL IgniteProjectionForRemotes(gcj::JniContext* ctx, void* obj) {
-        return ctx->ProjectionForRemotes(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteProjectionForDaemons(gcj::JniContext* ctx, void* obj) {
-        return ctx->ProjectionForDaemons(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteProjectionForRandom(gcj::JniContext* ctx, void* obj) {
-        return ctx->ProjectionForRandom(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteProjectionForOldest(gcj::JniContext* ctx, void* obj) {
-        return ctx->ProjectionForOldest(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteProjectionForYoungest(gcj::JniContext* ctx, void* obj) {
-        return ctx->ProjectionForYoungest(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteProjectionResetMetrics(gcj::JniContext* ctx, void* obj) {
-        ctx->ProjectionResetMetrics(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteProjectionOutOpRet(gcj::JniContext* ctx, void* obj, int type, long long memPtr) {
-        return ctx->ProjectionOutOpRet(static_cast<jobject>(obj), type, memPtr);
-    }
-
-    void IGNITE_CALL IgniteQueryCursorIterator(gcj::JniContext* ctx, void* obj) {
-        ctx->QueryCursorIterator(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteQueryCursorClose(gcj::JniContext* ctx, void* obj) {
-        ctx->QueryCursorClose(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteTransactionsStart(gcj::JniContext* ctx, void* obj, int concurrency, int isolation, long long timeout, int txSize) {
-        return ctx->TransactionsStart(static_cast<jobject>(obj), concurrency, isolation, timeout, txSize);
-    }   
-
-    int IGNITE_CALL IgniteTransactionsCommit(gcj::JniContext* ctx, void* obj, long long id) {
-        return ctx->TransactionsCommit(static_cast<jobject>(obj), id);
-    }
-
-    void IGNITE_CALL IgniteTransactionsCommitAsync(gcj::JniContext* ctx, void* obj, long long id, long long futId) {
-        return ctx->TransactionsCommitAsync(static_cast<jobject>(obj), id, futId);
-    }
-
-    int IGNITE_CALL IgniteTransactionsRollback(gcj::JniContext* ctx, void* obj, long long id) {
-        return ctx->TransactionsRollback(static_cast<jobject>(obj), id);
-    }
-
-    void IGNITE_CALL IgniteTransactionsRollbackAsync(gcj::JniContext* ctx, void* obj, long long id, long long futId) {
-        return ctx->TransactionsRollbackAsync(static_cast<jobject>(obj), id, futId);
-    }
-
-    int IGNITE_CALL IgniteTransactionsClose(gcj::JniContext* ctx, void* obj, long long id) {
-        return ctx->TransactionsClose(static_cast<jobject>(obj), id);
-    }
-
-    int IGNITE_CALL IgniteTransactionsState(gcj::JniContext* ctx, void* obj, long long id) {
-        return ctx->TransactionsState(static_cast<jobject>(obj), id);
-    }
-
-    bool IGNITE_CALL IgniteTransactionsSetRollbackOnly(gcj::JniContext* ctx, void* obj, long long id) {
-        return ctx->TransactionsSetRollbackOnly(static_cast<jobject>(obj), id);
-    }
-
-    void IGNITE_CALL IgniteTransactionsResetMetrics(gcj::JniContext* ctx, void* obj) {
-        ctx->TransactionsResetMetrics(static_cast<jobject>(obj));
-    }
-
     void* IGNITE_CALL IgniteAcquire(gcj::JniContext* ctx, void* obj) {
         return ctx->Acquire(static_cast<jobject>(obj));
     }
@@ -423,130 +218,6 @@ extern "C" {
         ctx->DestroyJvm();
     }
 
-    void* IGNITE_CALL IgniteEventsWithAsync(gcj::JniContext* ctx, void* obj) {
-        return ctx->EventsWithAsync(static_cast<jobject>(obj));
-    }
-
-    bool IGNITE_CALL IgniteEventsStopLocalListen(gcj::JniContext* ctx, void* obj, long long hnd) {
-        return ctx->EventsStopLocalListen(static_cast<jobject>(obj), hnd);
-    }
-
-    void IGNITE_CALL IgniteEventsLocalListen(gcj::JniContext* ctx, void* obj, long long hnd, int type) {
-        ctx->EventsLocalListen(static_cast<jobject>(obj), hnd, type);
-    }
-
-    bool IGNITE_CALL IgniteEventsIsEnabled(gcj::JniContext* ctx, void* obj, int type) {
-        return ctx->EventsIsEnabled(static_cast<jobject>(obj), type);
-    }    
-    
-	void* IGNITE_CALL IgniteServicesWithAsync(gcj::JniContext* ctx, void* obj) {
-		return ctx->ServicesWithAsync(static_cast<jobject>(obj));
-    }
-
-    void* IGNITE_CALL IgniteServicesWithServerKeepPortable(gcj::JniContext* ctx, void* obj) {
-        return ctx->ServicesWithServerKeepPortable(static_cast<jobject>(obj));
-    }
-
-	void IGNITE_CALL IgniteServicesCancel(gcj::JniContext* ctx, void* obj, char* name) {
-		ctx->ServicesCancel(static_cast<jobject>(obj), name);
-    }
-
-	void IGNITE_CALL IgniteServicesCancelAll(gcj::JniContext* ctx, void* obj) {
-		ctx->ServicesCancelAll(static_cast<jobject>(obj));
-    }
-
-	void* IGNITE_CALL IgniteServicesGetServiceProxy(gcj::JniContext* ctx, void* obj, char* name, bool sticky) {
-		return ctx->ServicesGetServiceProxy(static_cast<jobject>(obj), name, sticky);
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicLongGet(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongIncrementAndGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicLongIncrementAndGet(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongGetAndIncrement(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicLongGetAndIncrement(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongAddAndGet(gcj::JniContext* ctx, void* obj, long long value) {
-        return ctx->AtomicLongAddAndGet(static_cast<jobject>(obj), value);
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongGetAndAdd(gcj::JniContext* ctx, void* obj, long long value) {
-        return ctx->AtomicLongGetAndAdd(static_cast<jobject>(obj), value);
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongDecrementAndGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicLongDecrementAndGet(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongGetAndDecrement(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicLongGetAndDecrement(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongGetAndSet(gcj::JniContext* ctx, void* obj, long long value) {
-        return ctx->AtomicLongGetAndSet(static_cast<jobject>(obj), value);
-    }
-
-    long long IGNITE_CALL IgniteAtomicLongCompareAndSetAndGet(gcj::JniContext* ctx, void* obj, long long expVal, long long newVal) {
-        return ctx->AtomicLongCompareAndSetAndGet(static_cast<jobject>(obj), expVal, newVal);
-    }
-
-    bool IGNITE_CALL IgniteAtomicLongIsClosed(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicLongIsClosed(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteAtomicLongClose(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicLongClose(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicSequenceGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicSequenceGet(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicSequenceIncrementAndGet(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicSequenceIncrementAndGet(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicSequenceGetAndIncrement(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicSequenceGetAndIncrement(static_cast<jobject>(obj));
-    }
-
-    long long IGNITE_CALL IgniteAtomicSequenceAddAndGet(gcj::JniContext* ctx, void* obj, long long l) {
-        return ctx->AtomicSequenceAddAndGet(static_cast<jobject>(obj), l);
-    }
-
-    long long IGNITE_CALL IgniteAtomicSequenceGetAndAdd(gcj::JniContext* ctx, void* obj, long long l) {
-        return ctx->AtomicSequenceGetAndAdd(static_cast<jobject>(obj), l);
-    }
-
-    int IGNITE_CALL IgniteAtomicSequenceGetBatchSize(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicSequenceGetBatchSize(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteAtomicSequenceSetBatchSize(gcj::JniContext* ctx, void* obj, int size) {
-        return ctx->AtomicSequenceSetBatchSize(static_cast<jobject>(obj), size);
-    }
-
-    bool IGNITE_CALL IgniteAtomicSequenceIsClosed(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicSequenceIsClosed(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteAtomicSequenceClose(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicSequenceClose(static_cast<jobject>(obj));
-    }
-
-    bool IGNITE_CALL IgniteAtomicReferenceIsClosed(gcj::JniContext* ctx, void* obj) {
-        return ctx->AtomicReferenceIsClosed(static_cast<jobject>(obj));
-    }
-
-    void IGNITE_CALL IgniteAtomicReferenceClose(gcj::JniContext* ctx, void* obj) {
-        ctx->AtomicReferenceClose(static_cast<jobject>(obj));
-    }
-    
     bool IGNITE_CALL IgniteListenableCancel(gcj::JniContext* ctx, void* obj) {
         return ctx->ListenableCancel(static_cast<jobject>(obj));
     }


[16/40] ignite git commit: IGNITE-4041: Created separate processor for thread pools and refactored IO manager. This closes #1150.

Posted by av...@apache.org.
IGNITE-4041: Created separate processor for thread pools and refactored IO manager. This closes #1150.


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: f9a0676fad7fd6c23e3c91c10d7e0412ccb27c06
Parents: b9c776a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Oct 11 10:23:01 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 11 10:23:01 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/GridKernalContext.java      |  15 ++
 .../ignite/internal/GridKernalContextImpl.java  |  24 +++
 .../apache/ignite/internal/IgniteKernal.java    |   6 +
 .../org/apache/ignite/internal/IgnitionEx.java  |  19 ++-
 .../managers/communication/GridIoManager.java   | 161 ++-----------------
 .../processors/closure/GridClosurePolicy.java   |  51 ------
 .../closure/GridClosureProcessor.java           |  88 +++-------
 .../internal/processors/pool/PoolProcessor.java | 149 +++++++++++++++++
 .../resources/META-INF/classnames.properties    |   1 -
 .../managers/GridManagerStopSelfTest.java       |   2 +
 .../util/future/GridFutureAdapterSelfTest.java  |   3 +
 .../junits/GridTestKernalContext.java           |   1 +
 12 files changed, 250 insertions(+), 270 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index b123a4a..e608af2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@ -53,6 +53,7 @@ import org.apache.ignite.internal.processors.odbc.OdbcProcessor;
 import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
 import org.apache.ignite.internal.processors.platform.PlatformProcessor;
 import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
+import org.apache.ignite.internal.processors.pool.PoolProcessor;
 import org.apache.ignite.internal.processors.port.GridPortProcessor;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.processors.resource.GridResourceProcessor;
@@ -286,6 +287,13 @@ public interface GridKernalContext extends Iterable<GridComponent> {
     public HadoopProcessorAdapter hadoop();
 
     /**
+     * Gets pool processor.
+     *
+     * @return Pool processor.
+     */
+    public PoolProcessor pools();
+
+    /**
      * Gets Hadoop helper.
      *
      * @return Hadoop helper.
@@ -533,6 +541,13 @@ public interface GridKernalContext extends Iterable<GridComponent> {
     public ExecutorService getRestExecutorService();
 
     /**
+     * Get affinity executor service.
+     *
+     * @return Affinity executor service.
+     */
+    public ExecutorService getAffinityExecutorService();
+
+    /**
      * Gets exception registry.
      *
      * @return Exception registry.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index c7e26e9..ddef345 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -70,6 +70,7 @@ import org.apache.ignite.internal.processors.odbc.OdbcProcessor;
 import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
 import org.apache.ignite.internal.processors.platform.PlatformProcessor;
 import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
+import org.apache.ignite.internal.processors.pool.PoolProcessor;
 import org.apache.ignite.internal.processors.port.GridPortProcessor;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.processors.resource.GridResourceProcessor;
@@ -259,6 +260,10 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
 
     /** */
     @GridToStringExclude
+    private PoolProcessor poolProc;
+
+    /** */
+    @GridToStringExclude
     private IgnitePluginProcessor pluginProc;
 
     /** */
@@ -311,6 +316,10 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
 
     /** */
     @GridToStringExclude
+    protected ExecutorService affExecSvc;
+
+    /** */
+    @GridToStringExclude
     protected IgniteStripedThreadPoolExecutor callbackExecSvc;
 
     /** */
@@ -372,6 +381,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
      * @param mgmtExecSvc Management executor service.
      * @param igfsExecSvc IGFS executor service.
      * @param restExecSvc REST executor service.
+     * @param affExecSvc Affinity executor service.
      * @param plugins Plugin providers.
      * @throws IgniteCheckedException In case of error.
      */
@@ -389,6 +399,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         ExecutorService mgmtExecSvc,
         ExecutorService igfsExecSvc,
         ExecutorService restExecSvc,
+        ExecutorService affExecSvc,
         IgniteStripedThreadPoolExecutor callbackExecSvc,
         List<PluginProvider> plugins) throws IgniteCheckedException {
         assert grid != null;
@@ -406,6 +417,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         this.mgmtExecSvc = mgmtExecSvc;
         this.igfsExecSvc = igfsExecSvc;
         this.restExecSvc = restExecSvc;
+        this.affExecSvc = affExecSvc;
         this.callbackExecSvc = callbackExecSvc;
 
         String workDir = U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome());
@@ -533,6 +545,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
             cluster = (ClusterProcessor)comp;
         else if (comp instanceof PlatformProcessor)
             platformProc = (PlatformProcessor)comp;
+        else if (comp instanceof PoolProcessor)
+            poolProc = (PoolProcessor) comp;
         else if (!(comp instanceof DiscoveryNodeValidationProcessor))
             assert (comp instanceof GridPluginComponent) : "Unknown manager class: " + comp.getClass();
 
@@ -757,6 +771,11 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
     }
 
     /** {@inheritDoc} */
+    @Override public PoolProcessor pools() {
+        return poolProc;
+    }
+
+    /** {@inheritDoc} */
     @Override public ExecutorService utilityCachePool() {
         return utilityCachePool;
     }
@@ -942,6 +961,11 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
     }
 
     /** {@inheritDoc} */
+    @Override public ExecutorService getAffinityExecutorService() {
+        return affExecSvc;
+    }
+
+    /** {@inheritDoc} */
     @Override public IgniteExceptionRegistry exceptionRegistry() {
         return IgniteExceptionRegistry.get();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index e0a36a7..02f16af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -126,6 +126,7 @@ import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
 import org.apache.ignite.internal.processors.platform.PlatformNoopProcessor;
 import org.apache.ignite.internal.processors.platform.PlatformProcessor;
 import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
+import org.apache.ignite.internal.processors.pool.PoolProcessor;
 import org.apache.ignite.internal.processors.port.GridPortProcessor;
 import org.apache.ignite.internal.processors.port.GridPortRecord;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
@@ -666,6 +667,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
      * @param mgmtExecSvc Management executor service.
      * @param igfsExecSvc IGFS executor service.
      * @param restExecSvc Reset executor service.
+     * @param affExecSvc Affinity executor service.
      * @param errHnd Error handler to use for notification about startup problems.
      * @throws IgniteCheckedException Thrown in case of any errors.
      */
@@ -679,6 +681,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         ExecutorService mgmtExecSvc,
         ExecutorService igfsExecSvc,
         ExecutorService restExecSvc,
+        ExecutorService affExecSvc,
         IgniteStripedThreadPoolExecutor callbackExecSvc,
         GridAbsClosure errHnd)
         throws IgniteCheckedException
@@ -784,6 +787,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                 mgmtExecSvc,
                 igfsExecSvc,
                 restExecSvc,
+                affExecSvc,
                 callbackExecSvc,
                 plugins);
 
@@ -827,6 +831,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
             startProcessor(new IgnitePluginProcessor(ctx, cfg, plugins));
 
+            startProcessor(new PoolProcessor(ctx));
+
             // Off-heap processor has no dependencies.
             startProcessor(new GridOffHeapProcessor(ctx));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 001f599..a6860b3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1477,6 +1477,9 @@ public class IgnitionEx {
         /** Marshaller cache executor service. */
         private ThreadPoolExecutor marshCacheExecSvc;
 
+        /** Affinity executor service. */
+        private ThreadPoolExecutor affExecSvc;
+
         /** Continuous query executor service. */
         private IgniteStripedThreadPoolExecutor callbackExecSvc;
 
@@ -1734,6 +1737,16 @@ public class IgnitionEx {
 
             marshCacheExecSvc.allowCoreThreadTimeOut(true);
 
+            affExecSvc = new IgniteThreadPoolExecutor(
+                "aff",
+                cfg.getGridName(),
+                1,
+                1,
+                DFLT_THREAD_KEEP_ALIVE_TIME,
+                new LinkedBlockingQueue<Runnable>());
+
+            affExecSvc.allowCoreThreadTimeOut(true);
+
             // Register Ignite MBean for current grid instance.
             registerFactoryMbean(myCfg.getMBeanServer());
 
@@ -1746,7 +1759,7 @@ public class IgnitionEx {
                 grid = grid0;
 
                 grid0.start(myCfg, utilityCacheExecSvc, marshCacheExecSvc, execSvc, sysExecSvc, p2pExecSvc, mgmtExecSvc,
-                    igfsExecSvc, restExecSvc, callbackExecSvc,
+                    igfsExecSvc, restExecSvc, affExecSvc, callbackExecSvc,
                     new CA() {
                         @Override public void apply() {
                             startLatch.countDown();
@@ -2381,6 +2394,10 @@ public class IgnitionEx {
 
             marshCacheExecSvc = null;
 
+            U.shutdownNow(getClass(), affExecSvc, log);
+
+            affExecSvc = null;
+
             U.shutdownNow(getClass(), callbackExecSvc, log);
 
             callbackExecSvc = null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 4bc2eea..bd285b2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -29,9 +29,6 @@ import java.util.UUID;
 import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -54,6 +51,7 @@ import org.apache.ignite.internal.managers.deployment.GridDeployment;
 import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.platform.message.PlatformMessageFilter;
+import org.apache.ignite.internal.processors.pool.PoolProcessor;
 import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
 import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashSet;
 import org.apache.ignite.internal.util.GridSpinReadWriteLock;
@@ -68,7 +66,6 @@ import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgniteRunnable;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.plugin.extensions.communication.IoPool;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageFactory;
 import org.apache.ignite.plugin.extensions.communication.MessageFormatter;
@@ -78,7 +75,6 @@ import org.apache.ignite.spi.IgniteSpiException;
 import org.apache.ignite.spi.communication.CommunicationListener;
 import org.apache.ignite.spi.communication.CommunicationSpi;
 import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
-import org.apache.ignite.thread.IgniteThreadPoolExecutor;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 import org.jsr166.ConcurrentLinkedDeque8;
@@ -130,32 +126,8 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
     /** Disconnect listeners. */
     private final Collection<GridDisconnectListener> disconnectLsnrs = new ConcurrentLinkedQueue<>();
 
-    /** Map of {@link IoPool}-s injected by Ignite plugins. */
-    private final IoPool[] ioPools = new IoPool[128];
-
-    /** Public pool. */
-    private ExecutorService pubPool;
-
-    /** Internal P2P pool. */
-    private ExecutorService p2pPool;
-
-    /** Internal system pool. */
-    private ExecutorService sysPool;
-
-    /** Internal management pool. */
-    private ExecutorService mgmtPool;
-
-    /** Affinity assignment executor service. */
-    private ExecutorService affPool;
-
-    /** Utility cache pool. */
-    private ExecutorService utilityCachePool;
-
-    /** Marshaller cache pool. */
-    private ExecutorService marshCachePool;
-
-    /** IGFS pool. */
-    private ExecutorService igfsPool;
+    /** Pool processor. */
+    private PoolProcessor pools;
 
     /** Discovery listener. */
     private GridLocalEventListener discoLsnr;
@@ -210,6 +182,10 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
     public GridIoManager(GridKernalContext ctx) {
         super(ctx, ctx.config().getCommunicationSpi());
 
+        pools = ctx.pools();
+
+        assert pools != null;
+
         locNodeId = ctx.localNodeId();
 
         discoDelay = ctx.config().getDiscoveryStartupDelay();
@@ -253,21 +229,6 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
 
         startSpi();
 
-        pubPool = ctx.getExecutorService();
-        p2pPool = ctx.getPeerClassLoadingExecutorService();
-        sysPool = ctx.getSystemExecutorService();
-        mgmtPool = ctx.getManagementExecutorService();
-        utilityCachePool = ctx.utilityCachePool();
-        marshCachePool = ctx.marshallerCachePool();
-        igfsPool = ctx.getIgfsExecutorService();
-        affPool = new IgniteThreadPoolExecutor(
-            "aff",
-            ctx.gridName(),
-            1,
-            1,
-            0,
-            new LinkedBlockingQueue<Runnable>());
-
         getSpi().setListener(commLsnr = new CommunicationListener<Serializable>() {
             @Override public void onMessage(UUID nodeId, Serializable msg, IgniteRunnable msgC) {
                 try {
@@ -335,41 +296,6 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
 
         if (log.isDebugEnabled())
             log.debug(startInfo());
-
-        registerIoPoolExtensions();
-    }
-
-    /**
-     * Processes IO messaging pool extensions.
-     * @throws IgniteCheckedException On error.
-     */
-    private void registerIoPoolExtensions() throws IgniteCheckedException {
-        // Process custom IO messaging pool extensions:
-        final IoPool[] executorExtensions = ctx.plugins().extensions(IoPool.class);
-
-        if (executorExtensions != null) {
-            // Store it into the map and check for duplicates:
-            for (IoPool ex : executorExtensions) {
-                final byte id = ex.id();
-
-                // 1. Check the pool id is non-negative:
-                if (id < 0)
-                    throw new IgniteCheckedException("Failed to register IO executor pool because its Id is negative " +
-                        "[id=" + id + ']');
-
-                // 2. Check the pool id is in allowed range:
-                if (isReservedGridIoPolicy(id))
-                    throw new IgniteCheckedException("Failed to register IO executor pool because its Id in in the " +
-                        "reserved range (0-31) [id=" + id + ']');
-
-                // 3. Check the pool for duplicates:
-                if (ioPools[id] != null)
-                    throw new IgniteCheckedException("Failed to register IO executor pool because its " +
-                        "Id as already used [id=" + id + ']');
-
-                ioPools[id] = ex;
-            }
-        }
     }
 
     /** {@inheritDoc} */
@@ -546,8 +472,6 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
             if (interrupted)
                 Thread.currentThread().interrupt();
 
-            U.shutdownNow(getClass(), affPool, log);
-
             GridEventStorageManager evtMgr = ctx.event();
 
             if (evtMgr != null && discoLsnr != null)
@@ -566,8 +490,6 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
 
         if (log.isDebugEnabled())
             log.debug(stopInfo());
-
-        Arrays.fill(ioPools, null);
     }
 
     /**
@@ -683,67 +605,6 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
     }
 
     /**
-     * Gets execution pool for policy.
-     *
-     * @param plc Policy.
-     * @return Execution pool.
-     * @throws IgniteCheckedException If failed.
-     */
-    private Executor pool(byte plc) throws IgniteCheckedException {
-        switch (plc) {
-            case P2P_POOL:
-                return p2pPool;
-            case SYSTEM_POOL:
-                return sysPool;
-            case PUBLIC_POOL:
-                return pubPool;
-            case MANAGEMENT_POOL:
-                return mgmtPool;
-            case AFFINITY_POOL:
-                return affPool;
-
-            case UTILITY_CACHE_POOL:
-                assert utilityCachePool != null : "Utility cache pool is not configured.";
-
-                return utilityCachePool;
-
-            case MARSH_CACHE_POOL:
-                assert marshCachePool != null : "Marshaller cache pool is not configured.";
-
-                return marshCachePool;
-
-            case IGFS_POOL:
-                assert igfsPool != null : "IGFS pool is not configured.";
-
-                return igfsPool;
-
-            default: {
-                assert plc >= 0 : "Negative policy: " + plc;
-
-                if (isReservedGridIoPolicy(plc))
-                    throw new IgniteCheckedException("Failed to process message with policy of reserved" +
-                        " range (0-31), [policy=" + plc + ']');
-
-                IoPool pool = ioPools[plc];
-
-                if (pool == null)
-                    throw new IgniteCheckedException("Failed to process message because no pool is registered " +
-                        "for policy. [policy=" + plc + ']');
-
-                assert plc == pool.id();
-
-                Executor ex = pool.executor();
-
-                if (ex == null)
-                    throw new IgniteCheckedException("Failed to process message because corresponding executor " +
-                        "is null. [id=" + plc + ']');
-
-                return ex;
-            }
-        }
-    }
-
-    /**
      * @param nodeId Node ID.
      * @param msg Message.
      * @param msgC Closure to call when message processing finished.
@@ -778,7 +639,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         };
 
         try {
-            p2pPool.execute(c);
+            pools.p2pPool().execute(c);
         }
         catch (RejectedExecutionException e) {
             U.error(log, "Failed to process P2P message due to execution rejection. Increase the upper bound " +
@@ -818,7 +679,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         };
 
         try {
-            pool(plc).execute(c);
+            pools.poolForPolicy(plc).execute(c);
         }
         catch (RejectedExecutionException e) {
             U.error(log, "Failed to process regular message due to execution rejection. Increase the upper bound " +
@@ -1154,7 +1015,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         };
 
         try {
-            pool(plc).execute(c);
+            pools.poolForPolicy(plc).execute(c);
         }
         catch (RejectedExecutionException e) {
             U.error(log, "Failed to process ordered message due to execution rejection. " +
@@ -1781,7 +1642,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
 
             try {
                 for (final GridCommunicationMessageSet msgSet : msgSets) {
-                    pool(msgSet.policy()).execute(
+                    pools.poolForPolicy(msgSet.policy()).execute(
                         new Runnable() {
                             @Override public void run() {
                                 unwindMessageSet(msgSet, lsnrs0);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosurePolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosurePolicy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosurePolicy.java
deleted file mode 100644
index c17cedd..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosurePolicy.java
+++ /dev/null
@@ -1,51 +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.closure;
-
-import org.jetbrains.annotations.Nullable;
-
-/**
- * This enumeration defines different types of closure
- * processing by the closure processor.
- */
-public enum GridClosurePolicy {
-    /** Public execution pool. */
-    PUBLIC_POOL,
-
-    /** P2P execution pool. */
-    P2P_POOL,
-
-    /** System execution pool. */
-    SYSTEM_POOL,
-
-    /** IGFS pool. */
-    IGFS_POOL;
-
-    /** Enum values. */
-    private static final GridClosurePolicy[] VALS = values();
-
-    /**
-     * Efficiently gets enumerated value from its ordinal.
-     *
-     * @param ord Ordinal value.
-     * @return Enumerated value.
-     */
-    @Nullable public static GridClosurePolicy fromOrdinal(int ord) {
-        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
index 6f878ce..a96d6eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
@@ -50,8 +50,10 @@ import org.apache.ignite.internal.GridClosureCallMode;
 import org.apache.ignite.internal.GridInternalWrapper;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.pool.PoolProcessor;
 import org.apache.ignite.internal.processors.resource.GridNoImplicitInjection;
 import org.apache.ignite.internal.util.GridSpinReadWriteLock;
 import org.apache.ignite.internal.util.IgniteUtils;
@@ -88,14 +90,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
     /** Ignite version in which binarylizable versions of closures were introduced. */
     public static final IgniteProductVersion BINARYLIZABLE_CLOSURES_SINCE = IgniteProductVersion.fromString("1.6.0");
 
-    /** */
-    private final Executor sysPool;
-
-    /** */
-    private final Executor pubPool;
-
-    /** */
-    private final Executor igfsPool;
+    /** Pool processor. */
+    private final PoolProcessor pools;
 
     /** Lock to control execution after stop. */
     private final GridSpinReadWriteLock busyLock = new GridSpinReadWriteLock();
@@ -109,9 +105,9 @@ public class GridClosureProcessor extends GridProcessorAdapter {
     public GridClosureProcessor(GridKernalContext ctx) {
         super(ctx);
 
-        sysPool = ctx.getSystemExecutorService();
-        pubPool = ctx.getExecutorService();
-        igfsPool = ctx.getIgfsExecutorService();
+        pools = ctx.pools();
+
+        assert pools != null;
     }
 
     /** {@inheritDoc} */
@@ -731,57 +727,13 @@ public class GridClosureProcessor extends GridProcessorAdapter {
     }
 
     /**
-     * Gets pool by execution policy.
-     *
-     * @param plc Whether to get system or public pool.
-     * @return Requested worker pool.
-     */
-    private Executor pool(GridClosurePolicy plc) {
-        switch (plc) {
-            case PUBLIC_POOL:
-                return pubPool;
-
-            case SYSTEM_POOL:
-                return sysPool;
-
-            case IGFS_POOL:
-                return igfsPool;
-
-            default:
-                throw new IllegalArgumentException("Invalid closure execution policy: " + plc);
-        }
-    }
-
-    /**
-     * Gets pool name by execution policy.
-     *
-     * @param plc Policy to choose executor pool.
-     * @return Pool name.
-     */
-    private String poolName(GridClosurePolicy plc) {
-        switch (plc) {
-            case PUBLIC_POOL:
-                return "public";
-
-            case SYSTEM_POOL:
-                return "system";
-
-            case IGFS_POOL:
-                return "igfs";
-
-            default:
-                throw new IllegalArgumentException("Invalid closure execution policy: " + plc);
-        }
-    }
-
-    /**
      * @param c Closure to execute.
      * @param sys If {@code true}, then system pool will be used, otherwise public pool will be used.
      * @return Future.
      * @throws IgniteCheckedException Thrown in case of any errors.
      */
     private IgniteInternalFuture<?> runLocal(@Nullable final Runnable c, boolean sys) throws IgniteCheckedException {
-        return runLocal(c, sys ? GridClosurePolicy.SYSTEM_POOL : GridClosurePolicy.PUBLIC_POOL);
+        return runLocal(c, sys ? GridIoPolicy.SYSTEM_POOL : GridIoPolicy.PUBLIC_POOL);
     }
 
     /**
@@ -790,7 +742,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @return Future.
      * @throws IgniteCheckedException Thrown in case of any errors.
      */
-    private IgniteInternalFuture<?> runLocal(@Nullable final Runnable c, GridClosurePolicy plc) throws IgniteCheckedException {
+    private IgniteInternalFuture<?> runLocal(@Nullable final Runnable c, byte plc)
+        throws IgniteCheckedException {
         if (c == null)
             return new GridFinishedFuture();
 
@@ -830,11 +783,11 @@ public class GridClosureProcessor extends GridProcessorAdapter {
             fut.setWorker(w);
 
             try {
-                pool(plc).execute(w);
+                pools.poolForPolicy(plc).execute(w);
             }
             catch (RejectedExecutionException e) {
                 U.error(log, "Failed to execute worker due to execution rejection " +
-                    "(increase upper bound on " + poolName(plc) + " executor service).", e);
+                    "(increase upper bound on executor service) [policy=" + plc + ']', e);
 
                 w.run();
             }
@@ -866,7 +819,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @return Future.
      */
     public IgniteInternalFuture<?> runLocalSafe(Runnable c, boolean sys) {
-        return runLocalSafe(c, sys ? GridClosurePolicy.SYSTEM_POOL : GridClosurePolicy.PUBLIC_POOL);
+        return runLocalSafe(c, sys ? GridIoPolicy.SYSTEM_POOL : GridIoPolicy.PUBLIC_POOL);
     }
 
     /**
@@ -877,7 +830,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param plc Policy to choose executor pool.
      * @return Future.
      */
-    public IgniteInternalFuture<?> runLocalSafe(Runnable c, GridClosurePolicy plc) {
+    public IgniteInternalFuture<?> runLocalSafe(Runnable c, byte plc) {
         try {
             return runLocal(c, plc);
         }
@@ -921,7 +874,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException Thrown in case of any errors.
      */
     private <R> IgniteInternalFuture<R> callLocal(@Nullable final Callable<R> c, boolean sys) throws IgniteCheckedException {
-        return callLocal(c, sys ? GridClosurePolicy.SYSTEM_POOL : GridClosurePolicy.PUBLIC_POOL);
+        return callLocal(c, sys ? GridIoPolicy.SYSTEM_POOL : GridIoPolicy.PUBLIC_POOL);
     }
 
     /**
@@ -931,7 +884,8 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @return Future.
      * @throws IgniteCheckedException Thrown in case of any errors.
      */
-    private <R> IgniteInternalFuture<R> callLocal(@Nullable final Callable<R> c, GridClosurePolicy plc) throws IgniteCheckedException {
+    private <R> IgniteInternalFuture<R> callLocal(@Nullable final Callable<R> c, byte plc)
+        throws IgniteCheckedException {
         if (c == null)
             return new GridFinishedFuture<>();
 
@@ -969,11 +923,11 @@ public class GridClosureProcessor extends GridProcessorAdapter {
             fut.setWorker(w);
 
             try {
-                pool(plc).execute(w);
+                pools.poolForPolicy(plc).execute(w);
             }
             catch (RejectedExecutionException e) {
                 U.error(log, "Failed to execute worker due to execution rejection " +
-                    "(increase upper bound on " + poolName(plc) + " executor service).", e);
+                    "(increase upper bound on executor service) [policy=" + plc + ']', e);
 
                 w.run();
             }
@@ -1005,7 +959,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @return Future.
      */
     public <R> IgniteInternalFuture<R> callLocalSafe(Callable<R> c, boolean sys) {
-        return callLocalSafe(c, sys ? GridClosurePolicy.SYSTEM_POOL : GridClosurePolicy.PUBLIC_POOL);
+        return callLocalSafe(c, sys ? GridIoPolicy.SYSTEM_POOL : GridIoPolicy.PUBLIC_POOL);
     }
 
     /**
@@ -1016,7 +970,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
      * @param plc Policy to choose executor pool.
      * @return Future.
      */
-    public <R> IgniteInternalFuture<R> callLocalSafe(Callable<R> c, GridClosurePolicy plc) {
+    private <R> IgniteInternalFuture<R> callLocalSafe(Callable<R> c, byte plc) {
         try {
             return callLocal(c, plc);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
new file mode 100644
index 0000000..41e805e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/pool/PoolProcessor.java
@@ -0,0 +1,149 @@
+/*
+ * 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.pool;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.GridIoPolicy;
+import org.apache.ignite.internal.processors.GridProcessorAdapter;
+import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
+import org.apache.ignite.plugin.extensions.communication.IoPool;
+
+import java.util.Arrays;
+import java.util.concurrent.Executor;
+
+/**
+ * Processor which abstracts out thread pool management.
+ */
+public class PoolProcessor extends GridProcessorAdapter {
+    /** Map of {@link IoPool}-s injected by Ignite plugins. */
+    private final IoPool[] extPools = new IoPool[128];
+
+    /**
+     * Constructor.
+     *
+     * @param ctx Kernal context.
+     */
+    public PoolProcessor(GridKernalContext ctx) {
+        super(ctx);
+
+        IgnitePluginProcessor plugins = ctx.plugins();
+
+        if (plugins != null) {
+            // Process custom IO messaging pool extensions:
+            final IoPool[] executorExtensions = ctx.plugins().extensions(IoPool.class);
+
+            if (executorExtensions != null) {
+                // Store it into the map and check for duplicates:
+                for (IoPool ex : executorExtensions) {
+                    final byte id = ex.id();
+
+                    // 1. Check the pool id is non-negative:
+                    if (id < 0)
+                        throw new IgniteException("Failed to register IO executor pool because its ID is " +
+                            "negative: " + id);
+
+                    // 2. Check the pool id is in allowed range:
+                    if (GridIoPolicy.isReservedGridIoPolicy(id))
+                        throw new IgniteException("Failed to register IO executor pool because its ID in in the " +
+                            "reserved range: " + id);
+
+                    // 3. Check the pool for duplicates:
+                    if (extPools[id] != null)
+                        throw new IgniteException("Failed to register IO executor pool because its ID as " +
+                            "already used: " + id);
+
+                    extPools[id] = ex;
+                }
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop(boolean cancel) throws IgniteCheckedException {
+        // Avoid external thread pools GC retention.
+        Arrays.fill(extPools, null);
+    }
+
+    /**
+     * @return P2P pool.
+     */
+    public Executor p2pPool() {
+        return ctx.getPeerClassLoadingExecutorService();
+    }
+
+    /**
+     * Get executor service for policy.
+     *
+     * @param plc Policy.
+     * @return Executor service.
+     * @throws IgniteCheckedException If failed.
+     */
+    public Executor poolForPolicy(byte plc) throws IgniteCheckedException {
+        switch (plc) {
+            case GridIoPolicy.P2P_POOL:
+                return ctx.getPeerClassLoadingExecutorService();
+            case GridIoPolicy.SYSTEM_POOL:
+                return ctx.getSystemExecutorService();
+            case GridIoPolicy.PUBLIC_POOL:
+                return ctx.getExecutorService();
+            case GridIoPolicy.MANAGEMENT_POOL:
+                return ctx.getManagementExecutorService();
+            case GridIoPolicy.AFFINITY_POOL:
+                return ctx.getAffinityExecutorService();
+
+            case GridIoPolicy.UTILITY_CACHE_POOL:
+                assert ctx.utilityCachePool() != null : "Utility cache pool is not configured.";
+
+                return ctx.utilityCachePool();
+
+            case GridIoPolicy.MARSH_CACHE_POOL:
+                assert ctx.marshallerCachePool() != null : "Marshaller cache pool is not configured.";
+
+                return ctx.marshallerCachePool();
+
+            case GridIoPolicy.IGFS_POOL:
+                assert ctx.getIgfsExecutorService() != null : "IGFS pool is not configured.";
+
+                return ctx.getIgfsExecutorService();
+
+            default: {
+                if (plc < 0)
+                    throw new IgniteCheckedException("Policy cannot be negative: " + plc);
+
+                if (GridIoPolicy.isReservedGridIoPolicy(plc))
+                    throw new IgniteCheckedException("Policy is reserved for internal usage (range 0-31): " + plc);
+
+                IoPool pool = extPools[plc];
+
+                if (pool == null)
+                    throw new IgniteCheckedException("No pool is registered for policy: " + plc);
+
+                assert plc == pool.id();
+
+                Executor res = pool.executor();
+
+                if (res == null)
+                    throw new IgniteCheckedException("Thread pool for policy is null: " + plc);
+
+                return res;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 57762c7..2d8d245 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -948,7 +948,6 @@ org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl
 org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$UserKeyCacheObjectImpl
 org.apache.ignite.internal.processors.clock.GridClockDeltaSnapshotMessage
 org.apache.ignite.internal.processors.clock.GridClockDeltaVersion
-org.apache.ignite.internal.processors.closure.GridClosurePolicy
 org.apache.ignite.internal.processors.closure.GridClosureProcessor$C1
 org.apache.ignite.internal.processors.closure.GridClosureProcessor$C1MLA
 org.apache.ignite.internal.processors.closure.GridClosureProcessor$C1MLAV2

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java
index 04eb8ef..328b775 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
 import org.apache.ignite.internal.managers.failover.GridFailoverManager;
 import org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager;
 import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager;
+import org.apache.ignite.internal.processors.pool.PoolProcessor;
 import org.apache.ignite.internal.processors.resource.GridResourceProcessor;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
 import org.apache.ignite.resources.LoggerResource;
@@ -68,6 +69,7 @@ public class GridManagerStopSelfTest extends GridCommonAbstractTest {
 
         ctx.config().setPeerClassLoadingEnabled(true);
 
+        ctx.add(new PoolProcessor(ctx));
         ctx.add(new GridResourceProcessor(ctx));
 
         ctx.start();

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java
index f44d282..adcd144 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException;
 import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
+import org.apache.ignite.internal.processors.pool.PoolProcessor;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.CX1;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -174,6 +175,7 @@ public class GridFutureAdapterSelfTest extends GridCommonAbstractTest {
         ctx.setExecutorService(Executors.newFixedThreadPool(1));
         ctx.setSystemExecutorService(Executors.newFixedThreadPool(1));
 
+        ctx.add(new PoolProcessor(ctx));
         ctx.add(new GridClosureProcessor(ctx));
 
         ctx.start();
@@ -238,6 +240,7 @@ public class GridFutureAdapterSelfTest extends GridCommonAbstractTest {
         ctx.setExecutorService(Executors.newFixedThreadPool(1));
         ctx.setSystemExecutorService(Executors.newFixedThreadPool(1));
 
+        ctx.add(new PoolProcessor(ctx));
         ctx.add(new GridClosureProcessor(ctx));
 
         ctx.start();

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9a0676f/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
index e4afe73..cba67e0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
@@ -61,6 +61,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
                 null,
                 null,
                 null,
+                null,
                 U.allPluginProviders());
 
         GridTestUtils.setFieldValue(grid(), "cfg", config());