You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/01/18 09:23:47 UTC

[01/29] ignite git commit: Platforms now publish DEVNOTES.txt

Repository: ignite
Updated Branches:
  refs/heads/ignite-2236 0ca561aca -> 7d8e304d9


Platforms now publish DEVNOTES.txt


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

Branch: refs/heads/ignite-2236
Commit: f1f8cda2f3f62231f42a59951bf34c39577c1bec
Parents: f97dc9f
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue Dec 29 13:02:42 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Dec 29 13:02:42 2015 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/f1f8cda2/assembly/release-fabric-base.xml
----------------------------------------------------------------------
diff --git a/assembly/release-fabric-base.xml b/assembly/release-fabric-base.xml
index 5be9f8f..9f9d310 100644
--- a/assembly/release-fabric-base.xml
+++ b/assembly/release-fabric-base.xml
@@ -104,6 +104,7 @@
             <outputDirectory>/platforms/cpp</outputDirectory>
             <includes>
                 <include>README.txt</include>
+                <include>DEVNOTES.txt</include>
             </includes>
         </fileSet>
 


[12/29] ignite git commit: ignite-2359 Added locking for files used by MarshallerContextImpl.

Posted by vo...@apache.org.
ignite-2359 Added locking for files used by MarshallerContextImpl.


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

Branch: refs/heads/ignite-2236
Commit: 1d8c4e259dfe17611289cfac70bf1c3b351073cd
Parents: 59a893c
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 13 08:56:34 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 13 08:59:39 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/MarshallerContextImpl.java  |  86 +++++++--
 ...eMarshallerCacheConcurrentReadWriteTest.java | 189 +++++++++++++++++++
 .../dht/GridCacheTxNodeFailureSelfTest.java     |   6 +-
 .../ignite/testsuites/IgniteBasicTestSuite.java |   2 +
 4 files changed, 264 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1d8c4e25/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 c7fa902..e3f2bc9 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
@@ -19,12 +19,16 @@ package org.apache.ignite.internal;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.channels.FileLock;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.locks.Lock;
 import javax.cache.event.CacheEntryEvent;
 import javax.cache.event.CacheEntryListenerException;
 import javax.cache.event.CacheEntryUpdatedListener;
@@ -33,6 +37,7 @@ import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheTryPutFailedException;
+import org.apache.ignite.internal.util.GridStripedLock;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.plugin.PluginProvider;
@@ -42,6 +47,9 @@ import org.apache.ignite.plugin.PluginProvider;
  */
 public class MarshallerContextImpl extends MarshallerContextAdapter {
     /** */
+    private static final GridStripedLock fileLock = new GridStripedLock(32);
+
+    /** */
     private final CountDownLatch latch = new CountDownLatch(1);
 
     /** */
@@ -72,7 +80,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
      */
     public void onMarshallerCacheStarted(GridKernalContext ctx) throws IgniteCheckedException {
         ctx.cache().marshallerCache().context().continuousQueries().executeInternalQuery(
-            new ContinuousQueryListener(log, workDir),
+            new ContinuousQueryListener(ctx.log(MarshallerContextImpl.class), workDir),
             null,
             ctx.cache().marshallerCache().context().affinityNode(),
             true
@@ -149,14 +157,31 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
         String clsName = cache0.getTopologySafe(id);
 
         if (clsName == null) {
-            File file = new File(workDir, id + ".classname");
+            String fileName = id + ".classname";
+
+            Lock lock = fileLock(fileName);
+
+            lock.lock();
+
+            try {
+                File file = new File(workDir, fileName);
 
-            try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
-                clsName = reader.readLine();
+                try (FileInputStream in = new FileInputStream(file)) {
+                    FileLock fileLock = in.getChannel().lock(0L, Long.MAX_VALUE, true);
+
+                    assert fileLock != null : fileName;
+
+                    try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
+                        clsName = reader.readLine();
+                    }
+                }
+                catch (IOException e) {
+                    throw new IgniteCheckedException("Failed to read class name from file [id=" + id +
+                        ", file=" + file.getAbsolutePath() + ']', e);
+                }
             }
-            catch (IOException e) {
-                throw new IgniteCheckedException("Failed to read class name from file [id=" + id +
-                    ", file=" + file.getAbsolutePath() + ']', e);
+            finally {
+                lock.unlock();
             }
 
             // Must explicitly put entry to cache to invoke other continuous queries.
@@ -167,6 +192,14 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     }
 
     /**
+     * @param fileName File name.
+     * @return Lock instance.
+     */
+    private static Lock fileLock(String fileName) {
+        return fileLock.getLock(fileName.hashCode());
+    }
+
+    /**
      */
     private static class ContinuousQueryListener implements CacheEntryUpdatedListener<Integer, String> {
         /** */
@@ -185,23 +218,40 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
         }
 
         /** {@inheritDoc} */
-        @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> events)
+        @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> evts)
             throws CacheEntryListenerException {
-            for (CacheEntryEvent<? extends Integer, ? extends String> evt : events) {
+            for (CacheEntryEvent<? extends Integer, ? extends String> evt : evts) {
                 assert evt.getOldValue() == null || F.eq(evt.getOldValue(), evt.getValue()):
                     "Received cache entry update for system marshaller cache: " + evt;
 
                 if (evt.getOldValue() == null) {
-                    File file = new File(workDir, evt.getKey() + ".classname");
+                    String fileName = evt.getKey() + ".classname";
+
+                    Lock lock = fileLock(fileName);
+
+                    lock.lock();
+
+                    try {
+                        File file = new File(workDir, fileName);
+
+                        try (FileOutputStream out = new FileOutputStream(file)) {
+                            FileLock fileLock = out.getChannel().lock(0L, Long.MAX_VALUE, false);
+
+                            assert fileLock != null : fileName;
 
-                    try (Writer writer = new FileWriter(file)) {
-                        writer.write(evt.getValue());
+                            try (Writer writer = new OutputStreamWriter(out)) {
+                                writer.write(evt.getValue());
 
-                        writer.flush();
+                                writer.flush();
+                            }
+                        }
+                        catch (IOException e) {
+                            U.error(log, "Failed to write class name to file [id=" + evt.getKey() +
+                                ", clsName=" + evt.getValue() + ", file=" + file.getAbsolutePath() + ']', e);
+                        }
                     }
-                    catch (IOException e) {
-                        U.error(log, "Failed to write class name to file [id=" + evt.getKey() +
-                            ", clsName=" + evt.getValue() + ", file=" + file.getAbsolutePath() + ']', e);
+                    finally {
+                        lock.unlock();
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d8c4e25/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheConcurrentReadWriteTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheConcurrentReadWriteTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheConcurrentReadWriteTest.java
new file mode 100644
index 0000000..ad6f604
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheConcurrentReadWriteTest.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+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 static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteMarshallerCacheConcurrentReadWriteTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setCacheMode(REPLICATED);
+        ccfg.setRebalanceMode(SYNC);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        super.afterTest();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConcurrentReadWrite() throws Exception {
+        Ignite ignite = startGrid(0);
+
+        Map<Integer, Object> data = new HashMap<>();
+
+        final Map<Integer, byte[]> dataBytes = new HashMap<>();
+
+        for (int i = 0; i < 10; i++) {
+            Object obj = null;
+
+            switch (i % 10) {
+                case 0: obj = new TestClass1(); break;
+                case 1: obj = new TestClass2(); break;
+                case 2: obj = new TestClass3(); break;
+                case 3: obj = new TestClass4(); break;
+                case 4: obj = new TestClass5(); break;
+                case 5: obj = new TestClass6(); break;
+                case 6: obj = new TestClass7(); break;
+                case 7: obj = new TestClass8(); break;
+                case 8: obj = new TestClass9(); break;
+                case 9: obj = new TestClass10(); break;
+                default: fail();
+            }
+
+            data.put(i, obj);
+
+            dataBytes.put(i, ignite.configuration().getMarshaller().marshal(obj));
+        }
+
+        ignite.cache(null).putAll(data);
+
+        stopGrid(0);
+
+        for (int i = 0; i < 3; i++) {
+            log.info("Iteration: " + i);
+
+            final AtomicInteger idx = new AtomicInteger();
+
+            GridTestUtils.runMultiThreaded(new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    int node = idx.getAndIncrement();
+
+                    Ignite ignite = startGrid(node);
+
+                    IgniteCache<Object, Object> cache = ignite.cache(null);
+
+                    for (Map.Entry<Integer, byte[]> e : dataBytes.entrySet()) {
+                        Object obj = ignite.configuration().getMarshaller().unmarshal(e.getValue(), null);
+
+                        cache.put(e.getKey(), obj);
+                    }
+
+                    ignite.cache(null).getAll(dataBytes.keySet());
+
+                    return null;
+                }
+            }, 10, "test-thread");
+
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    static class TestClass1 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass2 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass3 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass4 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass5 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass6 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass7 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass8 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass9 implements Serializable { }
+
+    /**
+     *
+     */
+    static class TestClass10 implements Serializable { }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d8c4e25/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
index 78e7672..84838db 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -78,7 +78,11 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
 
         cfg.setCacheConfiguration(cacheConfiguration(gridName));
 
-        cfg.setCommunicationSpi(new BanningCommunicationSpi());
+        BanningCommunicationSpi commSpi = new BanningCommunicationSpi();
+
+        commSpi.setSharedMemoryPort(-1);
+
+        cfg.setCommunicationSpi(commSpi);
 
         return cfg;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d8c4e25/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 7ee301c..bcd1ede 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest;
 import org.apache.ignite.internal.processors.affinity.GridAffinityProcessorRendezvousSelfTest;
 import org.apache.ignite.internal.processors.cache.GridProjectionForCachesOnDaemonNodeSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteDaemonNodeMarshallerCacheTest;
+import org.apache.ignite.internal.processors.cache.IgniteMarshallerCacheConcurrentReadWriteTest;
 import org.apache.ignite.internal.processors.cache.OffHeapTieredTransactionSelfTest;
 import org.apache.ignite.internal.processors.closure.GridClosureProcessorSelfTest;
 import org.apache.ignite.internal.processors.continuous.GridEventConsumeSelfTest;
@@ -111,6 +112,7 @@ public class IgniteBasicTestSuite extends TestSuite {
         suite.addTestSuite(OffHeapTieredTransactionSelfTest.class);
         suite.addTestSuite(IgniteSlowClientDetectionSelfTest.class);
         suite.addTestSuite(IgniteDaemonNodeMarshallerCacheTest.class);
+        suite.addTestSuite(IgniteMarshallerCacheConcurrentReadWriteTest.class);
 
         suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
 


[23/29] ignite git commit: IGNITE-2032 Unwind undeploys in preloader - Fixes #369.

Posted by vo...@apache.org.
IGNITE-2032 Unwind undeploys in preloader - Fixes #369.

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


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

Branch: refs/heads/ignite-2236
Commit: 2af1d9bcb6c89fc94c54c2b6c02a922241a6896e
Parents: d608ebd
Author: vershov <ve...@gridgain.com>
Authored: Thu Jan 14 17:21:56 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jan 15 10:27:05 2016 +0300

----------------------------------------------------------------------
 .../dht/preloader/GridDhtPartitionsExchangeFuture.java       | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2af1d9bc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index a10294f..22fb59e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -569,6 +569,9 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
                             }
                             else
                                 cacheCtx.affinity().clientEventTopologyChange(discoEvt, exchId.topologyVersion());
+
+                            if (!exchId.isJoined())
+                                cacheCtx.preloader().unwindUndeploys();
                         }
 
                         if (exchId.isLeft())
@@ -845,8 +848,9 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
                     // Partition release future is done so we can flush the write-behind store.
                     cacheCtx.store().forceFlush();
 
-                    // Process queued undeploys prior to sending/spreading map.
-                    cacheCtx.preloader().unwindUndeploys();
+                    if (!exchId.isJoined())
+                        // Process queued undeploys prior to sending/spreading map.
+                        cacheCtx.preloader().unwindUndeploys();
 
                     GridDhtPartitionTopology top = cacheCtx.topology();
 


[20/29] ignite git commit: Merge remote-tracking branch 'origin/master'

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


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

Branch: refs/heads/ignite-2236
Commit: b409b8dee64d297fe03869533182109c8e40c7a4
Parents: 59cfbfd 2d10630
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Jan 14 12:55:10 2016 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Jan 14 12:55:10 2016 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteTransactions.java   |   4 +-
 .../apache/ignite/internal/GridComponent.java   |   5 +-
 .../ignite/internal/GridUpdateNotifier.java     | 454 ------------------
 .../apache/ignite/internal/IgniteKernal.java    | 221 ++++-----
 .../ignite/internal/IgniteVersionUtils.java     |   4 +-
 .../ignite/internal/MarshallerContextImpl.java  |  86 +++-
 .../discovery/GridDiscoveryManager.java         |   6 +-
 .../cache/CacheEntrySerializablePredicate.java  |   3 +-
 .../cache/CacheInvokeDirectResult.java          |   4 +-
 .../processors/cache/GridCacheIoManager.java    |  23 +
 .../processors/cache/GridCacheProcessor.java    |  52 ++-
 .../processors/cache/GridCacheReturn.java       |   2 +
 .../processors/cache/IgniteCacheProxy.java      |   2 +-
 .../GridDistributedLockResponse.java            |   2 +-
 .../GridDistributedTxFinishRequest.java         |  11 +-
 .../GridDistributedTxPrepareRequest.java        |   2 +-
 .../GridDistributedTxPrepareResponse.java       |   4 +-
 .../dht/GridDhtAffinityAssignmentResponse.java  |   4 +-
 .../distributed/dht/GridDhtLockFuture.java      |  44 +-
 .../distributed/dht/GridDhtLockRequest.java     |   2 +-
 .../distributed/dht/GridDhtTxFinishRequest.java |  90 ++--
 .../dht/GridDhtTxFinishResponse.java            |   4 +-
 .../cache/distributed/dht/GridDhtTxLocal.java   |   1 +
 .../dht/GridDhtTxPrepareRequest.java            |   2 +-
 .../dht/atomic/GridDhtAtomicUpdateRequest.java  |  21 +-
 .../dht/atomic/GridDhtAtomicUpdateResponse.java |   6 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java |  22 +-
 .../atomic/GridNearAtomicUpdateResponse.java    |   4 +-
 .../dht/preloader/GridDhtForceKeysResponse.java |   6 +-
 .../GridDhtPartitionDemandMessage.java          |   6 +-
 .../GridDhtPartitionSupplyMessageV2.java        |   6 +-
 .../preloader/GridDhtPartitionsFullMessage.java |   2 +-
 .../GridDhtPartitionsSingleMessage.java         |   4 +-
 .../distributed/near/GridNearGetResponse.java   |   4 +-
 ...ridNearOptimisticTxPrepareFutureAdapter.java |   6 +-
 .../near/GridNearSingleGetResponse.java         |   2 +-
 .../near/GridNearTxFinishFuture.java            | 432 +++++++++++++-----
 .../near/GridNearTxFinishRequest.java           |   5 +
 .../near/GridNearTxFinishResponse.java          |   4 +-
 .../cache/distributed/near/GridNearTxLocal.java |   2 +-
 .../near/GridNearTxPrepareResponse.java         |   4 +-
 .../cache/query/GridCacheQueryRequest.java      |  16 +-
 .../cache/query/GridCacheQueryResponse.java     |  18 +-
 .../cache/transactions/IgniteInternalTx.java    |   6 +
 .../cache/transactions/IgniteTxAdapter.java     |  23 +-
 .../cache/transactions/IgniteTxEntry.java       |  11 +-
 .../cache/transactions/IgniteTxHandler.java     |  26 +-
 .../transactions/IgniteTxLocalAdapter.java      |   6 +-
 .../cache/transactions/IgniteTxManager.java     |  20 +
 .../processors/cluster/ClusterProcessor.java    | 174 +++++++
 .../processors/cluster/GridUpdateNotifier.java  | 457 +++++++++++++++++++
 .../datastreamer/DataStreamerRequest.java       |   1 +
 .../datastructures/DataStructuresProcessor.java |  11 +-
 .../processors/igfs/IgfsAckMessage.java         |   4 +-
 .../handlers/cache/GridCacheCommandHandler.java |   6 +-
 .../ignite/spi/discovery/DiscoverySpi.java      |   2 +
 .../ignite/stream/socket/SocketStreamer.java    |   3 +-
 .../internal/GridUpdateNotifierSelfTest.java    | 137 ------
 ...UpdateNotifierPerClusterSettingSelfTest.java | 130 ++++++
 ...cheAbstractFullApiMultithreadedSelfTest.java |  13 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java |   2 +-
 .../processors/cache/GridCacheStopSelfTest.java |   2 +-
 .../cache/IgniteDynamicCacheStartSelfTest.java  |  30 +-
 ...eMarshallerCacheConcurrentReadWriteTest.java | 189 ++++++++
 .../IgniteClientDataStructuresAbstractTest.java |   3 +
 .../dht/GridCacheTxNodeFailureSelfTest.java     |  13 +-
 .../IgniteCacheCommitDelayTxRecoveryTest.java   | 376 +++++++++++++++
 .../IgniteCachePutRetryAbstractSelfTest.java    |  36 +-
 ...gniteCachePutRetryTransactionalSelfTest.java |  21 +
 .../cluster/GridUpdateNotifierSelfTest.java     | 140 ++++++
 .../continuous/GridEventConsumeSelfTest.java    |   3 +
 .../internal/util/nio/GridNioSelfTest.java      |  11 +-
 ...dTcpCommunicationSpiRecoveryAckSelfTest.java |   1 -
 ...CommunicationRecoveryAckClosureSelfTest.java |  19 +-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java |   2 +
 .../startup/GridRandomCommandLineLoader.java    |   4 +-
 .../junits/common/GridCommonAbstractTest.java   |  34 +-
 .../ignite/testsuites/IgniteBasicTestSuite.java |   2 +
 .../IgniteCacheTxRecoverySelfTestSuite.java     |   3 +
 .../testsuites/IgniteKernalSelfTestSuite.java   |   4 +-
 .../tcp/ipfinder/zk/ZookeeperIpFinderTest.java  |  69 ++-
 81 files changed, 2502 insertions(+), 1094 deletions(-)
----------------------------------------------------------------------



[04/29] ignite git commit: Revert "IGNITE-2330: Simplified GridFunc."

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 015be5c..0678657 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -35,10 +35,16 @@ import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentMap;
+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 org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
+import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.GridEmptyIterator;
@@ -46,6 +52,7 @@ import org.apache.ignite.internal.util.GridLeanMap;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.GridSerializableCollection;
 import org.apache.ignite.internal.util.GridSerializableIterator;
+import org.apache.ignite.internal.util.GridSerializableList;
 import org.apache.ignite.internal.util.GridSerializableMap;
 import org.apache.ignite.internal.util.GridSerializableSet;
 import org.apache.ignite.internal.util.typedef.C1;
@@ -61,6 +68,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteReducer;
 import org.jetbrains.annotations.NotNull;
@@ -144,6 +152,13 @@ public class GridFunc {
     };
 
     /** */
+    public static final IgnitePredicate<Object> IS_NULL = new P1<Object>() {
+        @Override public boolean apply(Object o) {
+            return o == null;
+        }
+    };
+
+    /** */
     public static final IgnitePredicate<Object> IS_NOT_NULL = new P1<Object>() {
         @Override public boolean apply(Object o) {
             return o != null;
@@ -151,6 +166,28 @@ public class GridFunc {
     };
 
     /** */
+    private static final IgniteCallable<?> LIST_FACTORY = new IgniteCallable<List>() {
+        @Override public List call() {
+            return new ArrayList();
+        }
+
+        @Override public String toString() {
+            return "Array list factory.";
+        }
+    };
+
+    /** */
+    private static final IgniteCallable<?> LINKED_LIST_FACTORY = new IgniteCallable<LinkedList>() {
+        @Override public LinkedList call() {
+            return new LinkedList();
+        }
+
+        @Override public String toString() {
+            return "Linked list factory.";
+        }
+    };
+
+    /** */
     private static final IgniteCallable<?> SET_FACTORY = new IgniteCallable<Set>() {
         @Override public Set call() {
             return new HashSet();
@@ -162,6 +199,61 @@ public class GridFunc {
     };
 
     /** */
+    private static final IgniteCallable<AtomicInteger> ATOMIC_INT_FACTORY = new IgniteCallable<AtomicInteger>() {
+        @Override public AtomicInteger call() {
+            return new AtomicInteger(0);
+        }
+
+        @Override public String toString() {
+            return "Atomic integer factory.";
+        }
+    };
+
+    /** */
+    private static final IgniteCallable<AtomicLong> ATOMIC_LONG_FACTORY = new IgniteCallable<AtomicLong>() {
+        @Override public AtomicLong call() {
+            return new AtomicLong(0);
+        }
+
+        @Override public String toString() {
+            return "Atomic long factory.";
+        }
+    };
+
+    /** */
+    private static final IgniteCallable<AtomicBoolean> ATOMIC_BOOL_FACTORY = new IgniteCallable<AtomicBoolean>() {
+        @Override public AtomicBoolean call() {
+            return new AtomicBoolean();
+        }
+
+        @Override public String toString() {
+            return "Atomic boolean factory.";
+        }
+    };
+
+    /** */
+    private static final IgniteCallable<?> ATOMIC_REF_FACTORY = new IgniteCallable<AtomicReference>() {
+        @Override public AtomicReference call() {
+            return new AtomicReference();
+        }
+
+        @Override public String toString() {
+            return "Atomic reference factory.";
+        }
+    };
+
+    /** */
+    private static final IgniteCallable<?> MAP_FACTORY = new IgniteCallable<Map>() {
+        @Override public Map call() {
+            return new HashMap();
+        }
+
+        @Override public String toString() {
+            return "Hash map factory.";
+        }
+    };
+
+    /** */
     private static final IgniteCallable<?> CONCURRENT_MAP_FACTORY = new IgniteCallable<ConcurrentMap>() {
         @Override public ConcurrentMap call() {
             return new ConcurrentHashMap8();
@@ -184,6 +276,42 @@ public class GridFunc {
     };
 
     /** */
+    private static final IgniteClosure CACHE_ENTRY_KEY = new IgniteClosure() {
+        @Override public Object apply(Object o) {
+            return ((Cache.Entry)o).getKey();
+        }
+
+        @Override public String toString() {
+            return "Map entry to key transformer closure.";
+        }
+    };
+
+
+    /** */
+    private static final IgniteClosure CACHE_ENTRY_VAL_GET = new IgniteClosure() {
+        @SuppressWarnings({"unchecked"})
+        @Nullable @Override public Object apply(Object o) {
+            return ((Cache.Entry)o).getValue();
+        }
+
+        @Override public String toString() {
+            return "Cache entry to get-value transformer closure.";
+        }
+    };
+
+    /** */
+    private static final IgnitePredicate CACHE_ENTRY_HAS_PEEK_VAL = new IgnitePredicate() {
+        @SuppressWarnings({"unchecked"})
+        @Override public boolean apply(Object o) {
+            return ((Cache.Entry)o).getValue() != null;
+        }
+
+        @Override public String toString() {
+            return "Cache entry has-peek-value predicate.";
+        }
+    };
+
+    /** */
     private static final IgniteClosure<ClusterNode, UUID> NODE2ID = new IgniteClosure<ClusterNode, UUID>() {
         @Override public UUID apply(ClusterNode n) {
             return n.id();
@@ -216,8 +344,12 @@ public class GridFunc {
         }
     };
 
-    /** Empty iterator. */
-    private static final GridEmptyIterator EMPTY_ITER = new GridEmptyIterator();
+    /** */
+    private static final IgnitePredicate<IgniteInternalFuture<?>> UNFINISHED_FUTURE = new IgnitePredicate<IgniteInternalFuture<?>>() {
+        @Override public boolean apply(IgniteInternalFuture<?> f) {
+            return !f.isDone();
+        }
+    };
 
     /**
      * Gets predicate that evaluates to {@code true} only for given local node ID.
@@ -250,6 +382,23 @@ public class GridFunc {
     }
 
     /**
+     * Creates new collection by removing duplicates from the given collection.
+     *
+     * @param c Collection to remove duplicates from.
+     * @param <T> Type of the collection.
+     * @return De-duped collection.
+     */
+    public static <T> Collection<T> dedup(Collection<? extends T> c) {
+        A.notNull(c, "c");
+
+        Collection<T> set = new GridLeanSet<>();
+
+        set.addAll(c);
+
+        return set;
+    }
+
+    /**
      * Calculates sum of all elements.
      * <p>
      * <img src="{@docRoot}/img/sum.png">
@@ -429,6 +578,8 @@ public class GridFunc {
         if (isEmpty(res))
             return Collections.emptyList();
 
+        assert res != null;
+
         Collection<T> c = new ArrayList<>(res.size());
 
         for (ComputeJobResult r : res)
@@ -542,6 +693,20 @@ public class GridFunc {
     }
 
     /**
+     * Gets random value from given array. This operation
+     * does not iterate through array elements and returns immediately.
+     *
+     * @param c Input collection.
+     * @param <T> Type of the collection.
+     * @return Random value from the input collection.
+     */
+    public static <T> T rand(T... c) {
+        A.notNull(c, "c");
+
+        return c[ThreadLocalRandom8.current().nextInt(c.length)];
+    }
+
+    /**
      * Concatenates an element to a collection. If {@code copy} flag is {@code true}, then
      * a new collection will be created and the element and passed in collection will be
      * copied into the new one. The returned collection will be modifiable. If {@code copy}
@@ -564,6 +729,8 @@ public class GridFunc {
                 return l;
             }
 
+            assert c != null;
+
             Collection<T> ret = new ArrayList<>(c.size() + 1);
 
             ret.add(t);
@@ -575,6 +742,8 @@ public class GridFunc {
             if (isEmpty(c))
                 return Collections.singletonList(t);
 
+            assert c != null;
+
             return new GridSerializableCollection<T>() {
                 @NotNull
                 @Override public Iterator<T> iterator() {
@@ -631,11 +800,8 @@ public class GridFunc {
             if (isEmpty(c1) && isEmpty(c2))
                 return new ArrayList<>(0);
 
-            if (isEmpty(c1)) {
-                assert c2 != null;
-
+            if (isEmpty(c1))
                 return new ArrayList<>(c2);
-            }
 
             if (isEmpty(c2))
                 return new ArrayList<>(c1);
@@ -708,7 +874,7 @@ public class GridFunc {
      * @param obj One or more elements.
      * @return Concatenated array.
      */
-    public static <T> T[] concat(@Nullable T[] arr, T[] obj) {
+    public static <T> T[] concat(@Nullable T[] arr, T... obj) {
         T[] newArr;
 
         if (arr == null || arr.length == 0)
@@ -723,15 +889,17 @@ public class GridFunc {
     }
 
     /**
-     * Concatenate two iterators.
+     * Concatenates multiple iterators as single one.
      *
-     * @param iter1 Iterator 1.
-     * @param iter2 Iterator 2.
+     * @param iters Iterators.
      * @return Single iterator.
      */
     @SuppressWarnings("unchecked")
-    public static <T> Iterator<T> concat(Iterator<T> iter1, Iterator<T> iter2) {
-        return concat(asList(iter1, iter2).iterator());
+    public static <T> Iterator<T> concat(Iterator<T> ... iters) {
+        if (iters.length == 1)
+            return iters[0];
+
+        return concat(asList(iters).iterator());
     }
 
     /**
@@ -812,10 +980,11 @@ public class GridFunc {
      * @param <T> Type of collections.
      * @return Collection of remaining elements
      */
-    public static <T0, T extends T0> Collection<T> lose(Collection<T> c, boolean cp, @Nullable Collection<T0> filter) {
+    public static <T0, T extends T0> Collection<T> lose(Collection<T> c, boolean cp,
+        @Nullable Collection<T0> filter) {
         A.notNull(c, "c");
 
-        return lose(c, cp, in(filter));
+        return lose(c, cp, F0.in(filter));
     }
 
     /**
@@ -825,11 +994,11 @@ public class GridFunc {
      * @param c Input collection.
      * @param cp If {@code true} method creates new collection without modifying the input one,
      *      otherwise does <tt>in-place</tt> modifications.
-     * @param p Predicate.
+     * @param p Predicates to filter by. If no predicates provided - no elements are lost.
      * @param <T> Type of collections.
      * @return Collection of remaining elements.
      */
-    public static <T> Collection<T> lose(Collection<T> c, boolean cp, IgnitePredicate<? super T> p) {
+    public static <T> Collection<T> lose(Collection<T> c, boolean cp, @Nullable IgnitePredicate<? super T>... p) {
         A.notNull(c, "c");
 
         Collection<T> res;
@@ -837,18 +1006,19 @@ public class GridFunc {
         if (!cp) {
             res = c;
 
-            if (!isAlwaysFalse(p)) {
-                for (Iterator<T> iter = res.iterator(); iter.hasNext(); )
-                    if (p.apply(iter.next()))
+            if (isEmpty(p))
+                res.clear();
+            else if (!isAlwaysFalse(p))
+                for (Iterator<T> iter = res.iterator(); iter.hasNext();)
+                    if (isAll(iter.next(), p))
                         iter.remove();
-            }
         }
         else {
             res = new LinkedList<>();
 
-            if (!isAlwaysTrue(p))
+            if (!isEmpty(p) && !isAlwaysTrue(p))
                 for (T t : c)
-                    if (!p.apply(t))
+                    if (!isAll(t, p))
                         res.add(t);
         }
 
@@ -856,6 +1026,162 @@ public class GridFunc {
     }
 
     /**
+     * Loses all entries in input map that are evaluated to {@code true} by all given predicates.
+     *
+     * @param m Map to filter.
+     * @param cp If {@code true} method creates new map not modifying input, otherwise does
+     *      <tt>in-place</tt> modifications.
+     * @param p Optional set of predicates to use for filtration. If none provided - original map
+     *  will (or its copy) be returned.
+     * @param <K> Type of the free variable for the predicate and type of map's keys.
+     * @param <V> Type of the free variable for the predicate and type of map's values.
+     * @return Filtered map.
+     */
+    @SuppressWarnings({"unchecked"})
+    public static <K, V> Map<K, V> lose(Map<K, V> m, boolean cp,
+        @Nullable IgnitePredicate<? super Map.Entry<K, V>>... p) {
+        A.notNull(m, "m");
+
+        Map<K, V> res;
+
+        if (!cp) {
+            res = m;
+
+            if (isEmpty(p))
+                res.clear();
+            else if (!isAlwaysFalse(p))
+                for (Iterator<Map.Entry<K, V>> iter = m.entrySet().iterator(); iter.hasNext();)
+                    if (isAll(iter.next(), p))
+                        iter.remove();
+        }
+        else {
+            res = U.newHashMap(m.size());
+
+            if (!isEmpty(p) && !isAlwaysTrue(p))
+                for (Map.Entry<K, V> e : m.entrySet())
+                    if (!F.isAll(e, p))
+                        res.put(e.getKey(), e.getValue());
+        }
+
+        return res;
+    }
+
+    /**
+     * Loses all entries in input map which keys are evaluated to {@code true} by all
+     * given predicates.
+     *
+     * @param m Map to filter.
+     * @param cp If {@code true} method creates new map not modifying input, otherwise does
+     *      <tt>in-place</tt> modifications.
+     * @param p Optional set of predicates to use for filtration. If none provided - original
+     *      map (or its copy) will be returned.
+     * @param <K> Type of the free variable for the predicate and type of map's keys.
+     * @param <V> Type of map's values.
+     * @return Filtered map.
+     */
+    public static <K, V> Map<K, V> loseKeys(
+        Map<K, V> m,
+        boolean cp,
+        @Nullable final IgnitePredicate<? super K>... p
+    ) {
+        return lose(m, cp, new P1<Map.Entry<K, V>>() {
+            @Override public boolean apply(Map.Entry<K, V> e) {
+                return isAll(e.getKey(), p);
+            }
+        });
+    }
+
+    /**
+     * Loses all entries in input map which values are evaluated to {@code true} by all
+     * given predicates.
+     *
+     * @param m Map to filter.
+     * @param cp If {@code true} method creates new map not modifying input, otherwise does
+     *      <tt>in-place</tt> modifications.
+     * @param p Optional set of predicates to use for filtration. If none provided - original
+     *      map (or its copy) will be returned.
+     * @param <K> Type of the free variable for the predicate and type of map's keys.
+     * @param <V> Type of map's values.
+     * @return Filtered map.
+     */
+    public static <K, V> Map<K, V> loseValues(Map<K, V> m, boolean cp,
+        @Nullable final IgnitePredicate<? super V>... p) {
+        return lose(m, cp, new P1<Map.Entry<K, V>>() {
+            @Override public boolean apply(Map.Entry<K, V> e) {
+                return isAll(e.getValue(), p);
+            }
+        });
+    }
+
+    /**
+     * Loses all elements in input list that are contained in {@code filter} collection.
+     *
+     * @param c Input list.
+     * @param cp If {@code true} method creates new list not modifying input,
+     *      otherwise does <tt>in-place</tt> modifications.
+     * @param filter Filter collection. If {@code filter} collection is empty or
+     *      {@code null} - no elements are lost.
+     * @param <T> Type of list.
+     * @return List of remaining elements
+     */
+    public static <T> List<T> loseList(List<T> c, boolean cp, @Nullable Collection<? super T> filter) {
+        A.notNull(c, "c");
+
+        List<T> res;
+
+        if (!cp) {
+            res = c;
+
+            if (filter != null)
+                res.removeAll(filter);
+        }
+        else {
+            res = new LinkedList<>();
+
+            for (T t : c) {
+                if (filter == null || !filter.contains(t))
+                    res.add(t);
+            }
+        }
+
+        return res;
+    }
+
+    /**
+     * Loses all elements in input list for which any of the predicates evaluate to {@code true}.
+     *
+     * @param c Input list.
+     * @param cp If {@code true} method creates new list not modifying input,
+     *      otherwise does <tt>in-place</tt> modifications.
+     * @param p Looses all elements for which any of the predicates evaluate to {@code true}.
+     * @param <T> Type of list.
+     * @return List of remaining elements
+     */
+    public static <T> List<T> filterList(List<T> c, boolean cp, @Nullable IgnitePredicate<T>... p) {
+        A.notNull(c, "c");
+
+        List<T> res;
+
+        if (!cp) {
+            res = c;
+
+            if (p != null)
+                for (Iterator<T> it = c.iterator(); it.hasNext();)
+                    if (isAny(it.next(), p))
+                        it.remove();
+        }
+        else {
+            res = new ArrayList<>(c.size());
+
+            for (T t : c)
+                if (!isAny(t, p))
+                    res.add(t);
+        }
+
+        return res;
+    }
+
+    /**
      * Gets closure which converts node to node ID.
      *
      * @return Closure which converts node to node ID.
@@ -927,40 +1253,34 @@ public class GridFunc {
     }
 
     /**
-     * Retains all elements in input collection that are contained in {@code filter}.
+     * Creates predicates that evaluates to {@code true} for each node in given collection.
+     * Note that if collection is empty the result predicate will always evaluate to {@code false}.
+     * Implementation simply creates {@link GridNodePredicate} instance.
      *
-     * @param c Input collection.
-     * @param cp If {@code true} method creates collection not modifying input, otherwise does
-     *      <tt>in-place</tt> modifications.
-     * @param filter Filter collection. If filter collection is {@code null} or empty -
-     *      an empty collection will be returned.
-     * @param <T> Type of collections.
-     * @return Collection of retain elements.
+     * @param nodes Collection of nodes. If none provided - result predicate will always
+     *      return {@code false}.
+     * @return Predicates that evaluates to {@code true} for each node in given collection.
      */
-    public static <T0, T extends T0> Collection<T> retain(Collection<T> c, boolean cp,
-        @Nullable Collection<? extends T0> filter) {
-        A.notNull(c, "c");
-
-        return retain(c, cp, in(filter));
+    public static IgnitePredicate<ClusterNode> nodeForNodes(ClusterNode... nodes) {
+        return new GridNodePredicate(nodes);
     }
 
     /**
-     * Retains all elements in input collection that are evaluated to {@code true}
-     * by the given predicate.
+     * Retains all elements in input collection that are contained in {@code filter}.
      *
      * @param c Input collection.
      * @param cp If {@code true} method creates collection not modifying input, otherwise does
      *      <tt>in-place</tt> modifications.
-     * @param p Predicates to filter by. If no predicates provides - all elements
-     *      will be retained.
+     * @param filter Filter collection. If filter collection is {@code null} or empty -
+     *      an empty collection will be returned.
      * @param <T> Type of collections.
      * @return Collection of retain elements.
      */
-    public static <T> Collection<T> retain(Collection<T> c, boolean cp, IgnitePredicate<? super T> p) {
+    public static <T0, T extends T0> Collection<T> retain(Collection<T> c, boolean cp,
+        @Nullable Collection<? extends T0> filter) {
         A.notNull(c, "c");
-        A.notNull(p, "p");
 
-        return lose(c, cp, not(p));
+        return retain(c, cp, F0.in(filter));
     }
 
     /**
@@ -975,7 +1295,7 @@ public class GridFunc {
      * @param <T> Type of collections.
      * @return Collection of retain elements.
      */
-    public static <T> Collection<T> retain(Collection<T> c, boolean cp, @Nullable IgnitePredicate<? super T>[] p) {
+    public static <T> Collection<T> retain(Collection<T> c, boolean cp, @Nullable IgnitePredicate<? super T>... p) {
         A.notNull(c, "c");
 
         return lose(c, cp, not(p));
@@ -1025,19 +1345,36 @@ public class GridFunc {
     }
 
     /**
-     * Create list containing two elements.
+     * Curries given closure.
      *
-     * @param t1 First element.
-     * @param t2 Second element.
-     * @return List.
+     * @param f Closure.
+     * @param e Parameter.
+     * @param <T> Input type.
+     * @param <R> Output type.
+     * @return Curried closure.
      */
-    public static <T> List<T> asList(T t1, T t2) {
-        ArrayList<T> res = new ArrayList<>(2);
-
-        res.add(t1);
-        res.add(t2);
+    public static <T, R> IgniteOutClosure<R> curry(final IgniteClosure<? super T, R> f, final T e) {
+        return new IgniteOutClosure<R>() {
+            @Override public R apply() {
+                return f.apply(e);
+            }
+        };
+    }
 
-        return res;
+    /**
+     * Curries given closure.
+     *
+     * @param f Closure.
+     * @param e Parameter.
+     * @param <T> Input type.
+     * @return Curried closure.
+     */
+    public static <T> GridAbsClosure curry(final IgniteInClosure<? super T> f, final T e) {
+        return new GridAbsClosure() {
+            @Override public void apply() {
+                f.apply(e);
+            }
+        };
     }
 
     /**
@@ -1053,7 +1390,6 @@ public class GridFunc {
      * @param <T> Array type.
      * @return {@link List} instance for array.
      */
-    @SuppressWarnings("unchecked")
     public static <T> List<T> asList(@Nullable T... vals) {
         return isEmpty(vals) ? Collections.<T>emptyList() : Arrays.asList(vals);
     }
@@ -1064,9 +1400,8 @@ public class GridFunc {
      * @param <T> Type of the iterator.
      * @return Newly created empty iterator.
      */
-    @SuppressWarnings("unchecked")
     public static <T> GridIterator<T> emptyIterator() {
-        return EMPTY_ITER;
+        return new GridEmptyIterator<>();
     }
 
     /**
@@ -1239,29 +1574,6 @@ public class GridFunc {
     }
 
     /**
-     * Gets size of the given collection.
-     *
-     * @param c Collection.
-     * @return Size.
-     */
-    public static <T> int size(@Nullable Collection<? extends T> c) {
-        return c == null || c.isEmpty() ? 0 : c.size();
-    }
-
-    /**
-     * Gets size of the given collection with provided optional predicates.
-     *
-     * @param c Collection to size.
-     * @param p Optional predicates that filters out elements from count.
-     * @param <T> Type of the iterator.
-     * @return Number of elements in the collection for which all given predicates
-     *      evaluates to {@code true}. If no predicates is provided - all elements are counted.
-     */
-    public static <T> int size(@Nullable Collection<? extends T> c, IgnitePredicate<? super T> p) {
-        return c == null || c.isEmpty() ? 0 : isAlwaysTrue(p) ? c.size() : size(c.iterator(), p);
-    }
-
-    /**
      * Gets size of the given collection with provided optional predicates.
      *
      * @param c Collection to size.
@@ -1270,34 +1582,12 @@ public class GridFunc {
      * @return Number of elements in the collection for which all given predicates
      *      evaluates to {@code true}. If no predicates is provided - all elements are counted.
      */
-    public static <T> int size(@Nullable Collection<? extends T> c, @Nullable IgnitePredicate<? super T>[] p) {
+    public static <T> int size(@Nullable Collection<? extends T> c, @Nullable IgnitePredicate<? super T>... p) {
         return c == null || c.isEmpty() ? 0 : isEmpty(p) || isAlwaysTrue(p) ? c.size() : size(c.iterator(), p);
     }
 
     /**
-     * Gets size of the given iterator. Iterator will be traversed to get the count.
-     *
-     * @param it Iterator to size.
-     * @param <T> Type of the iterator.
-     * @return Number of elements in the iterator.
-     */
-    public static <T> int size(@Nullable Iterator<? extends T> it) {
-        if (it == null)
-            return 0;
-
-        int n = 0;
-
-        while (it.hasNext()) {
-            n++;
-
-            it.next();
-        }
-
-        return n;
-    }
-
-    /**
-     * Gets size of the given iterator with provided optional predicate. Iterator
+     * Gets size of the given iterator with provided optional predicates. Iterator
      * will be traversed to get the count.
      *
      * @param it Iterator to size.
@@ -1306,7 +1596,7 @@ public class GridFunc {
      * @return Number of elements in the iterator for which all given predicates
      *      evaluates to {@code true}. If no predicates is provided - all elements are counted.
      */
-    public static <T> int size(@Nullable Iterator<? extends T> it, IgnitePredicate<? super T> p) {
+    public static <T> int size(@Nullable Iterator<? extends T> it, @Nullable IgnitePredicate<? super T>... p) {
         if (it == null)
             return 0;
 
@@ -1314,7 +1604,7 @@ public class GridFunc {
 
         if (!isAlwaysFalse(p)) {
             while (it.hasNext()) {
-                if (p.apply(it.next()))
+                if (isAll(it.next(), p))
                     n++;
             }
         }
@@ -1323,52 +1613,34 @@ public class GridFunc {
     }
 
     /**
-     * Gets size of the given iterator with provided optional predicates. Iterator
-     * will be traversed to get the count.
-     *
-     * @param it Iterator to size.
-     * @param p Optional predicates that filters out elements from count.
-     * @param <T> Type of the iterator.
-     * @return Number of elements in the iterator for which all given predicates
-     *      evaluates to {@code true}. If no predicates is provided - all elements are counted.
-     */
-    public static <T> int size(@Nullable Iterator<? extends T> it, @Nullable IgnitePredicate<? super T>[] p) {
-        if (it == null)
-            return 0;
-
-        int n = 0;
-
-        if (!isAlwaysFalse(p)) {
-            while (it.hasNext()) {
-                if (isAll(it.next(), p))
-                    n++;
-            }
-        }
-
-        return n;
-    }
-
-    /**
-     * Creates write-through light-weight view on given collection.
+     * Creates write-through light-weight view on given collection with provided predicates. Resulting
+     * collection will only "have" elements for which all provided predicates, if any, evaluate
+     * to {@code true}. Note that only wrapping collection will be created and no duplication of
+     * data will occur. Also note that if array of given predicates is not empty then method
+     * {@code size()} uses full iteration through the collection.
      *
      * @param c Input collection that serves as a base for the view.
      * @param p Optional predicates. If predicates are not provided - all elements will be in the view.
      * @param <T> Type of the collection.
      * @return Light-weight view on given collection with provided predicate.
      */
-    public static <T> Collection<T> view(@Nullable final Collection<T> c, final IgnitePredicate<? super T> p) {
+    @SafeVarargs
+    public static <T> Collection<T> view(@Nullable final Collection<T> c,
+        @Nullable final IgnitePredicate<? super T>... p) {
         if (isEmpty(c) || isAlwaysFalse(p))
             return Collections.emptyList();
 
-        return isAlwaysTrue(p) ? c : new GridSerializableCollection<T>() {
+        assert c != null;
+
+        return isEmpty(p) || isAlwaysTrue(p) ? c : new GridSerializableCollection<T>() {
             // Pass through (will fail for readonly).
             @Override public boolean add(T e) {
-                return p.apply(e) && c.add(e);
+                return isAll(e, p) && c.add(e);
             }
 
             @NotNull
             @Override public Iterator<T> iterator() {
-                return identityIterator(c, p);
+                return F.iterator0(c, false, p);
             }
 
             @Override public int size() {
@@ -1376,82 +1648,117 @@ public class GridFunc {
             }
 
             @Override public boolean isEmpty() {
-                return !iterator().hasNext();
+                return F.isEmpty(p) ? c.isEmpty() : !iterator().hasNext();
             }
         };
     }
 
     /**
-     * Creates read-only light-weight view on given collection with transformation.
+     * Creates read-only light-weight view on given collection with transformation and provided
+     * predicates. Resulting collection will only "have" {@code transformed} elements for which
+     * all provided predicate, if any, evaluates to {@code true}. Note that only wrapping
+     * collection will be created and no duplication of data will occur. Also note that if array
+     * of given predicates is not empty then method {@code size()} uses full iteration through
+     * the collection.
      *
      * @param c Input collection that serves as a base for the view.
      * @param trans Transformation closure.
+     * @param p Optional predicated. If predicates are not provided - all elements will be in the view.
      * @param <T1> Type of the collection.
      * @return Light-weight view on given collection with provided predicate.
      */
     @SuppressWarnings("RedundantTypeArguments")
+    @SafeVarargs
     public static <T1, T2> Collection<T2> viewReadOnly(@Nullable final Collection<? extends T1> c,
-        final IgniteClosure<? super T1, T2> trans) {
+        final IgniteClosure<? super T1, T2> trans, @Nullable final IgnitePredicate<? super T1>... p) {
         A.notNull(trans, "trans");
 
-        if (isEmpty(c))
+        if (isEmpty(c) || isAlwaysFalse(p))
             return Collections.emptyList();
 
+        assert c != null;
+
         return new GridSerializableCollection<T2>() {
             @NotNull
             @Override public Iterator<T2> iterator() {
-                return F.<T1, T2>iteratorReadOnly(c, trans);
+                return F.<T1, T2>iterator(c, trans, true, p);
             }
 
             @Override public int size() {
-                return c.size();
+                return F.isEmpty(p) ? c.size() : F.size(iterator());
             }
 
             @Override public boolean isEmpty() {
-                return c.isEmpty();
+                return F.isEmpty(p) ? c.isEmpty() : !iterator().hasNext();
             }
         };
     }
 
     /**
-     * Creates read-only light-weight view on given collection with transformation and provided
-     * predicates. Resulting collection will only "have" {@code transformed} elements for which
-     * all provided predicate, if any, evaluates to {@code true}. Note that only wrapping
-     * collection will be created and no duplication of data will occur. Also note that if array
-     * of given predicates is not empty then method {@code size()} uses full iteration through
-     * the collection.
+     * Creates read-only light-weight view on given list with provided transformation.
+     * Resulting list will only "have" {@code transformed} elements. Note that only wrapping
+     * list will be created and no duplication of data will occur.
      *
-     * @param c Input collection that serves as a base for the view.
+     * @param c Input list that serves as a base for the view.
      * @param trans Transformation closure.
-     * @param p Optional predicated. If predicates are not provided - all elements will be in the view.
-     * @param <T1> Type of the collection.
-     * @return Light-weight view on given collection with provided predicate.
+     * @param <T1> Type of the list.
+     * @return Light-weight view on given list with provided transformation.
      */
     @SuppressWarnings("RedundantTypeArguments")
-    public static <T1, T2> Collection<T2> viewReadOnly(@Nullable final Collection<? extends T1> c,
-        final IgniteClosure<? super T1, T2> trans, @Nullable final IgnitePredicate<? super T1> p) {
+    public static <T1, T2> List<T2> viewListReadOnly(@Nullable final List<? extends T1> c,
+        final IgniteClosure<? super T1, T2> trans) {
         A.notNull(trans, "trans");
 
-        if (isEmpty(c) || isAlwaysFalse(p))
+        if (isEmpty(c))
             return Collections.emptyList();
 
-        return new GridSerializableCollection<T2>() {
+        assert c != null;
+
+        return new GridSerializableList<T2>() {
+            /** */
+            private static final long serialVersionUID = 3126625219739967068L;
+
+            @Override public T2 get(int idx) {
+                return trans.apply(c.get(idx));
+            }
+
             @NotNull
             @Override public Iterator<T2> iterator() {
-                return F.<T1, T2>iterator(c, trans, true, p);
+                return F.<T1, T2>iterator(c, trans, true);
             }
 
             @Override public int size() {
-                return F.size(iterator());
+                return c.size();
             }
 
             @Override public boolean isEmpty() {
-                return !iterator().hasNext();
+                return c.isEmpty();
             }
         };
     }
 
     /**
+     * Creates a view on given list with provided transformer and predicates.
+     * Resulting list will only "have" elements for which all provided predicates, if any,
+     * evaluate to {@code true}. Note that a new collection will be created and data will
+     * be copied.
+     *
+     * @param c Input list that serves as a base for the view.
+     * @param trans Transforming closure from T1 to T2.
+     * @param p Optional predicates. If predicates are not provided - all elements will be in the view.
+     * @return View on given list with provided predicate.
+     */
+    public static <T1, T2> List<T2> transformList(Collection<? extends T1> c,
+        IgniteClosure<? super T1, T2> trans, @Nullable IgnitePredicate<? super T1>... p) {
+        A.notNull(c, "c", trans, "trans");
+
+        if (isAlwaysFalse(p))
+            return Collections.emptyList();
+
+        return new ArrayList<>(transform(retain(c, true, p), trans));
+    }
+
+    /**
      * Creates light-weight view on given map with provided predicates. Resulting map will
      * only "have" keys for which all provided predicates, if any, evaluates to {@code true}.
      * Note that only wrapping map will be created and no duplication of data will occur.
@@ -1459,24 +1766,26 @@ public class GridFunc {
      * uses full iteration through the entry set.
      *
      * @param m Input map that serves as a base for the view.
-     * @param p Predicate.
+     * @param p Optional predicates. If predicates are not provided - all will be in the view.
      * @param <K> Type of the key.
      * @param <V> Type of the value.
      * @return Light-weight view on given map with provided predicate.
      */
     public static <K0, K extends K0, V0, V extends V0> Map<K, V> view(@Nullable final Map<K, V> m,
-        final IgnitePredicate<? super K> p) {
+        @Nullable final IgnitePredicate<? super K>... p) {
         if (isEmpty(m) || isAlwaysFalse(p))
             return Collections.emptyMap();
 
-        return isAlwaysTrue(p) ? m : new GridSerializableMap<K, V>() {
+        assert m != null;
+
+        return isEmpty(p) || isAlwaysTrue(p) ? m : new GridSerializableMap<K, V>() {
             /** */
             private static final long serialVersionUID = 5531745605372387948L;
 
             /** Entry predicate. */
             private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
                 @Override public boolean apply(Entry<K, V> e) {
-                    return p.apply(e.getKey());
+                    return isAll(e.getKey(), p);
                 }
             };
 
@@ -1485,7 +1794,7 @@ public class GridFunc {
                 return new GridSerializableSet<Map.Entry<K, V>>() {
                     @NotNull
                     @Override public Iterator<Entry<K, V>> iterator() {
-                        return identityIterator(m.entrySet(), ep);
+                        return iterator0(m.entrySet(), false, ep);
                     }
 
                     @Override public int size() {
@@ -1494,12 +1803,12 @@ public class GridFunc {
 
                     @SuppressWarnings({"unchecked"})
                     @Override public boolean remove(Object o) {
-                        return ep.apply((Map.Entry<K, V>)o) && m.entrySet().remove(o);
+                        return F.isAll((Map.Entry<K, V>)o, ep) && m.entrySet().remove(o);
                     }
 
                     @SuppressWarnings({"unchecked"})
                     @Override public boolean contains(Object o) {
-                        return ep.apply((Map.Entry<K, V>)o) && m.entrySet().contains(o);
+                        return F.isAll((Map.Entry<K, V>)o, ep) && m.entrySet().contains(o);
                     }
 
                     @Override public boolean isEmpty() {
@@ -1514,13 +1823,13 @@ public class GridFunc {
 
             @SuppressWarnings({"unchecked"})
             @Nullable @Override public V get(Object key) {
-                return p.apply((K)key) ? m.get(key) : null;
+                return isAll((K)key, p) ? m.get(key) : null;
             }
 
             @Nullable @Override public V put(K key, V val) {
                 V oldVal = get(key);
 
-                if (p.apply(key))
+                if (isAll(key, p))
                     m.put(key, val);
 
                 return oldVal;
@@ -1528,7 +1837,7 @@ public class GridFunc {
 
             @SuppressWarnings({"unchecked"})
             @Override public boolean containsKey(Object key) {
-                return p.apply((K)key) && m.containsKey(key);
+                return isAll((K)key, p) && m.containsKey(key);
             }
         };
     }
@@ -1542,26 +1851,38 @@ public class GridFunc {
      *
      * @param m Input map that serves as a base for the view.
      * @param trans Transformer for map value transformation.
+     * @param p Optional predicates. If predicates are not provided - all will be in the view.
      * @param <K> Type of the key.
      * @param <V> Type of the input map value.
      * @param <V1> Type of the output map value.
      * @return Light-weight view on given map with provided predicate and transformer.
      */
     public static <K0, K extends K0, V0, V extends V0, V1> Map<K, V1> viewReadOnly(@Nullable final Map<K, V> m,
-        final IgniteClosure<V, V1> trans) {
+        final IgniteClosure<V, V1> trans, @Nullable final IgnitePredicate<? super K>... p) {
         A.notNull(trans, "trans");
 
-        if (isEmpty(m))
+        if (isEmpty(m) || isAlwaysFalse(p))
             return Collections.emptyMap();
 
+        assert m != null;
+
+        final boolean hasPred = p != null && p.length > 0;
+
         return new GridSerializableMap<K, V1>() {
+            /** Entry predicate. */
+            private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
+                @Override public boolean apply(Entry<K, V> e) {
+                    return isAll(e.getKey(), p);
+                }
+            };
+
             @NotNull
             @Override public Set<Entry<K, V1>> entrySet() {
                 return new GridSerializableSet<Map.Entry<K, V1>>() {
                     @NotNull
                     @Override public Iterator<Entry<K, V1>> iterator() {
                         return new Iterator<Entry<K, V1>>() {
-                            private Iterator<Entry<K, V>> it = identityIteratorReadOnly(m.entrySet());
+                            private Iterator<Entry<K, V>> it = iterator0(m.entrySet(), true, ep);
 
                             @Override public boolean hasNext() {
                                 return it.hasNext();
@@ -1592,7 +1913,7 @@ public class GridFunc {
                     }
 
                     @Override public int size() {
-                        return m.size();
+                        return hasPred ? F.size(m.keySet(), p) : m.size();
                     }
 
                     @SuppressWarnings({"unchecked"})
@@ -1602,25 +1923,27 @@ public class GridFunc {
 
                     @SuppressWarnings({"unchecked"})
                     @Override public boolean contains(Object o) {
-                        return m.entrySet().contains(o);
+                        return F.isAll((Map.Entry<K, V>)o, ep) && m.entrySet().contains(o);
                     }
 
                     @Override public boolean isEmpty() {
-                        return m.isEmpty();
+                        return hasPred ? !iterator().hasNext() : m.isEmpty();
                     }
                 };
             }
 
             @Override public boolean isEmpty() {
-                return m.isEmpty();
+                return hasPred ? entrySet().isEmpty() : m.isEmpty();
             }
 
             @SuppressWarnings({"unchecked"})
             @Nullable @Override public V1 get(Object key) {
-                V v = m.get(key);
+                if (isAll((K)key, p)) {
+                    V v = m.get(key);
 
-                if (v != null)
-                    return trans.apply(v);
+                    if (v != null)
+                        return trans.apply(v);
+                }
 
                 return null;
             }
@@ -1635,34 +1958,170 @@ public class GridFunc {
 
             @SuppressWarnings({"unchecked"})
             @Override public boolean containsKey(Object key) {
-                return m.containsKey(key);
+                return isAll((K)key, p) && m.containsKey(key);
             }
         };
     }
 
     /**
-     * Read-only map view of a collection.
+     * Read-only view on map that supports transformation of values and key filtering. Resulting map will
+     * only "have" keys for which all provided predicates, if any, evaluates to {@code true}.
+     * Note that only wrapping map will be created and no duplication of data will occur.
+     * Also note that if array of given predicates is not empty then method {@code size()}
+     * uses full iteration through the entry set.
+     *
+     * @param m Input map that serves as a base for the view.
+     * @param trans Transformer for map value transformation.
+     * @param p Optional predicates. If predicates are not provided - all will be in the view.
+     * @param <K> Type of the key.
+     * @param <V> Type of the input map value.
+     * @param <V1> Type of the output map value.
+     * @return Light-weight view on given map with provided predicate and transformer.
+     */
+    public static <K0, K extends K0, V0, V extends V0, V1> Map<K, V1> viewReadOnly(@Nullable final Map<K, V> m,
+        final IgniteBiClosure<K, V, V1> trans, @Nullable final IgnitePredicate<? super K>... p) {
+        A.notNull(trans, "trans");
+
+        if (isEmpty(m) || isAlwaysFalse(p))
+            return Collections.emptyMap();
+
+        assert m != null;
+
+        return new GridSerializableMap<K, V1>() {
+            /** Entry predicate. */
+            private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
+                @Override public boolean apply(Entry<K, V> e) {
+                    return isAll(e.getKey(), p);
+                }
+            };
+
+            @NotNull
+            @Override public Set<Entry<K, V1>> entrySet() {
+                return new GridSerializableSet<Map.Entry<K, V1>>() {
+                    @NotNull
+                    @Override public Iterator<Entry<K, V1>> iterator() {
+                        return new Iterator<Entry<K, V1>>() {
+                            private Iterator<Entry<K, V>> it = iterator0(m.entrySet(), true, ep);
+
+                            @Override public boolean hasNext() {
+                                return it.hasNext();
+                            }
+
+                            @Override public Entry<K, V1> next() {
+                                final Entry<K, V> e = it.next();
+
+                                return new Entry<K, V1>() {
+                                    @Override public K getKey() {
+                                        return e.getKey();
+                                    }
+
+                                    @Override public V1 getValue() {
+                                        return trans.apply(e.getKey(), e.getValue());
+                                    }
+
+                                    @Override public V1 setValue(V1 val) {
+                                        throw new UnsupportedOperationException(
+                                            "Put is not supported for readonly map view.");
+                                    }
+                                };
+                            }
+
+                            @Override public void remove() {
+                                throw new UnsupportedOperationException("Remove is not support for readonly map view.");
+                            }
+                        };
+                    }
+
+                    @Override public int size() {
+                        return F.size(m.keySet(), p);
+                    }
+
+                    @SuppressWarnings({"unchecked"})
+                    @Override public boolean remove(Object o) {
+                        throw new UnsupportedOperationException("Remove is not support for readonly map view.");
+                    }
+
+                    @SuppressWarnings({"unchecked"})
+                    @Override public boolean contains(Object o) {
+                        return F.isAll((Map.Entry<K, V>)o, ep) && m.entrySet().contains(o);
+                    }
+
+                    @Override public boolean isEmpty() {
+                        return !iterator().hasNext();
+                    }
+                };
+            }
+
+            @Override public boolean isEmpty() {
+                return entrySet().isEmpty();
+            }
+
+            @SuppressWarnings({"unchecked"})
+            @Nullable @Override public V1 get(Object key) {
+                if (isAll((K)key, p)) {
+                    V v = m.get(key);
+
+                    if (v != null)
+                        return trans.apply((K)key, v);
+                }
+
+                return null;
+            }
+
+            @Nullable @Override public V1 put(K key, V1 val) {
+                throw new UnsupportedOperationException("Put is not supported for readonly map view.");
+            }
+
+            @Override public V1 remove(Object key) {
+                throw new UnsupportedOperationException("Remove is not supported for readonly map view.");
+            }
+
+            @SuppressWarnings({"unchecked"})
+            @Override public boolean containsKey(Object key) {
+                return isAll((K)key, p) && m.containsKey(key);
+            }
+        };
+    }
+
+    /**
+     * Read-only map view of a collection. Resulting map is a lightweight view of an input collection,
+     * with filtered elements of an input collection as keys, and closure execution results
+     * as values. The map will only contain keys for which all provided predicates, if any, evaluate
+     * to {@code true}. Note that only wrapping map will be created and no duplication of data will occur.
+     * Also note that if array of given predicates is not empty then method {@code size()}
+     * uses full iteration through the entry set.
      *
      * @param c Input collection.
      * @param mapClo Mapping closure, that maps key to value.
+     * @param p Optional predicates to filter input collection. If predicates are not provided - all
+     *          elements will be in the view.
      * @param <K> Key type.
      * @param <V> Value type.
      * @return Light-weight view on given map with provided predicates and mapping.
      */
     @SuppressWarnings("TypeMayBeWeakened")
     public static <K0, K extends K0, V0, V extends V0> Map<K, V> viewAsMap(@Nullable final Set<K> c,
-        final IgniteClosure<? super K, V> mapClo) {
+        final IgniteClosure<? super K, V> mapClo, @Nullable final IgnitePredicate<? super K>... p) {
         A.notNull(mapClo, "trans");
 
-        if (isEmpty(c))
+        if (isEmpty(c) || isAlwaysFalse(p))
             return Collections.emptyMap();
 
+        assert c != null;
+
         return new GridSerializableMap<K, V>() {
+            /** Entry predicate. */
+            private IgnitePredicate<K> ep = new P1<K>() {
+                @Override public boolean apply(K e) {
+                    return isAll(e, p);
+                }
+            };
+
             @NotNull @Override public Set<Entry<K, V>> entrySet() {
                 return new GridSerializableSet<Entry<K, V>>() {
                     @NotNull @Override public Iterator<Entry<K, V>> iterator() {
                         return new Iterator<Entry<K, V>>() {
-                            private Iterator<K> it = identityIteratorReadOnly(c);
+                            private Iterator<K> it = iterator0(c, true, ep);
 
                             @Override public boolean hasNext() {
                                 return it.hasNext();
@@ -1695,7 +2154,7 @@ public class GridFunc {
                     }
 
                     @Override public int size() {
-                        return c.size();
+                        return F.size(c, p);
                     }
 
                     @Override public boolean remove(Object o) {
@@ -1703,16 +2162,15 @@ public class GridFunc {
                     }
 
                     @Override public boolean isEmpty() {
-                        return c.isEmpty();
+                        return !iterator().hasNext();
                     }
                 };
             }
 
             @Override public boolean isEmpty() {
-                return c.isEmpty();
+                return entrySet().isEmpty();
             }
 
-            @SuppressWarnings("unchecked")
             @Nullable @Override public V get(Object key) {
                 if (containsKey(key))
                     return mapClo.apply((K)key);
@@ -1728,9 +2186,8 @@ public class GridFunc {
                 throw new UnsupportedOperationException("Remove is not supported for readonly collection view.");
             }
 
-            @SuppressWarnings("SuspiciousMethodCalls")
             @Override public boolean containsKey(Object key) {
-                return c.contains(key);
+                return isAll((K)key, p) && c.contains(key);
             }
         };
     }
@@ -1833,6 +2290,40 @@ public class GridFunc {
     }
 
     /**
+     * Utility map getter. This method analogous to {@link #addIfAbsent(Map, Object, Callable)}
+     * method but this one doesn't put the default value into the map when key is not found.
+     *
+     * @param map Map to get value from.
+     * @param key Map key (can be {@code null}).
+     * @param c Optional factory closure for the default value to be returned in
+     *      when {@code key} is not found. If closure is not provided - {@code null} will be returned.
+     * @param <K> Map key type.
+     * @param <V> Map value type.
+     * @return Value for the {@code key} or default value produced by {@code c} if key is not
+     *      found (or {@code null} if key is not found and closure is not provided).
+     * @throws GridClosureException Thrown in case when callable throws exception.
+     * @see #newLinkedList()
+     * @see #newList()
+     * @see #newSet()
+     * @see #newMap()
+     * @see #newAtomicLong()
+     * @see #newAtomicInt()
+     * @see #newAtomicRef()
+     * @see #newAtomicBoolean()
+     */
+    @Nullable public static <K, V> V returnIfAbsent(Map<? extends K, ? extends V> map, @Nullable K key,
+        @Nullable Callable<V> c) {
+        A.notNull(map, "map");
+
+        try {
+            return !map.containsKey(key) ? c == null ? null : c.call() : map.get(key);
+        }
+        catch (Exception e) {
+            throw wrap(e);
+        }
+    }
+
+    /**
      * Returns a factory closure that creates new {@link ConcurrentLinkedDeque8} instance.
      * Note that this method does not create a new closure but returns a static one.
      *
@@ -1846,6 +2337,82 @@ public class GridFunc {
     }
 
     /**
+     * Returns a factory closure that creates new {@link List} instance. Note that this
+     * method does not create a new closure but returns a static one.
+     *
+     * @param <T> Type parameters for the created {@link List}.
+     * @return Factory closure that creates new {@link List} instance every
+     *      time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> IgniteCallable<List<T>> newList() {
+        return (IgniteCallable<List<T>>)LIST_FACTORY;
+    }
+
+    /**
+     * Returns a factory closure that creates new {@link AtomicInteger} instance
+     * initialized to {@code zero}. Note that this method does not create a new
+     * closure but returns a static one.
+     *
+     * @return Factory closure that creates new {@link AtomicInteger} instance
+     *      initialized to {@code zero} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
+     */
+    public static IgniteCallable<AtomicInteger> newAtomicInt() {
+        return ATOMIC_INT_FACTORY;
+    }
+
+    /**
+     * Returns a factory closure that creates new {@link AtomicLong} instance
+     * initialized to {@code zero}. Note that this method does not create a new
+     * closure but returns a static one.
+     *
+     * @return Factory closure that creates new {@link AtomicLong} instance
+     *      initialized to {@code zero} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
+     */
+    public static IgniteCallable<AtomicLong> newAtomicLong() {
+        return ATOMIC_LONG_FACTORY;
+    }
+
+    /**
+     * Returns a factory closure that creates new {@link AtomicReference} instance
+     * initialized to {@code null}. Note that this method does not create a new closure
+     * but returns a static one.
+     *
+     * @param <T> Type of the atomic reference.
+     * @return Factory closure that creates new {@link AtomicReference} instance
+     *      initialized to {@code null} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> IgniteCallable<AtomicReference<T>> newAtomicRef() {
+        return (IgniteCallable<AtomicReference<T>>)ATOMIC_REF_FACTORY;
+    }
+
+    /**
+     * Returns a factory closure that creates new {@link AtomicBoolean} instance
+     * initialized to {@code false}. Note that this method does not create a new
+     * closure but returns a static one.
+     *
+     * @return Factory closure that creates new {@link AtomicBoolean} instance
+     *      initialized to {@code false} every time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
+     */
+    public static IgniteCallable<AtomicBoolean> newAtomicBoolean() {
+        return ATOMIC_BOOL_FACTORY;
+    }
+
+    /**
+     * Returns a factory closure that creates new {@link LinkedList} instance.
+     * Note that this method does not create a new closure but returns a static one.
+     *
+     * @param <T> Type parameters for the created {@link LinkedList}.
+     * @return Factory closure that creates new {@link LinkedList} instance every time its {@link
+     *         org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> IgniteCallable<LinkedList<T>> newLinkedList() {
+        return (IgniteCallable<LinkedList<T>>)LINKED_LIST_FACTORY;
+    }
+
+    /**
      * Returns a factory closure that creates new {@link Set} instance. Note that this
      * method does not create a new closure but returns a static one.
      *
@@ -1859,6 +2426,20 @@ public class GridFunc {
     }
 
     /**
+     * Returns a factory closure that creates new {@link Map} instance. Note
+     * that this method does not create a new closure but returns a static one.
+     *
+     * @param <K> Type of the key for the created {@link Map}.
+     * @param <V> Type of the value for the created {@link Map}.
+     * @return Factory closure that creates new {@link Map} instance every
+     *      time its {@link org.apache.ignite.lang.IgniteOutClosure#apply()} method is called.
+     */
+    @SuppressWarnings("unchecked")
+    public static <K, V> IgniteCallable<Map<K, V>> newMap() {
+        return (IgniteCallable<Map<K, V>>)MAP_FACTORY;
+    }
+
+    /**
      * Returns a factory closure that creates new {@link ConcurrentMap} instance.
      * Note that this method does not create a new closure but returns a static one.
      *
@@ -1885,18 +2466,6 @@ public class GridFunc {
     }
 
     /**
-     * Creates and returns iterator from given collection.
-     *
-     * @param c Input collection.
-     * @param <T> Type of the collection elements.
-     * @return Iterator from given collection and optional filtering predicate.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static <T> GridIterator<T> identityIteratorReadOnly(Iterable<? extends T> c) {
-        return iteratorReadOnly(c, IDENTITY);
-    }
-
-    /**
      * Creates and returns iterator from given collection and optional filtering predicates.
      * Returned iterator will only have elements for which all given predicates evaluates to
      * {@code true} (if provided). Note that this method will not create new collection but
@@ -1904,29 +2473,16 @@ public class GridFunc {
      * evaluate to {@code true} for.
      *
      * @param c Input collection.
-     * @param p Optional filtering predicate.
+     * @param readOnly If {@code true}, then resulting iterator will not allow modifications
+     *      to the underlying collection.
+     * @param p Optional filtering predicates.
      * @param <T> Type of the collection elements.
      * @return Iterator from given collection and optional filtering predicate.
      */
     @SuppressWarnings({"unchecked"})
-    public static <T> GridIterator<T> identityIterator(Iterable<? extends T> c, IgnitePredicate<? super T> p) {
-        return iterator(c, IDENTITY, false, p);
-    }
-
-    /**
-     * Creates and returns transforming iterator from given collection.
-     *
-     * @param c Input collection.
-     * @param trans Transforming closure to convert from T1 to T2.
-     * @param <T1> Type of the collection elements.
-     * @param <T2> Type of returned elements.
-     * @return Iterator from given collection and optional filtering predicate.
-     */
-    public static <T1, T2> GridIterator<T2> iteratorReadOnly(final Iterable<? extends T1> c,
-        final IgniteClosure<? super T1, T2> trans) {
-        A.notNull(c, "c", trans, "trans");
-
-        return iterator(c.iterator(), trans, true);
+    public static <T> GridIterator<T> iterator0(Iterable<? extends T> c, boolean readOnly,
+        IgnitePredicate<? super T>... p) {
+        return F.iterator(c, IDENTITY, readOnly, p);
     }
 
     /**
@@ -1940,14 +2496,15 @@ public class GridFunc {
      * @param trans Transforming closure to convert from T1 to T2.
      * @param readOnly If {@code true}, then resulting iterator will not allow modifications
      *      to the underlying collection.
-     * @param p Filtering predicate.
+     * @param p Optional filtering predicates.
      * @param <T1> Type of the collection elements.
      * @param <T2> Type of returned elements.
      * @return Iterator from given collection and optional filtering predicate.
      */
     public static <T1, T2> GridIterator<T2> iterator(final Iterable<? extends T1> c,
-        final IgniteClosure<? super T1, T2> trans, final boolean readOnly, final IgnitePredicate<? super T1> p) {
-        A.notNull(c, "c", trans, "trans", p, "p");
+        final IgniteClosure<? super T1, T2> trans, final boolean readOnly,
+        @Nullable final IgnitePredicate<? super T1>... p) {
+        A.notNull(c, "c", trans, "trans");
 
         if (isAlwaysFalse(p))
             return F.emptyIterator();
@@ -1966,36 +2523,53 @@ public class GridFunc {
             private Iterator<? extends T1> iter = c.iterator();
 
             @Override public boolean hasNextX() {
-                if (!moved)
-                    return more;
+                if (isEmpty(p))
+                    return iter.hasNext();
                 else {
-                    more = false;
+                    if (!moved)
+                        return more;
+                    else {
+                        more = false;
+
+                        while (iter.hasNext()) {
+                            elem = iter.next();
 
-                    while (iter.hasNext()) {
-                        elem = iter.next();
+                            boolean isAll = true;
 
-                        if (p.apply(elem)) {
-                            more = true;
-                            moved = false;
+                            for (IgnitePredicate<? super T1> r : p)
+                                if (r != null && !r.apply(elem)) {
+                                    isAll = false;
 
-                            return true;
+                                    break;
+                                }
+
+                            if (isAll) {
+                                more = true;
+                                moved = false;
+
+                                return true;
+                            }
                         }
-                    }
 
-                    elem = null; // Give to GC.
+                        elem = null; // Give to GC.
 
-                    return false;
+                        return false;
+                    }
                 }
             }
 
             @Nullable @Override public T2 nextX() {
-                if (hasNext()) {
-                    moved = true;
+                if (isEmpty(p))
+                    return trans.apply(iter.next());
+                else {
+                    if (hasNext()) {
+                        moved = true;
 
-                    return trans.apply(elem);
+                        return trans.apply(elem);
+                    }
+                    else
+                        throw new NoSuchElementException();
                 }
-                else
-                    throw new NoSuchElementException();
             }
 
             @Override public void removeX() {
@@ -2012,22 +2586,80 @@ public class GridFunc {
      * @param trans Transforming closure to convert from T1 to T2.
      * @param readOnly If {@code true}, then resulting iterator will not allow modifications
      *      to the underlying collection.
+     * @param p Optional filtering predicates.
      * @return Iterator from given iterator and optional filtering predicate.
      */
-    public static <T1, T2> GridIterator<T2> iterator(final Iterator<? extends T1> c,
-        final IgniteClosure<? super T1, T2> trans, final boolean readOnly) {
+    public static <T1, T2> Iterator<T2> iterator(final Iterator<? extends T1> c,
+        final IgniteClosure<? super T1, T2> trans,
+        final boolean readOnly,
+        @Nullable final IgnitePredicate<? super T1>... p)
+    {
         A.notNull(c, "c", trans, "trans");
 
+        if (isAlwaysFalse(p))
+            return F.emptyIterator();
+
         return new GridIteratorAdapter<T2>() {
             /** */
+            private T1 elem;
+
+            /** */
+            private boolean moved = true;
+
+            /** */
+            private boolean more;
+
+            /** */
             private Iterator<? extends T1> iter = c;
 
             @Override public boolean hasNextX() {
-                return iter.hasNext();
+                if (isEmpty(p))
+                    return iter.hasNext();
+                else {
+                    if (!moved)
+                        return more;
+                    else {
+                        more = false;
+
+                        while (iter.hasNext()) {
+                            elem = iter.next();
+
+                            boolean isAll = true;
+
+                            for (IgnitePredicate<? super T1> r : p)
+                                if (r != null && !r.apply(elem)) {
+                                    isAll = false;
+
+                                    break;
+                                }
+
+                            if (isAll) {
+                                more = true;
+                                moved = false;
+
+                                return true;
+                            }
+                        }
+
+                        elem = null; // Give to GC.
+
+                        return false;
+                    }
+                }
             }
 
             @Nullable @Override public T2 nextX() {
-                return trans.apply(iter.next());
+                if (isEmpty(p))
+                    return trans.apply(iter.next());
+                else {
+                    if (hasNext()) {
+                        moved = true;
+
+                        return trans.apply(elem);
+                    }
+                    else
+                        throw new NoSuchElementException();
+                }
             }
 
             @Override public void removeX() {
@@ -2108,35 +2740,23 @@ public class GridFunc {
     }
 
     /**
-     * Gets predicate that evaluates to {@code true} if its free variable is not {@code null}.
+     * Gets predicate that evaluates to {@code true} if its free variable is {@code null}.
      *
      * @param <T> Type of the free variable, i.e. the element the predicate is called on.
-     * @return Predicate that evaluates to {@code true} if its free variable is not {@code null}.
+     * @return Predicate that evaluates to {@code true} if its free variable is {@code null}.
      */
-    @SuppressWarnings("unchecked")
-    public static <T> IgnitePredicate<T> notNull() {
-        return (IgnitePredicate<T>)IS_NOT_NULL;
+    public static <T> IgnitePredicate<T> isNull() {
+        return (IgnitePredicate<T>) IS_NULL;
     }
 
     /**
-     * Negates given predicate.
-     * <p>
-     * Gets predicate that evaluates to {@code true} if any of given predicates
-     * evaluates to {@code false}. If all predicates evaluate to {@code true} the
-     * result predicate will evaluate to {@code false}.
+     * Gets predicate that evaluates to {@code true} if its free variable is not {@code null}.
      *
-     * @param p Predicate to negate.
      * @param <T> Type of the free variable, i.e. the element the predicate is called on.
-     * @return Negated predicate.
+     * @return Predicate that evaluates to {@code true} if its free variable is not {@code null}.
      */
-    public static <T> IgnitePredicate<T> not(final IgnitePredicate<? super T> p) {
-        A.notNull(p, "p");
-
-        return isAlwaysFalse(p) ? F.<T>alwaysTrue() : isAlwaysTrue(p) ? F.<T>alwaysFalse() : new P1<T>() {
-            @Override public boolean apply(T t) {
-                return !p.apply(t);
-            }
-        };
+    public static <T> IgnitePredicate<T> notNull() {
+        return (IgnitePredicate<T>) IS_NOT_NULL;
     }
 
     /**
@@ -2150,7 +2770,8 @@ public class GridFunc {
      * @param <T> Type of the free variable, i.e. the element the predicate is called on.
      * @return Negated predicate.
      */
-    public static <T> IgnitePredicate<T> not(@Nullable final IgnitePredicate<? super T>[] p) {
+    @SafeVarargs
+    public static <T> IgnitePredicate<T> not(@Nullable final IgnitePredicate<? super T>... p) {
         return isAlwaysFalse(p) ? F.<T>alwaysTrue() : isAlwaysTrue(p) ? F.<T>alwaysFalse() : new P1<T>() {
             @Override public boolean apply(T t) {
                 return !isAll(t, p);
@@ -2193,13 +2814,30 @@ public class GridFunc {
     }
 
     /**
+     * Gets predicate that evaluates to {@code true} if its free variable is instance of the given class.
+     *
+     * @param cls Class to compare to.
+     * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+     * @return Predicate that evaluates to {@code true} if its free variable is instance
+     *      of the given class.
+     */
+    public static <T> IgnitePredicate<T> instanceOf(final Class<?> cls) {
+        A.notNull(cls, "cls");
+
+        return new P1<T>() {
+            @Override public boolean apply(T t) {
+                return t != null && cls.isAssignableFrom(t.getClass());
+            }
+        };
+    }
+
+    /**
      * Gets first element from given collection or returns {@code null} if the collection is empty.
      *
      * @param c A collection.
      * @param <T> Type of the collection.
      * @return Collections' first element or {@code null} in case if the collection is empty.
      */
-    @SuppressWarnings("unchecked")
     public static <T> T first(@Nullable Iterable<? extends T> c) {
         if (c == null)
             return null;
@@ -2232,11 +2870,12 @@ public class GridFunc {
      * @param <T> Type of the collection.
      * @return Collections' first element or {@code null} in case if the collection is empty.
      */
-    @SuppressWarnings("unchecked")
     @Nullable public static <T> T last(@Nullable Iterable<? extends T> c) {
         if (c == null)
             return null;
 
+        assert c != null;
+
         if (c instanceof RandomAccess && c instanceof List) {
             List<T> l = (List<T>)c;
 
@@ -2321,6 +2960,8 @@ public class GridFunc {
             return F.alwaysTrue();
 
         if (F0.isAllNodePredicates(ps)) {
+            assert ps != null;
+
             Set<UUID> ids = new HashSet<>();
 
             for (IgnitePredicate<? super T> p : ps) {
@@ -2340,6 +2981,8 @@ public class GridFunc {
         else {
             return new P1<T>() {
                 @Override public boolean apply(T t) {
+                    assert ps != null;
+
                     for (IgnitePredicate<? super T> p : ps)
                         if (p != null && !p.apply(t))
                             return false;
@@ -2376,24 +3019,6 @@ public class GridFunc {
     }
 
     /**
-     * Gets predicate (not peer-deployable) that returns {@code true} if its free variable is contained
-     * in given collection.
-     *
-     * @param c Collection to check for containment.
-     * @param <T> Type of the free variable for the predicate and type of the
-     *      collection elements.
-     * @return Predicate (not peer-deployable) that returns {@code true} if its free variable is
-     *      contained in given collection.
-     */
-    public static <T> IgnitePredicate<T> in(@Nullable final Collection<? extends T> c) {
-        return isEmpty(c) ? GridFunc.<T>alwaysFalse() : new P1<T>() {
-            @Override public boolean apply(T t) {
-                return c.contains(t);
-            }
-        };
-    }
-
-    /**
      * Gets predicate that returns {@code true} if its free variable is not
      * contained in given collection.
      *
@@ -2406,6 +3031,8 @@ public class GridFunc {
     public static <T> IgnitePredicate<T> notIn(@Nullable final Collection<? extends T> c) {
         return isEmpty(c) ? GridFunc.<T>alwaysTrue() : new P1<T>() {
             @Override public boolean apply(T t) {
+                assert c != null;
+
                 return !c.contains(t);
             }
         };
@@ -2418,13 +3045,27 @@ public class GridFunc {
      */
     @SuppressWarnings("unchecked")
     public static <T, C extends Collection<T>> C addAll(C c, Iterable<? extends T> it) {
+        if (it == null)
+            return c;
+
+        if (it instanceof Collection<?>) {
+            c.addAll((Collection<? extends T>)it);
+
+            return c;
+        }
+
+        return addAll(c, it.iterator());
+    }
+
+    /**
+     * @param c Target collection.
+     * @param it Iterator to fetch.
+     * @return Modified target collection.
+     */
+    public static <T, C extends Collection<T>> C addAll(C c, Iterator<? extends T> it) {
         if (it != null) {
-            if (it instanceof Collection<?>)
-                c.addAll((Collection<? extends T>)it);
-            else {
-                for (T item : it)
-                    c.add(item);
-            }
+            while (it.hasNext())
+                c.add(it.next());
         }
 
         return c;
@@ -2501,7 +3142,14 @@ public class GridFunc {
      *      found (or {@code null} if key is not found and closure is not provided). Note that
      *      in case when key is not found the default value will be put into the map.
      * @throws GridClosureException Thrown in case when callable throws exception.
+     * @see #newLinkedList()
+     * @see #newList()
      * @see #newSet()
+     * @see #newMap()
+     * @see #newAtomicLong()
+     * @see #newAtomicInt()
+     * @see #newAtomicRef()
+     * @see #newAtomicBoolean()
      */
     @Nullable public static <K, V> V addIfAbsent(Map<? super K, V> map, @Nullable K key,
         @Nullable Callable<? extends V> c) {
@@ -2579,34 +3227,79 @@ public class GridFunc {
      *
      * @param c Collection to call closure over.
      * @param f Side-effect only closure to call over the collection.
+     * @param p Optional set of predicates. Only if collection element evaluates
+     *      to {@code true} for given predicates the closure will be applied to it.
+     *      If no predicates provided - closure will be applied to all collection
+     *      elements.
      * @param <X> Type of the free variable for the closure and type of the
      *      collection elements.
      */
-    public static <X> void forEach(Iterable<? extends X> c, IgniteInClosure<? super X> f) {
-        A.notNull(c, "c", f, "f");
+    public static <X> void forEach(Iterable<? extends X> c, IgniteInClosure<? super X> f,
+        @Nullable IgnitePredicate<? super X>... p) {
+        A.notNull(c, "c", f, "f");
+
+        for (X x : c)
+            if (isAll(x, p))
+                f.apply(x);
+    }
+
+    /**
+     * Calls given {@code side-effect only} closure over the each element of the provided array.
+     *
+     * @param c Array to call closure over.
+     * @param f Side-effect only closure to call over the array.
+     * @param p Optional set of predicates. Only if collection element evaluates
+     *      to {@code true} for given predicates the closure will be applied to it.
+     *      If no predicates provided - closure will be applied to all collection
+     *      elements.
+     * @param <X> Type of the free variable for the closure and type of the array
+     *      elements.
+     */
+    @SuppressWarnings("RedundantTypeArguments")
+    public static <X> void forEach(X[] c, IgniteInClosure<? super X> f, @Nullable IgnitePredicate<? super X>... p) {
+        A.notNull(c, "c", f, "f");
+
+        F.<X>forEach(asList(c), f, p);
+    }
+
+    /**
+     * Adds (copies) to given collection all elements in <tt>'from'</tt> array.
+     *
+     * @param to Collection to copy to.
+     * @param from Array to copy from.
+     * @param <T> Type of the free variable for the predicate and type of the collection elements.
+     * @return Collection to copy to.
+     */
+    public static <T> Collection<T> copy(Collection<T> to, T... from) {
+        A.notNull(to, "to", from, "from");
 
-        for (X x : c)
-            f.apply(x);
+        copy(to, asList(from));
+
+        return to;
     }
 
     /**
-     * Calls given {@code side-effect only} closure over the each element of the provided
-     * collection.
+     * Adds (copies) to given collection using provided predicates. Element is copied if all
+     * predicates evaluate to {@code true}.
      *
-     * @param c Collection to call closure over.
-     * @param f Side-effect only closure to call over the collection.
-     * @param p Optional predicate. Only if collection element evaluates
-     *      to {@code true} for given predicate the closure will be applied to it.
-     * @param <X> Type of the free variable for the closure and type of the
-     *      collection elements.
+     * @param to Collection to copy to.
+     * @param from Collection to copy from.
+     * @param p Optional set of predicates to use for filtration.
+     * @param <T> Type of the free variable for the predicate and type of the collection elements.
+     * @return Collection to copy to.
      */
-    public static <X> void forEach(Iterable<? extends X> c, IgniteInClosure<? super X> f,
-        IgnitePredicate<? super X> p) {
-        A.notNull(c, "c", f, "f", p, "f");
+    public static <T> Collection<T> copy(Collection<T> to, Iterable<? extends T> from,
+        @Nullable IgnitePredicate<? super T>... p) {
+        A.notNull(to, "to", from, "from");
 
-        for (X x : c)
-            if (p.apply(x))
-                f.apply(x);
+        if (!isAlwaysFalse(p)) {
+            for (T t : from) {
+                if (isAll(t, p))
+                    to.add(t);
+            }
+        }
+
+        return to;
     }
 
     /**
@@ -2643,6 +3336,21 @@ public class GridFunc {
     }
 
     /**
+     * Transforms an array to read only collection using provided closure.
+     *
+     * @param c Initial array to transform.
+     * @param f Closure to use for transformation.
+     * @param <X> Type of the free variable for the closure and type of the array elements.
+     * @param <Y> Type of the closure's return value.
+     * @return Transformed read only collection.
+     */
+    public static <X, Y> Collection<Y> transform(X[] c, IgniteClosure<? super X, Y> f) {
+        A.notNull(c, "c", f, "f");
+
+        return viewReadOnly(asList(c), f);
+    }
+
+    /**
      * Tests if all provided predicates evaluate to {@code true} for given value. Note that
      * evaluation will be short-circuit when first predicate evaluated to {@code false} is found.
      *
@@ -2653,7 +3361,7 @@ public class GridFunc {
      * @return Returns {@code true} if given set of predicates is {@code null}, is empty, or all predicates
      *      evaluate to {@code true} for given value, {@code false} otherwise.
      */
-    public static <T> boolean isAll(@Nullable T t, @Nullable IgnitePredicate<? super T>[] p) {
+    public static <T> boolean isAll(@Nullable T t, @Nullable IgnitePredicate<? super T>... p) {
         if (p != null)
             for (IgnitePredicate<? super T> r : p)
                 if (r != null && !r.apply(t))
@@ -2663,6 +3371,27 @@ public class GridFunc {
     }
 
     /**
+     * Tests if any of provided predicates evaluate to {@code true} for given value. Note
+     * that evaluation will be short-circuit when first predicate evaluated to {@code true}
+     * is found.
+     *
+     * @param t Value to test.
+     * @param p Optional set of predicates to use for evaluation.
+     * @param <T> Type of the value and free variable of the predicates.
+     * @return Returns {@code true} if any of predicates evaluates to {@code true} for given
+     *      value, {@code false} otherwise. Returns {@code false} if given set of predicates
+     *      is {@code null} or empty.
+     */
+    public static <T> boolean isAny(@Nullable T t, @Nullable IgnitePredicate<? super T>... p) {
+        if (p != null)
+            for (IgnitePredicate<? super T> r : p)
+                if (r != null && r.apply(t))
+                    return true;
+
+        return false;
+    }
+
+    /**
      * Creates an absolute (no-arg) closure that does nothing.
      *
      * @return Absolute (no-arg) closure that does nothing.
@@ -2682,12 +3411,14 @@ public class GridFunc {
      * @return First element in given collection for which predicate evaluates to
      *      {@code true} - or {@code null} if such element cannot be found.
      */
-    @Nullable public static <V> V find(Iterable<? extends V> c, @Nullable V dfltVal, IgnitePredicate<? super V> p) {
+    @SafeVarargs
+    @Nullable public static <V> V find(Iterable<? extends V> c, @Nullable V dfltVal,
+        @Nullable IgnitePredicate<? super V>... p) {
         A.notNull(c, "c");
 
-        if (!isAlwaysFalse(p)) {
+        if (!isEmpty(p) && !isAlwaysFalse(p)) {
             for (V v : c) {
-                if (p.apply(v))
+                if (isAny(v, p))
                     return v;
             }
         }
@@ -2696,6 +3427,35 @@ public class GridFunc {
     }
 
     /**
+     * Finds, transforms and returns first element in given collection for which any of
+     * the provided predicates evaluates to {@code true}.
+     *
+     * @param c Input collection.
+     * @param dfltVal Default value to return when no element is found.
+     * @param f Transforming closure.
+     * @param p Optional set of finder predicates.
+     * @param <V> Type of the collection elements.
+     * @return First element in given collection for which predicate evaluates to
+     *      {@code true} - or {@code null} if such element cannot be found.
+     */
+    public static <V, Y> Y find(Iterable<? extends V> c, @Nullable Y dfltVal, IgniteClosure<? super V, Y> f,
+        @Nullable IgnitePredicate<? super V>... p) {
+        A.notNull(c, "c", f, "f");
+
+        if (isAlwaysTrue(p) && c.iterator().hasNext())
+            return f.apply(c.iterator().next());
+
+        if (!isEmpty(p) && !isAlwaysFalse(p)) {
+            for (V v : c) {
+                if (isAny(v, p))
+                    return f.apply(v);
+            }
+        }
+
+        return dfltVal;
+    }
+
+    /**
      * Checks if collection {@code c1} contains any elements from collection {@code c2}.
      *
      * @param c1 Collection to check for containment. If {@code null} - this method returns {@code false}.
@@ -2722,7 +3482,7 @@ public class GridFunc {
      * @return {@code true} if collection {@code c1} contains at least one element from collection
      *      {@code c2}.
      */
-    public static <T> boolean containsAny(@Nullable Collection<? extends T> c1, @Nullable T[] c2) {
+    public static <T> boolean containsAny(@Nullable Collection<? extends T> c1, @Nullable T... c2) {
         if (c1 != null && !c1.isEmpty() && c2 != null && c2.length > 0)
             for (T t : c2)
                 if (c1.contains(t))
@@ -2766,6 +3526,35 @@ public class GridFunc {
     }
 
     /**
+     * Partitions input collection in two: first containing elements for which given
+     * predicate evaluates to {@code true} - and second containing the elements for which
+     * predicate evaluates to {@code false}.
+     *
+     * @param c Input collection.
+     * @param p Partitioning predicate.
+     * @param <V> Type of the collection elements.
+     * @return Tuple of two collections: first containing elements for which given predicate
+     *      evaluates to {@code true} - and second containing the elements for which predicate
+     *      evaluates to {@code false}.
+     */
+    public static <V> IgniteBiTuple<Collection<V>, Collection<V>> partition(Iterable<? extends V> c,
+        IgnitePredicate<? super V> p) {
+        A.notNull(c, "c", p, "p");
+
+        Collection<V> c1 = new LinkedList<>();
+        Collection<V> c2 = new LinkedList<>();
+
+        for (V v : c) {
+            if (p.apply(v))
+                c1.add(v);
+            else
+                c2.add(v);
+        }
+
+        return t(c1, c2);
+    }
+
+    /**
      * Checks for existence of the element in input collection for which all provided predicates
      * evaluate to {@code true}.
      *
@@ -2775,16 +3564,18 @@ public class GridFunc {
      * @return {@code true} if input collection contains element for which all the provided
      *      predicates evaluates to {@code true} - otherwise returns {@code false}.
      */
-    public static <V> boolean exist(Iterable<? extends V> c, IgnitePredicate<? super V> p) {
+    public static <V> boolean exist(Iterable<? extends V> c, @Nullable IgnitePredicate<? super V>... p) {
         A.notNull(c, "c");
 
         if (isAlwaysFalse(p))
             return false;
         else if (isAlwaysTrue(p))
             return true;
+        else if (isEmpty(p))
+            return true;
         else
             for (V v : c)
-                if (p.apply(v))
+                if (isAll(v, p))
                     return true;
 
         return false;
@@ -2801,16 +3592,16 @@ public class GridFunc {
      * @return Returns {@code true} if all given predicates evaluate to {@code true} for
      *      all elements. Returns {@code false} otherwise.
      */
-    public static <V> boolean forAll(Iterable<? extends V> c, IgnitePredicate<? super V> p) {
+    public static <V> boolean forAll(Iterable<? extends V> c, @Nullable IgnitePredicate<? super V>... p) {
         A.notNull(c, "c");
 
         if (isAlwaysFalse(p))
             return false;
         else if (isAlwaysTrue(p))
             return true;
-        else {
+        else if (!isEmpty(p)) {
             for (V v : c) {
-                if (!p.apply(v))
+                if (!isAll(v, p))
                     return false;
             }
         }
@@ -2830,18 +3621,17 @@ public class GridFunc {
      *      entries. Returns {@code false} otherwise.
      */
     public static <K1, K extends K1, V1, V extends V1> boolean forAll(Map<K, V> m,
-        IgnitePredicate<? super Map.Entry<K, V>> p) {
+        @Nullable IgnitePredicate<? super Map.Entry<K, V>>... p) {
         A.notNull(m, "m");
 
         if (isAlwaysFalse(p))
             return false;
         else if (isAlwaysTrue(p))
             return true;
-        else {
+        else if (!isEmpty(p))
             for (Map.Entry<K, V> e : m.entrySet())
-                if (!p.apply(e))
+                if (!isAll(e, p))
                     return false;
-        }
 
         return true;
     }
@@ -2858,16 +3648,20 @@ public class GridFunc {
      * @return Returns {@code true} if all given predicates evaluate to {@code true} for
      *      at least one element. Returns {@code false} otherwise.
      */
-    public static <V> boolean forAny(Iterable<? extends V> c, IgnitePredicate<? super V> p) {
+    public static <V> boolean forAny(Iterable<? extends V> c, @Nullable IgnitePredicate<? super V>... p) {
         A.notNull(c, "c");
 
-        if (isAlwaysFalse(p))
+        if (!c.iterator().hasNext())
+            return false;
+        else if (isEmpty(p))
+            return true;
+        else if (isAlwaysFalse(p))
             return false;
         else if (isAlwaysTrue(p))
             return true;
         else {
             for (V v : c)
-                if (p.apply(v))
+                if (isAll(v, p))
                     return true;
 
             return false;
@@ -2897,17 +3691,22 @@ public class GridFunc {
      *
      * @param c Input collection.
      * @param b Optional first folding pair element.
-     * @param fs Optional folding closure.
+     * @param fs Optional set of folding closures.
      * @param <D> Type of the input collection elements and type of the free variable for the closure.
      * @param <B> Type of the folding value and return type of the closure.
      * @return Value representing folded collection.
      */
     @Nullable public static <D, B> B fold(Iterable<? extends D> c, @Nullable B b,
-        IgniteBiClosure<? super D, ? super B, B> fs) {
+        @Nullable IgniteBiClosure<? super D, ? super B, B>... fs) {
         A.notNull(c, "c");
 
-        for (D e : c)
-            b = fs.apply(e, b);
+        if (!isEmpty(fs))
+            for (D e : c) {
+                assert fs != null;
+
+                for (IgniteBiClosure<? super D, ? super B, B> f : fs)
+                    b = f.apply(e, b);
+            }
 

<TRUNCATED>

[24/29] ignite git commit: IGNITE-2365 - Notify policy if swap or offheap is enabled and rebalanced entry was not preloaded. IGNITE-2099 - Fixing custom collections. This closes #396

Posted by vo...@apache.org.
IGNITE-2365 - Notify policy if swap or offheap is enabled and rebalanced entry was not preloaded.
IGNITE-2099 - Fixing custom collections.
This closes #396


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

Branch: refs/heads/ignite-2236
Commit: 6524c79629f587fb28bc43ddbef973aa2e83f66b
Parents: 2af1d9b
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Jan 13 16:47:32 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jan 15 10:27:48 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/binary/BinaryUtils.java     |  78 ++++++++
 .../processors/cache/CacheObjectContext.java    |  91 +++++----
 .../binary/CacheObjectBinaryProcessorImpl.java  |  33 ++--
 .../dht/preloader/GridDhtPartitionDemander.java |  11 +-
 .../binary/BinaryMarshallerSelfTest.java        |  44 ++++-
 .../cache/GridCacheDeploymentSelfTest.java      |   3 +-
 ...IgniteCacheGetCustomCollectionsSelfTest.java | 128 +++++++++++++
 ...gniteCacheLoadRebalanceEvictionSelfTest.java | 188 +++++++++++++++++++
 .../platform/PlatformComputeEchoTask.java       |   6 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   5 +
 10 files changed, 515 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 62a9d26..a82b65f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -590,6 +590,43 @@ public class BinaryUtils {
     }
 
     /**
+     * @param map Map to check.
+     * @return {@code True} if this map type is supported.
+     */
+    public static boolean knownMap(Object map) {
+        Class<?> cls = map == null ? null : map.getClass();
+
+        return cls == HashMap.class ||
+            cls == LinkedHashMap.class ||
+            cls == TreeMap.class ||
+            cls == ConcurrentHashMap8.class ||
+            cls == ConcurrentHashMap.class;
+    }
+
+    /**
+     * Attempts to create a new map of the same known type. Will return null if map type is not supported.
+     *
+     * @param map Map.
+     * @return New map of the same type or null.
+     */
+    public static <K, V> Map<K, V> newKnownMap(Object map) {
+        Class<?> cls = map == null ? null : map.getClass();
+
+        if (cls == HashMap.class)
+            return U.newHashMap(((Map)map).size());
+        else if (cls == LinkedHashMap.class)
+            return U.newLinkedHashMap(((Map)map).size());
+        else if (cls == TreeMap.class)
+            return new TreeMap<>(((TreeMap<Object, Object>)map).comparator());
+        else if (cls == ConcurrentHashMap8.class)
+            return new ConcurrentHashMap8<>(U.capacity(((Map)map).size()));
+        else if (cls == ConcurrentHashMap.class)
+            return new ConcurrentHashMap<>(U.capacity(((Map)map).size()));
+
+        return null;
+    }
+
+    /**
      * Attempts to create a new map of the same type as {@code map} has. Otherwise returns new {@code HashMap} instance.
      *
      * @param map Original map.
@@ -609,6 +646,47 @@ public class BinaryUtils {
     }
 
     /**
+     * @param col Collection to check.
+     * @return True if this is a collection of a known type.
+     */
+    public static boolean knownCollection(Object col) {
+        Class<?> cls = col == null ? null : col.getClass();
+
+        return cls == HashSet.class ||
+            cls == LinkedHashSet.class ||
+            cls == TreeSet.class ||
+            cls == ConcurrentSkipListSet.class ||
+            cls == ArrayList.class ||
+            cls == LinkedList.class;
+    }
+
+    /**
+     * Attempts to create a new collection of the same known type. Will return null if collection type is
+     * unknown.
+     *
+     * @param col Collection.
+     * @return New empty collection.
+     */
+    public static <V> Collection<V> newKnownCollection(Object col) {
+        Class<?> cls = col == null ? null : col.getClass();
+
+        if (cls == HashSet.class)
+            return U.newHashSet(((Collection)col).size());
+        else if (cls == LinkedHashSet.class)
+            return U.newLinkedHashSet(((Collection)col).size());
+        else if (cls == TreeSet.class)
+            return new TreeSet<>(((TreeSet<Object>)col).comparator());
+        else if (cls == ConcurrentSkipListSet.class)
+            return new ConcurrentSkipListSet<>(((ConcurrentSkipListSet<Object>)col).comparator());
+        else if (cls == ArrayList.class)
+            return new ArrayList<>(((Collection)col).size());
+        else if (cls == LinkedList.class)
+            return new LinkedList<>();
+
+        return null;
+    }
+
+    /**
      * Attempts to create a new set of the same type as {@code set} has. Otherwise returns new {@code HashSet} instance.
      *
      * @param set Original set.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
index 7401434..d22bc75 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
@@ -19,8 +19,11 @@ package org.apache.ignite.internal.processors.cache;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.Map;
-import java.util.Set;
 import org.apache.ignite.cache.affinity.AffinityKeyMapper;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.binary.BinaryUtils;
@@ -161,13 +164,25 @@ import org.apache.ignite.internal.util.typedef.F;
      * @return Unwrapped collection.
      */
     public Collection<Object> unwrapBinariesIfNeeded(Collection<Object> col, boolean keepBinary, boolean cpy) {
-        if (col instanceof ArrayList)
-            return unwrapBinaries((ArrayList<Object>)col, keepBinary, cpy);
+        Collection<Object> col0 = BinaryUtils.newKnownCollection(col);
 
-        if (col instanceof Set)
-            return unwrapBinaries((Set<Object>)col, keepBinary, cpy);
+        if (col0 == null)
+            col0 = new ArrayList<>(col.size());
 
-        Collection<Object> col0 = new ArrayList<>(col.size());
+        for (Object obj : col)
+            col0.add(unwrapBinary(obj, keepBinary, cpy));
+
+        return col0;
+    }
+
+    /**
+     * @param col Collection to unwrap.
+     * @param keepBinary Keep binary flag.
+     * @param cpy Copy flag.
+     * @return Unwrapped collection.
+     */
+    private Collection<Object> unwrapKnownCollection(Collection<Object> col, boolean keepBinary, boolean cpy) {
+        Collection<Object> col0 = BinaryUtils.newKnownCollection(col);
 
         for (Object obj : col)
             col0.add(unwrapBinary(obj, keepBinary, cpy));
@@ -212,44 +227,6 @@ import org.apache.ignite.internal.util.typedef.F;
     }
 
     /**
-     * Unwraps array list.
-     *
-     * @param col List to unwrap.
-     * @return Unwrapped list.
-     */
-    private Collection<Object> unwrapBinaries(ArrayList<Object> col, boolean keepBinary, boolean cpy) {
-        int size = col.size();
-
-        col = new ArrayList<>(col);
-
-        for (int i = 0; i < size; i++) {
-            Object o = col.get(i);
-
-            Object unwrapped = unwrapBinary(o, keepBinary, cpy);
-
-            if (o != unwrapped)
-                col.set(i, unwrapped);
-        }
-
-        return col;
-    }
-
-    /**
-     * Unwraps set with binary.
-     *
-     * @param set Set to unwrap.
-     * @return Unwrapped set.
-     */
-    private Set<Object> unwrapBinaries(Set<Object> set, boolean keepBinary, boolean cpy) {
-        Set<Object> set0 = BinaryUtils.newSet(set);
-
-        for (Object obj : set)
-            set0.add(unwrapBinary(obj, keepBinary, cpy));
-
-        return set0;
-    }
-
-    /**
      * @param o Object to unwrap.
      * @return Unwrapped object.
      */
@@ -267,9 +244,9 @@ import org.apache.ignite.internal.util.typedef.F;
 
             return (key != uKey || val != uVal) ? F.t(uKey, uVal) : o;
         }
-        else if (o instanceof Collection)
-            return unwrapBinariesIfNeeded((Collection<Object>)o, keepBinary, cpy);
-        else if (o instanceof Map)
+        else if (BinaryUtils.knownCollection(o))
+            return unwrapKnownCollection((Collection<Object>)o, keepBinary, cpy);
+        else if (BinaryUtils.knownMap(o))
             return unwrapBinariesIfNeeded((Map<Object, Object>)o, keepBinary, cpy);
         else if (o instanceof Object[])
             return unwrapBinariesInArrayIfNeeded((Object[])o, keepBinary, cpy);
@@ -282,4 +259,24 @@ import org.apache.ignite.internal.util.typedef.F;
 
         return o;
     }
+
+    /**
+     * @param o Object to test.
+     * @return True if collection should be recursively unwrapped.
+     */
+    private boolean knownCollection(Object o) {
+        Class<?> cls = o == null ? null : o.getClass();
+
+        return cls == ArrayList.class || cls == LinkedList.class || cls == HashSet.class;
+    }
+
+    /**
+     * @param o Object to test.
+     * @return True if map should be recursively unwrapped.
+     */
+    private boolean knownMap(Object o) {
+        Class<?> cls = o == null ? null : o.getClass();
+
+        return cls == HashMap.class || cls == LinkedHashMap.class;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index bcc2ab7..c9d6dad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -402,31 +402,30 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
             return new IgniteBiTuple<>(marshalToBinary(tup.get1()), marshalToBinary(tup.get2()));
         }
 
-        if (obj instanceof Collection) {
-            Collection<Object> col = (Collection<Object>)obj;
+        {
+            Collection<Object> pCol = BinaryUtils.newKnownCollection(obj);
 
-            Collection<Object> pCol;
+            if (pCol != null) {
+                Collection<?> col = (Collection<?>)obj;
 
-            if (col instanceof Set)
-                pCol = (Collection<Object>)BinaryUtils.newSet((Set<?>)col);
-            else
-                pCol = new ArrayList<>(col.size());
+                for (Object item : col)
+                    pCol.add(marshalToBinary(item));
 
-            for (Object item : col)
-                pCol.add(marshalToBinary(item));
-
-            return pCol;
+                return pCol;
+            }
         }
 
-        if (obj instanceof Map) {
-            Map<?, ?> map = (Map<?, ?>)obj;
+        {
+            Map<Object, Object> pMap = BinaryUtils.newKnownMap(obj);
 
-            Map<Object, Object> pMap = BinaryUtils.newMap((Map<Object, Object>)obj);
+            if (pMap != null) {
+                Map<?, ?> map = (Map<?, ?>)obj;
 
-            for (Map.Entry<?, ?> e : map.entrySet())
-                pMap.put(marshalToBinary(e.getKey()), marshalToBinary(e.getValue()));
+                for (Map.Entry<?, ?> e : map.entrySet())
+                    pMap.put(marshalToBinary(e.getKey()), marshalToBinary(e.getValue()));
 
-            return pMap;
+                return pMap;
+            }
         }
 
         if (obj instanceof Map.Entry) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 998f7a2..9553656 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -696,9 +696,14 @@ public class GridDhtPartitionDemander {
                                 (IgniteUuid)null, null, EVT_CACHE_REBALANCE_OBJECT_LOADED, entry.value(), true, null,
                                 false, null, null, null, true);
                     }
-                    else if (log.isDebugEnabled())
-                        log.debug("Rebalancing entry is already in cache (will ignore) [key=" + cached.key() +
-                            ", part=" + p + ']');
+                    else {
+                        if (cctx.isSwapOrOffheapEnabled())
+                            cctx.evicts().touch(cached, topVer); // Start tracking.
+
+                        if (log.isDebugEnabled())
+                            log.debug("Rebalancing entry is already in cache (will ignore) [key=" + cached.key() +
+                                ", part=" + p + ']');
+                    }
                 }
                 else if (log.isDebugEnabled())
                     log.debug("Rebalance predicate evaluated to false for entry (will ignore): " + entry);

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index 20b2258..c347b9f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -113,7 +113,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testByte() throws Exception {
-        assertEquals((byte) 100, marshalUnmarshal((byte)100).byteValue());
+        assertEquals((byte)100, marshalUnmarshal((byte)100).byteValue());
     }
 
     /**
@@ -401,7 +401,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         CustomCollections cc = new CustomCollections();
 
         cc.list.add(1);
-        cc.customList.add(2);
+        cc.customList.add(new Value(1));
 
         CustomCollections copiedCc = marshalUnmarshal(cc);
 
@@ -415,6 +415,28 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Test serialization of custom collections.
+     *
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("unchecked")
+    public void testCustomCollections2() throws Exception {
+        CustomArrayList arrList = new CustomArrayList();
+
+        arrList.add(1);
+
+        Object cp = marshalUnmarshal(arrList);
+
+        assert cp.getClass().equals(CustomArrayList.class);
+
+        CustomArrayList customCp = (CustomArrayList)cp;
+
+        assertEquals(customCp.size(), arrList.size());
+
+        assertEquals(customCp.get(0), arrList.get(0));
+    }
+
+    /**
      * Test custom collections with factories.
      *
      * @throws Exception If failed.
@@ -3958,6 +3980,24 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         private Value(int val) {
             this.val = val;
         }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (!(o instanceof Value))
+                return false;
+
+            Value value = (Value)o;
+
+            return val == value.val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return val;
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
index c18554e..613e98c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.cache;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
@@ -306,7 +307,7 @@ public class GridCacheDeploymentSelfTest extends GridCommonAbstractTest {
 
             assert cache != null;
 
-            cache.put(key, Arrays.asList(val1Cls.newInstance()));
+            cache.put(key, new ArrayList<>(Arrays.asList(val1Cls.newInstance())));
 
             info(">>>>>>> First put completed.");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetCustomCollectionsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetCustomCollectionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetCustomCollectionsSelfTest.java
new file mode 100644
index 0000000..aa6fbd5
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetCustomCollectionsSelfTest.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.IgniteCache;
+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.internal.IgniteEx;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class IgniteCacheGetCustomCollectionsSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setMarshaller(null);
+
+        final CacheConfiguration<String, MyMap> mapCacheConfig = new CacheConfiguration<>();
+
+        mapCacheConfig.setCacheMode(CacheMode.PARTITIONED);
+        mapCacheConfig.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        mapCacheConfig.setBackups(1);
+        mapCacheConfig.setName("cache");
+
+        cfg.setCacheConfiguration(mapCacheConfig);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPutGet() throws Exception {
+        startGrids(3);
+
+        try {
+            IgniteEx ignite = grid(0);
+
+            IgniteCache<String, MyMap> cache = ignite.cache("cache");
+
+            Set<String> keys = new HashSet<>();
+
+            for (int i = 0; i < 100; i++) {
+                String key = "a" + i;;
+
+                MyMap map = new MyMap();
+
+                map.put("a", new Value());
+
+                cache.put(key, map);
+
+                map = cache.get(key);
+
+                keys.add(key);
+
+                Object a = map.get("a");
+
+                assertNotNull(a);
+                assertEquals(Value.class, a.getClass());
+            }
+
+            Map<String, MyMap> vals = cache.getAll(keys);
+
+            for (String key : keys) {
+                MyMap map = vals.get(key);
+
+                Object a = map.get("a");
+
+                assertNotNull(a);
+                assertEquals(Value.class, a.getClass());
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MyMap extends HashMap implements Serializable {
+
+    }
+
+    /**
+     *
+     */
+    private static class Value implements Serializable {
+        private int val;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLoadRebalanceEvictionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLoadRebalanceEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLoadRebalanceEvictionSelfTest.java
new file mode 100644
index 0000000..0b1e029
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLoadRebalanceEvictionSelfTest.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import javax.cache.Cache;
+import javax.cache.configuration.FactoryBuilder;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.PA;
+import org.apache.ignite.lang.IgniteBiInClosure;
+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.jetbrains.annotations.Nullable;
+
+/**
+ *
+ */
+public class IgniteCacheLoadRebalanceEvictionSelfTest extends GridCommonAbstractTest {
+    /** */
+    public static final int LRU_MAX_SIZE = 10;
+
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final int ENTRIES_CNT = 10000;
+
+    /** {@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);
+
+        LruEvictionPolicy evictionPolicy = new LruEvictionPolicy<>();
+        evictionPolicy.setMaxSize(LRU_MAX_SIZE);
+
+        CacheConfiguration<String, byte[]> cacheCfg = new CacheConfiguration<>();
+        cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+        cacheCfg.setEvictSynchronized(false);
+        cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+        cacheCfg.setBackups(1);
+        cacheCfg.setReadFromBackup(true);
+        cacheCfg.setEvictionPolicy(evictionPolicy);
+        cacheCfg.setOffHeapMaxMemory(1024 * 1024 * 1024L);
+        cacheCfg.setStatisticsEnabled(true);
+
+        cacheCfg.setWriteThrough(false);
+        cacheCfg.setReadThrough(false);
+
+        cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new Storage()));
+
+        cfg.setCacheConfiguration(cacheCfg);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStartRebalancing() throws Exception {
+        List<IgniteInternalFuture<Object>> futs = new ArrayList<>();
+
+        int gridCnt = 4;
+
+        for (int i = 0; i < gridCnt; i++) {
+            final IgniteEx ig = startGrid(i);
+
+            futs.add(GridTestUtils.runAsync(new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    ig.cache(null).localLoadCache(null);
+
+                    return null;
+                }
+            }));
+        }
+
+        try {
+            for (IgniteInternalFuture<Object> fut : futs)
+                fut.get();
+
+            for (int i = 0; i < gridCnt; i++) {
+                IgniteEx grid = grid(i);
+
+                final IgniteCache<Object, Object> cache = grid.cache(null);
+
+                GridTestUtils.waitForCondition(new PA() {
+                    @Override public boolean apply() {
+                        return cache.localSize(CachePeekMode.ONHEAP) <= 10;
+                    }
+                }, getTestTimeout());
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class Storage extends CacheStoreAdapter<Integer, byte[]> implements Serializable {
+        /** */
+        private static final byte[] data = new byte[1024];
+
+        /** {@inheritDoc} */
+        @Override public void write(Cache.Entry<? extends Integer, ? extends byte[]> e) throws CacheWriterException {
+            throw new UnsupportedOperationException("Unsupported");
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends byte[]>> entries)
+            throws CacheWriterException {
+            throw new UnsupportedOperationException("Unsupported");
+        }
+
+        /** {@inheritDoc} */
+        @Override public void delete(Object key) throws CacheWriterException {
+            throw new UnsupportedOperationException("Unsupported");
+        }
+
+        /** {@inheritDoc} */
+        @Override public void deleteAll(Collection<?> keys) throws CacheWriterException {
+            throw new UnsupportedOperationException("Unsupported");
+        }
+
+        /** {@inheritDoc} */
+        @Override public byte[] load(Integer key) throws CacheLoaderException {
+            return data;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<Integer, byte[]> loadAll(Iterable<? extends Integer> keys) throws CacheLoaderException {
+            Map<Integer, byte[]> res = new HashMap<>();
+
+            for (Integer key : keys)
+                res.put(key, data);
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void loadCache(IgniteBiInClosure<Integer, byte[]> clo,
+            @Nullable Object... args) throws CacheLoaderException {
+
+            for (int i = 0; i < ENTRIES_CNT; i++)
+                clo.apply(i, data);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
index 03ab998..e945ada 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.platform;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
@@ -160,10 +162,10 @@ public class PlatformComputeEchoTask extends ComputeTaskAdapter<Integer, Object>
                     return new int[] { 1 };
 
                 case TYPE_COLLECTION:
-                    return Collections.singletonList(1);
+                    return new ArrayList<>(Collections.singletonList(1));
 
                 case TYPE_MAP:
-                    return Collections.singletonMap(1, 1);
+                    return new HashMap<>(Collections.singletonMap(1, 1));
 
                 case TYPE_BINARY:
                     return new PlatformComputeBinarizable(1);

http://git-wip-us.apache.org/repos/asf/ignite/blob/6524c796/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 fcc8d37..1b8eeda 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
@@ -19,6 +19,7 @@ package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListenerSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheGetCustomCollectionsSelfTest;
 import org.apache.ignite.internal.processors.GridCacheTxLoadFromStoreOnLockSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheClientStoreSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheOffheapMapEntrySelfTest;
@@ -57,6 +58,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheConfigurationDefau
 import org.apache.ignite.internal.processors.cache.IgniteCacheConfigurationTemplateTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheDynamicStopSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheInvokeReadThroughTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheLoadRebalanceEvictionSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheTxCopyOnReadDisabledTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheTxLocalPeekModesTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheTxLocalStoreValueTest;
@@ -286,6 +288,9 @@ public class IgniteCacheTestSuite4 extends TestSuite {
 
         suite.addTestSuite(IgniteCacheSingleGetMessageTest.class);
 
+        suite.addTestSuite(IgniteCacheGetCustomCollectionsSelfTest.class);
+        suite.addTestSuite(IgniteCacheLoadRebalanceEvictionSelfTest.class);
+
         return suite;
     }
 }
\ No newline at end of file


[29/29] ignite git commit: Merge branch 'master' into ignite-2236

Posted by vo...@apache.org.
Merge branch 'master' into ignite-2236


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

Branch: refs/heads/ignite-2236
Commit: 7d8e304d9014869cd71e4470d5faeea9a6c1523a
Parents: 0ca561a d881417
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Jan 18 11:24:24 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Jan 18 11:24:24 2016 +0300

----------------------------------------------------------------------
 assembly/release-fabric-base.xml                |    1 +
 .../org/apache/ignite/IgniteTransactions.java   |    4 +-
 .../org/apache/ignite/igfs/IgfsUserContext.java |   16 +-
 .../igfs/secondary/IgfsSecondaryFileSystem.java |   14 -
 .../apache/ignite/internal/GridComponent.java   |    5 +-
 .../ignite/internal/GridUpdateNotifier.java     |  454 -----
 .../apache/ignite/internal/IgniteKernal.java    |  248 +--
 .../ignite/internal/IgniteVersionUtils.java     |    4 +-
 .../ignite/internal/MarshallerContextImpl.java  |   86 +-
 .../ignite/internal/binary/BinaryUtils.java     |   78 +
 .../internal/cluster/ClusterGroupAdapter.java   |   10 +-
 .../internal/direct/DirectMessageReader.java    |   11 +
 .../internal/direct/DirectMessageWriter.java    |   13 +
 .../direct/state/DirectMessageState.java        |   10 +
 .../stream/v1/DirectByteBufferStreamImplV1.java |    8 +
 .../stream/v2/DirectByteBufferStreamImplV2.java |    8 +
 .../managers/discovery/CustomEventListener.java |    4 +-
 .../discovery/DiscoveryCustomMessage.java       |    9 -
 .../discovery/GridDiscoveryManager.java         |   58 +-
 .../loadbalancer/GridLoadBalancerManager.java   |    8 +-
 .../cache/CacheEntrySerializablePredicate.java  |    3 +-
 .../cache/CacheInvokeDirectResult.java          |    4 +-
 .../processors/cache/CacheObjectContext.java    |   91 +-
 .../cache/DynamicCacheChangeBatch.java          |    5 -
 .../processors/cache/GridCacheAdapter.java      |   14 +-
 .../processors/cache/GridCacheContext.java      |    3 +-
 .../cache/GridCacheEvictionManager.java         |    5 +-
 .../processors/cache/GridCacheIoManager.java    |   28 +-
 .../processors/cache/GridCacheIterator.java     |    4 +-
 .../processors/cache/GridCacheKeySet.java       |    2 +-
 .../GridCachePartitionExchangeManager.java      |   12 +-
 .../processors/cache/GridCacheProcessor.java    |  103 +-
 .../processors/cache/GridCacheReturn.java       |    2 +
 .../processors/cache/GridCacheSwapManager.java  |    7 +-
 .../processors/cache/GridCacheUtils.java        |   92 -
 .../cache/GridCacheValueCollection.java         |    5 +-
 .../processors/cache/IgniteCacheProxy.java      |    6 +-
 .../binary/CacheObjectBinaryProcessorImpl.java  |   33 +-
 .../GridDistributedLockResponse.java            |    2 +-
 .../GridDistributedTxFinishRequest.java         |   11 +-
 .../GridDistributedTxPrepareRequest.java        |    2 +-
 .../GridDistributedTxPrepareResponse.java       |    4 +-
 .../dht/GridClientPartitionTopology.java        |    3 +-
 .../dht/GridDhtAffinityAssignmentResponse.java  |    4 +-
 .../distributed/dht/GridDhtLockFuture.java      |   44 +-
 .../distributed/dht/GridDhtLockRequest.java     |    2 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |    3 +-
 .../dht/GridDhtTransactionalCacheAdapter.java   |    3 +-
 .../distributed/dht/GridDhtTxFinishRequest.java |   90 +-
 .../dht/GridDhtTxFinishResponse.java            |    4 +-
 .../cache/distributed/dht/GridDhtTxLocal.java   |    1 +
 .../distributed/dht/GridDhtTxLocalAdapter.java  |    3 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |    5 +-
 .../dht/GridDhtTxPrepareRequest.java            |    2 +-
 .../dht/atomic/GridDhtAtomicCache.java          |   21 +-
 .../dht/atomic/GridDhtAtomicUpdateRequest.java  |   21 +-
 .../dht/atomic/GridDhtAtomicUpdateResponse.java |    6 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java |   22 +-
 .../atomic/GridNearAtomicUpdateResponse.java    |    4 +-
 .../dht/preloader/GridDhtForceKeysFuture.java   |    8 +-
 .../dht/preloader/GridDhtForceKeysResponse.java |    6 +-
 .../GridDhtPartitionDemandMessage.java          |    6 +-
 .../dht/preloader/GridDhtPartitionDemander.java |   11 +-
 .../GridDhtPartitionSupplyMessageV2.java        |    6 +-
 .../GridDhtPartitionsExchangeFuture.java        |    8 +-
 .../preloader/GridDhtPartitionsFullMessage.java |    2 +-
 .../GridDhtPartitionsSingleMessage.java         |    4 +-
 .../distributed/near/GridNearCacheAdapter.java  |   11 +-
 .../distributed/near/GridNearGetResponse.java   |    4 +-
 ...ridNearOptimisticTxPrepareFutureAdapter.java |    6 +-
 .../near/GridNearSingleGetResponse.java         |    2 +-
 .../near/GridNearTxFinishFuture.java            |  432 +++--
 .../near/GridNearTxFinishRequest.java           |    5 +
 .../near/GridNearTxFinishResponse.java          |    4 +-
 .../cache/distributed/near/GridNearTxLocal.java |    2 +-
 .../near/GridNearTxPrepareResponse.java         |    4 +-
 .../local/atomic/GridLocalAtomicCache.java      |   17 +-
 .../cache/query/GridCacheQueryRequest.java      |   16 +-
 .../cache/query/GridCacheQueryResponse.java     |   18 +-
 .../continuous/CacheContinuousQueryEntry.java   |   70 +-
 .../cache/transactions/IgniteInternalTx.java    |    6 +
 .../cache/transactions/IgniteTxAdapter.java     |   23 +-
 .../cache/transactions/IgniteTxEntry.java       |   11 +-
 .../cache/transactions/IgniteTxHandler.java     |   26 +-
 .../transactions/IgniteTxLocalAdapter.java      |    6 +-
 .../cache/transactions/IgniteTxManager.java     |   20 +
 .../processors/cluster/ClusterProcessor.java    |  174 ++
 .../processors/cluster/GridUpdateNotifier.java  |  457 +++++
 .../continuous/AbstractContinuousMessage.java   |    5 -
 .../continuous/GridContinuousProcessor.java     |   13 +-
 .../datastreamer/DataStreamerRequest.java       |    1 +
 .../datastructures/DataStructuresProcessor.java |   11 +-
 .../GridCacheAtomicStampedImpl.java             |    5 +-
 .../processors/hadoop/HadoopPayloadAware.java   |   28 +
 .../processors/igfs/IgfsAckMessage.java         |    4 +-
 .../ignite/internal/processors/igfs/IgfsEx.java |   13 -
 .../internal/processors/igfs/IgfsImpl.java      |   16 +-
 .../internal/processors/igfs/IgfsPaths.java     |   62 +-
 .../internal/processors/igfs/IgfsProcessor.java |    8 +-
 .../igfs/IgfsSecondaryFileSystemImpl.java       |   11 -
 .../dotnet/PlatformDotNetCacheStore.java        |    4 +-
 .../handlers/cache/GridCacheCommandHandler.java |    6 +-
 .../top/GridTopologyCommandHandler.java         |    3 +-
 .../org/apache/ignite/internal/util/F0.java     |  325 +++-
 .../internal/util/GridExecutionStatistics.java  |    4 +-
 .../ignite/internal/util/GridStringBuilder.java |   19 +
 .../ignite/internal/util/IgniteUtils.java       |   14 +-
 .../ignite/internal/util/lang/GridFunc.java     | 1764 ++++++++++++++----
 .../ignite/internal/util/lang/GridTuple3.java   |    1 +
 .../ignite/internal/util/lang/GridTuple4.java   |    1 +
 .../ignite/internal/util/lang/GridTuple5.java   |    1 +
 .../ignite/internal/util/lang/GridTuple6.java   |    1 +
 .../ignite/internal/util/lang/GridTupleV.java   |    1 +
 .../internal/util/nio/GridDirectParser.java     |   52 +-
 .../visor/node/VisorIgfsConfiguration.java      |   43 -
 .../java/org/apache/ignite/lang/IgniteUuid.java |    2 +-
 .../communication/tcp/TcpCommunicationSpi.java  |    9 +-
 .../ignite/spi/discovery/DiscoverySpi.java      |    2 +
 .../tcp/ipfinder/TcpDiscoveryIpFinder.java      |   14 +-
 .../memory/MemoryEventStorageSpi.java           |    1 -
 .../ignite/stream/socket/SocketStreamer.java    |    3 +-
 .../internal/GridUpdateNotifierSelfTest.java    |  137 --
 ...UpdateNotifierPerClusterSettingSelfTest.java |  130 ++
 .../binary/BinaryMarshallerSelfTest.java        |   44 +-
 ...cheAbstractFullApiMultithreadedSelfTest.java |   13 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java |    2 +-
 .../cache/GridCacheDeploymentSelfTest.java      |    3 +-
 .../cache/GridCacheLuceneQueryIndexTest.java    |    4 +-
 .../processors/cache/GridCacheStopSelfTest.java |    2 +-
 ...IgniteCacheGetCustomCollectionsSelfTest.java |  128 ++
 ...gniteCacheLoadRebalanceEvictionSelfTest.java |  188 ++
 .../cache/IgniteDynamicCacheStartSelfTest.java  |   30 +-
 ...niteDynamicCacheStartStopConcurrentTest.java |  119 ++
 ...eMarshallerCacheConcurrentReadWriteTest.java |  189 ++
 .../IgniteClientDataStructuresAbstractTest.java |    3 +
 .../distributed/GridCacheEventAbstractTest.java |    2 +-
 .../dht/GridCacheTxNodeFailureSelfTest.java     |   13 +-
 .../IgniteCacheCommitDelayTxRecoveryTest.java   |  376 ++++
 .../IgniteCachePutRetryAbstractSelfTest.java    |   36 +-
 ...gniteCachePutRetryTransactionalSelfTest.java |   21 +
 .../cluster/GridUpdateNotifierSelfTest.java     |  140 ++
 .../continuous/GridEventConsumeSelfTest.java    |    3 +
 .../processors/igfs/IgfsAbstractSelfTest.java   |    8 +-
 .../igfs/IgfsExUniversalFileSystemAdapter.java  |   11 +-
 .../igfs/UniversalFileSystemAdapter.java        |    5 +-
 .../IpcSharedMemoryCrashDetectionSelfTest.java  |   16 +-
 .../internal/util/nio/GridNioSelfTest.java      |   11 +-
 .../ignite/lang/GridBasicPerformanceTest.java   |   10 +-
 .../ignite/lang/GridFuncPerformanceTest.java    |  102 +
 .../ignite/loadtest/GridLoadTestStatistics.java |    2 +-
 .../platform/PlatformComputeEchoTask.java       |    6 +-
 ...dTcpCommunicationSpiRecoveryAckSelfTest.java |    1 -
 ...CommunicationRecoveryAckClosureSelfTest.java |   19 +-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java |    2 +
 .../startup/GridRandomCommandLineLoader.java    |    4 +-
 .../ignite/testframework/GridTestUtils.java     |   27 +
 .../junits/common/GridCommonAbstractTest.java   |   34 +-
 .../ignite/testsuites/IgniteBasicTestSuite.java |    2 +
 .../testsuites/IgniteCacheTestSuite4.java       |    7 +
 .../testsuites/IgniteCacheTestSuite5.java       |    2 +
 .../IgniteCacheTxRecoverySelfTestSuite.java     |    3 +
 .../testsuites/IgniteKernalSelfTestSuite.java   |    4 +-
 .../hadoop/fs/BasicHadoopFileSystemFactory.java |  209 +++
 .../fs/CachingHadoopFileSystemFactory.java      |   86 +
 .../hadoop/fs/HadoopFileSystemFactory.java      |   52 +
 .../fs/IgniteHadoopIgfsSecondaryFileSystem.java |  264 +--
 .../hadoop/fs/v1/IgniteHadoopFileSystem.java    |  144 +-
 .../hadoop/fs/v2/IgniteHadoopFileSystem.java    |  115 +-
 .../processors/hadoop/HadoopClassLoader.java    |  689 +++++--
 .../hadoop/SecondaryFileSystemProvider.java     |  139 --
 .../hadoop/fs/HadoopFileSystemCacheUtils.java   |    8 +-
 .../hadoop/fs/HadoopLazyConcurrentMap.java      |    5 +-
 .../hadoop/v2/HadoopNativeCodeLoader.java       |   74 -
 .../ignite/igfs/Hadoop1DualAbstractTest.java    |   14 +-
 .../igfs/HadoopFIleSystemFactorySelfTest.java   |  326 ++++
 ...oopFileSystemUniversalFileSystemAdapter.java |   53 +-
 ...oopSecondaryFileSystemConfigurationTest.java |   27 +-
 .../IgniteHadoopFileSystemAbstractSelfTest.java |   71 +-
 .../hadoop/HadoopAbstractWordCountTest.java     |   46 +-
 .../hadoop/HadoopClassLoaderTest.java           |  101 +-
 .../hadoop/HadoopMapReduceEmbeddedSelfTest.java |    2 +-
 .../processors/hadoop/HadoopMapReduceTest.java  |   15 +-
 .../hadoop/HadoopSnappyFullMapReduceTest.java   |   28 +
 .../processors/hadoop/HadoopSnappyTest.java     |  102 +
 .../processors/hadoop/HadoopTasksV2Test.java    |    2 +-
 .../hadoop/deps/CircularWIthHadoop.java         |   32 +
 .../hadoop/deps/CircularWithoutHadoop.java      |   27 +
 .../processors/hadoop/deps/WithCast.java        |   41 +
 .../hadoop/deps/WithClassAnnotation.java        |   28 +
 .../hadoop/deps/WithConstructorInvocation.java  |   31 +
 .../processors/hadoop/deps/WithExtends.java     |   27 +
 .../processors/hadoop/deps/WithField.java       |   29 +
 .../processors/hadoop/deps/WithImplements.java  |   36 +
 .../hadoop/deps/WithIndirectField.java          |   27 +
 .../processors/hadoop/deps/WithInitializer.java |   33 +
 .../processors/hadoop/deps/WithInnerClass.java  |   31 +
 .../hadoop/deps/WithLocalVariable.java          |   38 +
 .../hadoop/deps/WithMethodAnnotation.java       |   32 +
 .../hadoop/deps/WithMethodArgument.java         |   31 +
 .../hadoop/deps/WithMethodCheckedException.java |   31 +
 .../hadoop/deps/WithMethodInvocation.java       |   31 +
 .../hadoop/deps/WithMethodReturnType.java       |   31 +
 .../hadoop/deps/WithMethodRuntimeException.java |   31 +
 .../processors/hadoop/deps/WithOuterClass.java  |   38 +
 .../hadoop/deps/WithParameterAnnotation.java    |   31 +
 .../processors/hadoop/deps/WithStaticField.java |   29 +
 .../hadoop/deps/WithStaticInitializer.java      |   34 +
 .../processors/hadoop/deps/Without.java         |   25 +
 .../hadoop/examples/HadoopWordCount1Reduce.java |    1 +
 .../hadoop/examples/HadoopWordCount2.java       |   18 +-
 .../examples/HadoopWordCount2Reducer.java       |    1 +
 .../testsuites/IgniteHadoopTestSuite.java       |   24 +-
 .../query/h2/opt/GridH2TreeIndex.java           |    4 +-
 modules/storm/README.txt                        |   37 +
 modules/storm/licenses/apache-2.0.txt           |  202 ++
 modules/storm/pom.xml                           |  104 ++
 .../ignite/stream/storm/StormStreamer.java      |  304 +++
 .../ignite/stream/storm/package-info.java       |   22 +
 .../storm/IgniteStormStreamerSelfTestSuite.java |   38 +
 .../storm/StormIgniteStreamerSelfTest.java      |  184 ++
 .../ignite/stream/storm/TestStormSpout.java     |  141 ++
 .../storm/src/test/resources/example-ignite.xml |   71 +
 .../yardstick/cache/IgniteGetTxBenchmark.java   |   30 +
 .../tcp/ipfinder/zk/ZookeeperIpFinderTest.java  |   69 +-
 pom.xml                                         |    1 +
 225 files changed, 9255 insertions(+), 2688 deletions(-)
----------------------------------------------------------------------


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

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

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d8e304d/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------


[02/29] ignite git commit: Merge remote-tracking branch 'remotes/origin/ignite-1.5' into ignite-1.5.1-2

Posted by vo...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-1.5' into ignite-1.5.1-2


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

Branch: refs/heads/ignite-2236
Commit: cca90c77f56db5d96f99610ca8dc48f6066ac1b3
Parents: 8e6b365 f1f8cda
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Dec 30 09:57:01 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Dec 30 09:57:01 2015 +0300

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



[09/29] ignite git commit: IGNITE-2206: Hadoop file system creation is now abstracted out using factory interface.

Posted by vo...@apache.org.
IGNITE-2206: Hadoop file system creation is now abstracted out using factory interface.


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

Branch: refs/heads/ignite-2236
Commit: 8ed73b4af8024167daeb4775e084b1f6a23fbf13
Parents: 7d58d14
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jan 5 10:59:31 2016 +0400
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jan 5 10:59:31 2016 +0400

----------------------------------------------------------------------
 .../org/apache/ignite/igfs/IgfsUserContext.java |  16 +-
 .../igfs/secondary/IgfsSecondaryFileSystem.java |  14 -
 .../processors/hadoop/HadoopPayloadAware.java   |  28 ++
 .../ignite/internal/processors/igfs/IgfsEx.java |  13 -
 .../internal/processors/igfs/IgfsImpl.java      |  16 +-
 .../internal/processors/igfs/IgfsPaths.java     |  62 +++-
 .../igfs/IgfsSecondaryFileSystemImpl.java       |  11 -
 .../visor/node/VisorIgfsConfiguration.java      |  43 ---
 .../processors/igfs/IgfsAbstractSelfTest.java   |   8 +-
 .../igfs/IgfsExUniversalFileSystemAdapter.java  |  11 +-
 .../igfs/UniversalFileSystemAdapter.java        |   5 +-
 .../hadoop/fs/BasicHadoopFileSystemFactory.java | 209 ++++++++++++
 .../fs/CachingHadoopFileSystemFactory.java      |  86 +++++
 .../hadoop/fs/HadoopFileSystemFactory.java      |  52 +++
 .../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 264 +++++++--------
 .../hadoop/fs/v1/IgniteHadoopFileSystem.java    | 144 +++++---
 .../hadoop/fs/v2/IgniteHadoopFileSystem.java    | 115 ++++---
 .../hadoop/SecondaryFileSystemProvider.java     | 139 --------
 .../hadoop/fs/HadoopFileSystemCacheUtils.java   |   8 +-
 .../hadoop/fs/HadoopLazyConcurrentMap.java      |   5 +-
 .../ignite/igfs/Hadoop1DualAbstractTest.java    |  14 +-
 .../igfs/HadoopFIleSystemFactorySelfTest.java   | 326 +++++++++++++++++++
 ...oopFileSystemUniversalFileSystemAdapter.java |  53 +--
 ...oopSecondaryFileSystemConfigurationTest.java |  27 +-
 .../IgniteHadoopFileSystemAbstractSelfTest.java |  71 ++--
 .../testsuites/IgniteHadoopTestSuite.java       |   3 +
 26 files changed, 1191 insertions(+), 552 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java
index 8db4e23..1e1cd31 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java
@@ -34,24 +34,24 @@ public abstract class IgfsUserContext {
      * The main contract of this method is that {@link #currentUser()} method invoked
      * inside closure always returns 'user' this callable executed with.
      * @param user the user name to invoke closure on behalf of.
-     * @param clo the closure to execute
+     * @param c the closure to execute
      * @param <T> The type of closure result.
      * @return the result of closure execution.
      * @throws IllegalArgumentException if user name is null or empty String or if the closure is null.
      */
-    public static <T> T doAs(String user, final IgniteOutClosure<T> clo) {
+    public static <T> T doAs(String user, final IgniteOutClosure<T> c) {
         if (F.isEmpty(user))
             throw new IllegalArgumentException("Failed to use null or empty user name.");
 
         final String ctxUser = userStackThreadLocal.get();
 
         if (F.eq(ctxUser, user))
-            return clo.apply(); // correct context is already there
+            return c.apply(); // correct context is already there
 
         userStackThreadLocal.set(user);
 
         try {
-            return clo.apply();
+            return c.apply();
         }
         finally {
             userStackThreadLocal.set(ctxUser);
@@ -81,24 +81,24 @@ public abstract class IgfsUserContext {
      *  }
      * </pre>
      * @param user the user name to invoke closure on behalf of.
-     * @param clbl the Callable to execute
+     * @param c the Callable to execute
      * @param <T> The type of callable result.
      * @return the result of closure execution.
      * @throws IllegalArgumentException if user name is null or empty String or if the closure is null.
      */
-    public static <T> T doAs(String user, final Callable<T> clbl) throws Exception {
+    public static <T> T doAs(String user, final Callable<T> c) throws Exception {
         if (F.isEmpty(user))
             throw new IllegalArgumentException("Failed to use null or empty user name.");
 
         final String ctxUser = userStackThreadLocal.get();
 
         if (F.eq(ctxUser, user))
-            return clbl.call(); // correct context is already there
+            return c.call(); // correct context is already there
 
         userStackThreadLocal.set(user);
 
         try {
-            return clbl.call();
+            return c.call();
         }
         finally {
             userStackThreadLocal.set(ctxUser);

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
index ca6ecb7..3f124eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
@@ -192,18 +192,4 @@ public interface IgfsSecondaryFileSystem {
      * @throws IgniteException In case of error.
      */
     public long usedSpaceSize() throws IgniteException;
-
-    /**
-     * Gets the implementation specific properties of file system.
-     *
-     * @return Map of properties.
-     */
-    public Map<String,String> properties();
-
-
-    /**
-     * Closes the secondary file system.
-     * @throws IgniteException in case of an error.
-     */
-    public void close() throws IgniteException;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopPayloadAware.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopPayloadAware.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopPayloadAware.java
new file mode 100644
index 0000000..9b79729
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopPayloadAware.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop;
+
+/**
+ * Gets payload for Hadoop secondary file system.
+ */
+public interface HadoopPayloadAware {
+    /**
+     * @return Payload.
+     */
+    public Object getPayload();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
index 8ff7247..cf268e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
@@ -43,19 +43,6 @@ public interface IgfsEx extends IgniteFileSystem {
     /** File property: prefer writes to local node. */
     public static final String PROP_PREFER_LOCAL_WRITES = "locWrite";
 
-    /** Property name for path to Hadoop configuration. */
-    public static final String SECONDARY_FS_CONFIG_PATH = "SECONDARY_FS_CONFIG_PATH";
-
-    /** Property name for URI of file system. */
-    public static final String SECONDARY_FS_URI = "SECONDARY_FS_URI";
-
-    /** Property name for default user name of file system.
-     * NOTE: for secondary file system this is just a default user name, which is used
-     * when the 2ndary filesystem is used outside of any user context.
-     * If another user name is set in the context, 2ndary file system will work on behalf
-     * of that user, which is different from the default. */
-     public static final String SECONDARY_FS_USER_NAME = "SECONDARY_FS_USER_NAME";
-
     /**
      * Stops IGFS cleaning all used resources.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/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 680e660..38914ea 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
@@ -72,6 +72,7 @@ import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.managers.communication.GridMessageListener;
 import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
+import org.apache.ignite.internal.processors.hadoop.HadoopPayloadAware;
 import org.apache.ignite.internal.processors.task.GridInternal;
 import org.apache.ignite.internal.util.GridSpinBusyLock;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
@@ -87,6 +88,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.lifecycle.LifecycleAware;
 import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.thread.IgniteThreadPoolExecutor;
 import org.jetbrains.annotations.Nullable;
@@ -200,6 +202,9 @@ public final class IgfsImpl implements IgfsEx {
         data = igfsCtx.data();
         secondaryFs = cfg.getSecondaryFileSystem();
 
+        if (secondaryFs instanceof LifecycleAware)
+            ((LifecycleAware) secondaryFs).start();
+
         /* Default IGFS mode. */
         IgfsMode dfltMode;
 
@@ -256,8 +261,12 @@ public final class IgfsImpl implements IgfsEx {
 
         modeRslvr = new IgfsModeResolver(dfltMode, modes);
 
-        secondaryPaths = new IgfsPaths(secondaryFs == null ? null : secondaryFs.properties(), dfltMode,
-            modeRslvr.modesOrdered());
+        Object secondaryFsPayload = null;
+
+        if (secondaryFs instanceof HadoopPayloadAware)
+            secondaryFsPayload = ((HadoopPayloadAware) secondaryFs).getPayload();
+
+        secondaryPaths = new IgfsPaths(secondaryFsPayload, dfltMode, modeRslvr.modesOrdered());
 
         // Check whether IGFS LRU eviction policy is set on data cache.
         String dataCacheName = igfsCtx.configuration().getDataCacheName();
@@ -305,7 +314,8 @@ public final class IgfsImpl implements IgfsEx {
                 batch.cancel();
 
             try {
-                secondaryFs.close();
+                if (secondaryFs instanceof LifecycleAware)
+                    ((LifecycleAware)secondaryFs).stop();
             }
             catch (Exception e) {
                 log.error("Failed to close secondary file system.", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/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 fbf89ce..4a79259 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
@@ -17,17 +17,21 @@
 
 package org.apache.ignite.internal.processors.igfs;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
+
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.igfs.IgfsMode;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -37,8 +41,8 @@ public class IgfsPaths implements Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** Additional secondary file system properties. */
-    private Map<String, String> props;
+    /** */
+    private byte[] payloadBytes;
 
     /** Default IGFS mode. */
     private IgfsMode dfltMode;
@@ -56,22 +60,25 @@ public class IgfsPaths implements Externalizable {
     /**
      * Constructor.
      *
-     * @param props Additional secondary file system properties.
+     * @param payload Payload.
      * @param dfltMode Default IGFS mode.
      * @param pathModes Path modes.
+     * @throws IgniteCheckedException If failed.
      */
-    public IgfsPaths(Map<String, String> props, IgfsMode dfltMode, @Nullable List<T2<IgfsPath,
-        IgfsMode>> pathModes) {
-        this.props = props;
+    public IgfsPaths(Object payload, IgfsMode dfltMode, @Nullable List<T2<IgfsPath, IgfsMode>> pathModes)
+        throws IgniteCheckedException {
         this.dfltMode = dfltMode;
         this.pathModes = pathModes;
-    }
 
-    /**
-     * @return Secondary file system properties.
-     */
-    public Map<String, String> properties() {
-        return props;
+        if (payload == null)
+            payloadBytes = null;
+        else {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+            new JdkMarshaller().marshal(payload, out);
+
+            payloadBytes = out.toByteArray();
+        }
     }
 
     /**
@@ -88,9 +95,25 @@ public class IgfsPaths implements Externalizable {
         return pathModes;
     }
 
+    /**
+     * @return Payload.
+     *
+     * @throws IgniteCheckedException If failed to deserialize the payload.
+     */
+    @Nullable public Object getPayload(ClassLoader clsLdr) throws IgniteCheckedException {
+        if (payloadBytes == null)
+            return null;
+        else {
+            ByteArrayInputStream in = new ByteArrayInputStream(payloadBytes);
+
+            return new JdkMarshaller().unmarshal(in, clsLdr);
+        }
+    }
+
     /** {@inheritDoc} */
     @Override public void writeExternal(ObjectOutput out) throws IOException {
-        U.writeStringMap(out, props);
+        U.writeByteArray(out, payloadBytes);
+
         U.writeEnum(out, dfltMode);
 
         if (pathModes != null) {
@@ -98,7 +121,10 @@ public class IgfsPaths implements Externalizable {
             out.writeInt(pathModes.size());
 
             for (T2<IgfsPath, IgfsMode> pathMode : pathModes) {
+                assert pathMode.getKey() != null;
+
                 pathMode.getKey().writeExternal(out);
+
                 U.writeEnum(out, pathMode.getValue());
             }
         }
@@ -108,7 +134,8 @@ public class IgfsPaths implements Externalizable {
 
     /** {@inheritDoc} */
     @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        props = U.readStringMap(in);
+        payloadBytes = U.readByteArray(in);
+
         dfltMode = IgfsMode.fromOrdinal(in.readByte());
 
         if (in.readBoolean()) {
@@ -118,11 +145,10 @@ public class IgfsPaths implements Externalizable {
 
             for (int i = 0; i < size; i++) {
                 IgfsPath path = new IgfsPath();
-                path.readExternal(in);
 
-                T2<IgfsPath, IgfsMode> entry = new T2<>(path, IgfsMode.fromOrdinal(in.readByte()));
+                path.readExternal(in);
 
-                pathModes.add(entry);
+                pathModes.add(new T2<>(path, IgfsMode.fromOrdinal(in.readByte())));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
index 23d6322..44e858f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.igfs;
 
 import java.io.OutputStream;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.igfs.IgfsFile;
@@ -116,14 +115,4 @@ class IgfsSecondaryFileSystemImpl implements IgfsSecondaryFileSystem {
     @Override public long usedSpaceSize() throws IgniteException {
         return igfs.usedSpaceSize();
     }
-
-    /** {@inheritDoc} */
-    @Override public Map<String, String> properties() {
-        return Collections.emptyMap();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void close() throws IgniteException {
-        // No-op.
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
index e85484d..ea0e721 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
@@ -29,9 +29,6 @@ import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_CONFIG_PATH;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_URI;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_USER_NAME;
 import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass;
 
 /**
@@ -65,15 +62,6 @@ public class VisorIgfsConfiguration implements Serializable {
     /** Number of batches that can be concurrently sent to remote node. */
     private int perNodeParallelBatchCnt;
 
-    /** URI of the secondary Hadoop file system. */
-    private String secondaryHadoopFileSysUri;
-
-    /** Path for the secondary hadoop file system config. */
-    private String secondaryHadoopFileSysCfgPath;
-
-    /** User name for the secondary hadoop file system config. */
-    private String secondaryHadoopFileSysUserName;
-
     /** IGFS instance mode. */
     private IgfsMode dfltMode;
 
@@ -141,16 +129,6 @@ public class VisorIgfsConfiguration implements Serializable {
         cfg.perNodeBatchSize = igfs.getPerNodeBatchSize();
         cfg.perNodeParallelBatchCnt = igfs.getPerNodeParallelBatchCount();
 
-        IgfsSecondaryFileSystem secFs = igfs.getSecondaryFileSystem();
-
-        if (secFs != null) {
-            Map<String, String> props = secFs.properties();
-
-            cfg.secondaryHadoopFileSysUri = props.get(SECONDARY_FS_URI);
-            cfg.secondaryHadoopFileSysCfgPath = props.get(SECONDARY_FS_CONFIG_PATH);
-            cfg.secondaryHadoopFileSysUserName = props.get(SECONDARY_FS_USER_NAME);
-        }
-
         cfg.dfltMode = igfs.getDefaultMode();
         cfg.pathModes = igfs.getPathModes();
         cfg.dualModePutExecutorSrvc = compactClass(igfs.getDualModePutExecutorService());
@@ -251,27 +229,6 @@ public class VisorIgfsConfiguration implements Serializable {
     }
 
     /**
-     * @return URI of the secondary Hadoop file system.
-     */
-    @Nullable public String secondaryHadoopFileSystemUri() {
-        return secondaryHadoopFileSysUri;
-    }
-
-    /**
-     * @return User name of the secondary Hadoop file system.
-     */
-    @Nullable public String secondaryHadoopFileSystemUserName() {
-        return secondaryHadoopFileSysUserName;
-    }
-
-    /**
-     * @return Path for the secondary hadoop file system config.
-     */
-    @Nullable public String secondaryHadoopFileSystemConfigPath() {
-        return secondaryHadoopFileSysCfgPath;
-    }
-
-    /**
      * @return IGFS instance mode.
      */
     public IgfsMode defaultMode() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/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 b290303..015b992 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
@@ -2744,7 +2744,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         finally {
             U.closeQuiet(os);
 
-            IgfsEx igfsEx = uni.getAdapter(IgfsEx.class);
+            IgfsEx igfsEx = uni.unwrap(IgfsEx.class);
 
             if (igfsEx != null)
                 awaitFileClose(igfsEx.asSecondary(), file);
@@ -2868,7 +2868,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws IgniteCheckedException If failed.
      */
     protected void checkExist(UniversalFileSystemAdapter uni, IgfsPath... paths) throws IgniteCheckedException {
-        IgfsEx ex = uni.getAdapter(IgfsEx.class);
+        IgfsEx ex = uni.unwrap(IgfsEx.class);
         for (IgfsPath path : paths) {
             if (ex != null)
                 assert ex.context().meta().fileId(path) != null : "Path doesn't exist [igfs=" + ex.name() +
@@ -2921,7 +2921,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     protected void checkNotExist(UniversalFileSystemAdapter uni, IgfsPath... paths) throws Exception {
-        IgfsEx ex = uni.getAdapter(IgfsEx.class);
+        IgfsEx ex = uni.unwrap(IgfsEx.class);
         for (IgfsPath path : paths) {
             if (ex != null)
                 assert ex.context().meta().fileId(path) == null : "Path exists [igfs=" + ex.name() + ", path=" +
@@ -3222,7 +3222,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      */
     @SuppressWarnings("unchecked")
     public static void clear(UniversalFileSystemAdapter uni) throws Exception {
-        IgfsEx igfsEx = uni.getAdapter(IgfsEx.class);
+        IgfsEx igfsEx = uni.unwrap(IgfsEx.class);
 
         if (igfsEx != null)
             clear(igfsEx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java
index 7583364..c6bef72 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsExUniversalFileSystemAdapter.java
@@ -28,7 +28,6 @@ import org.apache.ignite.igfs.IgfsPath;
  * Universal adapter over {@link IgfsEx} filesystem.
  */
 public class IgfsExUniversalFileSystemAdapter implements UniversalFileSystemAdapter {
-
     /** The wrapped igfs. */
     private final IgfsEx igfsEx;
 
@@ -69,18 +68,14 @@ public class IgfsExUniversalFileSystemAdapter implements UniversalFileSystemAdap
     @Override public boolean delete(String path, boolean recursive) throws IOException {
         IgfsPath igfsPath = new IgfsPath(path);
 
-        boolean del = igfsEx.delete(igfsPath, recursive);
-
-        return del;
+        return igfsEx.delete(igfsPath, recursive);
     }
 
     /** {@inheritDoc} */
     @Override public InputStream openInputStream(String path) throws IOException {
         IgfsPath igfsPath = new IgfsPath(path);
 
-        IgfsInputStreamAdapter adapter = igfsEx.open(igfsPath);
-
-        return adapter;
+        return igfsEx.open(igfsPath);
     }
 
     /** {@inheritDoc} */
@@ -97,7 +92,7 @@ public class IgfsExUniversalFileSystemAdapter implements UniversalFileSystemAdap
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T getAdapter(Class<T> clazz) {
+    @Override public <T> T unwrap(Class<T> clazz) {
         if (clazz == IgfsEx.class)
             return (T)igfsEx;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java
index ba8c164..eef0057 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/UniversalFileSystemAdapter.java
@@ -31,8 +31,9 @@ public interface UniversalFileSystemAdapter {
     /**
      * Gets name of the FS.
      * @return name of this file system.
+     * @throws IOException in case of failure.
      */
-    String name();
+    String name() throws IOException;
 
     /**
      * Answers if a file denoted by path exists.
@@ -93,5 +94,5 @@ public interface UniversalFileSystemAdapter {
      * @param <T> The type we need to adapt to.
      * @return the adapter object of the given type.
      */
-    <T> T getAdapter(Class<T> clazz);
+    <T> T unwrap(Class<T> clazz);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
new file mode 100644
index 0000000..1e2bbf2
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
@@ -0,0 +1,209 @@
+/*
+ * 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.hadoop.fs;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
+import org.apache.ignite.internal.processors.hadoop.HadoopUtils;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Arrays;
+
+/**
+ * Simple Hadoop file system factory which delegates to {@code FileSystem.get()} on each call.
+ * <p>
+ * If {@code "fs.[prefix].impl.disable.cache"} is set to {@code true}, file system instances will be cached by Hadoop.
+ */
+public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory, Externalizable, LifecycleAware {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** File system URI. */
+    protected String uri;
+
+    /** File system config paths. */
+    protected String[] cfgPaths;
+
+    /** Configuration of the secondary filesystem, never null. */
+    protected transient Configuration cfg;
+
+    /** Resulting URI. */
+    protected transient URI fullUri;
+
+    /**
+     * Constructor.
+     */
+    public BasicHadoopFileSystemFactory() {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public FileSystem get(String usrName) throws IOException {
+        return create0(IgfsUtils.fixUserName(usrName));
+    }
+
+    /**
+     * Internal file system create routine.
+     *
+     * @param usrName User name.
+     * @return File system.
+     * @throws IOException If failed.
+     */
+    protected FileSystem create0(String usrName) throws IOException {
+        assert cfg != null;
+
+        try {
+            return FileSystem.get(fullUri, cfg, usrName);
+        }
+        catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+
+            throw new IOException("Failed to create file system due to interrupt.", e);
+        }
+    }
+
+    /**
+     * Gets file system URI.
+     * <p>
+     * This URI will be used as a first argument when calling {@link FileSystem#get(URI, Configuration, String)}.
+     * <p>
+     * If not set, default URI will be picked from file system configuration using
+     * {@link FileSystem#getDefaultUri(Configuration)} method.
+     *
+     * @return File system URI.
+     */
+    @Nullable public String getUri() {
+        return uri;
+    }
+
+    /**
+     * Sets file system URI. See {@link #getUri()} for more information.
+     *
+     * @param uri File system URI.
+     */
+    public void setUri(@Nullable String uri) {
+        this.uri = uri;
+    }
+
+    /**
+     * Gets paths to additional file system configuration files (e.g. core-site.xml).
+     * <p>
+     * Path could be either absolute or relative to {@code IGNITE_HOME} environment variable.
+     * <p>
+     * All provided paths will be loaded in the order they provided and then applied to {@link Configuration}. It means
+     * that path order might be important in some cases.
+     * <p>
+     * <b>NOTE!</b> Factory can be serialized and transferred to other machines where instance of
+     * {@link IgniteHadoopFileSystem} resides. Corresponding paths must exist on these machines as well.
+     *
+     * @return Paths to file system configuration files.
+     */
+    @Nullable public String[] getConfigPaths() {
+        return cfgPaths;
+    }
+
+    /**
+     * Set paths to additional file system configuration files (e.g. core-site.xml). See {@link #getConfigPaths()} for
+     * more information.
+     *
+     * @param cfgPaths Paths to file system configuration files.
+     */
+    public void setConfigPaths(String... cfgPaths) {
+        this.cfgPaths = cfgPaths;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start() throws IgniteException {
+        cfg = HadoopUtils.safeCreateConfiguration();
+
+        if (cfgPaths != null) {
+            for (String cfgPath : cfgPaths) {
+                if (cfgPath == null)
+                    throw new NullPointerException("Configuration path cannot be null: " + Arrays.toString(cfgPaths));
+                else {
+                    URL url = U.resolveIgniteUrl(cfgPath);
+
+                    if (url == null) {
+                        // If secConfPath is given, it should be resolvable:
+                        throw new IgniteException("Failed to resolve secondary file system configuration path " +
+                            "(ensure that it exists locally and you have read access to it): " + cfgPath);
+                    }
+
+                    cfg.addResource(url);
+                }
+            }
+        }
+
+        // If secondary fs URI is not given explicitly, try to get it from the configuration:
+        if (uri == null)
+            fullUri = FileSystem.getDefaultUri(cfg);
+        else {
+            try {
+                fullUri = new URI(uri);
+            }
+            catch (URISyntaxException use) {
+                throw new IgniteException("Failed to resolve secondary file system URI: " + uri);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop() throws IgniteException {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        U.writeString(out, uri);
+
+        if (cfgPaths != null) {
+            out.writeInt(cfgPaths.length);
+
+            for (String cfgPath : cfgPaths)
+                U.writeString(out, cfgPath);
+        }
+        else
+            out.writeInt(-1);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        uri = U.readString(in);
+
+        int cfgPathsCnt = in.readInt();
+
+        if (cfgPathsCnt != -1) {
+            cfgPaths = new String[cfgPathsCnt];
+
+            for (int i = 0; i < cfgPathsCnt; i++)
+                cfgPaths[i] = U.readString(in);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
new file mode 100644
index 0000000..91f7777
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.hadoop.fs;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.hadoop.fs.HadoopFileSystemsUtils;
+import org.apache.ignite.internal.processors.hadoop.fs.HadoopLazyConcurrentMap;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+
+import java.io.IOException;
+import java.net.URI;
+
+/**
+ * Caching Hadoop file system factory. Caches {@link FileSystem} instances on per-user basis. Doesn't rely on
+ * built-in Hadoop {@code FileSystem} caching mechanics. Separate {@code FileSystem} instance is created for each
+ * user instead.
+ * <p>
+ * This makes cache instance resistant to concurrent calls to {@link FileSystem#close()} in other parts of the user
+ * code. On the other hand, this might cause problems on some environments. E.g. if Kerberos is enabled, a call to
+ * {@link FileSystem#get(URI, Configuration, String)} will refresh Kerberos token. But this factory implementation
+ * calls this method only once per user what may lead to token expiration. In such cases it makes sense to either
+ * use {@link BasicHadoopFileSystemFactory} or implement your own factory.
+ */
+public class CachingHadoopFileSystemFactory extends BasicHadoopFileSystemFactory {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Per-user file system cache. */
+    private final transient HadoopLazyConcurrentMap<String, FileSystem> cache = new HadoopLazyConcurrentMap<>(
+        new HadoopLazyConcurrentMap.ValueFactory<String, FileSystem>() {
+            @Override public FileSystem createValue(String key) throws IOException {
+                return create0(key);
+            }
+        }
+    );
+
+    /**
+     * Public non-arg constructor.
+     */
+    public CachingHadoopFileSystemFactory() {
+        // noop
+    }
+
+    /** {@inheritDoc} */
+    @Override public FileSystem get(String usrName) throws IOException {
+        return cache.getOrCreate(IgfsUtils.fixUserName(usrName));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start() throws IgniteException {
+        super.start();
+
+        // Disable caching.
+        cfg.setBoolean(HadoopFileSystemsUtils.disableFsCachePropertyName(fullUri.getScheme()), true);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop() throws IgniteException {
+        super.stop();
+
+        try {
+            cache.close();
+        }
+        catch (IgniteCheckedException ice) {
+            throw new IgniteException(ice);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/HadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/HadoopFileSystemFactory.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/HadoopFileSystemFactory.java
new file mode 100644
index 0000000..5ad08ab
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/HadoopFileSystemFactory.java
@@ -0,0 +1,52 @@
+/*
+ * 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.hadoop.fs;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
+import org.apache.ignite.igfs.IgfsMode;
+import org.apache.ignite.lifecycle.LifecycleAware;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * Factory for Hadoop {@link FileSystem} used by {@link IgniteHadoopIgfsSecondaryFileSystem}.
+ * <p>
+ * {@link #get(String)} method will be used whenever a call to a target {@code FileSystem} is required.
+ * <p>
+ * It is implementation dependent whether to rely on built-in Hadoop file system cache, implement own caching facility
+ * or doesn't cache file systems at all.
+ * <p>
+ * Concrete factory may implement {@link LifecycleAware} interface. In this case start and stop callbacks will be
+ * performed by Ignite. You may want to implement some initialization or cleanup there.
+ * <p>
+ * Note that factory extends {@link Serializable} interface as it might be necessary to transfer factories over the
+ * wire to {@link IgniteHadoopFileSystem} if {@link IgfsMode#PROXY} is enabled for some file
+ * system paths.
+ */
+public interface HadoopFileSystemFactory extends Serializable {
+    /**
+     * Gets file system for the given user name.
+     *
+     * @param usrName User name
+     * @return File system.
+     * @throws IOException In case of error.
+     */
+    public FileSystem get(String usrName) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
index 1ca6938..9f544c1 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
@@ -17,15 +17,7 @@
 
 package org.apache.ignite.hadoop.fs;
 
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.ParentNotDirectoryException;
@@ -35,6 +27,7 @@ import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteFileSystem;
 import org.apache.ignite.igfs.IgfsDirectoryNotEmptyException;
 import org.apache.ignite.igfs.IgfsException;
 import org.apache.ignite.igfs.IgfsFile;
@@ -45,71 +38,59 @@ import org.apache.ignite.igfs.IgfsPathNotFoundException;
 import org.apache.ignite.igfs.IgfsUserContext;
 import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
 import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
-import org.apache.ignite.internal.processors.hadoop.SecondaryFileSystemProvider;
-import org.apache.ignite.internal.processors.hadoop.fs.HadoopLazyConcurrentMap;
-import org.apache.ignite.internal.processors.hadoop.fs.HadoopLazyConcurrentMap.ValueFactory;
+import org.apache.ignite.internal.processors.hadoop.HadoopPayloadAware;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsProperties;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsSecondaryFileSystemPositionedReadable;
-import org.apache.ignite.internal.processors.igfs.IgfsEx;
 import org.apache.ignite.internal.processors.igfs.IgfsFileImpl;
 import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
 import org.apache.ignite.internal.processors.igfs.IgfsUtils;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteOutClosure;
+import org.apache.ignite.lifecycle.LifecycleAware;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_GROUP_NAME;
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_USER_NAME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_CONFIG_PATH;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_URI;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_USER_NAME;
 
 /**
- * Adapter to use any Hadoop file system {@link FileSystem} as {@link IgfsSecondaryFileSystem}.
- * In fact, this class deals with different FileSystems depending on the user context,
- * see {@link IgfsUserContext#currentUser()}.
+ * Secondary file system which delegates calls to an instance of Hadoop {@link FileSystem}.
+ * <p>
+ * Target {@code FileSystem}'s are created on per-user basis using passed {@link HadoopFileSystemFactory}.
  */
-public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem {
-    /** Properties of file system, see {@link #properties()}
-     *
-     * See {@link IgfsEx#SECONDARY_FS_CONFIG_PATH}
-     * See {@link IgfsEx#SECONDARY_FS_URI}
-     * See {@link IgfsEx#SECONDARY_FS_USER_NAME}
-     * */
-    private final Map<String, String> props = new HashMap<>();
-
-    /** Secondary file system provider. */
-    private final SecondaryFileSystemProvider secProvider;
-
+public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, LifecycleAware,
+    HadoopPayloadAware {
     /** The default user name. It is used if no user context is set. */
-    private final String dfltUserName;
+    private String dfltUsrName;
 
-    /** FileSystem instance created for the default user.
-     * Stored outside the fileSysLazyMap due to performance reasons. */
-    private final FileSystem dfltFs;
+    /** Factory. */
+    private HadoopFileSystemFactory fsFactory;
 
-    /** Lazy per-user cache for the file systems. It is cleared and nulled in #close() method. */
-    private final HadoopLazyConcurrentMap<String, FileSystem> fileSysLazyMap = new HadoopLazyConcurrentMap<>(
-        new ValueFactory<String, FileSystem>() {
-            @Override public FileSystem createValue(String key) {
-                try {
-                    assert !F.isEmpty(key);
-
-                    return secProvider.createFileSystem(key);
-                }
-                catch (IOException ioe) {
-                    throw new IgniteException(ioe);
-                }
-            }
-        }
-    );
+    /**
+     * Default constructor for Spring.
+     */
+    public IgniteHadoopIgfsSecondaryFileSystem() {
+        // No-op.
+    }
 
     /**
      * Simple constructor that is to be used by default.
      *
      * @param uri URI of file system.
      * @throws IgniteCheckedException In case of error.
+     * @deprecated Use {@link #getFileSystemFactory()} instead.
      */
+    @Deprecated
     public IgniteHadoopIgfsSecondaryFileSystem(String uri) throws IgniteCheckedException {
         this(uri, null, null);
     }
@@ -120,7 +101,9 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
      * @param uri URI of file system.
      * @param cfgPath Additional path to Hadoop configuration.
      * @throws IgniteCheckedException In case of error.
+     * @deprecated Use {@link #getFileSystemFactory()} instead.
      */
+    @Deprecated
     public IgniteHadoopIgfsSecondaryFileSystem(@Nullable String uri, @Nullable String cfgPath)
         throws IgniteCheckedException {
         this(uri, cfgPath, null);
@@ -131,46 +114,73 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
      *
      * @param uri URI of file system.
      * @param cfgPath Additional path to Hadoop configuration.
-     * @param userName User name.
+     * @param usrName User name.
      * @throws IgniteCheckedException In case of error.
+     * @deprecated Use {@link #getFileSystemFactory()} instead.
      */
+    @Deprecated
     public IgniteHadoopIgfsSecondaryFileSystem(@Nullable String uri, @Nullable String cfgPath,
-        @Nullable String userName) throws IgniteCheckedException {
-        // Treat empty uri and userName arguments as nulls to improve configuration usability:
-        if (F.isEmpty(uri))
-            uri = null;
-
-        if (F.isEmpty(cfgPath))
-            cfgPath = null;
-
-        if (F.isEmpty(userName))
-            userName = null;
+        @Nullable String usrName) throws IgniteCheckedException {
+        setDefaultUserName(usrName);
 
-        this.dfltUserName = IgfsUtils.fixUserName(userName);
+        CachingHadoopFileSystemFactory fac = new CachingHadoopFileSystemFactory();
 
-        try {
-            this.secProvider = new SecondaryFileSystemProvider(uri, cfgPath);
+        fac.setUri(uri);
 
-            // File system creation for the default user name.
-            // The value is *not* stored in the 'fileSysLazyMap' cache, but saved in field:
-            this.dfltFs = secProvider.createFileSystem(dfltUserName);
-        }
-        catch (IOException e) {
-            throw new IgniteCheckedException(e);
-        }
+        if (cfgPath != null)
+            fac.setConfigPaths(cfgPath);
 
-        assert dfltFs != null;
+        setFileSystemFactory(fac);
+    }
 
-        uri = secProvider.uri().toString();
+    /**
+     * Gets default user name.
+     * <p>
+     * Defines user name which will be used during file system invocation in case no user name is defined explicitly
+     * through {@link FileSystem#get(URI, Configuration, String)}.
+     * <p>
+     * Also this name will be used if you manipulate {@link IgniteFileSystem} directly and do not set user name
+     * explicitly using {@link IgfsUserContext#doAs(String, IgniteOutClosure)} or
+     * {@link IgfsUserContext#doAs(String, Callable)} methods.
+     * <p>
+     * If not set value of system property {@code "user.name"} will be used. If this property is not set either,
+     * {@code "anonymous"} will be used.
+     *
+     * @return Default user name.
+     */
+    @Nullable public String getDefaultUserName() {
+        return dfltUsrName;
+    }
 
-        if (!uri.endsWith("/"))
-            uri += "/";
+    /**
+     * Sets default user name. See {@link #getDefaultUserName()} for details.
+     *
+     * @param dfltUsrName Default user name.
+     */
+    public void setDefaultUserName(@Nullable String dfltUsrName) {
+        this.dfltUsrName = dfltUsrName;
+    }
 
-        if (cfgPath != null)
-            props.put(SECONDARY_FS_CONFIG_PATH, cfgPath);
+    /**
+     * Gets secondary file system factory.
+     * <p>
+     * This factory will be used whenever a call to a target {@link FileSystem} is required.
+     * <p>
+     * If not set, {@link CachingHadoopFileSystemFactory} will be used.
+     *
+     * @return Secondary file system factory.
+     */
+    public HadoopFileSystemFactory getFileSystemFactory() {
+        return fsFactory;
+    }
 
-        props.put(SECONDARY_FS_URI, uri);
-        props.put(SECONDARY_FS_USER_NAME, dfltUserName);
+    /**
+     * Sets secondary file system factory. See {@link #getFileSystemFactory()} for details.
+     *
+     * @param factory Secondary file system factory.
+     */
+    public void setFileSystemFactory(HadoopFileSystemFactory factory) {
+        this.fsFactory = factory;
     }
 
     /**
@@ -180,7 +190,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
      * @return Hadoop path.
      */
     private Path convert(IgfsPath path) {
-        URI uri = fileSysForUser().getUri();
+        URI uri = fileSystemForUser().getUri();
 
         return new Path(uri.getScheme(), uri.getAuthority(), path.toString());
     }
@@ -234,7 +244,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     /** {@inheritDoc} */
     @Override public boolean exists(IgfsPath path) {
         try {
-            return fileSysForUser().exists(convert(path));
+            return fileSystemForUser().exists(convert(path));
         }
         catch (IOException e) {
             throw handleSecondaryFsError(e, "Failed to check file existence [path=" + path + "]");
@@ -245,7 +255,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     @Nullable @Override public IgfsFile update(IgfsPath path, Map<String, String> props) {
         HadoopIgfsProperties props0 = new HadoopIgfsProperties(props);
 
-        final FileSystem fileSys = fileSysForUser();
+        final FileSystem fileSys = fileSystemForUser();
 
         try {
             if (props0.userName() != null || props0.groupName() != null)
@@ -266,7 +276,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     @Override public void rename(IgfsPath src, IgfsPath dest) {
         // Delegate to the secondary file system.
         try {
-            if (!fileSysForUser().rename(convert(src), convert(dest)))
+            if (!fileSystemForUser().rename(convert(src), convert(dest)))
                 throw new IgfsException("Failed to rename (secondary file system returned false) " +
                     "[src=" + src + ", dest=" + dest + ']');
         }
@@ -278,7 +288,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     /** {@inheritDoc} */
     @Override public boolean delete(IgfsPath path, boolean recursive) {
         try {
-            return fileSysForUser().delete(convert(path), recursive);
+            return fileSystemForUser().delete(convert(path), recursive);
         }
         catch (IOException e) {
             throw handleSecondaryFsError(e, "Failed to delete file [path=" + path + ", recursive=" + recursive + "]");
@@ -288,7 +298,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     /** {@inheritDoc} */
     @Override public void mkdirs(IgfsPath path) {
         try {
-            if (!fileSysForUser().mkdirs(convert(path)))
+            if (!fileSystemForUser().mkdirs(convert(path)))
                 throw new IgniteException("Failed to make directories [path=" + path + "]");
         }
         catch (IOException e) {
@@ -299,7 +309,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     /** {@inheritDoc} */
     @Override public void mkdirs(IgfsPath path, @Nullable Map<String, String> props) {
         try {
-            if (!fileSysForUser().mkdirs(convert(path), new HadoopIgfsProperties(props).permission()))
+            if (!fileSystemForUser().mkdirs(convert(path), new HadoopIgfsProperties(props).permission()))
                 throw new IgniteException("Failed to make directories [path=" + path + ", props=" + props + "]");
         }
         catch (IOException e) {
@@ -310,7 +320,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     /** {@inheritDoc} */
     @Override public Collection<IgfsPath> listPaths(IgfsPath path) {
         try {
-            FileStatus[] statuses = fileSysForUser().listStatus(convert(path));
+            FileStatus[] statuses = fileSystemForUser().listStatus(convert(path));
 
             if (statuses == null)
                 throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
@@ -333,7 +343,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     /** {@inheritDoc} */
     @Override public Collection<IgfsFile> listFiles(IgfsPath path) {
         try {
-            FileStatus[] statuses = fileSysForUser().listStatus(convert(path));
+            FileStatus[] statuses = fileSystemForUser().listStatus(convert(path));
 
             if (statuses == null)
                 throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
@@ -360,13 +370,13 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
 
     /** {@inheritDoc} */
     @Override public IgfsSecondaryFileSystemPositionedReadable open(IgfsPath path, int bufSize) {
-        return new HadoopIgfsSecondaryFileSystemPositionedReadable(fileSysForUser(), convert(path), bufSize);
+        return new HadoopIgfsSecondaryFileSystemPositionedReadable(fileSystemForUser(), convert(path), bufSize);
     }
 
     /** {@inheritDoc} */
     @Override public OutputStream create(IgfsPath path, boolean overwrite) {
         try {
-            return fileSysForUser().create(convert(path), overwrite);
+            return fileSystemForUser().create(convert(path), overwrite);
         }
         catch (IOException e) {
             throw handleSecondaryFsError(e, "Failed to create file [path=" + path + ", overwrite=" + overwrite + "]");
@@ -380,8 +390,8 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
             new HadoopIgfsProperties(props != null ? props : Collections.<String, String>emptyMap());
 
         try {
-            return fileSysForUser().create(convert(path), props0.permission(), overwrite, bufSize,
-                (short)replication, blockSize, null);
+            return fileSystemForUser().create(convert(path), props0.permission(), overwrite, bufSize,
+                (short) replication, blockSize, null);
         }
         catch (IOException e) {
             throw handleSecondaryFsError(e, "Failed to create file [path=" + path + ", props=" + props +
@@ -394,7 +404,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     @Override public OutputStream append(IgfsPath path, int bufSize, boolean create,
         @Nullable Map<String, String> props) {
         try {
-            return fileSysForUser().append(convert(path), bufSize);
+            return fileSystemForUser().append(convert(path), bufSize);
         }
         catch (IOException e) {
             throw handleSecondaryFsError(e, "Failed to append file [path=" + path + ", bufSize=" + bufSize + "]");
@@ -404,7 +414,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
     /** {@inheritDoc} */
     @Override public IgfsFile info(final IgfsPath path) {
         try {
-            final FileStatus status = fileSysForUser().getFileStatus(convert(path));
+            final FileStatus status = fileSystemForUser().getFileStatus(convert(path));
 
             if (status == null)
                 return null;
@@ -479,65 +489,61 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
         try {
             // We don't use FileSystem#getUsed() since it counts only the files
             // in the filesystem root, not all the files recursively.
-            return fileSysForUser().getContentSummary(new Path("/")).getSpaceConsumed();
+            return fileSystemForUser().getContentSummary(new Path("/")).getSpaceConsumed();
         }
         catch (IOException e) {
             throw handleSecondaryFsError(e, "Failed to get used space size of file system.");
         }
     }
 
-    /** {@inheritDoc} */
-    @Override public Map<String, String> properties() {
-        return props;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void close() throws IgniteException {
-        Exception e = null;
-
-        try {
-            dfltFs.close();
-        }
-        catch (Exception e0) {
-            e = e0;
-        }
-
-        try {
-            fileSysLazyMap.close();
-        }
-        catch (IgniteCheckedException ice) {
-            if (e == null)
-                e = ice;
-        }
-
-        if (e != null)
-            throw new IgniteException(e);
-    }
-
     /**
      * Gets the underlying {@link FileSystem}.
      * This method is used solely for testing.
      * @return the underlying Hadoop {@link FileSystem}.
      */
     public FileSystem fileSystem() {
-        return fileSysForUser();
+        return fileSystemForUser();
     }
 
     /**
      * Gets the FileSystem for the current context user.
      * @return the FileSystem instance, never null.
      */
-    private FileSystem fileSysForUser() {
+    private FileSystem fileSystemForUser() {
         String user = IgfsUserContext.currentUser();
 
         if (F.isEmpty(user))
-            user = dfltUserName; // default is never empty.
+            user = IgfsUtils.fixUserName(dfltUsrName);
 
         assert !F.isEmpty(user);
 
-        if (F.eq(user, dfltUserName))
-            return dfltFs; // optimization
+        try {
+            return fsFactory.get(user);
+        }
+        catch (IOException ioe) {
+            throw new IgniteException(ioe);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start() throws IgniteException {
+        dfltUsrName = IgfsUtils.fixUserName(dfltUsrName);
+
+        if (fsFactory == null)
+            fsFactory = new CachingHadoopFileSystemFactory();
+
+        if (fsFactory instanceof LifecycleAware)
+            ((LifecycleAware) fsFactory).start();
+    }
 
-        return fileSysLazyMap.getOrCreate(user);
+    /** {@inheritDoc} */
+    @Override public void stop() throws IgniteException {
+        if (fsFactory instanceof LifecycleAware)
+             ((LifecycleAware)fsFactory).stop();
+    }
+
+    /** {@inheritDoc} */
+    @Override public HadoopFileSystemFactory getPayload() {
+        return fsFactory;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
index 5dce67f..71f6435 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
@@ -17,19 +17,6 @@
 
 package org.apache.ignite.hadoop.fs.v1;
 
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.BlockLocation;
 import org.apache.hadoop.fs.ContentSummary;
@@ -43,7 +30,9 @@ import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.DFSUtil;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.Progressable;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
 import org.apache.ignite.igfs.IgfsBlockLocation;
 import org.apache.ignite.igfs.IgfsException;
 import org.apache.ignite.igfs.IgfsFile;
@@ -51,7 +40,6 @@ import org.apache.ignite.igfs.IgfsMode;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.igfs.IgfsPathSummary;
 import org.apache.ignite.internal.igfs.common.IgfsLogger;
-import org.apache.ignite.internal.processors.hadoop.SecondaryFileSystemProvider;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsInputStream;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsOutputStream;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsProxyInputStream;
@@ -68,8 +56,23 @@ import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lifecycle.LifecycleAware;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 import static org.apache.ignite.configuration.FileSystemConfiguration.DFLT_IGFS_LOG_BATCH_SIZE;
 import static org.apache.ignite.configuration.FileSystemConfiguration.DFLT_IGFS_LOG_DIR;
 import static org.apache.ignite.igfs.IgfsMode.PROXY;
@@ -85,8 +88,6 @@ import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_GROUP_NAME;
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PREFER_LOCAL_WRITES;
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_USER_NAME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_CONFIG_PATH;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_URI;
 
 /**
  * {@code IGFS} Hadoop 1.x file system driver over file system API. To use
@@ -165,8 +166,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
     /** IGFS mode resolver. */
     private IgfsModeResolver modeRslvr;
 
-    /** Secondary file system instance. */
-    private FileSystem secondaryFs;
+    /** The secondary file system factory. */
+    private HadoopFileSystemFactory factory;
 
     /** Management connection flag. */
     private boolean mgmt;
@@ -327,21 +328,28 @@ public class IgniteHadoopFileSystem extends FileSystem {
             }
 
             if (initSecondary) {
-                Map<String, String> props = paths.properties();
+                try {
+                    factory = (HadoopFileSystemFactory) paths.getPayload(getClass().getClassLoader());
+                }
+                catch (IgniteCheckedException e) {
+                    throw new IOException("Failed to get secondary file system factory.", e);
+                }
+
+                assert factory != null;
 
-                String secUri = props.get(SECONDARY_FS_URI);
-                String secConfPath = props.get(SECONDARY_FS_CONFIG_PATH);
+                if (factory instanceof LifecycleAware)
+                    ((LifecycleAware) factory).start();
 
                 try {
-                    SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(secUri, secConfPath);
+                    FileSystem secFs = factory.get(user);
 
-                    secondaryFs = secProvider.createFileSystem(user);
+                    secondaryUri = secFs.getUri();
 
-                    secondaryUri = secProvider.uri();
+                    A.ensure(secondaryUri != null, "Secondary file system uri should not be null.");
                 }
                 catch (IOException e) {
                     if (!mgmt)
-                        throw new IOException("Failed to connect to the secondary file system: " + secUri, e);
+                        throw new IOException("Failed to connect to the secondary file system: " + secondaryUri, e);
                     else
                         LOG.warn("Visor failed to create secondary file system (operations on paths with PROXY mode " +
                             "will have no effect): " + e.getMessage());
@@ -409,8 +417,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
         if (clientLog.isLogEnabled())
             clientLog.close();
 
-        if (secondaryFs != null)
-            U.closeQuiet(secondaryFs);
+        if (factory instanceof LifecycleAware)
+            ((LifecycleAware) factory).stop();
 
         // Reset initialized resources.
         uri = null;
@@ -425,6 +433,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
             A.notNull(p, "p");
 
             if (mode(p) == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -453,6 +463,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
             A.notNull(p, "p");
 
             if (mode(p) == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -482,6 +494,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
 
         try {
             if (mode(p) == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -490,8 +504,7 @@ public class IgniteHadoopFileSystem extends FileSystem {
                 }
 
                 secondaryFs.setOwner(toSecondary(p), username, grpName);
-            }
-            else if (rmtClient.update(convert(p), F.asMap(PROP_USER_NAME, username, PROP_GROUP_NAME, grpName)) == null)
+            } else if (rmtClient.update(convert(p), F.asMap(PROP_USER_NAME, username, PROP_GROUP_NAME, grpName)) == null)
                 throw new IOException("Failed to set file permission (file not found?)" +
                     " [path=" + p + ", userName=" + username + ", groupName=" + grpName + ']');
         }
@@ -511,6 +524,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
             IgfsMode mode = mode(path);
 
             if (mode == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -583,6 +598,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
                     path + ", overwrite=" + overwrite + ", bufSize=" + bufSize + ']');
 
             if (mode == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -664,6 +681,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
                     ", path=" + path + ", bufSize=" + bufSize + ']');
 
             if (mode == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -727,6 +746,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
             IgfsMode mode = mode(srcPath);
 
             if (mode == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -787,6 +808,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
             IgfsMode mode = mode(path);
 
             if (mode == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -832,6 +855,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
             IgfsMode mode = mode(path);
 
             if (mode == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -896,26 +921,35 @@ public class IgniteHadoopFileSystem extends FileSystem {
 
     /** {@inheritDoc} */
     @Override public void setWorkingDirectory(Path newPath) {
-        if (newPath == null) {
-            Path homeDir = getHomeDirectory();
+        try {
+            if (newPath == null) {
+                Path homeDir = getHomeDirectory();
 
-            if (secondaryFs != null)
-                secondaryFs.setWorkingDirectory(toSecondary(homeDir));
+                FileSystem secondaryFs  = secondaryFileSystem();
 
-            workingDir = homeDir;
-        }
-        else {
-            Path fixedNewPath = fixRelativePart(newPath);
+                if (secondaryFs != null)
+                    secondaryFs.setWorkingDirectory(toSecondary(homeDir));
+
+                workingDir = homeDir;
+            }
+            else {
+                Path fixedNewPath = fixRelativePart(newPath);
 
-            String res = fixedNewPath.toUri().getPath();
+                String res = fixedNewPath.toUri().getPath();
 
-            if (!DFSUtil.isValidName(res))
-                throw new IllegalArgumentException("Invalid DFS directory name " + res);
+                if (!DFSUtil.isValidName(res))
+                    throw new IllegalArgumentException("Invalid DFS directory name " + res);
 
-            if (secondaryFs != null)
-                secondaryFs.setWorkingDirectory(toSecondary(fixedNewPath));
+                FileSystem secondaryFs  = secondaryFileSystem();
 
-            workingDir = fixedNewPath;
+                if (secondaryFs != null)
+                    secondaryFs.setWorkingDirectory(toSecondary(fixedNewPath));
+
+                workingDir = fixedNewPath;
+            }
+        }
+        catch (IOException e) {
+            throw new RuntimeException("Failed to obtain secondary file system instance.", e);
         }
     }
 
@@ -936,6 +970,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
             IgfsMode mode = mode(path);
 
             if (mode == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -977,6 +1013,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
 
         try {
             if (mode(f) == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -1007,6 +1045,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
 
         try {
             if (mode(f) == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -1038,6 +1078,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
             IgfsPath path = convert(status.getPath());
 
             if (mode(status.getPath()) == PROXY) {
+                final FileSystem secondaryFs = secondaryFileSystem();
+
                 if (secondaryFs == null) {
                     assert mgmt;
 
@@ -1103,7 +1145,7 @@ public class IgniteHadoopFileSystem extends FileSystem {
      * @return {@code true} If secondary file system is initialized.
      */
     public boolean hasSecondaryFileSystem() {
-        return secondaryFs != null;
+        return factory != null;
     }
 
     /**
@@ -1123,7 +1165,7 @@ public class IgniteHadoopFileSystem extends FileSystem {
      * @return Secondary file system path.
      */
     private Path toSecondary(Path path) {
-        assert secondaryFs != null;
+        assert factory != null;
         assert secondaryUri != null;
 
         return convertPath(path, secondaryUri);
@@ -1298,4 +1340,16 @@ public class IgniteHadoopFileSystem extends FileSystem {
     public String user() {
         return user;
     }
+
+    /**
+     * Gets cached or creates a {@link FileSystem}.
+     *
+     * @return The secondary file system.
+     */
+    private @Nullable FileSystem secondaryFileSystem() throws IOException{
+        if (factory == null)
+            return null;
+
+        return factory.get(user);
+    }
 }
\ No newline at end of file


[27/29] ignite git commit: IGNITE-429

Posted by vo...@apache.org.
 IGNITE-429


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

Branch: refs/heads/ignite-2236
Commit: 3a0cb51f8303af5a841c2d5353f9d0ddc0e626df
Parents: fa427dc
Author: shtykh_roman <rs...@yahoo.com>
Authored: Fri Jan 15 14:24:22 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Jan 15 14:24:22 2016 +0300

----------------------------------------------------------------------
 modules/storm/README.txt                        |  37 +++
 modules/storm/licenses/apache-2.0.txt           | 202 ++++++++++++
 modules/storm/pom.xml                           | 104 +++++++
 .../ignite/stream/storm/StormStreamer.java      | 304 +++++++++++++++++++
 .../ignite/stream/storm/package-info.java       |  22 ++
 .../storm/IgniteStormStreamerSelfTestSuite.java |  38 +++
 .../storm/StormIgniteStreamerSelfTest.java      | 184 +++++++++++
 .../ignite/stream/storm/TestStormSpout.java     | 141 +++++++++
 .../storm/src/test/resources/example-ignite.xml |  71 +++++
 pom.xml                                         |   1 +
 10 files changed, 1104 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3a0cb51f/modules/storm/README.txt
----------------------------------------------------------------------
diff --git a/modules/storm/README.txt b/modules/storm/README.txt
new file mode 100644
index 0000000..eb20f25
--- /dev/null
+++ b/modules/storm/README.txt
@@ -0,0 +1,37 @@
+Apache Ignite Storm Streamer Module
+-----------------------------------
+
+Apache Ignite Storm Streamer module provides streaming via Storm to Ignite cache.
+
+Starting data transfer to Ignite cache can be done with the following steps.
+
+1. Import Ignite Kafka Streamer Module In Maven Project
+
+If you are using Maven to manage dependencies of your project, you can add Storm module
+dependency like this (replace '${ignite.version}' with actual Ignite version you are
+interested in):
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+                        http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    ...
+    <dependencies>
+        ...
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-storm</artifactId>
+            <version>${ignite.version}</version>
+        </dependency>
+        ...
+    </dependencies>
+    ...
+</project>
+
+2. Create an Ignite configuration file (see example-ignite.xml) and make sure it is accessible from the streamer.
+
+3. Make sure your key-value data input to the streamer is specified with the field named "ignite"
+(or a different one you configure with StormStreamer.setIgniteTupleField(...)).
+See TestStormSpout.declareOutputFields(...) for an example.
+
+4. Create a topology with the streamer and start.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a0cb51f/modules/storm/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/storm/licenses/apache-2.0.txt b/modules/storm/licenses/apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/modules/storm/licenses/apache-2.0.txt
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a0cb51f/modules/storm/pom.xml
----------------------------------------------------------------------
diff --git a/modules/storm/pom.xml b/modules/storm/pom.xml
new file mode 100644
index 0000000..0cd1fcb
--- /dev/null
+++ b/modules/storm/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+    POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ignite</groupId>
+        <artifactId>ignite-parent</artifactId>
+        <version>1</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <artifactId>ignite-storm</artifactId>
+    <version>1.5.1.final-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
+
+    <properties>
+        <storm.version>0.10.0</storm.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.storm</groupId>
+            <artifactId>storm-core</artifactId>
+            <version>${storm.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>log4j</groupId>
+                    <artifactId>log4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>commons-logging</groupId>
+                    <artifactId>commons-logging</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-simple</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>log4j-over-slf4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.zookeeper</groupId>
+                    <artifactId>zookeeper</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-core</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-log4j</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-spring</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a0cb51f/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java
----------------------------------------------------------------------
diff --git a/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java b/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java
new file mode 100644
index 0000000..bdaec0b
--- /dev/null
+++ b/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java
@@ -0,0 +1,304 @@
+/*
+ * 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.stream.storm;
+
+import backtype.storm.task.OutputCollector;
+import backtype.storm.task.TopologyContext;
+import backtype.storm.topology.IRichBolt;
+import backtype.storm.topology.OutputFieldsDeclarer;
+import backtype.storm.tuple.Tuple;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.stream.StreamAdapter;
+
+/**
+ * Apache Storm streamer implemented as a Storm bolt.
+ * Obtaining data from other bolts and spouts is done by the specified tuple field.
+ */
+public class StormStreamer<K, V> extends StreamAdapter<Tuple, K, V> implements IRichBolt {
+    /** Default flush frequency. */
+    private static final long DFLT_FLUSH_FREQ = 10000L;
+
+    /** Default Ignite tuple field. */
+    private static final String DFLT_TUPLE_FIELD = "ignite";
+
+    /** Logger. */
+    private IgniteLogger log;
+
+    /** Field by which tuple data is obtained in topology. */
+    private String igniteTupleField = DFLT_TUPLE_FIELD;
+
+    /** Automatic flush frequency. */
+    private long autoFlushFrequency = DFLT_FLUSH_FREQ;
+
+    /** Enables overwriting existing values in cache. */
+    private boolean allowOverwrite = false;
+
+    /** Flag for stopped state. */
+    private static volatile boolean stopped = true;
+
+    /** Storm output collector. */
+    private OutputCollector collector;
+
+    /** Ignite grid configuration file. */
+    private static String igniteConfigFile;
+
+    /** Cache name. */
+    private static String cacheName;
+
+    /**
+     * Gets Ignite tuple field, by which tuple data is obtained in topology.
+     *
+     * @return Tuple field.
+     */
+    public String getIgniteTupleField() {
+        return igniteTupleField;
+    }
+
+    /**
+     * Names Ignite tuple field, by which tuple data is obtained in topology.
+     *
+     * @param igniteTupleField Name of tuple field.
+     */
+    public void setIgniteTupleField(String igniteTupleField) {
+        this.igniteTupleField = igniteTupleField;
+    }
+
+    /**
+     * Gets the cache name.
+     *
+     * @return Cache name.
+     */
+    public String getCacheName() {
+        return cacheName;
+    }
+
+    /**
+     * Sets the cache name.
+     *
+     * @param cacheName Cache name.
+     */
+    public void setCacheName(String cacheName) {
+        StormStreamer.cacheName = cacheName;
+    }
+
+    /**
+     * Gets Ignite configuration file.
+     *
+     * @return Configuration file.
+     */
+    public String getIgniteConfigFile() {
+        return igniteConfigFile;
+    }
+
+    /**
+     * Specifies Ignite configuration file.
+     *
+     * @param igniteConfigFile Ignite config file.
+     */
+    public void setIgniteConfigFile(String igniteConfigFile) {
+        StormStreamer.igniteConfigFile = igniteConfigFile;
+    }
+
+    /**
+     * Obtains data flush frequency.
+     *
+     * @return Flush frequency.
+     */
+    public long getAutoFlushFrequency() {
+        return autoFlushFrequency;
+    }
+
+    /**
+     * Specifies data flush frequency into the grid.
+     *
+     * @param autoFlushFrequency Flush frequency.
+     */
+    public void setAutoFlushFrequency(long autoFlushFrequency) {
+        this.autoFlushFrequency = autoFlushFrequency;
+    }
+
+    /**
+     * Obtains flag for enabling overwriting existing values in cache.
+     *
+     * @return True if overwriting is allowed, false otherwise.
+     */
+    public boolean getAllowOverwrite() {
+        return allowOverwrite;
+    }
+
+    /**
+     * Enables overwriting existing values in cache.
+     *
+     * @param allowOverwrite Flag value.
+     */
+    public void setAllowOverwrite(boolean allowOverwrite) {
+        this.allowOverwrite = allowOverwrite;
+    }
+
+    /**
+     * Starts streamer.
+     *
+     * @throws IgniteException If failed.
+     */
+    @SuppressWarnings("unchecked")
+    public void start() throws IgniteException {
+        A.notNull(igniteConfigFile, "Ignite config file");
+        A.notNull(cacheName, "Cache name");
+        A.notNull(igniteTupleField, "Ignite tuple field");
+
+        setIgnite(StreamerContext.getIgnite());
+
+        final IgniteDataStreamer<K, V> dataStreamer = StreamerContext.getStreamer();
+        dataStreamer.autoFlushFrequency(autoFlushFrequency);
+        dataStreamer.allowOverwrite(allowOverwrite);
+
+        setStreamer(dataStreamer);
+
+        log = getIgnite().log();
+
+        stopped = false;
+    }
+
+    /**
+     * Stops streamer.
+     *
+     * @throws IgniteException If failed.
+     */
+    public void stop() throws IgniteException {
+        if (stopped)
+            return;
+
+        stopped = true;
+
+        getIgnite().<K, V>dataStreamer(cacheName).close(true);
+
+        getIgnite().close();
+    }
+
+    /**
+     * Initializes Ignite client instance from a configuration file and declares the output collector of the bolt.
+     *
+     * @param map Map derived from topology.
+     * @param topologyContext Context topology in storm.
+     * @param collector Output collector.
+     */
+    @Override
+    public void prepare(Map map, TopologyContext topologyContext, OutputCollector collector) {
+        start();
+
+        this.collector = collector;
+    }
+
+    /**
+     * Transfers data into grid.
+     *
+     * @param tuple Storm tuple.
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public void execute(Tuple tuple) {
+        if (stopped)
+            return;
+
+        if (!(tuple.getValueByField(igniteTupleField) instanceof Map))
+            throw new IgniteException("Map as a streamer input is expected!");
+
+        final Map<K, V> gridVals = (Map<K, V>)tuple.getValueByField(igniteTupleField);
+
+        try {
+            if (log.isDebugEnabled())
+                log.debug("Tuple (id:" + tuple.getMessageId() + ") from storm: " + gridVals);
+
+            getStreamer().addData(gridVals);
+
+            collector.ack(tuple);
+        }
+        catch (Exception e) {
+            log.error("Error while processing tuple of " + gridVals, e);
+            collector.fail(tuple);
+        }
+    }
+
+    /**
+     * Cleans up the streamer when the bolt is going to shutdown.
+     */
+    @Override
+    public void cleanup() {
+        stop();
+    }
+
+    /**
+     * Normally declares output fields for the stream of the topology.
+     * Empty because we have no tuples for any further processing.
+     *
+     * @param declarer OutputFieldsDeclarer.
+     */
+    @Override
+    public void declareOutputFields(OutputFieldsDeclarer declarer) {
+        // No-op.
+    }
+
+    /**
+     * Not used.
+     *
+     * @return Configurations.
+     */
+    @Override
+    public Map<String, Object> getComponentConfiguration() {
+        return null;
+    }
+
+    /**
+     * Streamer context initializing grid and data streamer instances on demand.
+     */
+    public static class StreamerContext {
+        /** Constructor. */
+        private StreamerContext() {
+        }
+
+        /** Instance holder. */
+        private static class Holder {
+            private static final Ignite IGNITE = Ignition.start(igniteConfigFile);
+            private static final IgniteDataStreamer STREAMER = IGNITE.dataStreamer(cacheName);
+        }
+
+        /**
+         * Obtains grid instance.
+         *
+         * @return Grid instance.
+         */
+        public static Ignite getIgnite() {
+            return Holder.IGNITE;
+        }
+
+        /**
+         * Obtains data streamer instance.
+         *
+         * @return Data streamer instance.
+         */
+        public static IgniteDataStreamer getStreamer() {
+            return Holder.STREAMER;
+        }
+    }
+}

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

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

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a0cb51f/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java b/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java
new file mode 100644
index 0000000..0ce4c6e
--- /dev/null
+++ b/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java
@@ -0,0 +1,184 @@
+/*
+ * 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.stream.storm;
+
+import backtype.storm.Config;
+import backtype.storm.ILocalCluster;
+import backtype.storm.Testing;
+import backtype.storm.generated.StormTopology;
+import backtype.storm.testing.CompleteTopologyParam;
+import backtype.storm.testing.MkClusterParam;
+import backtype.storm.testing.MockedSources;
+import backtype.storm.testing.TestJob;
+import backtype.storm.topology.TopologyBuilder;
+import backtype.storm.tuple.Values;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.CacheEvent;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.NotNull;
+
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT;
+
+/**
+ * Tests for {@link StormStreamer}.
+ */
+public class StormIgniteStreamerSelfTest extends GridCommonAbstractTest {
+    /** Cache name. */
+    private static final String TEST_CACHE = "testCache";
+
+    /** Ignite test configuration file. */
+    private static final String GRID_CONF_FILE = "modules/storm/src/test/resources/example-ignite.xml";
+
+    /** Ignite instance. */
+    private Ignite ignite;
+
+    /** Parallelization in Storm. */
+    private static final int STORM_EXECUTORS = 2;
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override protected void beforeTest() throws Exception {
+        IgniteConfiguration cfg = loadConfiguration(GRID_CONF_FILE);
+
+        cfg.setClientMode(false);
+
+        ignite = startGrid("igniteServerNode", cfg);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * Tests for the streamer bolt. Ignite started in bolt based on what is specified in the configuration file.
+     *
+     * @throws TimeoutException
+     * @throws InterruptedException
+     */
+    public void testStormStreamerIgniteBolt() throws TimeoutException, InterruptedException {
+        final StormStreamer<String, String> stormStreamer = new StormStreamer<>();
+
+        stormStreamer.setAutoFlushFrequency(10L);
+        stormStreamer.setAllowOverwrite(true);
+        stormStreamer.setCacheName(TEST_CACHE);
+        stormStreamer.setIgniteTupleField(TestStormSpout.IGNITE_TUPLE_FIELD);
+        stormStreamer.setIgniteConfigFile(GRID_CONF_FILE);
+
+        Config daemonConf = new Config();
+
+        daemonConf.put(Config.STORM_LOCAL_MODE_ZMQ, false);
+
+        MkClusterParam mkClusterParam = new MkClusterParam();
+
+        mkClusterParam.setDaemonConf(daemonConf);
+        mkClusterParam.setSupervisors(4);
+
+        final CountDownLatch latch = new CountDownLatch(TestStormSpout.CNT);
+
+        IgniteBiPredicate<UUID, CacheEvent> putLsnr = new IgniteBiPredicate<UUID, CacheEvent>() {
+            @Override public boolean apply(UUID uuid, CacheEvent evt) {
+                assert evt != null;
+
+                latch.countDown();
+
+                return true;
+            }
+        };
+
+        final UUID putLsnrId = ignite.events(ignite.cluster().forCacheNodes(TEST_CACHE))
+            .remoteListen(putLsnr, null, EVT_CACHE_OBJECT_PUT);
+
+        Testing.withSimulatedTimeLocalCluster(mkClusterParam, new TestJob() {
+                @Override public void run(ILocalCluster cluster) throws IOException, InterruptedException {
+                    // Creates a test topology.
+                    TopologyBuilder builder = new TopologyBuilder();
+
+                    TestStormSpout testStormSpout = new TestStormSpout();
+
+                    builder.setSpout("test-spout", testStormSpout);
+                    builder.setBolt("ignite-bolt", stormStreamer, STORM_EXECUTORS).shuffleGrouping("test-spout");
+
+                    StormTopology topology = builder.createTopology();
+
+                    // Prepares a mock data for the spout.
+                    MockedSources mockedSources = new MockedSources();
+
+                    mockedSources.addMockData("test-spout", getMockData());
+
+                    // Prepares the config.
+                    Config conf = new Config();
+
+                    conf.setMessageTimeoutSecs(10);
+
+                    IgniteCache<Integer, String> cache = ignite.cache(TEST_CACHE);
+
+                    CompleteTopologyParam completeTopologyParam = new CompleteTopologyParam();
+
+                    completeTopologyParam.setTimeoutMs(10000);
+                    completeTopologyParam.setMockedSources(mockedSources);
+                    completeTopologyParam.setStormConf(conf);
+
+                    // Checks the cache doesn't contain any entries yet.
+                    assertEquals(0, cache.size(CachePeekMode.PRIMARY));
+
+                    Testing.completeTopology(cluster, topology, completeTopologyParam);
+
+                    // Checks events successfully processed in 20 seconds.
+                    assertTrue(latch.await(10, TimeUnit.SECONDS));
+
+                    ignite.events(ignite.cluster().forCacheNodes(TEST_CACHE)).stopRemoteListen(putLsnrId);
+
+                    // Validates all entries are in the cache.
+                    assertEquals(TestStormSpout.CNT, cache.size(CachePeekMode.PRIMARY));
+
+                    for (Map.Entry<Integer, String> entry : TestStormSpout.getKeyValMap().entrySet())
+                        assertEquals(entry.getValue(), cache.get(entry.getKey()));
+                }
+            }
+        );
+    }
+
+    /**
+     * Prepares entry values for test input.
+     *
+     * @return Array of entry values.
+     */
+    @NotNull
+    private static Values[] getMockData() {
+        final int SIZE = 10;
+
+        ArrayList<Values> mockData = new ArrayList<>();
+
+        for (int i = 0; i < TestStormSpout.CNT; i += SIZE)
+            mockData.add(new Values(TestStormSpout.getKeyValMap().subMap(i, i + SIZE)));
+
+        return mockData.toArray(new Values[mockData.size()]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a0cb51f/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java
----------------------------------------------------------------------
diff --git a/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java b/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java
new file mode 100644
index 0000000..a006ca7
--- /dev/null
+++ b/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java
@@ -0,0 +1,141 @@
+/*
+ * 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.stream.storm;
+
+import backtype.storm.spout.SpoutOutputCollector;
+import backtype.storm.task.TopologyContext;
+import backtype.storm.topology.IRichSpout;
+import backtype.storm.topology.OutputFieldsDeclarer;
+import backtype.storm.tuple.Fields;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Testing Storm spout.
+ */
+public class TestStormSpout implements IRichSpout {
+
+    /** Field by which tuple data is obtained by the streamer. */
+    public static final String IGNITE_TUPLE_FIELD = "test-field";
+
+    /** Number of outgoing tuples. */
+    public static final int CNT = 500;
+
+    /** Spout message prefix. */
+    private static final String VAL_PREFIX = "v:";
+
+    /** Spout output collector. */
+    private SpoutOutputCollector collector;
+
+    /** Map of messages to be sent. */
+    private static TreeMap<Integer, String> keyValMap;
+
+    static {
+        keyValMap = generateKeyValMap();
+    }
+
+    /**
+     * Declares the output field for the component.
+     *
+     * @param outputFieldsDeclarer Declarer to declare fields on.
+     */
+    @Override
+    public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
+        outputFieldsDeclarer.declare(new Fields(IGNITE_TUPLE_FIELD));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void open(Map map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {
+        this.collector = spoutOutputCollector;
+    }
+
+    /**
+     * Requests to emit a tuple to the output collector.
+     */
+    @Override
+    public void nextTuple() {
+        // No-op. Sent via mocked sources.
+    }
+
+    /**
+     * Generates key,value pair to emit to bolt({@link StormStreamer}).
+     *
+     * @return Key, value pair.
+     */
+    private static TreeMap<Integer, String> generateKeyValMap() {
+        TreeMap<Integer, String> keyValMap = new TreeMap<>();
+
+        for (int evt = 0; evt < CNT; evt++) {
+            String msg = VAL_PREFIX + evt;
+
+            keyValMap.put(evt, msg);
+        }
+
+        return keyValMap;
+    }
+
+    public static TreeMap<Integer, String> getKeyValMap() {
+        return keyValMap;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void ack(Object msgId) {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void fail(Object msgId) {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void close() {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void activate() {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void deactivate() {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Map<String, Object> getComponentConfiguration() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a0cb51f/modules/storm/src/test/resources/example-ignite.xml
----------------------------------------------------------------------
diff --git a/modules/storm/src/test/resources/example-ignite.xml b/modules/storm/src/test/resources/example-ignite.xml
new file mode 100644
index 0000000..fbb05d3
--- /dev/null
+++ b/modules/storm/src/test/resources/example-ignite.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+    Ignite configuration with all defaults and enabled p2p deployment and enabled events.
+    Used for testing IgniteSink running Ignite in a client mode.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <!-- Enable client mode. -->
+        <property name="clientMode" value="true"/>
+
+        <!-- Cache accessed from IgniteSink. -->
+        <property name="cacheConfiguration">
+            <list>
+                <!-- Partitioned cache example configuration with configurations adjusted to server nodes'. -->
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="atomicityMode" value="ATOMIC"/>
+
+                    <property name="name" value="testCache"/>
+                </bean>
+            </list>
+        </property>
+
+        <!-- Enable cache events. -->
+        <property name="includeEventTypes">
+            <list>
+                <!-- Cache events (only EVT_CACHE_OBJECT_PUT for tests). -->
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
+            </list>
+        </property>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <value>127.0.0.1:47500</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a0cb51f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5c6e87c..0a74c47 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,6 +80,7 @@
         <module>modules/mqtt</module>
         <module>modules/zookeeper</module>
         <module>modules/camel</module>
+        <module>modules/storm</module>
         <module>modules/osgi-paxlogging</module>
         <module>modules/osgi-karaf</module>
         <module>modules/osgi</module>


[16/29] ignite git commit: Fixed compatibility issues from commit 457a9ae.

Posted by vo...@apache.org.
Fixed compatibility issues from commit 457a9ae.


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

Branch: refs/heads/ignite-2236
Commit: cd44be5f0398148313f4c8d1802302c7a04f16ff
Parents: 457a9ae
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 13 12:19:16 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 13 12:19:16 2016 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java  | 2 +-
 .../processors/cache/distributed/near/GridNearTxFinishFuture.java  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cd44be5f/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 95fdeb6..8f1d9a2 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
@@ -165,7 +165,7 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
 
         prepareMarshalCacheObjects(nearEvicted, cctx);
 
-        if (err != null && errBytes == null)
+        if (errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd44be5f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
index 1b40d6e..26e189b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
@@ -68,7 +68,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
     public static final IgniteProductVersion FINISH_NEAR_ONE_PHASE_SINCE = IgniteProductVersion.fromString("1.4.0");
 
     /** */
-    public static final IgniteProductVersion WAIT_REMOTE_TXS_SINCE = IgniteProductVersion.fromString("1.5.0");
+    public static final IgniteProductVersion WAIT_REMOTE_TXS_SINCE = IgniteProductVersion.fromString("1.5.1");
 
     /** */
     private static final long serialVersionUID = 0L;


[25/29] ignite git commit: IGNITE-2328 - Added the ticket test to the suite.

Posted by vo...@apache.org.
IGNITE-2328 - Added the ticket test to the suite.


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

Branch: refs/heads/ignite-2236
Commit: c4ff7111638e939ee395111840fd786314527003
Parents: 6524c79
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Jan 15 10:31:37 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jan 15 10:31:37 2016 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java   | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ff7111/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 0f86c4c..442e116 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
 import junit.framework.TestSuite;
 import org.apache.ignite.internal.processors.cache.CacheNearReaderUpdateTest;
 import org.apache.ignite.internal.processors.cache.CacheSerializableTransactionsTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
 
 /**
  * Test suite.
@@ -34,6 +35,7 @@ public class IgniteCacheTestSuite5 extends TestSuite {
 
         suite.addTestSuite(CacheSerializableTransactionsTest.class);
         suite.addTestSuite(CacheNearReaderUpdateTest.class);
+        suite.addTestSuite(IgniteCacheStoreCollectionTest.class);
 
         return suite;
     }


[07/29] ignite git commit: IGNITE-2218: Fixed a problem with native Hadoop libraries load. This closes #378.

Posted by vo...@apache.org.
IGNITE-2218: Fixed a problem with native Hadoop libraries load. This closes #378.


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

Branch: refs/heads/ignite-2236
Commit: 7d58d14a80b1c32f88fbb4cf68e5d289c5aee474
Parents: 012ca73
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Jan 4 12:14:58 2016 +0400
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Jan 4 12:14:58 2016 +0400

----------------------------------------------------------------------
 .../processors/hadoop/HadoopClassLoader.java    |  71 ++++++++++---
 .../hadoop/v2/HadoopNativeCodeLoader.java       |  74 --------------
 .../hadoop/HadoopAbstractWordCountTest.java     |  46 +++++++--
 .../hadoop/HadoopMapReduceEmbeddedSelfTest.java |   2 +-
 .../processors/hadoop/HadoopMapReduceTest.java  |  15 ++-
 .../hadoop/HadoopSnappyFullMapReduceTest.java   |  28 +++++
 .../processors/hadoop/HadoopSnappyTest.java     | 102 +++++++++++++++++++
 .../processors/hadoop/HadoopTasksV2Test.java    |   2 +-
 .../hadoop/examples/HadoopWordCount1Reduce.java |   1 +
 .../hadoop/examples/HadoopWordCount2.java       |  18 +++-
 .../examples/HadoopWordCount2Reducer.java       |   1 +
 .../testsuites/IgniteHadoopTestSuite.java       |  18 +++-
 12 files changed, 279 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
index 735133f..270b31d 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
@@ -30,13 +30,14 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
-
+import java.util.Vector;
+import org.apache.hadoop.util.NativeCodeLoader;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.hadoop.v2.HadoopDaemon;
-import org.apache.ignite.internal.processors.hadoop.v2.HadoopNativeCodeLoader;
 import org.apache.ignite.internal.processors.hadoop.v2.HadoopShutdownHookManager;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 import org.objectweb.asm.AnnotationVisitor;
@@ -69,6 +70,9 @@ public class HadoopClassLoader extends URLClassLoader {
     /** Name of the Hadoop daemon class. */
     public static final String HADOOP_DAEMON_CLASS_NAME = "org.apache.hadoop.util.Daemon";
 
+    /** Name of libhadoop library. */
+    private static final String LIBHADOOP = "hadoop.";
+
     /** */
     private static final URLClassLoader APP_CLS_LDR = (URLClassLoader)HadoopClassLoader.class.getClassLoader();
 
@@ -119,6 +123,51 @@ public class HadoopClassLoader extends URLClassLoader {
         assert !(getParent() instanceof HadoopClassLoader);
 
         this.name = name;
+
+        initializeNativeLibraries();
+    }
+
+    /**
+     * Workaround to load native Hadoop libraries. Java doesn't allow native libraries to be loaded from different
+     * classloaders. But we load Hadoop classes many times and one of these classes - {@code NativeCodeLoader} - tries
+     * to load the same native library over and over again.
+     * <p>
+     * To fix the problem, we force native library load in parent class loader and then "link" handle to this native
+     * library to our class loader. As a result, our class loader will think that the library is already loaded and will
+     * be able to link native methods.
+     *
+     * @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/invocation.html#library_version">
+     *     JNI specification</a>
+     */
+    private void initializeNativeLibraries() {
+        try {
+            // This must trigger native library load.
+            Class.forName(NativeCodeLoader.class.getName(), true, APP_CLS_LDR);
+
+            final Vector<Object> curVector = U.field(this, "nativeLibraries");
+
+            ClassLoader ldr = APP_CLS_LDR;
+
+            while (ldr != null) {
+                Vector vector = U.field(ldr, "nativeLibraries");
+
+                for (Object lib : vector) {
+                    String libName = U.field(lib, "name");
+
+                    if (libName.contains(LIBHADOOP)) {
+                        curVector.add(lib);
+
+                        return;
+                    }
+                }
+
+                ldr = ldr.getParent();
+            }
+        }
+        catch (Exception e) {
+            U.quietAndWarn(null, "Failed to initialize Hadoop native library " +
+                "(native Hadoop methods might not work properly): " + e);
+        }
     }
 
     /**
@@ -152,8 +201,6 @@ public class HadoopClassLoader extends URLClassLoader {
             if (isHadoop(name)) { // Always load Hadoop classes explicitly, since Hadoop can be available in App classpath.
                 if (name.endsWith(".util.ShutdownHookManager"))  // Dirty hack to get rid of Hadoop shutdown hooks.
                     return loadFromBytes(name, HadoopShutdownHookManager.class.getName());
-                else if (name.endsWith(".util.NativeCodeLoader"))
-                    return loadFromBytes(name, HadoopNativeCodeLoader.class.getName());
                 else if (name.equals(HADOOP_DAEMON_CLASS_NAME))
                     // We replace this in order to be able to forcibly stop some daemon threads
                     // that otherwise never stop (e.g. PeerCache runnables):
@@ -274,7 +321,7 @@ public class HadoopClassLoader extends URLClassLoader {
 
     /**
      * Check whether class has external dependencies on Hadoop.
-     * 
+     *
      * @param clsName Class name.
      * @return {@code True} if class has external dependencies.
      */
@@ -285,15 +332,15 @@ public class HadoopClassLoader extends URLClassLoader {
         ctx.mthdVisitor = new CollectingMethodVisitor(ctx, ctx.annVisitor);
         ctx.fldVisitor = new CollectingFieldVisitor(ctx, ctx.annVisitor);
         ctx.clsVisitor = new CollectingClassVisitor(ctx, ctx.annVisitor, ctx.mthdVisitor, ctx.fldVisitor);
-        
+
         return hasExternalDependencies(clsName, ctx);
     }
-        
+
     /**
      * Check whether class has external dependencies on Hadoop.
-     * 
+     *
      * @param clsName Class name.
-     * @param ctx Context.                
+     * @param ctx Context.
      * @return {@code true} If the class has external dependencies.
      */
     boolean hasExternalDependencies(String clsName, CollectingContext ctx) {
@@ -519,7 +566,7 @@ public class HadoopClassLoader extends URLClassLoader {
 
         /** Field visitor. */
         private FieldVisitor fldVisitor;
-        
+
         /** Class visitor. */
         private ClassVisitor clsVisitor;
 
@@ -627,7 +674,7 @@ public class HadoopClassLoader extends URLClassLoader {
                 onType(t);
             }
         }
-    }    
+    }
 
     /**
      * Annotation visitor.
@@ -638,7 +685,7 @@ public class HadoopClassLoader extends URLClassLoader {
 
         /**
          * Annotation visitor.
-         * 
+         *
          * @param ctx The collector.
          */
         CollectingAnnotationVisitor(CollectingContext ctx) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopNativeCodeLoader.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopNativeCodeLoader.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopNativeCodeLoader.java
deleted file mode 100644
index 4c4840d..0000000
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopNativeCodeLoader.java
+++ /dev/null
@@ -1,74 +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.hadoop.v2;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.conf.Configuration;
-
-/**
- * A fake helper to load the native hadoop code i.e. libhadoop.so.
- */
-@InterfaceAudience.Private
-@InterfaceStability.Unstable
-public class HadoopNativeCodeLoader {
-    /**
-     * Check if native-hadoop code is loaded for this platform.
-     *
-     * @return <code>true</code> if native-hadoop is loaded,
-     *         else <code>false</code>
-     */
-    public static boolean isNativeCodeLoaded() {
-        return false;
-    }
-
-    /**
-     * Returns true only if this build was compiled with support for snappy.
-     */
-    public static boolean buildSupportsSnappy() {
-        return false;
-    }
-
-    /**
-     * @return Library name.
-     */
-    public static String getLibraryName() {
-        throw new IllegalStateException();
-    }
-
-    /**
-     * Return if native hadoop libraries, if present, can be used for this job.
-     * @param conf configuration
-     *
-     * @return <code>true</code> if native hadoop libraries, if present, can be
-     *         used for this job; <code>false</code> otherwise.
-     */
-    public boolean getLoadNativeLibraries(Configuration conf) {
-        return false;
-    }
-
-    /**
-     * Set if native hadoop libraries, if present, can be used for this job.
-     *
-     * @param conf configuration
-     * @param loadNativeLibraries can native hadoop libraries be loaded
-     */
-    public void setLoadNativeLibraries(Configuration conf, boolean loadNativeLibraries) {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractWordCountTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractWordCountTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractWordCountTest.java
index a47eaf6..e45c127 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractWordCountTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopAbstractWordCountTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.hadoop;
 
 import com.google.common.base.Joiner;
 import java.io.BufferedReader;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -26,6 +27,11 @@ import java.util.Collections;
 import java.util.List;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.SequenceFile;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.processors.igfs.IgfsEx;
 
@@ -118,21 +124,49 @@ public abstract class HadoopAbstractWordCountTest extends HadoopAbstractSelfTest
     }
 
     /**
+     * Read w/o decoding (default).
+     *
+     * @param fileName The file.
+     * @return The file contents, human-readable.
+     * @throws Exception On error.
+     */
+    protected String readAndSortFile(String fileName) throws Exception {
+        return readAndSortFile(fileName, null);
+    }
+
+    /**
      * Reads whole text file into String.
      *
      * @param fileName Name of the file to read.
      * @return Content of the file as String value.
      * @throws Exception If could not read the file.
      */
-    protected String readAndSortFile(String fileName) throws Exception {
-        BufferedReader reader = new BufferedReader(new InputStreamReader(igfs.open(new IgfsPath(fileName))));
+    protected String readAndSortFile(String fileName, Configuration conf) throws Exception {
+        final List<String> list = new ArrayList<>();
+
+        final boolean snappyDecode = conf != null && conf.getBoolean(FileOutputFormat.COMPRESS, false);
+
+        if (snappyDecode) {
+            try (SequenceFile.Reader reader = new SequenceFile.Reader(conf,
+                    SequenceFile.Reader.file(new Path(fileName)))) {
+                Text key = new Text();
 
-        List<String> list = new ArrayList<>();
+                IntWritable val = new IntWritable();
 
-        String line;
+                while (reader.next(key, val))
+                    list.add(key + "\t" + val);
+            }
+        }
+        else {
+            try (InputStream is0 = igfs.open(new IgfsPath(fileName))) {
+                BufferedReader reader = new BufferedReader(new InputStreamReader(is0));
+
+                String line;
 
-        while ((line = reader.readLine()) != null)
-            list.add(line);
+                while ((line = reader.readLine()) != null)
+                    list.add(line);
+            }
+        }
 
         Collections.sort(list);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceEmbeddedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceEmbeddedSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceEmbeddedSelfTest.java
index c0eff48..25ef382 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceEmbeddedSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceEmbeddedSelfTest.java
@@ -106,7 +106,7 @@ public class HadoopMapReduceEmbeddedSelfTest extends HadoopMapReduceTest {
 
             Job job = Job.getInstance(jobConf);
 
-            HadoopWordCount2.setTasksClasses(job, useNewAPI, useNewAPI, useNewAPI);
+            HadoopWordCount2.setTasksClasses(job, useNewAPI, useNewAPI, useNewAPI, false);
 
             if (useNewAPI) {
                 job.setPartitionerClass(CustomV2Partitioner.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
index d0bd92b..7fd8272 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
@@ -183,7 +183,7 @@ public class HadoopMapReduceTest extends HadoopAbstractWordCountTest {
 
             Job job = Job.getInstance(jobConf);
 
-            HadoopWordCount2.setTasksClasses(job, useNewMapper, useNewCombiner, useNewReducer);
+            HadoopWordCount2.setTasksClasses(job, useNewMapper, useNewCombiner, useNewReducer, compressOutputSnappy());
 
             job.setOutputKeyClass(Text.class);
             job.setOutputValueClass(IntWritable.class);
@@ -207,18 +207,29 @@ public class HadoopMapReduceTest extends HadoopAbstractWordCountTest {
 
             checkOwner(new IgfsPath(outFile));
 
+            String actual = readAndSortFile(outFile, job.getConfiguration());
+
             assertEquals("Use new mapper: " + useNewMapper + ", new combiner: " + useNewCombiner + ", new reducer: " +
                 useNewReducer,
                 "blue\t" + blue + "\n" +
                 "green\t" + green + "\n" +
                 "red\t" + red + "\n" +
                 "yellow\t" + yellow + "\n",
-                readAndSortFile(outFile)
+                actual
             );
         }
     }
 
     /**
+     * Gets if to compress output data with Snappy.
+     *
+     * @return If to compress output data with Snappy.
+     */
+    protected boolean compressOutputSnappy() {
+        return false;
+    }
+
+    /**
      * Simple test job statistics.
      *
      * @param jobId Job id.

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

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopSnappyTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopSnappyTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopSnappyTest.java
new file mode 100644
index 0000000..014ff1e
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopSnappyTest.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+import java.util.concurrent.ThreadLocalRandom;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.compress.CompressionInputStream;
+import org.apache.hadoop.io.compress.CompressionOutputStream;
+import org.apache.hadoop.io.compress.SnappyCodec;
+import org.apache.hadoop.io.compress.snappy.SnappyCompressor;
+import org.apache.hadoop.util.NativeCodeLoader;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests isolated Hadoop Snappy codec usage.
+ */
+public class HadoopSnappyTest extends GridCommonAbstractTest {
+    /** Length of data. */
+    private static final int BYTE_SIZE = 1024 * 50;
+
+    /**
+     * Checks Snappy codec usage.
+     *
+     * @throws Exception On error.
+     */
+    public void testSnappy() throws Throwable {
+        // Run Snappy test in default class loader:
+        checkSnappy();
+
+        // Run the same in several more class loaders simulating jobs and tasks:
+        for (int i = 0; i < 2; i++) {
+            ClassLoader hadoopClsLdr = new HadoopClassLoader(null, "cl-" + i);
+
+            Class<?> cls = (Class)Class.forName(HadoopSnappyTest.class.getName(), true, hadoopClsLdr);
+
+            assertEquals(hadoopClsLdr, cls.getClassLoader());
+
+            U.invoke(cls, null, "checkSnappy");
+        }
+    }
+
+    /**
+     * Internal check routine.
+     *
+     * @throws Throwable If failed.
+     */
+    public static void checkSnappy() throws Throwable {
+        try {
+            byte[] expBytes = new byte[BYTE_SIZE];
+            byte[] actualBytes = new byte[BYTE_SIZE];
+
+            for (int i = 0; i < expBytes.length ; i++)
+                expBytes[i] = (byte)ThreadLocalRandom.current().nextInt(16);
+
+            SnappyCodec codec = new SnappyCodec();
+
+            codec.setConf(new Configuration());
+
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+            try (CompressionOutputStream cos = codec.createOutputStream(baos)) {
+                cos.write(expBytes);
+                cos.flush();
+            }
+
+            try (CompressionInputStream cis = codec.createInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
+                int read = cis.read(actualBytes, 0, actualBytes.length);
+
+                assert read == actualBytes.length;
+            }
+
+            assert Arrays.equals(expBytes, actualBytes);
+        }
+        catch (Throwable e) {
+            System.out.println("Snappy check failed:");
+            System.out.println("### NativeCodeLoader.isNativeCodeLoaded:  " + NativeCodeLoader.isNativeCodeLoaded());
+            System.out.println("### SnappyCompressor.isNativeCodeLoaded:  " + SnappyCompressor.isNativeCodeLoaded());
+
+            throw e;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTasksV2Test.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTasksV2Test.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTasksV2Test.java
index 3a964d6..d125deb 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTasksV2Test.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTasksV2Test.java
@@ -48,7 +48,7 @@ public class HadoopTasksV2Test extends HadoopTasksAllVersionsTest {
         job.setOutputKeyClass(Text.class);
         job.setOutputValueClass(IntWritable.class);
 
-        HadoopWordCount2.setTasksClasses(job, true, true, true);
+        HadoopWordCount2.setTasksClasses(job, true, true, true, false);
 
         Configuration conf = job.getConfiguration();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount1Reduce.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount1Reduce.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount1Reduce.java
index 120ac19..2335911 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount1Reduce.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount1Reduce.java
@@ -47,6 +47,7 @@ public class HadoopWordCount1Reduce extends MapReduceBase implements Reducer<Tex
         output.collect(key, new IntWritable(sum));
     }
 
+    /** {@inheritDoc} */
     @Override public void configure(JobConf job) {
         super.configure(job);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2.java
index 942a908..4b508ca 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2.java
@@ -20,11 +20,14 @@ package org.apache.ignite.internal.processors.hadoop.examples;
 import java.io.IOException;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.compress.SnappyCodec;
 import org.apache.hadoop.mapreduce.Job;
 import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
 import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
 import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
 
 /**
@@ -62,7 +65,7 @@ public class HadoopWordCount2 {
         job.setOutputKeyClass(Text.class);
         job.setOutputValueClass(IntWritable.class);
 
-        setTasksClasses(job, true, true, true);
+        setTasksClasses(job, true, true, true, false);
 
         FileInputFormat.setInputPaths(job, new Path(input));
         FileOutputFormat.setOutputPath(job, new Path(output));
@@ -80,7 +83,8 @@ public class HadoopWordCount2 {
      * @param setCombiner Option to set combiner class.
      * @param setReducer Option to set reducer and output format classes.
      */
-    public static void setTasksClasses(Job job, boolean setMapper, boolean setCombiner, boolean setReducer) {
+    public static void setTasksClasses(Job job, boolean setMapper, boolean setCombiner, boolean setReducer,
+            boolean outputCompression) {
         if (setMapper) {
             job.setMapperClass(HadoopWordCount2Mapper.class);
             job.setInputFormatClass(TextInputFormat.class);
@@ -93,5 +97,15 @@ public class HadoopWordCount2 {
             job.setReducerClass(HadoopWordCount2Reducer.class);
             job.setOutputFormatClass(TextOutputFormat.class);
         }
+
+        if (outputCompression) {
+            job.setOutputFormatClass(SequenceFileOutputFormat.class);
+
+            SequenceFileOutputFormat.setOutputCompressionType(job, SequenceFile.CompressionType.BLOCK);
+
+            SequenceFileOutputFormat.setCompressOutput(job, true);
+
+            job.getConfiguration().set(FileOutputFormat.COMPRESS_CODEC, SnappyCodec.class.getName());
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2Reducer.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2Reducer.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2Reducer.java
index b2be53e..63a9d95 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2Reducer.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/examples/HadoopWordCount2Reducer.java
@@ -55,6 +55,7 @@ public class HadoopWordCount2Reducer extends Reducer<Text, IntWritable, Text, In
     /** {@inheritDoc} */
     @Override protected void setup(Context context) throws IOException, InterruptedException {
         super.setup(context);
+
         wasSetUp = true;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d58d14a/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 1831085..6c542b5 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
@@ -25,6 +25,8 @@ import java.io.IOException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.List;
 import junit.framework.TestSuite;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
@@ -63,6 +65,7 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobTrackerSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopMapReduceEmbeddedSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopMapReduceTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopSerializationWrapperSelfTest;
+import org.apache.ignite.internal.processors.hadoop.HadoopSnappyTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopSortingTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapperSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopTaskExecutionSelfTest;
@@ -70,6 +73,7 @@ import org.apache.ignite.internal.processors.hadoop.HadoopTasksV1Test;
 import org.apache.ignite.internal.processors.hadoop.HadoopTasksV2Test;
 import org.apache.ignite.internal.processors.hadoop.HadoopV2JobSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopValidationSelfTest;
+import org.apache.ignite.internal.processors.hadoop.HadoopSnappyFullMapReduceTest;
 import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopConcurrentHashMultimapSelftest;
 import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopHashMapSelfTest;
 import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipListSelfTest;
@@ -96,6 +100,9 @@ public class IgniteHadoopTestSuite extends TestSuite {
 
         TestSuite suite = new TestSuite("Ignite Hadoop MR Test Suite");
 
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopSnappyTest.class.getName())));
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopSnappyFullMapReduceTest.class.getName())));
+
         suite.addTest(new TestSuite(ldr.loadClass(HadoopClassLoaderTest.class.getName())));
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfs20FileSystemLoopbackPrimarySelfTest.class.getName())));
@@ -192,7 +199,7 @@ public class IgniteHadoopTestSuite extends TestSuite {
 
         X.println("Will use Hadoop version: " + ver);
 
-        String downloadPath = "hadoop/common/hadoop-" + ver + "/hadoop-" + ver + ".tar.gz";
+        String downloadPath = "hadoop/core/hadoop-" + ver + "/hadoop-" + ver + ".tar.gz";
 
         download("Hadoop", "HADOOP_HOME", downloadPath, "hadoop-" + ver);
     }
@@ -217,6 +224,7 @@ public class IgniteHadoopTestSuite extends TestSuite {
         }
 
         List<String> urls = F.asList(
+            "http://archive.apache.org/dist/",
             "http://apache-mirror.rbc.ru/pub/apache/",
             "http://www.eu.apache.org/dist/",
             "http://www.us.apache.org/dist/");
@@ -273,6 +281,14 @@ public class IgniteHadoopTestSuite extends TestSuite {
                             if (!dest.mkdirs())
                                 throw new IllegalStateException();
                         }
+                        else if (entry.isSymbolicLink()) {
+                            // Important: in Hadoop installation there are symlinks, we need to create them:
+                            Path theLinkItself = Paths.get(install.getAbsolutePath(), entry.getName());
+
+                            Path linkTarget = Paths.get(entry.getLinkName());
+
+                            Files.createSymbolicLink(theLinkItself, linkTarget);
+                        }
                         else {
                             File parent = dest.getParentFile();
 


[05/29] ignite git commit: Revert "IGNITE-2330: Simplified GridFunc."

Posted by vo...@apache.org.
Revert "IGNITE-2330: Simplified GridFunc."

This reverts commit 80579253febd6389dbb3a84706671cc8083df1f2.


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

Branch: refs/heads/ignite-2236
Commit: ddbe2d596e5aaf0b04a26c584dfe2ca8a664c570
Parents: cd5cd2e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Sun Jan 3 23:49:09 2016 +0400
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Sun Jan 3 23:49:09 2016 +0400

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |   27 +-
 .../internal/cluster/ClusterGroupAdapter.java   |   10 +-
 .../discovery/GridDiscoveryManager.java         |   19 +-
 .../loadbalancer/GridLoadBalancerManager.java   |    8 +-
 .../processors/cache/GridCacheAdapter.java      |   14 +-
 .../processors/cache/GridCacheContext.java      |    3 +-
 .../cache/GridCacheEvictionManager.java         |    5 +-
 .../processors/cache/GridCacheIoManager.java    |    5 +-
 .../processors/cache/GridCacheIterator.java     |    4 +-
 .../processors/cache/GridCacheKeySet.java       |    2 +-
 .../GridCachePartitionExchangeManager.java      |   12 +-
 .../processors/cache/GridCacheProcessor.java    |    9 +-
 .../processors/cache/GridCacheSwapManager.java  |    7 +-
 .../processors/cache/GridCacheUtils.java        |   92 -
 .../cache/GridCacheValueCollection.java         |    5 +-
 .../processors/cache/IgniteCacheProxy.java      |    4 +-
 .../dht/GridClientPartitionTopology.java        |    3 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |    3 +-
 .../dht/GridDhtTransactionalCacheAdapter.java   |    3 +-
 .../distributed/dht/GridDhtTxLocalAdapter.java  |    3 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |    5 +-
 .../dht/atomic/GridDhtAtomicCache.java          |   21 +-
 .../dht/preloader/GridDhtForceKeysFuture.java   |    8 +-
 .../distributed/near/GridNearCacheAdapter.java  |   11 +-
 .../local/atomic/GridLocalAtomicCache.java      |   17 +-
 .../GridCacheAtomicStampedImpl.java             |    5 +-
 .../internal/processors/igfs/IgfsProcessor.java |    8 +-
 .../dotnet/PlatformDotNetCacheStore.java        |    4 +-
 .../top/GridTopologyCommandHandler.java         |    3 +-
 .../org/apache/ignite/internal/util/F0.java     |  325 +++-
 .../internal/util/GridExecutionStatistics.java  |    4 +-
 .../ignite/internal/util/IgniteUtils.java       |    4 +-
 .../ignite/internal/util/lang/GridFunc.java     | 1764 ++++++++++++++----
 .../ignite/internal/util/lang/GridTuple3.java   |    1 +
 .../ignite/internal/util/lang/GridTuple4.java   |    1 +
 .../ignite/internal/util/lang/GridTuple5.java   |    1 +
 .../ignite/internal/util/lang/GridTuple6.java   |    1 +
 .../ignite/internal/util/lang/GridTupleV.java   |    1 +
 .../java/org/apache/ignite/lang/IgniteUuid.java |    2 +-
 .../memory/MemoryEventStorageSpi.java           |    1 -
 .../cache/GridCacheLuceneQueryIndexTest.java    |    4 +-
 .../distributed/GridCacheEventAbstractTest.java |    2 +-
 .../IpcSharedMemoryCrashDetectionSelfTest.java  |   16 +-
 .../ignite/lang/GridBasicPerformanceTest.java   |   10 +-
 .../ignite/lang/GridFuncPerformanceTest.java    |  102 +
 .../ignite/loadtest/GridLoadTestStatistics.java |    2 +-
 .../query/h2/opt/GridH2TreeIndex.java           |    4 +-
 47 files changed, 1988 insertions(+), 577 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 7fc0313..14b5816 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
@@ -589,16 +589,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     @Override public List<String> getLifecycleBeansFormatted() {
         LifecycleBean[] beans = cfg.getLifecycleBeans();
 
-        if (F.isEmpty(beans))
-            return Collections.emptyList();
-        else {
-            List<String> res = new ArrayList<>(beans.length);
-
-            for (LifecycleBean bean : beans)
-                res.add(String.valueOf(bean));
-
-            return res;
-        }
+        return F.isEmpty(beans) ? Collections.<String>emptyList() :
+            (List<String>)F.transform(beans, F.<LifecycleBean>string());
     }
 
     /**
@@ -2277,19 +2269,16 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         Collection<Object> objs = new ArrayList<>();
 
         if (!F.isEmpty(cfg.getLifecycleBeans()))
-            Collections.addAll(objs, cfg.getLifecycleBeans());
+            F.copy(objs, cfg.getLifecycleBeans());
 
         if (!F.isEmpty(cfg.getSegmentationResolvers()))
-            Collections.addAll(objs, cfg.getSegmentationResolvers());
+            F.copy(objs, cfg.getSegmentationResolvers());
 
-        if (cfg.getConnectorConfiguration() != null) {
-            objs.add(cfg.getConnectorConfiguration().getMessageInterceptor());
-            objs.add(cfg.getConnectorConfiguration().getSslContextFactory());
-        }
+        if (cfg.getConnectorConfiguration() != null)
+            F.copy(objs, cfg.getConnectorConfiguration().getMessageInterceptor(),
+                cfg.getConnectorConfiguration().getSslContextFactory());
 
-        objs.add(cfg.getMarshaller());
-        objs.add(cfg.getGridLogger());
-        objs.add(cfg.getMBeanServer());
+        F.copy(objs, cfg.getMarshaller(), cfg.getGridLogger(), cfg.getMBeanServer());
 
         return objs;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
index a153b83..75168a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
@@ -51,7 +51,6 @@ import org.apache.ignite.internal.IgniteServicesImpl;
 import org.apache.ignite.internal.IgnitionEx;
 import org.apache.ignite.internal.executor.GridExecutorService;
 import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
-import org.apache.ignite.internal.util.lang.GridNodePredicate;
 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;
@@ -368,7 +367,8 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
         guard();
 
         try {
-            ctx.resource().injectGeneric(p);
+            if (p != null)
+                ctx.resource().injectGeneric(p);
 
             return new ClusterGroupAdapter(ctx, subjId, this.p != null ? F.and(p, this.p) : p);
         }
@@ -703,7 +703,6 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
     @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         gridName = U.readString(in);
         subjId = U.readUuid(in);
@@ -920,7 +919,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
 
                 ClusterNode node = isOldest ? U.oldest(super.nodes(), null) : U.youngest(super.nodes(), null);
 
-                IgnitePredicate<ClusterNode> p = new GridNodePredicate(node);
+                IgnitePredicate<ClusterNode> p = F.nodeForNodes(node);
 
                 state = new AgeClusterGroupState(node, p, lastTopVer);
             }
@@ -962,7 +961,8 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
             guard();
 
             try {
-                ctx.resource().injectGeneric(p);
+                if (p != null)
+                    ctx.resource().injectGeneric(p);
 
                 return new ClusterGroupAdapter(ctx, this.subjId, new GroupPredicate(this, p));
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 844fd0f..72a2bef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -30,6 +30,7 @@ import java.util.ArrayDeque;
 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;
@@ -78,6 +79,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.jobmetrics.GridJobMetrics;
 import org.apache.ignite.internal.processors.security.SecurityContext;
 import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridBoundedConcurrentOrderedMap;
 import org.apache.ignite.internal.util.GridSpinBusyLock;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -1315,26 +1317,13 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
     }
 
     /**
-     * Gets collection of node for given node IDs.
-     *
-     * @param ids Ids to include.
-     * @return Collection with all alive nodes for given IDs.
-     */
-    public Collection<ClusterNode> nodes(@Nullable Collection<UUID> ids) {
-        return F.isEmpty(ids) ? Collections.<ClusterNode>emptyList() :
-            F.view(
-                F.viewReadOnly(ids, U.id2Node(ctx)),
-                F.notNull());
-    }
-
-    /**
      * Gets collection of node for given node IDs and predicates.
      *
      * @param ids Ids to include.
      * @param p Filter for IDs.
      * @return Collection with all alive nodes for given IDs.
      */
-    public Collection<ClusterNode> nodes(@Nullable Collection<UUID> ids, IgnitePredicate<UUID> p) {
+    public Collection<ClusterNode> nodes(@Nullable Collection<UUID> ids, IgnitePredicate<UUID>... p) {
         return F.isEmpty(ids) ? Collections.<ClusterNode>emptyList() :
             F.view(
                 F.viewReadOnly(ids, U.id2Node(ctx), p),
@@ -2576,7 +2565,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
             nearEnabledCaches = Collections.unmodifiableSet(nearEnabledSet);
 
             daemonNodes = Collections.unmodifiableList(new ArrayList<>(
-                F.view(F.concat(false, loc, rmts), F.not(daemonFilter))));
+                F.view(F.concat(false, loc, rmts), F0.not(daemonFilter))));
 
             Map<UUID, ClusterNode> nodeMap = new HashMap<>(allNodes().size() + daemonNodes.size(), 1.0f);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
index efe09b0..631168b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/loadbalancer/GridLoadBalancerManager.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.managers.loadbalancer;
 
 import java.util.Collection;
-import java.util.LinkedList;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -93,12 +92,7 @@ public class GridLoadBalancerManager extends GridManagerAdapter<LoadBalancingSpi
                 if (F.isEmpty(exclNodes))
                     return GridLoadBalancerManager.this.getBalancedNode(ses, top, job);
 
-                List<ClusterNode> nodes = new LinkedList<>();
-
-                for (ClusterNode topNode : top) {
-                    if (!exclNodes.contains(topNode))
-                        nodes.add(topNode);
-                }
+                List<ClusterNode> nodes = F.loseList(top, true, exclNodes);
 
                 if (nodes.isEmpty())
                     return null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index a4cf737..5d4c386 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -106,6 +106,7 @@ import org.apache.ignite.internal.util.future.GridFutureAdapter;
 import org.apache.ignite.internal.util.lang.GridClosureException;
 import org.apache.ignite.internal.util.lang.GridTriple;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.C1;
 import org.apache.ignite.internal.util.typedef.C2;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.CI2;
@@ -2149,7 +2150,12 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         return syncOp(new SyncOp<Map<K, EntryProcessorResult<T>>>(keys.size() == 1) {
             @Nullable @Override public Map<K, EntryProcessorResult<T>> op(IgniteTxLocalAdapter tx)
                 throws IgniteCheckedException {
-                Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = CU.invokeMap(keys, entryProcessor);
+                Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = F.viewAsMap(keys,
+                    new C1<K, EntryProcessor<K, V, Object>>() {
+                            @Override public EntryProcessor apply(K k) {
+                            return entryProcessor;
+                        }
+                    });
 
                 IgniteInternalFuture<GridCacheReturn> fut = tx.invokeAsync(ctx, invokeMap, args);
 
@@ -2216,7 +2222,11 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
         IgniteInternalFuture<?> fut = asyncOp(new AsyncInOp(keys) {
             @Override public IgniteInternalFuture<GridCacheReturn> inOp(IgniteTxLocalAdapter tx) {
-                Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = CU.invokeMap(keys, entryProcessor);
+                Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = F.viewAsMap(keys, new C1<K, EntryProcessor<K, V, Object>>() {
+                    @Override public EntryProcessor apply(K k) {
+                        return entryProcessor;
+                    }
+                });
 
                 return tx.invokeAsync(ctx, invokeMap, args);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index ef49567..c10ebf3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -85,6 +85,7 @@ import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
 import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
 import org.apache.ignite.internal.processors.plugin.CachePluginManager;
 import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.lang.GridFunc;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -1511,7 +1512,7 @@ public class GridCacheContext<K, V> implements Externalizable {
             Collection<ClusterNode> nearNodes = null;
 
             if (!F.isEmpty(readers)) {
-                nearNodes = discovery().nodes(readers, F.notEqualTo(nearNodeId));
+                nearNodes = discovery().nodes(readers, F0.notEqualTo(nearNodeId));
 
                 if (log.isDebugEnabled())
                     log.debug("Mapping entry to near nodes [nodes=" + U.nodeIds(nearNodes) + ", entry=" + entry + ']');

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index f542f4b..845e204 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -63,6 +63,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
 import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridBusyLock;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.GridUnsafe;
@@ -1309,7 +1310,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
                 try {
                     GridCacheVersion ver = e.version();
 
-                    return info.version().equals(ver) && F.isAll(e, info.filter());
+                    return info.version().equals(ver) && F.isAll(info.filter());
                 }
                 catch (GridCacheEntryRemovedException ignored) {
                     return false;
@@ -1340,7 +1341,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
         Collection<ClusterNode> backups;
 
         if (evictSync)
-            backups = F.view(cctx.dht().topology().nodes(entry.partition(), topVer), F.notEqualTo(cctx.localNode()));
+            backups = F.view(cctx.dht().topology().nodes(entry.partition(), topVer), F0.notEqualTo(cctx.localNode()));
         else
             backups = Collections.emptySet();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 4c9cdf2..0aa8b1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -57,6 +57,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPr
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
 import org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest;
 import org.apache.ignite.internal.processors.cache.query.GridCacheQueryResponse;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.GridSpinReadWriteLock;
 import org.apache.ignite.internal.util.typedef.CI1;
@@ -730,7 +731,7 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
                 }
 
                 if (added) {
-                    if (!F.exist(F.nodeIds(nodes), F.not(F.contains(leftIds)))) {
+                    if (!F.exist(F.nodeIds(nodes), F0.not(F.contains(leftIds)))) {
                         if (log.isDebugEnabled())
                             log.debug("Message will not be sent because all nodes left topology [msg=" + msg +
                                 ", nodes=" + U.toShortString(nodes) + ']');
@@ -766,7 +767,7 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
                     U.sleep(retryDelay);
                 }
 
-                if (!F.exist(F.nodeIds(nodes), F.not(F.contains(leftIds)))) {
+                if (!F.exist(F.nodeIds(nodes), F0.not(F.contains(leftIds)))) {
                     if (log.isDebugEnabled())
                         log.debug("Message will not be sent because all nodes left topology [msg=" + msg + ", nodes=" +
                             U.toShortString(nodes) + ']');

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java
index e4a471c..19da4a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java
@@ -19,8 +19,6 @@ package org.apache.ignite.internal.processors.cache;
 
 import java.util.Iterator;
 import javax.cache.Cache;
-
-import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridSerializableIterator;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgniteClosure;
@@ -59,7 +57,7 @@ public class GridCacheIterator<K, V, T> implements GridSerializableIterator<T> {
     ) {
         this.cctx = cctx;
 
-        it = F.identityIterator(c, F0.and(filter));
+        it = F.iterator0(c, false, filter);
 
         this.trans = trans;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
index af0c704..6d18b7d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
@@ -66,7 +66,7 @@ public class GridCacheKeySet<K, V> extends GridSerializableSet<K> {
 
     /** {@inheritDoc} */
     @Override public Iterator<K> iterator() {
-        return new GridCacheIterator<>(ctx, map.values(), CU.<K, V>cacheEntry2Key(), filter);
+        return new GridCacheIterator<>(ctx, map.values(), F.<K, V>cacheEntry2Key(), filter);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 4732597..a0f7f93 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -80,7 +80,6 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.worker.GridWorker;
 import org.apache.ignite.lang.IgniteBiInClosure;
-import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.thread.IgniteThread;
@@ -1271,16 +1270,9 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
                     }
 
                     // After workers line up and before preloading starts we initialize all futures.
-                    if (log.isDebugEnabled()) {
-                        IgnitePredicate p = new IgnitePredicate<IgniteInternalFuture<?>>() {
-                            @Override public boolean apply(IgniteInternalFuture<?> f) {
-                                return !f.isDone();
-                            }
-                        };
-
+                    if (log.isDebugEnabled())
                         log.debug("Before waiting for exchange futures [futs" +
-                            F.view(exchFuts.values(), p) + ", worker=" + this + ']');
-                    }
+                            F.view(exchFuts.values(), F.unfinishedFutures()) + ", worker=" + this + ']');
 
                     // Take next exchange future.
                     exchFut = poll(futQ, timeout, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 f6fc9d4..ff02e70 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -96,6 +96,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
 import org.apache.ignite.internal.processors.plugin.CachePluginManager;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -1159,12 +1160,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 log.debug("Executed onKernalStart() callback for DHT cache: " + dht.name());
         }
 
-        Collection<GridCacheManager> excluded = dhtExcludes(ctx);
-
-        for (GridCacheManager mgr : ctx.managers()) {
-            if (!excluded.contains(mgr))
-                mgr.onKernalStart();
-        }
+        for (GridCacheManager mgr : F.view(ctx.managers(), F0.notContains(dhtExcludes(ctx))))
+            mgr.onKernalStart();
 
         cache.onKernalStart();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 4490f63..37b5e15 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -42,6 +42,7 @@ import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.GridEmptyCloseableIterator;
+import org.apache.ignite.internal.util.GridEmptyIterator;
 import org.apache.ignite.internal.util.GridWeakIterator;
 import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.lang.GridTuple;
@@ -1580,7 +1581,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
      */
     public <K, V> Iterator<Map.Entry<K, V>> lazySwapIterator() throws IgniteCheckedException {
         if (!swapEnabled)
-            return F.emptyIterator();
+            return new GridEmptyIterator<>();
 
         return lazyIterator(cctx.gridSwap().rawIterator(spaceName));
     }
@@ -1671,7 +1672,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
     private <K, V> Iterator<Map.Entry<K, V>> lazyIterator(
         final GridCloseableIterator<? extends Map.Entry<byte[], byte[]>> it) {
         if (it == null)
-            return F.emptyIterator();
+            return new GridEmptyIterator<>();
 
         checkIteratorQueue();
 
@@ -1742,7 +1743,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
     private Iterator<KeyCacheObject> keyIterator(
         final GridCloseableIterator<? extends Map.Entry<byte[], byte[]>> it) {
         if (it == null)
-            return F.emptyIterator();
+            return new GridEmptyIterator<>();
 
         checkIteratorQueue();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 b7baf7e..51f6dcd 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
@@ -43,8 +43,6 @@ import javax.cache.configuration.Factory;
 import javax.cache.expiry.Duration;
 import javax.cache.expiry.ExpiryPolicy;
 import javax.cache.integration.CacheWriterException;
-import javax.cache.processor.EntryProcessor;
-
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
@@ -286,41 +284,6 @@ public class GridCacheUtils {
         }
     };
 
-    /** */
-    private static final IgniteClosure CACHE_ENTRY_KEY = new IgniteClosure() {
-        @Override public Object apply(Object o) {
-            return ((Cache.Entry)o).getKey();
-        }
-
-        @Override public String toString() {
-            return "Map entry to key transformer closure.";
-        }
-    };
-
-    /** */
-    private static final IgniteClosure CACHE_ENTRY_VAL_GET = new IgniteClosure() {
-        @SuppressWarnings({"unchecked"})
-        @Nullable @Override public Object apply(Object o) {
-            return ((Cache.Entry)o).getValue();
-        }
-
-        @Override public String toString() {
-            return "Cache entry to get-value transformer closure.";
-        }
-    };
-
-    /** */
-    private static final IgnitePredicate CACHE_ENTRY_HAS_PEEK_VAL = new IgnitePredicate() {
-        @SuppressWarnings({"unchecked"})
-        @Override public boolean apply(Object o) {
-            return ((Cache.Entry)o).getValue() != null;
-        }
-
-        @Override public String toString() {
-            return "Cache entry has-peek-value predicate.";
-        }
-    };
-
     /**
      * Ensure singleton.
      */
@@ -1900,59 +1863,4 @@ public class GridCacheUtils {
 
         return res;
     }
-
-    /**
-     * Create invoke map for the given key set. All provided values will be set to the passed entry processor.
-     *
-     * @param keys Keys.
-     * @param entryProc Entry processor.
-     * @return Invoke map.
-     */
-    @SuppressWarnings("unchecked")
-    public static <K, V, T> Map<? extends K, EntryProcessor<K, V, Object>> invokeMap(
-        final Set<? extends K> keys, final EntryProcessor<K, V, T> entryProc) {
-        return F.viewAsMap(keys,
-            new C1<K, EntryProcessor<K, V, Object>>() {
-                @Override public EntryProcessor apply(K k) {
-                    return entryProc;
-                }
-            });
-    }
-
-    /**
-     * Gets closure that returns key for cache entry. The closure internally
-     * delegates to {@link javax.cache.Cache.Entry#getKey()} method.
-     *
-     * @param <K> Key type.
-     * @return Closure that returns key for an entry.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static <K, V> IgniteClosure<Cache.Entry<K, V>, K> cacheEntry2Key() {
-        return (IgniteClosure<Cache.Entry<K, V>, K>)CACHE_ENTRY_KEY;
-    }
-
-    /**
-     * Gets closure that returns value for an entry. The closure internally
-     * delegates to {@link javax.cache.Cache.Entry#get(Object)} method.
-     *
-     * @param <K> Key type.
-     * @param <V> Value type.
-     * @return Closure that returns value for an entry.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static <K, V> IgniteClosure<Cache.Entry<K, V>, V> cacheEntry2Get() {
-        return (IgniteClosure<Cache.Entry<K, V>, V>)CACHE_ENTRY_VAL_GET;
-    }
-
-    /**
-     * Gets predicate which returns {@code true} if entry has peek value.
-     *
-     * @param <K> Cache key type.
-     * @param <V> Cache value type.
-     * @return Predicate which returns {@code true} if entry has peek value.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static <K, V> IgnitePredicate<Cache.Entry<K, V>> cacheHasPeekValue() {
-        return (IgnitePredicate<Cache.Entry<K, V>>)CACHE_ENTRY_HAS_PEEK_VAL;
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
index 68b54b3..2d1686e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java
@@ -27,7 +27,6 @@ import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridSerializableCollection;
 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.CU;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.jetbrains.annotations.Nullable;
 
@@ -73,8 +72,8 @@ public class GridCacheValueCollection<K, V> extends GridSerializableCollection<V
         return new GridCacheIterator<K, V, V>(
             ctx,
             map.values(),
-            CU.<K, V>cacheEntry2Get(),
-            ctx.vararg(F0.and(filter, CU.<K, V>cacheHasPeekValue()))
+            F.<K, V>cacheEntry2Get(),
+            ctx.vararg(F0.and(filter, F.<K, V>cacheHasPeekValue()))
         ) {
             {
                 advance();

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 a6e0ea8..27a7587 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
@@ -69,6 +69,7 @@ import org.apache.ignite.internal.processors.cache.query.CacheQuery;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
+import org.apache.ignite.internal.util.GridEmptyIterator;
 import org.apache.ignite.internal.util.future.IgniteFutureImpl;
 import org.apache.ignite.internal.util.lang.GridClosureException;
 import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
@@ -76,7 +77,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.CX1;
-import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -579,7 +579,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
 
             return new QueryCursor<Cache.Entry<K, V>>() {
                 @Override public Iterator<Cache.Entry<K, V>> iterator() {
-                    return cur != null ? cur.iterator() : F.<Cache.Entry<K, V>>emptyIterator();
+                    return cur != null ? cur.iterator() : new GridEmptyIterator<Cache.Entry<K, V>>();
                 }
 
                 @Override public List<Cache.Entry<K, V>> getAll() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index 9c18ad0..8aef5ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Gri
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridAtomicLong;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.F;
@@ -697,7 +698,7 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
 
             // Remove obsolete mappings.
             if (cur != null) {
-                for (Integer p : F.view(cur.keySet(), F.notIn(parts.keySet()))) {
+                for (Integer p : F.view(cur.keySet(), F0.notIn(parts.keySet()))) {
                     Set<UUID> ids = part2node.get(p);
 
                     if (ids != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index cdf0fc2..a0709c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Gri
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridAtomicLong;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.F;
@@ -1054,7 +1055,7 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
 
             // Remove obsolete mappings.
             if (cur != null) {
-                for (Integer p : F.view(cur.keySet(), F.notIn(parts.keySet()))) {
+                for (Integer p : F.view(cur.keySet(), F0.notIn(parts.keySet()))) {
                     Set<UUID> ids = part2node.get(p);
 
                     if (ids != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 2b40436..ae24ed1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -60,6 +60,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.lang.GridClosureException;
@@ -1381,7 +1382,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
         Collection<ClusterNode> nearNodes = null;
 
         if (!F.isEmpty(readers)) {
-            nearNodes = ctx.discovery().nodes(readers, F.not(F.idForNodeId(nodeId)));
+            nearNodes = ctx.discovery().nodes(readers, F0.not(F.idForNodeId(nodeId)));
 
             if (log.isDebugEnabled())
                 log.debug("Mapping entry to near nodes [nodes=" + U.toShortString(nearNodes) + ", entry=" + cached +

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index 1fe3ae2..534a560 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@ -42,6 +42,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridLeanMap;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
@@ -640,7 +641,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
             // Otherwise, during rollback we will not know whether locks need
             // to be rolled back.
             // Loose all skipped and previously locked (we cannot reenter locks here).
-            final Collection<KeyCacheObject> passedKeys = skipped != null ? F.view(keys, F.notIn(skipped)) : keys;
+            final Collection<KeyCacheObject> passedKeys = skipped != null ? F.view(keys, F0.notIn(skipped)) : keys;
 
             if (log.isDebugEnabled())
                 log.debug("Lock keys: " + passedKeys);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 23fdbf5..d8b2f37 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -61,6 +61,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.dr.GridDrType;
 import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
 import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -1303,14 +1304,14 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
 
                 if (!F.isEmpty(readers)) {
                     Collection<ClusterNode> nearNodes =
-                        cctx.discovery().nodes(readers, F.not(F.idForNodeId(tx.nearNodeId())));
+                        cctx.discovery().nodes(readers, F0.not(F.idForNodeId(tx.nearNodeId())));
 
                     if (log.isDebugEnabled())
                         log.debug("Mapping entry to near nodes [nodes=" + U.toShortString(nearNodes) +
                             ", entry=" + entry + ']');
 
                     // Exclude DHT nodes.
-                    map(entry, F.view(nearNodes, F.notIn(dhtNodes)), nearMap);
+                    map(entry, F.view(nearNodes, F0.notIn(dhtNodes)), nearMap);
                 }
                 else if (log.isDebugEnabled())
                     log.debug("Entry has no near readers: " + entry);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index e0b108b..393413e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -77,10 +77,12 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSing
 import org.apache.ignite.internal.processors.cache.dr.GridCacheDrExpirationInfo;
 import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx;
 import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -410,9 +412,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public IgniteInternalFuture<V> getAndPutAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) {
-        A.notNull(key, "key", val, "val");
+        A.notNull(key, "key");
 
-        return updateAllAsync0(F.asMap(key, val),
+        return updateAllAsync0(F0.asMap(key, val),
             null,
             null,
             null,
@@ -426,9 +428,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public IgniteInternalFuture<Boolean> putAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) {
-        A.notNull(key, "key", val, "val");
+        A.notNull(key, "key");
 
-        return updateAllAsync0(F.asMap(key, val),
+        return updateAllAsync0(F0.asMap(key, val),
             null,
             null,
             null,
@@ -443,7 +445,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException {
         A.notNull(key, "key", val, "val");
 
-        return (V)updateAllAsync0(F.asMap(key, val),
+        return (V)updateAllAsync0(F0.asMap(key, val),
             null,
             null,
             null,
@@ -793,13 +795,18 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> IgniteInternalFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
-        EntryProcessor<K, V, T> entryProcessor, Object... args) {
+        final EntryProcessor<K, V, T> entryProcessor,
+        Object... args) {
         A.notNull(keys, "keys", entryProcessor, "entryProcessor");
 
         if (keyCheck)
             validateCacheKeys(keys);
 
-        Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = CU.invokeMap(keys, entryProcessor);
+        Map<? extends K, EntryProcessor> invokeMap = F.viewAsMap(keys, new C1<K, EntryProcessor>() {
+            @Override public EntryProcessor apply(K k) {
+                return entryProcessor;
+            }
+        });
 
         CacheOperationContext opCtx = ctx.operationContextPerCall();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
index 6b03131..7970a44 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
@@ -43,6 +43,7 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtFuture;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -520,11 +521,8 @@ public final class GridDhtForceKeysFuture<K, V> extends GridCompoundFuture<Objec
             if (!cctx.rebalanceEnabled()) {
                 Collection<KeyCacheObject> retryKeys = F.view(
                     keys,
-                    F.and(
-                        F.notIn(missedKeys),
-                        F.notIn(F.viewReadOnly(res.forcedInfos(), CU.<KeyCacheObject, V>info2Key()))
-                    )
-                );
+                    F0.notIn(missedKeys),
+                    F0.notIn(F.viewReadOnly(res.forcedInfos(), CU.<KeyCacheObject, V>info2Key())));
 
                 if (!retryKeys.isEmpty())
                     map(retryKeys, F.concat(false, node, exc));

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 5c48dc7..5bf18d9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -64,7 +64,6 @@ import org.apache.ignite.internal.util.typedef.C1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
 import org.apache.ignite.internal.util.typedef.internal.A;
-import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.jetbrains.annotations.NotNull;
@@ -417,7 +416,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
 
     /** {@inheritDoc} */
     @Override public Collection<V> values(CacheEntryPredicate... filter) {
-        return new GridCacheValueCollection<>(ctx, entrySet(filter), ctx.vararg(CU.<K, V>cacheHasPeekValue()));
+        return new GridCacheValueCollection<>(ctx, entrySet(filter), ctx.vararg(F.<K, V>cacheHasPeekValue()));
     }
 
     /** {@inheritDoc} */
@@ -559,12 +558,12 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
         /** {@inheritDoc} */
         @NotNull @Override public Iterator<Cache.Entry<K, V>> iterator() {
             return new EntryIterator(nearSet.iterator(),
-                F.identityIterator(dhtSet, new P1<Cache.Entry<K, V>>() {
-                    @Override
-                    public boolean apply(Cache.Entry<K, V> e) {
+                F.iterator0(dhtSet, false, new P1<Cache.Entry<K, V>>() {
+                    @Override public boolean apply(Cache.Entry<K, V> e) {
                         try {
                             return GridNearCacheAdapter.super.localPeek(e.getKey(), NEAR_PEEK_MODE, null) == null;
-                        } catch (IgniteCheckedException ex) {
+                        }
+                        catch (IgniteCheckedException ex) {
                             throw new IgniteException(ex);
                         }
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index 3b60f96..6130ead 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -60,6 +60,7 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.local.GridLocalCacheEntry;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -188,7 +189,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     @Override public IgniteInternalFuture<V> getAndPutAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) {
         A.notNull(key, "key", val, "val");
 
-        return updateAllAsync0(F.asMap(key, val),
+        return updateAllAsync0(F0.asMap(key, val),
             null,
             null,
             true,
@@ -201,7 +202,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     @Override public IgniteInternalFuture<Boolean> putAsync0(K key, V val, @Nullable CacheEntryPredicate... filter) {
         A.notNull(key, "key", val, "val");
 
-        return updateAllAsync0(F.asMap(key, val),
+        return updateAllAsync0(F0.asMap(key, val),
             null,
             null,
             false,
@@ -658,7 +659,11 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         if (keyCheck)
             validateCacheKeys(keys);
 
-        Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = CU.invokeMap(keys, entryProcessor);
+        Map<? extends K, EntryProcessor> invokeMap = F.viewAsMap(keys, new C1<K, EntryProcessor>() {
+            @Override public EntryProcessor apply(K k) {
+                return entryProcessor;
+            }
+        });
 
         CacheOperationContext opCtx = ctx.operationContextPerCall();
 
@@ -724,7 +729,11 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         if (keyCheck)
             validateCacheKeys(keys);
 
-        Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = CU.invokeMap(keys, entryProcessor);
+        Map<? extends K, EntryProcessor> invokeMap = F.viewAsMap(keys, new C1<K, EntryProcessor>() {
+            @Override public EntryProcessor apply(K k) {
+                return entryProcessor;
+            }
+        });
 
         return updateAllAsync0(null,
             invokeMap,

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
index 84c4269..f7a82a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -178,8 +179,8 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt
         checkRemoved();
 
         try {
-            return CU.outTx(internalCompareAndSet(F.equalTo(expVal), wrapperClosure(newVal),
-                F.equalTo(expStamp), wrapperClosure(newStamp)), ctx);
+            return CU.outTx(internalCompareAndSet(F0.equalTo(expVal), wrapperClosure(newVal),
+                F0.equalTo(expStamp), wrapperClosure(newStamp)), ctx);
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index b313084..5b8cf86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -45,6 +45,7 @@ import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.util.ipc.IpcServerEndpoint;
 import org.apache.ignite.internal.util.typedef.C1;
+import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -127,8 +128,11 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
 
         final Map<String, CacheConfiguration> cacheCfgs = new HashMap<>();
 
-        for (CacheConfiguration c : gridCfg.getCacheConfiguration())
-            cacheCfgs.put(c.getName(), c);
+        F.forEach(gridCfg.getCacheConfiguration(), new CI1<CacheConfiguration>() {
+            @Override public void apply(CacheConfiguration c) {
+                cacheCfgs.put(c.getName(), c);
+            }
+        });
 
         Collection<IgfsAttributes> attrVals = new ArrayList<>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 9f0fd3f..7e65c22 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
@@ -235,13 +235,13 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
                         @Override public Set<Entry<K, V>> entrySet() {
                             return new AbstractSet<Entry<K, V>>() {
                                 @Override public Iterator<Entry<K, V>> iterator() {
-                                    return F.iteratorReadOnly(entries, new C1<Cache.Entry<? extends K, ? extends V>, Entry<K, V>>() {
+                                    return F.iterator(entries, new C1<Cache.Entry<? extends K, ? extends V>, Entry<K, V>>() {
                                         private static final long serialVersionUID = 0L;
 
                                         @Override public Entry<K, V> apply(Cache.Entry<? extends K, ? extends V> entry) {
                                             return new GridMapEntry<>(entry.getKey(), entry.getValue());
                                         }
-                                    });
+                                    }, true);
                                 }
 
                                 @Override public int size() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
index 5e12199..297785e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
@@ -135,7 +135,8 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
                 }
                 else
                     node = F.find(ctx.discovery().allNodes(), null, new P1<ClusterNode>() {
-                        @Override public boolean apply(ClusterNode n) {
+                        @Override
+                        public boolean apply(ClusterNode n) {
                             return containsIp(n.addresses(), ip);
                         }
                     });

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java b/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java
index b819226..7e9e448 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/F0.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.util;
 
+import java.util.Collection;
+import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
@@ -25,9 +27,11 @@ import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
 import org.apache.ignite.internal.processors.cache.CacheEntrySerializablePredicate;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
+import org.apache.ignite.internal.util.lang.GridFunc;
 import org.apache.ignite.internal.util.lang.GridNodePredicate;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.jetbrains.annotations.Nullable;
@@ -38,6 +42,79 @@ import org.jetbrains.annotations.Nullable;
  */
 public class F0 {
     /**
+     * Negates given predicates.
+     * <p>
+     * Gets predicate (not peer-deployable) that evaluates to {@code true} if any of given predicates
+     * evaluates to {@code false}. If all predicates evaluate to {@code true} the
+     * result predicate will evaluate to {@code false}.
+     *
+     * @param p Predicate to negate.
+     * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+     * @return Negated predicate (not peer-deployable).
+     */
+    public static <T> IgnitePredicate<T> not(@Nullable final IgnitePredicate<? super T>... p) {
+        return F.isAlwaysFalse(p) ? F.<T>alwaysTrue() : F.isAlwaysTrue(p) ? F.<T>alwaysFalse() : new P1<T>() {
+            @Override public boolean apply(T t) {
+                return !F.isAll(t, p);
+            }
+        };
+    }
+
+    /**
+     * Gets predicate (not peer-deployable) that evaluates to {@code true} if its free variable is not equal
+     * to {@code target} or both are {@code null}.
+     *
+     * @param target Object to compare free variable to.
+     * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+     * @return Predicate (not peer-deployable) that evaluates to {@code true} if its free variable is not equal
+     *      to {@code target} or both are {@code null}.
+     */
+    public static <T> IgnitePredicate<T> notEqualTo(@Nullable final T target) {
+        return new P1<T>() {
+            @Override public boolean apply(T t) {
+                return !F.eq(t, target);
+            }
+        };
+    }
+
+    /**
+     * Gets predicate (not peer-deployable) that returns {@code true} if its free variable
+     * is not contained in given collection.
+     *
+     * @param c Collection to check for containment.
+     * @param <T> Type of the free variable for the predicate and type of the
+     *      collection elements.
+     * @return Predicate (not peer-deployable) that returns {@code true} if its free variable is not
+     *      contained in given collection.
+     */
+    public static <T> IgnitePredicate<T> notIn(@Nullable final Collection<? extends T> c) {
+        return F.isEmpty(c) ? GridFunc.<T>alwaysTrue() : new P1<T>() {
+            @Override public boolean apply(T t) {
+                assert c != null;
+
+                return !c.contains(t);
+            }
+        };
+    }
+
+    /**
+     * Gets predicate (not perr-deployable) that evaluates to {@code true} if its free variable is equal
+     * to {@code target} or both are {@code null}.
+     *
+     * @param target Object to compare free variable to.
+     * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+     * @return Predicate that evaluates to {@code true} if its free variable is equal to
+     *      {@code target} or both are {@code null}.
+     */
+    public static <T> IgnitePredicate<T> equalTo(@Nullable final T target) {
+        return new P1<T>() {
+            @Override public boolean apply(T t) {
+                return F.eq(t, target);
+            }
+        };
+    }
+
+    /**
      * @param p1 Filter1.
      * @param p2 Filter2.
      * @return And filter.
@@ -56,12 +133,16 @@ public class F0 {
         if (e1 && e2)
             return CU.alwaysTrue0();
 
-        if (e1) {
+        if (e1 && !e2) {
+            assert p2 != null;
+
             if (p2.length == 1)
                 return p2[0];
         }
 
-        if (e2) {
+        if (!e1 && e2) {
+            assert p1 != null;
+
             if (p1.length == 1)
                 return p1[0];
         }
@@ -69,12 +150,16 @@ public class F0 {
         return new CacheEntrySerializablePredicate(new CacheEntryPredicateAdapter() {
             @Override public boolean apply(GridCacheEntryEx e) {
                 if (!e1) {
+                    assert p1 != null;
+
                     for (CacheEntryPredicate p : p1)
                         if (p != null && !p.apply(e))
                             return false;
                 }
 
                 if (!e2) {
+                    assert p2 != null;
+
                     for (CacheEntryPredicate p : p2)
                         if (p != null && !p.apply(e))
                             return false;
@@ -101,11 +186,15 @@ public class F0 {
 
             @Override public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException {
                 if (!e1) {
+                    assert p1 != null;
+
                     for (CacheEntryPredicate p : p1)
                         p.prepareMarshal(ctx);
                 }
 
                 if (!e2) {
+                    assert p2 != null;
+
                     for (CacheEntryPredicate p : p2)
                         p.prepareMarshal(ctx);
                 }
@@ -114,6 +203,63 @@ public class F0 {
     }
 
     /**
+     * @param p Filter1.
+     * @param ps Filter2.
+     * @return And filter.
+     */
+    public static CacheEntryPredicate and0(
+        @Nullable final CacheEntryPredicate p,
+        @Nullable final CacheEntryPredicate... ps) {
+        if (p == null && F.isEmptyOrNulls(ps))
+            return CU.alwaysTrue0();
+
+        if (F.isAlwaysFalse(p) && F.isAlwaysFalse(ps))
+            return CU.alwaysFalse0();
+
+        if (F.isAlwaysTrue(p) && F.isAlwaysTrue(ps))
+            return CU.alwaysTrue0();
+
+        return new CacheEntrySerializablePredicate(new CacheEntryPredicateAdapter() {
+            @Override public boolean apply(GridCacheEntryEx e) {
+                assert ps != null;
+
+                if (p != null && !p.apply(e))
+                    return false;
+
+                for (CacheEntryPredicate p : ps) {
+                    if (p != null && !p.apply(e))
+                        return false;
+                }
+
+                return true;
+            }
+
+            @Override public void entryLocked(boolean locked) {
+                assert ps != null;
+
+                if (p != null)
+                    p.entryLocked(locked);
+
+                for (CacheEntryPredicate p : ps) {
+                    if (p != null)
+                        p.entryLocked(locked);
+                }
+            }
+
+            @Override public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException {
+                assert ps != null;
+
+                if (p != null)
+                    p.prepareMarshal(ctx);
+
+                for (CacheEntryPredicate p : ps)
+                    if (p != null)
+                        p.prepareMarshal(ctx);
+            }
+        });
+    }
+
+    /**
      * Get a predicate (non peer-deployable) that evaluates to {@code true} if each of its component predicates
      * evaluates to {@code true}. The components are evaluated in order they are supplied.
      * Evaluation will be stopped as soon as first predicate evaluates to {@code false}.
@@ -141,12 +287,16 @@ public class F0 {
         if (e1 && e2)
             return F.alwaysTrue();
 
-        if (e1) {
+        if (e1 && !e2) {
+            assert p2 != null;
+
             if (p2.length == 1)
                 return (IgnitePredicate<T>)p2[0];
         }
 
-        if (e2) {
+        if (!e1 && e2) {
+            assert p1 != null;
+
             if (p1.length == 1)
                 return (IgnitePredicate<T>)p1[0];
         }
@@ -155,11 +305,15 @@ public class F0 {
             Set<UUID> ids = new GridLeanSet<>();
 
             if (!e1) {
+                assert p1 != null;
+
                 for (IgnitePredicate<? super T> p : p1)
                     ids.addAll(((GridNodePredicate)p).nodeIds());
             }
 
             if (!e2) {
+                assert p2 != null;
+
                 for (IgnitePredicate<? super T> p : p2)
                     ids.addAll(((GridNodePredicate)p).nodeIds());
             }
@@ -171,12 +325,16 @@ public class F0 {
             return new P1<T>() {
                 @Override public boolean apply(T t) {
                     if (!e1) {
+                        assert p1 != null;
+
                         for (IgnitePredicate<? super T> p : p1)
                             if (p != null && !p.apply(t))
                                 return false;
                     }
 
                     if (!e2) {
+                        assert p2 != null;
+
                         for (IgnitePredicate<? super T> p : p2)
                             if (p != null && !p.apply(t))
                                 return false;
@@ -189,6 +347,148 @@ public class F0 {
     }
 
     /**
+     * Get a predicate (not peer-deployable) that evaluates to {@code true} if each of its component predicates
+     * evaluates to {@code true}. The components are evaluated in order they are supplied.
+     * Evaluation will be stopped as soon as first predicate evaluates to {@code false}.
+     * Passed in predicates are NOT copied. If no predicates are passed in the returned
+     * predicate will always evaluate to {@code false}.
+     *
+     * @param ps Passed in predicate. If none provided - always-{@code false} predicate is
+     *      returned.
+     * @param <T> Type of the free variable, i.e. the element the predicate is called on.
+     * @return Predicate that evaluates to {@code true} if each of its component predicates
+     *      evaluates to {@code true}.
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> IgnitePredicate<T> and(
+        @Nullable final IgnitePredicate<? super T> p,
+        @Nullable final IgnitePredicate<? super T>... ps
+    ) {
+        if (p == null && F.isEmptyOrNulls(ps))
+            return F.alwaysTrue();
+
+        if (F.isAlwaysFalse(p) && F.isAlwaysFalse(ps))
+            return F.alwaysFalse();
+
+        if (F.isAlwaysTrue(p) && F.isAlwaysTrue(ps))
+            return F.alwaysTrue();
+
+        if (isAllNodePredicates(p) && isAllNodePredicates(ps)) {
+            assert ps != null;
+
+            Set<UUID> ids = new GridLeanSet<>();
+
+            for (IgnitePredicate<? super T> p0 : ps) {
+                Collection<UUID> list = ((GridNodePredicate)p0).nodeIds();
+
+                if (ids.isEmpty())
+                    ids.addAll(list);
+                else
+                    ids.retainAll(list);
+            }
+
+            Collection<UUID> list = ((GridNodePredicate)p).nodeIds();
+
+            if (ids.isEmpty())
+                ids.addAll(list);
+            else
+                ids.retainAll(list);
+
+            // T must be <T extends GridNode>.
+            return (IgnitePredicate<T>)new GridNodePredicate(ids);
+        }
+        else {
+            return new P1<T>() {
+                @Override public boolean apply(T t) {
+                    assert ps != null;
+
+                    if (p != null && !p.apply(t))
+                        return false;
+
+                    for (IgnitePredicate<? super T> p : ps)
+                        if (p != null && !p.apply(t))
+                            return false;
+
+                    return true;
+                }
+            };
+        }
+    }
+
+    /**
+     * Gets predicate (not peer-deployable) that returns {@code true} if its free variable is contained
+     * in given collection.
+     *
+     * @param c Collection to check for containment.
+     * @param <T> Type of the free variable for the predicate and type of the
+     *      collection elements.
+     * @return Predicate (not peer-deployable) that returns {@code true} if its free variable is
+     *      contained in given collection.
+     */
+    public static <T> IgnitePredicate<T> in(@Nullable final Collection<? extends T> c) {
+        return F.isEmpty(c) ? GridFunc.<T>alwaysFalse() : new P1<T>() {
+            @Override public boolean apply(T t) {
+                assert c != null;
+
+                return c.contains(t);
+            }
+        };
+    }
+
+    /**
+     * Provides predicate (not peer-deployable) which returns {@code true} if it receives an element
+     * that is contained in the passed in collection.
+     *
+     * @param c Collection used for predicate filter.
+     * @param <T> Element type.
+     * @return Predicate which returns {@code true} if it receives an element
+     *  that is contained in the passed in collection.
+     */
+    public static <T> IgnitePredicate<T> contains(@Nullable final Collection<T> c) {
+        return c == null || c.isEmpty() ? GridFunc.<T>alwaysFalse() : new P1<T>() {
+            @Override public boolean apply(T t) {
+                return c.contains(t);
+            }
+        };
+    }
+
+    /**
+     * Provides predicate (not peer-deployable) which returns {@code true} if it receives an element
+     * that is not contained in the passed in collection.
+     *
+     * @param c Collection used for predicate filter.
+     * @param <T> Element type.
+     * @return Predicate which returns {@code true} if it receives an element
+     *  that is not contained in the passed in collection.
+     */
+    public static <T> IgnitePredicate<T> notContains(@Nullable final Collection<T> c) {
+        return c == null || c.isEmpty() ? GridFunc.<T>alwaysTrue() : new P1<T>() {
+            @Override public boolean apply(T t) {
+                return !c.contains(t);
+            }
+        };
+    }
+
+    /**
+     * Tests if all passed in predicates are instances of {@link GridNodePredicate} class.
+     *
+     * @param ps Collection of predicates to test.
+     * @return {@code True} if all passed in predicates are instances of {@link GridNodePredicate} class.
+     */
+    public static boolean isAllNodePredicates(@Nullable Iterable<? extends IgnitePredicate<?>> ps) {
+        if (F.isEmpty(ps))
+            return false;
+
+        assert ps != null;
+
+        for (IgnitePredicate<?> p : ps)
+            if (!(p instanceof GridNodePredicate))
+                return false;
+
+        return true;
+    }
+
+    /**
      * Tests if all passed in predicates are instances of {@link GridNodePredicate} class.
      *
      * @param ps Collection of predicates to test.
@@ -198,10 +498,27 @@ public class F0 {
         if (F.isEmpty(ps))
             return false;
 
+        assert ps != null;
+
         for (IgnitePredicate<?> p : ps)
             if (!(p instanceof GridNodePredicate))
                 return false;
 
         return true;
     }
+
+    /**
+     * Creates map with given values, adding a strict not-null check for value.
+     *
+     * @param key Key.
+     * @param val Value.
+     * @param <K> Key's type.
+     * @param <V> Value's type.
+     * @return Created map.
+     */
+    public static <K, V> Map<K, V> asMap(K key, V val) {
+        A.notNull(val, "val");
+
+        return F.asMap(key, val);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/util/GridExecutionStatistics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridExecutionStatistics.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridExecutionStatistics.java
index fc2e3a2..a23fe28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridExecutionStatistics.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridExecutionStatistics.java
@@ -71,13 +71,13 @@ public class GridExecutionStatistics {
 
         long time = startTime.get().get2();
 
-        AtomicInteger cnt = F.addIfAbsent(cntMap, name, new AtomicInteger());
+        AtomicInteger cnt = F.addIfAbsent(cntMap, name, F.newAtomicInt());
 
         assert cnt != null;
 
         cnt.incrementAndGet();
 
-        AtomicLong d = F.addIfAbsent(durationMap, name, new AtomicLong());
+        AtomicLong d = F.addIfAbsent(durationMap, name, F.newAtomicLong());
 
         assert d != null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 a92ccab..480859d 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
@@ -8508,7 +8508,7 @@ public abstract class IgniteUtils {
             throw new IgniteCheckedException("Addresses can not be resolved [addr=" + addrs +
                 ", hostNames=" + hostNames + ']');
 
-        return Collections.unmodifiableList(res);
+        return F.viewListReadOnly(res, F.<InetAddress>identity());
     }
 
     /**
@@ -8555,7 +8555,7 @@ public abstract class IgniteUtils {
             res.add(new InetSocketAddress(addr, port));
         }
 
-        return Collections.unmodifiableList(res);
+        return F.viewListReadOnly(res, F.<InetSocketAddress>identity());
     }
 
     /**


[11/29] ignite git commit: Page Memory WIP.

Posted by vo...@apache.org.
Page Memory WIP.


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

Branch: refs/heads/ignite-2236
Commit: 59a893c2598a64a4777d4db3875f99df70577193
Parents: 10012b4
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Jan 11 20:05:55 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Jan 11 20:05:55 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/GridStringBuilder.java  | 19 +++++++++++++++++++
 .../apache/ignite/internal/util/IgniteUtils.java | 10 ++++++++++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/59a893c2/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
index bc979f5..e9b72cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
@@ -425,6 +425,25 @@ public class GridStringBuilder implements Serializable {
     }
 
     /**
+     * Appends given long value as a hex string to this string builder.
+     *
+     * @param val Value to append.
+     * @return This builder for chaining method calls.
+     */
+    public GridStringBuilder appendHex(long val) {
+        String hex = Long.toHexString(val);
+
+        int len = hex.length();
+
+        for (int i = 0; i < 16 - len; i++)
+            a('0');
+
+        a(hex);
+
+        return this;
+    }
+
+    /**
      *
      * @param s Stream to write to.
      * @throws IOException Thrown in case of any IO errors.

http://git-wip-us.apache.org/repos/asf/ignite/blob/59a893c2/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 480859d..6a7145c 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
@@ -2482,6 +2482,16 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * Gets a hex string representation of the given long value.
+     *
+     * @param val Value to convert to string.
+     * @return Hex string.
+     */
+    public static String hexLong(long val) {
+        return new SB().appendHex(val).toString();
+    }
+
+    /**
      * Return byte value for certain character.
      *
      * @param ch Character


[21/29] ignite git commit: Added more logging for direct message read errors.

Posted by vo...@apache.org.
Added more logging for direct message read errors.


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

Branch: refs/heads/ignite-2236
Commit: 8b0c59a25822e69bd2fe896685be5e921b859e26
Parents: b409b8d
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jan 14 16:42:46 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jan 14 16:42:46 2016 +0300

----------------------------------------------------------------------
 .../internal/direct/DirectMessageReader.java    | 11 +++++
 .../internal/direct/DirectMessageWriter.java    | 13 +++++
 .../direct/state/DirectMessageState.java        | 10 ++++
 .../stream/v1/DirectByteBufferStreamImplV1.java |  8 +++
 .../stream/v2/DirectByteBufferStreamImplV2.java |  8 +++
 .../internal/util/nio/GridDirectParser.java     | 52 +++++++++++++-------
 .../communication/tcp/TcpCommunicationSpi.java  |  9 +++-
 7 files changed, 92 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
index e0b7b22..10bc7e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.direct.state.DirectMessageStateItem;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1;
 import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -373,6 +374,11 @@ public class DirectMessageReader implements MessageReader {
         state.reset();
     }
 
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectMessageReader.class, this);
+    }
+
     /**
      */
     private static class StateItem implements DirectMessageStateItem {
@@ -407,5 +413,10 @@ public class DirectMessageReader implements MessageReader {
         @Override public void reset() {
             state = 0;
         }
+
+        /** {@inheritDoc} */
+        public String toString() {
+            return S.toString(StateItem.class, this);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
index 085cf68..730f9bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
@@ -27,6 +27,8 @@ import org.apache.ignite.internal.direct.state.DirectMessageStateItem;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1;
 import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -39,6 +41,7 @@ import org.jetbrains.annotations.Nullable;
  */
 public class DirectMessageWriter implements MessageWriter {
     /** State. */
+    @GridToStringInclude
     private final DirectMessageState<StateItem> state;
 
     /**
@@ -327,6 +330,11 @@ public class DirectMessageWriter implements MessageWriter {
         state.reset();
     }
 
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectMessageWriter.class, this);
+    }
+
     /**
      */
     private static class StateItem implements DirectMessageStateItem {
@@ -364,5 +372,10 @@ public class DirectMessageWriter implements MessageWriter {
             state = 0;
             hdrWritten = false;
         }
+
+        /** {@inheritDoc} */
+        public String toString() {
+            return S.toString(StateItem.class, this);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
index a61bb30..8ad7fe0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/state/DirectMessageState.java
@@ -18,6 +18,9 @@
 package org.apache.ignite.internal.direct.state;
 
 import java.lang.reflect.Array;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteOutClosure;
 
 /**
@@ -28,9 +31,11 @@ public class DirectMessageState<T extends DirectMessageStateItem> {
     private static final int INIT_SIZE = 10;
 
     /** Item factory. */
+    @GridToStringExclude
     private final IgniteOutClosure<T> factory;
 
     /** Stack array. */
+    @GridToStringInclude
     private T[] stack;
 
     /** Current position. */
@@ -95,4 +100,9 @@ public class DirectMessageState<T extends DirectMessageStateItem> {
 
         stack[0].reset();
     }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectMessageState.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
index ad8671d..5292f35 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
@@ -28,6 +28,8 @@ import java.util.NoSuchElementException;
 import java.util.UUID;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.util.GridUnsafe;
+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;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -217,6 +219,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     private static final Object NULL = new Object();
 
     /** */
+    @GridToStringExclude
     private final MessageFactory msgFactory;
 
     /** */
@@ -1347,6 +1350,11 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         };
     }
 
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectByteBufferStreamImplV1.class, this);
+    }
+
     /**
      * Array creator.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
index 89c9cc6..ed3eb7c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
@@ -29,6 +29,8 @@ import java.util.RandomAccess;
 import java.util.UUID;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.util.GridUnsafe;
+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;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -218,6 +220,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     private static final Object NULL = new Object();
 
     /** */
+    @GridToStringExclude
     private final MessageFactory msgFactory;
 
     /** */
@@ -1570,6 +1573,11 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         }
     }
 
+    /** {@inheritDoc} */
+    public String toString() {
+        return S.toString(DirectByteBufferStreamImplV2.class, this);
+    }
+
     /**
      * Array creator.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
index aa88808..76e7d4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
@@ -21,6 +21,8 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.plugin.extensions.communication.MessageFactory;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -37,19 +39,24 @@ public class GridDirectParser implements GridNioParser {
     private static final int READER_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
 
     /** */
+    private final IgniteLogger log;
+
+    /** */
     private final MessageFactory msgFactory;
 
     /** */
     private final GridNioMessageReaderFactory readerFactory;
 
     /**
+     * @param log Logger.
      * @param msgFactory Message factory.
      * @param readerFactory Message reader factory.
      */
-    public GridDirectParser(MessageFactory msgFactory, GridNioMessageReaderFactory readerFactory) {
+    public GridDirectParser(IgniteLogger log, MessageFactory msgFactory, GridNioMessageReaderFactory readerFactory) {
         assert msgFactory != null;
         assert readerFactory != null;
 
+        this.log = log;
         this.msgFactory = msgFactory;
         this.readerFactory = readerFactory;
     }
@@ -64,28 +71,39 @@ public class GridDirectParser implements GridNioParser {
 
         Message msg = ses.removeMeta(MSG_META_KEY);
 
-        if (msg == null && buf.hasRemaining())
-            msg = msgFactory.create(buf.get());
+        try {
+            if (msg == null && buf.hasRemaining())
+                msg = msgFactory.create(buf.get());
 
-        boolean finished = false;
+            boolean finished = false;
 
-        if (buf.hasRemaining()) {
-            if (reader != null)
-                reader.setCurrentReadClass(msg.getClass());
+            if (buf.hasRemaining()) {
+                if (reader != null)
+                    reader.setCurrentReadClass(msg.getClass());
 
-            finished = msg.readFrom(buf, reader);
-        }
+                finished = msg.readFrom(buf, reader);
+            }
 
-        if (finished) {
-            if (reader != null)
-                reader.reset();
+            if (finished) {
+                if (reader != null)
+                    reader.reset();
 
-            return msg;
-        }
-        else {
-            ses.addMeta(MSG_META_KEY, msg);
+                return msg;
+            }
+            else {
+                ses.addMeta(MSG_META_KEY, msg);
 
-            return null;
+                return null;
+            }
+        }
+        catch (Throwable e) {
+            U.error(log, "Failed to read message [msg=" + msg +
+                ", buf=" + buf +
+                ", reader=" + reader +
+                ", ses=" + ses + "]",
+                e);
+
+            throw e;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0c59a2/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 6cdfe9a..918bc83 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
@@ -1611,7 +1611,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                     }
                 };
 
-                GridDirectParser parser = new GridDirectParser(msgFactory, readerFactory);
+                GridDirectParser parser = new GridDirectParser(log.getLogger(GridDirectParser.class),
+                    msgFactory,
+                    readerFactory);
 
                 IgnitePredicate<Message> skipRecoveryPred = new IgnitePredicate<Message>() {
                     @Override public boolean apply(Message msg) {
@@ -2983,7 +2985,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                     endpoint,
                     srvLsnr,
                     writerFactory,
-                    new GridNioCodecFilter(new GridDirectParser(msgFactory, readerFactory), log, true),
+                    new GridNioCodecFilter(
+                        new GridDirectParser(log.getLogger(GridDirectParser.class),msgFactory, readerFactory),
+                        log,
+                        true),
                     new GridConnectionBytesVerifyFilter(log)
                 );
 


[26/29] ignite git commit: Renamed fields to change fields write order (to preserve backward compatibility).

Posted by vo...@apache.org.
Renamed fields to change fields write order (to preserve backward compatibility).


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

Branch: refs/heads/ignite-2236
Commit: fa427dce25061b3c85be04f83debb452e60f08a2
Parents: c4ff711
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jan 15 11:17:30 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jan 15 11:17:30 2016 +0300

----------------------------------------------------------------------
 .../continuous/CacheContinuousQueryEntry.java   | 70 ++++++++++----------
 1 file changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fa427dce/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
index 4d3786a..bcc2576 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
@@ -84,17 +84,17 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
     private GridDeploymentInfo depInfo;
 
     /** Partition. */
-    private int part;
+    private int _part;
 
     /** Update counter. */
-    private long updateCntr;
+    private long _updateCntr;
 
     /** Flags. */
     private byte flags;
 
     /** */
     @GridToStringInclude
-    private AffinityTopologyVersion topVer;
+    private AffinityTopologyVersion _topVer;
 
     /** Filtered events. */
     private GridLongList filteredEvts;
@@ -134,9 +134,9 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
         this.key = key;
         this.newVal = newVal;
         this.oldVal = oldVal;
-        this.part = part;
-        this.updateCntr = updateCntr;
-        this.topVer = topVer;
+        this._part = part;
+        this._updateCntr = updateCntr;
+        this._topVer = topVer;
         this.keepBinary = keepBinary;
     }
 
@@ -144,7 +144,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
      * @return Topology version if applicable.
      */
     @Nullable AffinityTopologyVersion topologyVersion() {
-        return topVer;
+        return _topVer;
     }
 
     /**
@@ -165,14 +165,14 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
      * @return Partition.
      */
     int partition() {
-        return part;
+        return _part;
     }
 
     /**
      * @return Update counter.
      */
     long updateCounter() {
-        return updateCntr;
+        return _updateCntr;
     }
 
     /**
@@ -310,67 +310,67 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
 
         switch (writer.state()) {
             case 0:
-                if (!writer.writeInt("cacheId", cacheId))
+                if (!writer.writeInt("_part", _part))
                     return false;
 
                 writer.incrementState();
 
             case 1:
-                if (!writer.writeByte("evtType", evtType != null ? (byte)evtType.ordinal() : -1))
+                if (!writer.writeMessage("_topVer", _topVer))
                     return false;
 
                 writer.incrementState();
 
             case 2:
-                if (!writer.writeMessage("filteredEvts", filteredEvts))
+                if (!writer.writeLong("_updateCntr", _updateCntr))
                     return false;
 
                 writer.incrementState();
 
             case 3:
-                if (!writer.writeByte("flags", flags))
+                if (!writer.writeInt("cacheId", cacheId))
                     return false;
 
                 writer.incrementState();
 
             case 4:
-                if (!writer.writeBoolean("keepBinary", keepBinary))
+                if (!writer.writeByte("evtType", evtType != null ? (byte)evtType.ordinal() : -1))
                     return false;
 
                 writer.incrementState();
 
             case 5:
-                if (!writer.writeMessage("key", key))
+                if (!writer.writeMessage("filteredEvts", filteredEvts))
                     return false;
 
                 writer.incrementState();
 
             case 6:
-                if (!writer.writeMessage("newVal", newVal))
+                if (!writer.writeByte("flags", flags))
                     return false;
 
                 writer.incrementState();
 
             case 7:
-                if (!writer.writeMessage("oldVal", oldVal))
+                if (!writer.writeBoolean("keepBinary", keepBinary))
                     return false;
 
                 writer.incrementState();
 
             case 8:
-                if (!writer.writeInt("part", part))
+                if (!writer.writeMessage("key", key))
                     return false;
 
                 writer.incrementState();
 
             case 9:
-                if (!writer.writeMessage("topVer", topVer))
+                if (!writer.writeMessage("newVal", newVal))
                     return false;
 
                 writer.incrementState();
 
             case 10:
-                if (!writer.writeLong("updateCntr", updateCntr))
+                if (!writer.writeMessage("oldVal", oldVal))
                     return false;
 
                 writer.incrementState();
@@ -389,7 +389,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
 
         switch (reader.state()) {
             case 0:
-                cacheId = reader.readInt("cacheId");
+                _part = reader.readInt("_part");
 
                 if (!reader.isLastRead())
                     return false;
@@ -397,19 +397,15 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
                 reader.incrementState();
 
             case 1:
-                byte evtTypeOrd;
-
-                evtTypeOrd = reader.readByte("evtType");
+                _topVer = reader.readMessage("_topVer");
 
                 if (!reader.isLastRead())
                     return false;
 
-                evtType = eventTypeFromOrdinal(evtTypeOrd);
-
                 reader.incrementState();
 
             case 2:
-                filteredEvts = reader.readMessage("filteredEvts");
+                _updateCntr = reader.readLong("_updateCntr");
 
                 if (!reader.isLastRead())
                     return false;
@@ -417,7 +413,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
                 reader.incrementState();
 
             case 3:
-                flags = reader.readByte("flags");
+                cacheId = reader.readInt("cacheId");
 
                 if (!reader.isLastRead())
                     return false;
@@ -425,15 +421,19 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
                 reader.incrementState();
 
             case 4:
-                keepBinary = reader.readBoolean("keepBinary");
+                byte evtTypeOrd;
+
+                evtTypeOrd = reader.readByte("evtType");
 
                 if (!reader.isLastRead())
                     return false;
 
+                evtType = eventTypeFromOrdinal(evtTypeOrd);
+
                 reader.incrementState();
 
             case 5:
-                key = reader.readMessage("key");
+                filteredEvts = reader.readMessage("filteredEvts");
 
                 if (!reader.isLastRead())
                     return false;
@@ -441,7 +441,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
                 reader.incrementState();
 
             case 6:
-                newVal = reader.readMessage("newVal");
+                flags = reader.readByte("flags");
 
                 if (!reader.isLastRead())
                     return false;
@@ -449,7 +449,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
                 reader.incrementState();
 
             case 7:
-                oldVal = reader.readMessage("oldVal");
+                keepBinary = reader.readBoolean("keepBinary");
 
                 if (!reader.isLastRead())
                     return false;
@@ -457,7 +457,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
                 reader.incrementState();
 
             case 8:
-                part = reader.readInt("part");
+                key = reader.readMessage("key");
 
                 if (!reader.isLastRead())
                     return false;
@@ -465,7 +465,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
                 reader.incrementState();
 
             case 9:
-                topVer = reader.readMessage("topVer");
+                newVal = reader.readMessage("newVal");
 
                 if (!reader.isLastRead())
                     return false;
@@ -473,7 +473,7 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
                 reader.incrementState();
 
             case 10:
-                updateCntr = reader.readLong("updateCntr");
+                oldVal = reader.readMessage("oldVal");
 
                 if (!reader.isLastRead())
                     return false;


[03/29] ignite git commit: Revert "IGNITE-2330: Simplified GridFunc."

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java
index e5d247a..b999e2a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple3.java
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
+ * @see GridFunc#t3()
  * @see GridFunc#t(Object, Object, Object)
  */
 public class GridTuple3<V1, V2, V3> implements Iterable<Object>, Externalizable, Cloneable {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
index d1e69b5..c95a859 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
+ * @see GridFunc#t4()
  * @see GridFunc#t(Object, Object, Object, Object)
  */
 public class GridTuple4<V1, V2, V3, V4> implements Iterable<Object>, Externalizable, Cloneable {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java
index 7d25996..9790f48 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple5.java
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
+ * @see GridFunc#t5()
  * @see GridFunc#t(Object, Object, Object, Object, Object)
  */
 public class GridTuple5<V1, V2, V3, V4, V5> implements Iterable<Object>, Externalizable, Cloneable {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java
index c904587..044944b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple6.java
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
+ * @see GridFunc#t5()
  * @see GridFunc#t(Object, Object, Object, Object, Object)
  */
 public class GridTuple6<V1, V2, V3, V4, V5, V6> implements Iterable<Object>, Externalizable,

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java
index 58e18aa..225366a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTupleV.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
  * This class doesn't provide any synchronization for multi-threaded access
  * and it is responsibility of the user of this class to provide outside
  * synchronization, if needed.
+ * @see GridFunc#tv(Object...)
  */
 public class GridTupleV implements Iterable<Object>, Externalizable, Cloneable {
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java b/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
index 44ca067..5c6bb9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
+++ b/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
@@ -186,7 +186,7 @@ public final class IgniteUuid implements Comparable<IgniteUuid>, Iterable<Ignite
 
     /** {@inheritDoc} */
     @Override public GridIterator<IgniteUuid> iterator() {
-        return F.identityIteratorReadOnly(Collections.singleton(this));
+        return F.iterator(Collections.singleton(this), F.<IgniteUuid>identity(), true);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
index 56a627a..c7c635e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/eventstorage/memory/MemoryEventStorageSpi.java
@@ -216,7 +216,6 @@ public class MemoryEventStorageSpi extends IgniteSpiAdapter implements EventStor
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
     @Override public <T extends Event> Collection<T> localEvents(IgnitePredicate<T> p) {
         A.notNull(p, "p");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
index 1e868b7..59a3eca 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
@@ -21,7 +21,6 @@ import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
@@ -336,8 +335,7 @@ public class GridCacheLuceneQueryIndexTest extends GridCommonAbstractTest {
                             map = new HashMap<>();
                         }
 
-                        map.put(new ObjectKey(String.valueOf(i)),
-                            vals[ThreadLocalRandom.current().nextInt(vals.length)]);
+                        map.put(new ObjectKey(String.valueOf(i)), F.rand(vals));
                     }
 
                     if (!map.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
index 52737e7..cb24e54 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
@@ -757,7 +757,7 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
             if (TEST_INFO)
                 X.println("Cache event: " + evt.shortDisplay());
 
-            AtomicInteger cntr = F.addIfAbsent(cntrs, evt.type(), new AtomicInteger());
+            AtomicInteger cntr = F.addIfAbsent(cntrs, evt.type(), F.newAtomicInt());
 
             assert cntr != null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/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 3482fd6..1aae999 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
@@ -517,16 +517,12 @@ public class IpcSharedMemoryCrashDetectionSelfTest extends GridCommonAbstractTes
          * @param shmemIds Shared memory IDs string.
          */
         public void shmemIds(String shmemIds) {
-            if (shmemIds == null)
-                this.shmemIds = null;
-            else {
-                String[] tokens = shmemIds.split(",");
-
-                this.shmemIds = new ArrayList<>(tokens.length);
-
-                for (String token : tokens)
-                    this.shmemIds.add(Long.valueOf(token).intValue());
-            }
+            this.shmemIds = (shmemIds == null) ? null :
+                F.transform(shmemIds.split(","), new C1<String, Integer>() {
+                    @Override public Integer apply(String s) {
+                        return Long.valueOf(s).intValue();
+                    }
+                });
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
index 353367e..37e7afe 100644
--- a/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
@@ -748,14 +748,8 @@ public class GridBasicPerformanceTest {
         for (int i = 0; i < MAX; i++) {
             if (sort)
                 Arrays.binarySearch(arr, ThreadLocalRandom8.current().nextInt(lim));
-            else {
-                int val = ThreadLocalRandom8.current().nextInt(lim);
-
-                for (long arrItem : arr) {
-                    if (arrItem == val)
-                        break;
-                }
-            }
+            else
+                F.contains(arr, ThreadLocalRandom8.current().nextInt(lim));
         }
 
         long time =  System.currentTimeMillis() - start;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java
new file mode 100644
index 0000000..5afd75f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.lang;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.internal.util.lang.GridIterator;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * GridFunc performance test.
+ */
+@GridCommonTest(group = "Lang")
+public class GridFuncPerformanceTest extends GridCommonAbstractTest {
+    /**
+     *  Creates test.
+     */
+    public GridFuncPerformanceTest() {
+        super(/*start grid*/false);
+    }
+
+    /**
+     *
+     */
+    public void testTransformingIteratorPerformance() {
+        // Warmup.
+        testBody();
+        testBody();
+        testBody();
+
+        long r1 = testBody();
+        long r2 = testBody();
+        long r3 = testBody();
+
+        double r = (r1 + r2 + r3) / 3.f;
+
+        System.out.println("Average result is: " + Math.round(r) + "msec.");
+    }
+
+    /**
+     *
+     * @return Duration of the test.
+     */
+    @SuppressWarnings({"UnusedDeclaration"})
+    private long testBody() {
+        int MAX = 20000000;
+
+        Collection<Integer> l = new ArrayList<>(MAX);
+
+        for (int i = 0; i < MAX / 10; i++)
+            l.add(i);
+
+        IgniteClosure<Integer, Integer> c = new IgniteClosure<Integer, Integer>() {
+            @Override public Integer apply(Integer e) {
+                return e;
+            }
+        };
+
+        IgnitePredicate<Integer> p1 = new IgnitePredicate<Integer>() {
+            @Override public boolean apply(Integer e) {
+                return e % 2 == 0;
+            }
+        };
+        IgnitePredicate<Integer> p2 = new IgnitePredicate<Integer>() {
+            @Override public boolean apply(Integer e) {
+                return e % 2 != 0;
+            }
+        };
+
+        GridIterator<Integer> iter = F.iterator(l, c, true, p1, p2);
+
+        long n = 0;
+
+        long start = System.currentTimeMillis();
+
+        for (Integer i : iter)
+            n += i;
+
+        long duration = System.currentTimeMillis() - start;
+
+        System.out.println("Duration: " + duration + "msec.");
+
+        return duration;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java b/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
index 10b140e..5d517a4 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtest/GridLoadTestStatistics.java
@@ -107,7 +107,7 @@ public class GridLoadTestStatistics {
                     AtomicInteger cnt;
 
                     synchronized (nodeCnts) {
-                        cnt = F.addIfAbsent(nodeCnts, id, new AtomicInteger());
+                        cnt = F.addIfAbsent(nodeCnts, id, F.newAtomicInt());
                     }
 
                     assert cnt != null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ddbe2d59/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index 9582df0..28adeee 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -24,10 +24,10 @@ import java.util.Iterator;
 import java.util.NavigableMap;
 import java.util.concurrent.ConcurrentNavigableMap;
 import java.util.concurrent.ConcurrentSkipListMap;
+import org.apache.ignite.internal.util.GridEmptyIterator;
 import org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeGuard;
 import org.apache.ignite.internal.util.snaptree.SnapTreeMap;
-import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.indexing.IndexingQueryFilter;
@@ -319,7 +319,7 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
             comparable(last, 1));
 
         if (range == null)
-            return F.emptyIterator();
+            return new GridEmptyIterator<>();
 
         return filter(range.values().iterator());
     }


[13/29] ignite git commit: Fixes: - allow 'committing' -> 'marked_rollback' tx state change only for thread committing transaction - fixed 'full_sync' mode for case when tx primary nodes fail - fixed race between statically configured cache start and

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java
index d07a1e6..34872c6 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java
@@ -85,7 +85,6 @@ public class GridTcpCommunicationSpiRecoveryAckSelfTest<T extends CommunicationS
     }
 
     /** */
-    @SuppressWarnings({"deprecation"})
     private class TestListener implements CommunicationListener<Message> {
         /** */
         private ConcurrentHashSet<Long> msgIds = new ConcurrentHashSet<>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java
index 7521f2e..b7c0deb 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java
@@ -49,11 +49,13 @@ import org.apache.ignite.testframework.GridTestNode;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.IgniteTestResources;
 import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
+import org.apache.ignite.testframework.junits.spi.GridSpiTest;
 import org.eclipse.jetty.util.ConcurrentHashSet;
 
 /**
  *
  */
+@GridSpiTest(spi = TcpCommunicationSpi.class, group = "Communication SPI")
 public class IgniteTcpCommunicationRecoveryAckClosureSelfTest<T extends CommunicationSpi>
     extends GridSpiAbstractTest<T> {
     /** */
@@ -87,7 +89,6 @@ public class IgniteTcpCommunicationRecoveryAckClosureSelfTest<T extends Communic
     }
 
     /** */
-    @SuppressWarnings({"deprecation"})
     private class TestListener implements CommunicationListener<Message> {
         /** */
         private ConcurrentHashSet<Long> msgIds = new ConcurrentHashSet<>();
@@ -151,6 +152,8 @@ public class IgniteTcpCommunicationRecoveryAckClosureSelfTest<T extends Communic
 
             int expMsgs = 0;
 
+            long totAcked = 0;
+
             for (int i = 0; i < 5; i++) {
                 info("Iteration: " + i);
 
@@ -172,6 +175,8 @@ public class IgniteTcpCommunicationRecoveryAckClosureSelfTest<T extends Communic
 
                 expMsgs += msgPerIter;
 
+                final long totAcked0 = totAcked;
+
                 for (TcpCommunicationSpi spi : spis) {
                     GridNioServer srv = U.field(spi, "nioSrvr");
 
@@ -189,6 +194,14 @@ public class IgniteTcpCommunicationRecoveryAckClosureSelfTest<T extends Communic
 
                             GridTestUtils.waitForCondition(new GridAbsPredicate() {
                                 @Override public boolean apply() {
+                                    long acked = GridTestUtils.getFieldValue(recoveryDesc, "acked");
+
+                                    return acked > totAcked0;
+                                }
+                            }, 5000);
+
+                            GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                                @Override public boolean apply() {
                                     return recoveryDesc.messagesFutures().isEmpty();
                                 }
                             }, 10_000);
@@ -218,6 +231,8 @@ public class IgniteTcpCommunicationRecoveryAckClosureSelfTest<T extends Communic
                 }
 
                 assertEquals(msgPerIter * 2, ackMsgs.get());
+
+                totAcked += msgPerIter;
             }
         }
         finally {
@@ -337,6 +352,8 @@ public class IgniteTcpCommunicationRecoveryAckClosureSelfTest<T extends Communic
                 return expMsgs == ackMsgs.get();
             }
         }, 5000);
+
+        assertEquals(expMsgs, ackMsgs.get());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index 0df7da6..4f329e1 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -118,6 +118,8 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
         TcpDiscoverySpi spi = nodeSpi.get();
 
         if (spi == null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index e0ffc60..949290e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -978,7 +978,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
     /**
      * @param key Key.
      * @param cacheName Cache name.
-     * @return Ignite instance which has primary cache for given key.
+     * @return Ignite instance which has backup cache for given key.
      */
     protected Ignite backupNode(Object key, String cacheName) {
         List<Ignite> allGrids = Ignition.allGrids();
@@ -1001,8 +1001,38 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
     }
 
     /**
+     * @param key Key.
+     * @param cacheName Cache name.
+     * @return Ignite instances which has backup cache for given key.
+     */
+    protected List<Ignite> backupNodes(Object key, String cacheName) {
+        List<Ignite> allGrids = Ignition.allGrids();
+
+        assertFalse("There are no alive nodes.", F.isEmpty(allGrids));
+
+        Ignite ignite = allGrids.get(0);
+
+        Affinity<Object> aff = ignite.affinity(cacheName);
+
+        Collection<ClusterNode> nodes = aff.mapKeyToPrimaryAndBackups(key);
+
+        assertTrue("Expected more than one node for key [key=" + key + ", nodes=" + nodes +']', nodes.size() > 1);
+
+        Iterator<ClusterNode> it = nodes.iterator();
+
+        it.next(); // Skip primary.
+
+        List<Ignite> backups = new ArrayList<>(nodes.size() - 1);
+
+        while (it.hasNext())
+            backups.add(grid(it.next()));
+
+        return backups;
+    }
+
+    /**
      * In ATOMIC cache with CLOCK mode if key is updated from different nodes at same time
-     * only one update wins others are ignored (can happen in test event when updates are executed from
+     * only one update wins others are ignored (can happen in test even when updates are executed from
      * different nodes sequentially), this delay is used to avoid lost updates.
      *
      * @param cache Cache.

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java
index d81efd9..7363c7c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedTxPessimisticOriginatingNodeFailureSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledTxOriginatingNodeFailureSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedTxOriginatingNodeFailureSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheCommitDelayTxRecoveryTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedNearDisabledPrimaryNodeFailureRecoveryTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedPrimaryNodeFailureRecoveryTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedTwoBackupsPrimaryNodeFailureRecoveryTest;
@@ -39,6 +40,8 @@ public class IgniteCacheTxRecoverySelfTestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("Cache tx recovery test suite");
 
+        suite.addTestSuite(IgniteCacheCommitDelayTxRecoveryTest.class);
+
         suite.addTestSuite(IgniteCachePartitionedPrimaryNodeFailureRecoveryTest.class);
         suite.addTestSuite(IgniteCachePartitionedNearDisabledPrimaryNodeFailureRecoveryTest.class);
         suite.addTestSuite(IgniteCachePartitionedTwoBackupsPrimaryNodeFailureRecoveryTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
index c19a8fc..e53f335 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
@@ -31,8 +31,10 @@ 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.lang.GridAbsPredicate;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 /**
@@ -41,7 +43,6 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
  * @author Raul Kripalani
  */
 public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
-
     /** ZK Cluster size. */
     private static final int ZK_CLUSTER_SIZE = 3;
 
@@ -79,7 +80,6 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
         // start the Curator client so we can perform assertions on the ZK state later
         zkCurator = CuratorFrameworkFactory.newClient(zkCluster.getConnectString(), new RetryNTimes(10, 1000));
         zkCurator.start();
-
     }
 
     /**
@@ -98,22 +98,21 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
         }
 
         stopAllGrids();
-
     }
 
     /**
      * Enhances the default configuration with the {#TcpDiscoveryZookeeperIpFinder}.
      *
      * @param gridName Grid name.
-     * @return
-     * @throws Exception
+     * @return Ignite configuration.
+     * @throws Exception If failed.
      */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration configuration = super.getConfiguration(gridName);
 
         TcpDiscoverySpi tcpDisco = (TcpDiscoverySpi) configuration.getDiscoverySpi();
         TcpDiscoveryZookeeperIpFinder zkIpFinder = new TcpDiscoveryZookeeperIpFinder();
-        zkIpFinder.setAllowDuplicateRegistrations(isAllowDuplicateRegistrations());
+        zkIpFinder.setAllowDuplicateRegistrations(allowDuplicateRegistrations);
 
         // first node => configure with zkUrl; second node => configure with CuratorFramework; third and subsequent
         // shall be configured through system property
@@ -126,11 +125,12 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
         }
 
         tcpDisco.setIpFinder(zkIpFinder);
+
         return configuration;
     }
 
     /**
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testOneIgniteNodeIsAlone() throws Exception {
         startGrid(0);
@@ -141,7 +141,7 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
     }
 
     /**
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testTwoIgniteNodesFindEachOther() throws Exception {
         // start one node
@@ -164,7 +164,7 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
     }
 
     /**
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testThreeNodesWithThreeDifferentConfigMethods() throws Exception {
         // start one node
@@ -195,7 +195,7 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
     }
 
     /**
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testFourNodesStartingAndStopping() throws Exception {
         // start one node
@@ -242,10 +242,10 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
     }
 
     /**
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testFourNodesWithDuplicateRegistrations() throws Exception {
-        setAllowDuplicateRegistrations(true);
+        allowDuplicateRegistrations = true;
 
         // start 4 nodes
         System.setProperty(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING, zkCluster.getConnectString());
@@ -265,10 +265,10 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
     }
 
     /**
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testFourNodesWithNoDuplicateRegistrations() throws Exception {
-        setAllowDuplicateRegistrations(false);
+        allowDuplicateRegistrations = false;
 
         // start 4 nodes
         System.setProperty(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING, zkCluster.getConnectString());
@@ -288,10 +288,10 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
     }
 
     /**
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testFourNodesRestartLastSeveralTimes() throws Exception {
-        setAllowDuplicateRegistrations(false);
+        allowDuplicateRegistrations = false;
 
         // start 4 nodes
         System.setProperty(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING, zkCluster.getConnectString());
@@ -321,14 +321,13 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
         stopAllGrids();
 
         assertEquals(0, zkCurator.getChildren().forPath(SERVICES_IGNITE_ZK_PATH).size());
-
     }
 
     /**
-     * @throws Exception
+     * @throws Exception If failed.
      */
     public void testFourNodesKillRestartZookeeper() throws Exception {
-        setAllowDuplicateRegistrations(false);
+        allowDuplicateRegistrations = false;
 
         // start 4 nodes
         System.setProperty(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING, zkCluster.getConnectString());
@@ -357,14 +356,28 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
 
         // stop all grids
         stopAllGrids();
-        Thread.sleep(2000);
+
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                try {
+                    return zkCurator.getChildren().forPath(SERVICES_IGNITE_ZK_PATH).size() == 0;
+                }
+                catch (Exception e) {
+                    fail("Unexpected error: ");
+
+                    return true;
+                }
+            }
+        }, 5000);
 
         // check that all nodes are gone in ZK
         assertEquals(0, zkCurator.getChildren().forPath(SERVICES_IGNITE_ZK_PATH).size());
     }
 
     /**
-     * @throws Exception
+     * @param ignite Node.
+     * @param joinEventCount Expected events number.
+     * @return Events latch.
      */
     private CountDownLatch expectJoinEvents(Ignite ignite, int joinEventCount) {
         final CountDownLatch latch = new CountDownLatch(joinEventCount);
@@ -378,18 +391,4 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
 
         return latch;
     }
-
-    /**
-     * @throws Exception
-     */
-    public void setAllowDuplicateRegistrations(boolean allowDuplicateRegistrations) {
-        this.allowDuplicateRegistrations = allowDuplicateRegistrations;
-    }
-
-    /**
-     * @throws Exception
-     */
-    public boolean isAllowDuplicateRegistrations() {
-        return allowDuplicateRegistrations;
-    }
 }
\ No newline at end of file


[17/29] ignite git commit: ignite-2350 Pass update notifier flag in discovery data (all cluster nodes will have the same notifier status as first cluster node)

Posted by vo...@apache.org.
ignite-2350 Pass update notifier flag in discovery data (all cluster nodes will have the same notifier status as first cluster node)


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

Branch: refs/heads/ignite-2236
Commit: 7175a425aeec1f225a9409778c8a316c3ee35151
Parents: cd44be5
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 13 18:40:08 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 13 18:40:08 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/GridComponent.java   |   5 +-
 .../ignite/internal/GridUpdateNotifier.java     | 454 ------------------
 .../apache/ignite/internal/IgniteKernal.java    | 126 +----
 .../discovery/GridDiscoveryManager.java         |   6 +-
 .../processors/cluster/ClusterProcessor.java    | 174 +++++++
 .../processors/cluster/GridUpdateNotifier.java  | 457 +++++++++++++++++++
 .../internal/GridUpdateNotifierSelfTest.java    | 137 ------
 ...UpdateNotifierPerClusterSettingSelfTest.java | 130 ++++++
 .../cluster/GridUpdateNotifierSelfTest.java     | 140 ++++++
 .../testsuites/IgniteKernalSelfTestSuite.java   |   4 +-
 10 files changed, 920 insertions(+), 713 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java b/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
index 0e234cd..5c77aee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
@@ -40,7 +40,10 @@ public interface GridComponent {
         CACHE_PROC,
 
         /** */
-        PLUGIN
+        PLUGIN,
+
+        /** */
+        CLUSTER_PROC
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java b/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java
deleted file mode 100644
index 5d2cf35..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridUpdateNotifier.java
+++ /dev/null
@@ -1,454 +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;
-
-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;
-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.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-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;
-
-/**
- * This class is responsible for notification about new version availability.
- * <p>
- * Note also that this connectivity is not necessary to successfully start the system as it will
- * gracefully ignore any errors occurred during notification and verification process.
- */
-class GridUpdateNotifier {
-    /** Default encoding. */
-    private static final String CHARSET = "UTF-8";
-
-    /** Access URL to be used to access latest version data. */
-    private static final String UPD_STATUS_PARAMS = IgniteProperties.get("ignite.update.status.params");
-
-    /** Throttling for logging out. */
-    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;
-
-    /** 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;
-
-    /** Whether or not to report only new version. */
-    private volatile boolean reportOnlyNew;
-
-    /** */
-    private volatile int topSize;
-
-    /** System properties */
-    private final String vmProps;
-
-    /** Plugins information for request */
-    private final String pluginsVers;
-
-    /** Kernal gateway */
-    private final GridKernalGateway gw;
-
-    /** */
-    private long lastLog = -1;
-
-    /** Command for worker thread. */
-    private final AtomicReference<Runnable> cmd = new AtomicReference<>();
-
-    /** Worker thread to process http request. */
-    private final Thread workerThread;
-
-    /**
-     * Creates new notifier with default values.
-     *
-     * @param gridName gridName
-     * @param ver Compound Ignite version.
-     * @param gw Kernal gateway.
-     * @param pluginProviders Kernal gateway.
-     * @param reportOnlyNew Whether or not to report only new version.
-     * @throws IgniteCheckedException If failed.
-     */
-    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;
-
-            SB pluginsBuilder = new SB();
-
-            for (PluginProvider provider : pluginProviders)
-                pluginsBuilder.a("&").a(provider.name() + "-plugin-version").a("=").
-                    a(encode(provider.version(), CHARSET));
-
-            pluginsVers = pluginsBuilder.toString();
-
-            this.reportOnlyNew = reportOnlyNew;
-
-            vmProps = getSystemProperties();
-
-            workerThread = new Thread(new Runnable() {
-                @Override public void run() {
-                    try {
-                        while(!Thread.currentThread().isInterrupted()) {
-                            Runnable cmd0 = cmd.getAndSet(null);
-
-                            if (cmd0 != null)
-                                cmd0.run();
-                            else
-                                Thread.sleep(WORKER_THREAD_SLEEP_TIME);
-                        }
-                    }
-                    catch (InterruptedException ignore) {
-                        // No-op.
-                    }
-                }
-            }, "upd-ver-checker");
-
-            workerThread.setDaemon(true);
-
-            workerThread.start();
-        }
-        catch (ParserConfigurationException e) {
-            throw new IgniteCheckedException("Failed to create xml parser.", e);
-        }
-        catch (UnsupportedEncodingException e) {
-            throw new IgniteCheckedException("Failed to encode.", e);
-        }
-    }
-
-    /**
-     * Gets system properties.
-     *
-     * @return System properties.
-     */
-    private static String getSystemProperties() {
-        try {
-            StringWriter sw = new StringWriter();
-
-            try {
-                System.getProperties().store(new PrintWriter(sw), "");
-            }
-            catch (IOException ignore) {
-                return null;
-            }
-
-            return sw.toString();
-        }
-        catch (SecurityException ignore) {
-            return null;
-        }
-    }
-
-    /**
-     * @param reportOnlyNew Whether or not to report only new version.
-     */
-    void reportOnlyNew(boolean reportOnlyNew) {
-        this.reportOnlyNew = reportOnlyNew;
-    }
-
-    /**
-     * @param topSize Size of topology for license verification purpose.
-     */
-    void topologySize(int topSize) {
-        this.topSize = topSize;
-    }
-
-    /**
-     * @return Latest version.
-     */
-    String latestVersion() {
-        return latestVer;
-    }
-
-    /**
-     * Starts asynchronous process for retrieving latest version data.
-     *
-     * @param log Logger.
-     */
-    void checkForNewVersion(IgniteLogger log) {
-        assert log != null;
-
-        log = log.getLogger(getClass());
-
-        try {
-            cmd.set(new UpdateChecker(log));
-        }
-        catch (RejectedExecutionException e) {
-            U.error(log, "Failed to schedule a thread due to execution rejection (safely ignoring): " +
-                e.getMessage());
-        }
-    }
-
-    /**
-     * Logs out latest version notification if such was received and available.
-     *
-     * @param log Logger.
-     */
-    void reportStatus(IgniteLogger log) {
-        assert log != null;
-
-        log = log.getLogger(getClass());
-
-        String latestVer = this.latestVer;
-        String downloadUrl = this.downloadUrl;
-
-        downloadUrl = downloadUrl != null ? downloadUrl : IgniteKernal.SITE;
-
-        if (latestVer != null)
-            if (latestVer.equals(ver)) {
-                if (!reportOnlyNew)
-                    throttle(log, false, "Your version is up to date.");
-            }
-            else
-                throttle(log, true, "New version is available at " + downloadUrl + ": " + latestVer);
-        else
-            if (!reportOnlyNew)
-                throttle(log, false, "Update status is not available.");
-    }
-
-    /**
-     *
-     * @param log Logger to use.
-     * @param warn Whether or not this is a warning.
-     * @param msg Message to log.
-     */
-    private void throttle(IgniteLogger log, boolean warn, String msg) {
-        assert(log != null);
-        assert(msg != null);
-
-        long now = U.currentTimeMillis();
-
-        if (now - lastLog > THROTTLE_PERIOD) {
-            if (!warn)
-                U.log(log, msg);
-            else {
-                U.quiet(true, msg);
-
-                if (log.isInfoEnabled())
-                    log.warning(msg);
-            }
-
-            lastLog = now;
-        }
-    }
-
-    /**
-     * Stops update notifier.
-     */
-    public void stop() {
-        workerThread.interrupt();
-    }
-
-    /**
-     * Asynchronous checker of the latest version available.
-     */
-    private class UpdateChecker extends GridWorker {
-        /** Logger. */
-        private final IgniteLogger log;
-
-        /**
-         * Creates checked with given logger.
-         *
-         * @param log Logger.
-         */
-        UpdateChecker(IgniteLogger log) {
-            super(gridName, "grid-version-checker", log);
-
-            this.log = log.getLogger(getClass());
-        }
-
-        /** {@inheritDoc} */
-        @Override protected void body() throws InterruptedException {
-            try {
-                String stackTrace = gw != null ? gw.userStackTrace() : null;
-
-                String postParams =
-                    "gridName=" + encode(gridName, CHARSET) +
-                    (!F.isEmpty(UPD_STATUS_PARAMS) ? "&" + UPD_STATUS_PARAMS : "") +
-                    (topSize > 0 ? "&topSize=" + topSize : "") +
-                    (!F.isEmpty(stackTrace) ? "&stackTrace=" + encode(stackTrace, CHARSET) : "") +
-                    (!F.isEmpty(vmProps) ? "&vmProps=" + encode(vmProps, CHARSET) : "") +
-                        pluginsVers;
-
-                URLConnection conn = new URL(url).openConnection();
-
-                if (!isCancelled()) {
-                    conn.setDoOutput(true);
-                    conn.setRequestProperty("Accept-Charset", CHARSET);
-                    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + CHARSET);
-
-                    conn.setConnectTimeout(3000);
-                    conn.setReadTimeout(3000);
-
-                    Document dom = null;
-
-                    try {
-                        try (OutputStream os = conn.getOutputStream()) {
-                            os.write(postParams.getBytes(CHARSET));
-                        }
-
-                        try (InputStream in = conn.getInputStream()) {
-                            if (in == null)
-                                return;
-
-                            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');
-                            }
-
-                            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) {
-                if (log.isDebugEnabled())
-                    log.debug("Unexpected exception in update checker. " + e.getMessage());
-            }
-        }
-
-        /**
-         * Gets the version from the current {@code node}, if one exists.
-         *
-         * @param node W3C DOM node.
-         * @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");
-
-                    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));
-
-                if (ver != null)
-                    return ver;
-            }
-
-            return null;
-        }
-
-        /**
-         * Gets the version from the current {@code node}, if one exists.
-         *
-         * @param node W3C DOM node.
-         * @return Version or {@code null} if one's not found.
-         */
-        @Nullable private String obtainVersionFrom(Node node) {
-            return obtainMeta("version", node);
-        }
-
-        /**
-         * Gets the download url from the current {@code node}, if one exists.
-         *
-         * @param node W3C DOM node.
-         * @return download url or {@code null} if one's not found.
-         */
-        @Nullable private String obtainDownloadUrlFrom(Node node) {
-            return obtainMeta("downloadUrl", node);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/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 3def718..e3017ff 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
@@ -28,7 +28,6 @@ import java.io.ObjectStreamException;
 import java.io.Serializable;
 import java.lang.management.ManagementFactory;
 import java.lang.management.RuntimeMXBean;
-import java.lang.ref.WeakReference;
 import java.lang.reflect.Constructor;
 import java.text.DateFormat;
 import java.text.DecimalFormat;
@@ -41,7 +40,6 @@ import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Timer;
 import java.util.UUID;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -83,6 +81,8 @@ import org.apache.ignite.configuration.CollectionConfiguration;
 import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.binary.BinaryEnumCache;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
 import org.apache.ignite.internal.cluster.IgniteClusterEx;
 import org.apache.ignite.internal.managers.GridManager;
@@ -96,8 +96,6 @@ import org.apache.ignite.internal.managers.failover.GridFailoverManager;
 import org.apache.ignite.internal.managers.indexing.GridIndexingManager;
 import org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager;
 import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager;
-import org.apache.ignite.internal.binary.BinaryEnumCache;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.processors.GridProcessor;
 import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
@@ -135,7 +133,6 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessor;
 import org.apache.ignite.internal.processors.session.GridTaskSessionProcessor;
 import org.apache.ignite.internal.processors.task.GridTaskProcessor;
 import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
-import org.apache.ignite.internal.util.GridTimerTask;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -178,7 +175,6 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALL
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_STARVATION_CHECK_INTERVAL;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_SUCCESS_FILE;
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER;
 import static org.apache.ignite.IgniteSystemProperties.getBoolean;
 import static org.apache.ignite.IgniteSystemProperties.snapshot;
 import static org.apache.ignite.internal.GridKernalState.DISCONNECTED;
@@ -234,17 +230,11 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     private static final long serialVersionUID = 0L;
 
     /** Ignite site that is shown in log messages. */
-    static final String SITE = "ignite.apache.org";
+    public static final String SITE = "ignite.apache.org";
 
     /** System line separator. */
     private static final String NL = U.nl();
 
-    /** Periodic version check delay. */
-    private static final long PERIODIC_VER_CHECK_DELAY = 1000 * 60 * 60; // Every hour.
-
-    /** Periodic version check delay. */
-    private static final long PERIODIC_VER_CHECK_CONN_TIMEOUT = 10 * 1000; // 10 seconds.
-
     /** Periodic starvation check interval. */
     private static final long PERIODIC_STARVATION_CHECK_FREQ = 1000 * 30;
 
@@ -299,10 +289,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
     /** */
     @GridToStringExclude
-    private Timer updateNtfTimer;
-
-    /** */
-    @GridToStringExclude
     private GridTimeoutProcessor.CancelableTask starveTask;
 
     /** */
@@ -325,10 +311,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     @GridToStringExclude
     private final AtomicBoolean stopGuard = new AtomicBoolean();
 
-    /** Version checker. */
-    @GridToStringExclude
-    private GridUpdateNotifier verChecker;
-
     /**
      * No-arg constructor is required by externalization.
      */
@@ -745,9 +727,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         // Run background network diagnostics.
         GridDiagnostic.runBackgroundCheck(gridName, execSvc, log);
 
-        boolean notifyEnabled = IgniteSystemProperties.getBoolean(IGNITE_UPDATE_NOTIFIER,
-            Boolean.parseBoolean(IgniteProperties.get("ignite.update.notifier.enabled.by.default")));
-
         // Ack 3-rd party licenses location.
         if (log.isInfoEnabled() && cfg.getIgniteHome() != null)
             log.info("3-rd party licenses can be found at: " + cfg.getIgniteHome() + File.separatorChar + "libs" +
@@ -786,9 +765,11 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
             cfg.getMarshaller().setContext(ctx.marshallerContext());
 
-            startProcessor(new ClusterProcessor(ctx));
+            ClusterProcessor clusterProc = new ClusterProcessor(ctx);
 
-            fillNodeAttributes(notifyEnabled);
+            startProcessor(clusterProc);
+
+            fillNodeAttributes(clusterProc.updateNotifierEnabled());
 
             U.onGridStart();
 
@@ -820,24 +801,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
             startProcessor(new IgnitePluginProcessor(ctx, cfg, plugins));
 
-            verChecker = null;
-
-            if (notifyEnabled) {
-                try {
-                    verChecker = new GridUpdateNotifier(gridName, VER_STR, gw, ctx.plugins().allProviders(), false);
-
-                    updateNtfTimer = new Timer("ignite-update-notifier-timer", true);
-
-                    // Setup periodic version check.
-                    updateNtfTimer.scheduleAtFixedRate(new UpdateNotifierTimerTask(this, execSvc, verChecker),
-                        0, PERIODIC_VER_CHECK_DELAY);
-                }
-                catch (IgniteCheckedException e) {
-                    if (log.isDebugEnabled())
-                        log.debug("Failed to create GridUpdateNotifier: " + e);
-                }
-            }
-
             // Off-heap processor has no dependencies.
             startProcessor(new GridOffHeapProcessor(ctx));
 
@@ -1860,13 +1823,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                 }
             }
 
-            // Cancel update notification timer.
-            if (updateNtfTimer != null)
-                updateNtfTimer.cancel();
-
-            if (verChecker != null)
-                verChecker.stop();
-
             if (starveTask != null)
                 starveTask.close();
 
@@ -2893,7 +2849,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         ctx.gateway().readLock();
 
         try {
-            return verChecker != null ? verChecker.latestVersion() : null;
+            return ctx.cluster().latestVersion();
         }
         finally {
             ctx.gateway().readUnlock();
@@ -3332,70 +3288,4 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     @Override public String toString() {
         return S.toString(IgniteKernal.class, this);
     }
-
-    /**
-     * Update notifier timer task.
-     */
-    private static class UpdateNotifierTimerTask extends GridTimerTask {
-        /** Reference to kernal. */
-        private final WeakReference<IgniteKernal> kernalRef;
-
-        /** Logger. */
-        private final IgniteLogger log;
-
-        /** Executor service. */
-        private final ExecutorService execSvc;
-
-        /** Version checker. */
-        private final GridUpdateNotifier verChecker;
-
-        /** Whether this is the first run. */
-        private boolean first = true;
-
-        /**
-         * Constructor.
-         *
-         * @param kernal Kernal.
-         * @param execSvc Executor service.
-         * @param verChecker Version checker.
-         */
-        private UpdateNotifierTimerTask(IgniteKernal kernal, ExecutorService execSvc, GridUpdateNotifier verChecker) {
-            kernalRef = new WeakReference<>(kernal);
-
-            log = kernal.log.getLogger(UpdateNotifierTimerTask.class);
-
-            this.execSvc = execSvc;
-            this.verChecker = verChecker;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void safeRun() throws InterruptedException {
-            if (!first) {
-                IgniteKernal kernal = kernalRef.get();
-
-                if (kernal != null)
-                    verChecker.topologySize(kernal.cluster().nodes().size());
-            }
-
-            verChecker.checkForNewVersion(log);
-
-            // Just wait for 10 secs.
-            Thread.sleep(PERIODIC_VER_CHECK_CONN_TIMEOUT);
-
-            // Just wait another 60 secs in order to get
-            // version info even on slow connection.
-            for (int i = 0; i < 60 && verChecker.latestVersion() == null; i++)
-                Thread.sleep(1000);
-
-            // Report status if one is available.
-            // No-op if status is NOT available.
-            verChecker.reportStatus(log);
-
-            if (first) {
-                first = false;
-
-                verChecker.reportOnlyNew(true);
-            }
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 72a2bef..23a85e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -651,8 +651,10 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
 
                     if (comp != null)
                         comp.onDiscoveryDataReceived(joiningNodeId, nodeId, e.getValue());
-                    else
-                        U.warn(log, "Received discovery data for unknown component: " + e.getKey());
+                    else {
+                        if (log.isDebugEnabled())
+                            log.debug("Received discovery data for unknown component: " + e.getKey());
+                    }
                 }
             }
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/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 a72615c..5e8e98d 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
@@ -17,25 +17,65 @@
 
 package org.apache.ignite.internal.processors.cluster;
 
+import java.io.Serializable;
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Timer;
+import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.IgniteProperties;
 import org.apache.ignite.internal.cluster.IgniteClusterImpl;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
+import org.apache.ignite.internal.util.GridTimerTask;
 import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.lang.IgniteFuture;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
 
 /**
  *
  */
 public class ClusterProcessor extends GridProcessorAdapter {
     /** */
+    private static final String ATTR_UPDATE_NOTIFIER_STATUS = "UPDATE_NOTIFIER_STATUS";
+
+    /** Periodic version check delay. */
+    private static final long PERIODIC_VER_CHECK_DELAY = 1000 * 60 * 60; // Every hour.
+
+    /** Periodic version check delay. */
+    private static final long PERIODIC_VER_CHECK_CONN_TIMEOUT = 10 * 1000; // 10 seconds.
+
+    /** */
     private IgniteClusterImpl cluster;
 
+    /** */
+    private boolean notifyEnabled;
+
+    /** */
+    @GridToStringExclude
+    private Timer updateNtfTimer;
+
+    /** Version checker. */
+    @GridToStringExclude
+    private GridUpdateNotifier verChecker;
+
     /**
      * @param ctx Kernal context.
      */
     public ClusterProcessor(GridKernalContext ctx) {
         super(ctx);
 
+        notifyEnabled = IgniteSystemProperties.getBoolean(IGNITE_UPDATE_NOTIFIER,
+            Boolean.parseBoolean(IgniteProperties.get("ignite.update.notifier.enabled.by.default")));
+
         cluster = new IgniteClusterImpl(ctx);
     }
 
@@ -54,4 +94,138 @@ public class ClusterProcessor extends GridProcessorAdapter {
 
         return fut != null ? fut : new IgniteFinishedFutureImpl<>();
     }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public DiscoveryDataExchangeType discoveryDataType() {
+        return DiscoveryDataExchangeType.CLUSTER_PROC;
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public Serializable collectDiscoveryData(UUID nodeId) {
+        HashMap<String, Object> map = new HashMap<>();
+
+        map.put(ATTR_UPDATE_NOTIFIER_STATUS, notifyEnabled);
+
+        return map;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public void onDiscoveryDataReceived(UUID joiningNodeId, UUID rmtNodeId, Serializable data) {
+        if (joiningNodeId.equals(ctx.localNodeId())) {
+            Map<String, Object> map = (Map<String, Object>)data;
+
+            if (map != null && map.containsKey(ATTR_UPDATE_NOTIFIER_STATUS))
+                notifyEnabled = (Boolean)map.get(ATTR_UPDATE_NOTIFIER_STATUS);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onKernalStart() throws IgniteCheckedException {
+        if (notifyEnabled) {
+            try {
+                verChecker = new GridUpdateNotifier(ctx.gridName(),
+                    VER_STR,
+                    ctx.gateway(),
+                    ctx.plugins().allProviders(),
+                    false);
+
+                updateNtfTimer = new Timer("ignite-update-notifier-timer", true);
+
+                // Setup periodic version check.
+                updateNtfTimer.scheduleAtFixedRate(new UpdateNotifierTimerTask((IgniteKernal)ctx.grid(), verChecker),
+                    0, PERIODIC_VER_CHECK_DELAY);
+            }
+            catch (IgniteCheckedException e) {
+                if (log.isDebugEnabled())
+                    log.debug("Failed to create GridUpdateNotifier: " + e);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop(boolean cancel) throws IgniteCheckedException {
+        // Cancel update notification timer.
+        if (updateNtfTimer != null)
+            updateNtfTimer.cancel();
+
+        if (verChecker != null)
+            verChecker.stop();
+
+    }
+
+    /**
+     * @return Update notifier status.
+     */
+    public boolean updateNotifierEnabled() {
+        return notifyEnabled;
+    }
+
+    /**
+     * @return Latest version string.
+     */
+    public String latestVersion() {
+        return verChecker != null ? verChecker.latestVersion() : null;
+    }
+
+    /**
+     * Update notifier timer task.
+     */
+    private static class UpdateNotifierTimerTask extends GridTimerTask {
+        /** Reference to kernal. */
+        private final WeakReference<IgniteKernal> kernalRef;
+
+        /** Logger. */
+        private final IgniteLogger log;
+
+        /** Version checker. */
+        private final GridUpdateNotifier verChecker;
+
+        /** Whether this is the first run. */
+        private boolean first = true;
+
+        /**
+         * Constructor.
+         *
+         * @param kernal Kernal.
+         * @param verChecker Version checker.
+         */
+        private UpdateNotifierTimerTask(IgniteKernal kernal, GridUpdateNotifier verChecker) {
+            kernalRef = new WeakReference<>(kernal);
+
+            log = kernal.context().log(UpdateNotifierTimerTask.class);
+
+            this.verChecker = verChecker;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void safeRun() throws InterruptedException {
+            if (!first) {
+                IgniteKernal kernal = kernalRef.get();
+
+                if (kernal != null)
+                    verChecker.topologySize(kernal.cluster().nodes().size());
+            }
+
+            verChecker.checkForNewVersion(log);
+
+            // Just wait for 10 secs.
+            Thread.sleep(PERIODIC_VER_CHECK_CONN_TIMEOUT);
+
+            // Just wait another 60 secs in order to get
+            // version info even on slow connection.
+            for (int i = 0; i < 60 && verChecker.latestVersion() == null; i++)
+                Thread.sleep(1000);
+
+            // Report status if one is available.
+            // No-op if status is NOT available.
+            verChecker.reportStatus(log);
+
+            if (first) {
+                first = false;
+
+                verChecker.reportOnlyNew(true);
+            }
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/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
new file mode 100644
index 0000000..2e2f9e4
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
@@ -0,0 +1,457 @@
+/*
+ * 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.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;
+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.internal.GridKernalGateway;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.IgniteProperties;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+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;
+
+/**
+ * This class is responsible for notification about new version availability.
+ * <p>
+ * Note also that this connectivity is not necessary to successfully start the system as it will
+ * gracefully ignore any errors occurred during notification and verification process.
+ */
+class GridUpdateNotifier {
+    /** Default encoding. */
+    private static final String CHARSET = "UTF-8";
+
+    /** Access URL to be used to access latest version data. */
+    private final String UPD_STATUS_PARAMS = IgniteProperties.get("ignite.update.status.params");
+
+    /** Throttling for logging out. */
+    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;
+
+    /** 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;
+
+    /** Whether or not to report only new version. */
+    private volatile boolean reportOnlyNew;
+
+    /** */
+    private volatile int topSize;
+
+    /** System properties */
+    private final String vmProps;
+
+    /** Plugins information for request */
+    private final String pluginsVers;
+
+    /** Kernal gateway */
+    private final GridKernalGateway gw;
+
+    /** */
+    private long lastLog = -1;
+
+    /** Command for worker thread. */
+    private final AtomicReference<Runnable> cmd = new AtomicReference<>();
+
+    /** Worker thread to process http request. */
+    private final Thread workerThread;
+
+    /**
+     * Creates new notifier with default values.
+     *
+     * @param gridName gridName
+     * @param ver Compound Ignite version.
+     * @param gw Kernal gateway.
+     * @param pluginProviders Kernal gateway.
+     * @param reportOnlyNew Whether or not to report only new version.
+     * @throws IgniteCheckedException If failed.
+     */
+    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;
+
+            SB pluginsBuilder = new SB();
+
+            for (PluginProvider provider : pluginProviders)
+                pluginsBuilder.a("&").a(provider.name() + "-plugin-version").a("=").
+                    a(encode(provider.version(), CHARSET));
+
+            pluginsVers = pluginsBuilder.toString();
+
+            this.reportOnlyNew = reportOnlyNew;
+
+            vmProps = getSystemProperties();
+
+            workerThread = new Thread(new Runnable() {
+                @Override public void run() {
+                    try {
+                        while(!Thread.currentThread().isInterrupted()) {
+                            Runnable cmd0 = cmd.getAndSet(null);
+
+                            if (cmd0 != null)
+                                cmd0.run();
+                            else
+                                Thread.sleep(WORKER_THREAD_SLEEP_TIME);
+                        }
+                    }
+                    catch (InterruptedException ignore) {
+                        // No-op.
+                    }
+                }
+            }, "upd-ver-checker");
+
+            workerThread.setDaemon(true);
+
+            workerThread.start();
+        }
+        catch (ParserConfigurationException e) {
+            throw new IgniteCheckedException("Failed to create xml parser.", e);
+        }
+        catch (UnsupportedEncodingException e) {
+            throw new IgniteCheckedException("Failed to encode.", e);
+        }
+    }
+
+    /**
+     * Gets system properties.
+     *
+     * @return System properties.
+     */
+    private static String getSystemProperties() {
+        try {
+            StringWriter sw = new StringWriter();
+
+            try {
+                System.getProperties().store(new PrintWriter(sw), "");
+            }
+            catch (IOException ignore) {
+                return null;
+            }
+
+            return sw.toString();
+        }
+        catch (SecurityException ignore) {
+            return null;
+        }
+    }
+
+    /**
+     * @param reportOnlyNew Whether or not to report only new version.
+     */
+    void reportOnlyNew(boolean reportOnlyNew) {
+        this.reportOnlyNew = reportOnlyNew;
+    }
+
+    /**
+     * @param topSize Size of topology for license verification purpose.
+     */
+    void topologySize(int topSize) {
+        this.topSize = topSize;
+    }
+
+    /**
+     * @return Latest version.
+     */
+    String latestVersion() {
+        return latestVer;
+    }
+
+    /**
+     * Starts asynchronous process for retrieving latest version data.
+     *
+     * @param log Logger.
+     */
+    void checkForNewVersion(IgniteLogger log) {
+        assert log != null;
+
+        log = log.getLogger(getClass());
+
+        try {
+            cmd.set(new UpdateChecker(log));
+        }
+        catch (RejectedExecutionException e) {
+            U.error(log, "Failed to schedule a thread due to execution rejection (safely ignoring): " +
+                e.getMessage());
+        }
+    }
+
+    /**
+     * Logs out latest version notification if such was received and available.
+     *
+     * @param log Logger.
+     */
+    void reportStatus(IgniteLogger log) {
+        assert log != null;
+
+        log = log.getLogger(getClass());
+
+        String latestVer = this.latestVer;
+        String downloadUrl = this.downloadUrl;
+
+        downloadUrl = downloadUrl != null ? downloadUrl : IgniteKernal.SITE;
+
+        if (latestVer != null)
+            if (latestVer.equals(ver)) {
+                if (!reportOnlyNew)
+                    throttle(log, false, "Your version is up to date.");
+            }
+            else
+                throttle(log, true, "New version is available at " + downloadUrl + ": " + latestVer);
+        else
+            if (!reportOnlyNew)
+                throttle(log, false, "Update status is not available.");
+    }
+
+    /**
+     *
+     * @param log Logger to use.
+     * @param warn Whether or not this is a warning.
+     * @param msg Message to log.
+     */
+    private void throttle(IgniteLogger log, boolean warn, String msg) {
+        assert(log != null);
+        assert(msg != null);
+
+        long now = U.currentTimeMillis();
+
+        if (now - lastLog > THROTTLE_PERIOD) {
+            if (!warn)
+                U.log(log, msg);
+            else {
+                U.quiet(true, msg);
+
+                if (log.isInfoEnabled())
+                    log.warning(msg);
+            }
+
+            lastLog = now;
+        }
+    }
+
+    /**
+     * Stops update notifier.
+     */
+    public void stop() {
+        workerThread.interrupt();
+    }
+
+    /**
+     * Asynchronous checker of the latest version available.
+     */
+    private class UpdateChecker extends GridWorker {
+        /** Logger. */
+        private final IgniteLogger log;
+
+        /**
+         * Creates checked with given logger.
+         *
+         * @param log Logger.
+         */
+        UpdateChecker(IgniteLogger log) {
+            super(gridName, "grid-version-checker", log);
+
+            this.log = log.getLogger(getClass());
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void body() throws InterruptedException {
+            try {
+                String stackTrace = gw != null ? gw.userStackTrace() : null;
+
+                String postParams =
+                    "gridName=" + encode(gridName, CHARSET) +
+                    (!F.isEmpty(UPD_STATUS_PARAMS) ? "&" + UPD_STATUS_PARAMS : "") +
+                    (topSize > 0 ? "&topSize=" + topSize : "") +
+                    (!F.isEmpty(stackTrace) ? "&stackTrace=" + encode(stackTrace, CHARSET) : "") +
+                    (!F.isEmpty(vmProps) ? "&vmProps=" + encode(vmProps, CHARSET) : "") +
+                        pluginsVers;
+
+                URLConnection conn = new URL(url).openConnection();
+
+                if (!isCancelled()) {
+                    conn.setDoOutput(true);
+                    conn.setRequestProperty("Accept-Charset", CHARSET);
+                    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + CHARSET);
+
+                    conn.setConnectTimeout(3000);
+                    conn.setReadTimeout(3000);
+
+                    Document dom = null;
+
+                    try {
+                        try (OutputStream os = conn.getOutputStream()) {
+                            os.write(postParams.getBytes(CHARSET));
+                        }
+
+                        try (InputStream in = conn.getInputStream()) {
+                            if (in == null)
+                                return;
+
+                            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');
+                            }
+
+                            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) {
+                if (log.isDebugEnabled())
+                    log.debug("Unexpected exception in update checker. " + e.getMessage());
+            }
+        }
+
+        /**
+         * Gets the version from the current {@code node}, if one exists.
+         *
+         * @param node W3C DOM node.
+         * @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");
+
+                    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));
+
+                if (ver != null)
+                    return ver;
+            }
+
+            return null;
+        }
+
+        /**
+         * Gets the version from the current {@code node}, if one exists.
+         *
+         * @param node W3C DOM node.
+         * @return Version or {@code null} if one's not found.
+         */
+        @Nullable private String obtainVersionFrom(Node node) {
+            return obtainMeta("version", node);
+        }
+
+        /**
+         * Gets the download url from the current {@code node}, if one exists.
+         *
+         * @param node W3C DOM node.
+         * @return download url or {@code null} if one's not found.
+         */
+        @Nullable private String obtainDownloadUrlFrom(Node node) {
+            return obtainMeta("downloadUrl", node);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/modules/core/src/test/java/org/apache/ignite/internal/GridUpdateNotifierSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridUpdateNotifierSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridUpdateNotifierSelfTest.java
deleted file mode 100644
index afaa645..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridUpdateNotifierSelfTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal;
-
-import java.util.Collections;
-import java.util.Properties;
-import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteProductVersion;
-import org.apache.ignite.plugin.PluginProvider;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.testframework.junits.common.GridCommonTest;
-
-/**
- * Update notifier test.
- */
-@GridCommonTest(group = "Kernal Self")
-public class GridUpdateNotifierSelfTest extends GridCommonAbstractTest {
-    /** */
-    private String updateStatusParams;
-
-    /** {@inheritDoc} */
-    @Override protected long getTestTimeout() {
-        return 120 * 1000;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        super.beforeTestsStarted();
-
-        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "true");
-
-        Properties props = U.field(IgniteProperties.class, "PROPS");
-
-        updateStatusParams = props.getProperty("ignite.update.status.params");
-
-        props.setProperty("ignite.update.status.params", "ver=" + IgniteProperties.get("ignite.version"));
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        super.afterTestsStopped();
-
-        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false");
-
-        Properties props = U.field(IgniteProperties.class, "PROPS");
-
-        props.setProperty("ignite.update.status.params", updateStatusParams);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNotifier() throws Exception {
-        String nodeVer = IgniteProperties.get("ignite.version");
-
-        GridUpdateNotifier ntf = new GridUpdateNotifier(null, nodeVer,
-            TEST_GATEWAY, Collections.<PluginProvider>emptyList(), false);
-
-        ntf.checkForNewVersion(log);
-
-        String ver = ntf.latestVersion();
-
-        // Wait 60 sec for response.
-        for (int i = 0; ver == null && i < 600; i++) {
-            Thread.sleep(100);
-
-            ver = ntf.latestVersion();
-        }
-
-        info("Latest version: " + ver);
-
-        assertNotNull("Ignite latest version has not been detected.", ver);
-
-        byte nodeMaintenance = IgniteProductVersion.fromString(nodeVer).maintenance();
-
-        byte lastMaintenance = IgniteProductVersion.fromString(ver).maintenance();
-
-        assertTrue("Wrong latest version.", (nodeMaintenance == 0 && lastMaintenance == 0) ||
-            (nodeMaintenance > 0 && lastMaintenance > 0));
-
-        ntf.reportStatus(log);
-    }
-
-    /**
-     * Test kernal gateway that always return uninitialized user stack trace.
-     */
-    private static final GridKernalGateway TEST_GATEWAY = new GridKernalGateway() {
-        @Override public void readLock() throws IllegalStateException {}
-
-        @Override public void readLockAnyway() {}
-
-        @Override public void setState(GridKernalState state) {}
-
-        @Override public GridKernalState getState() {
-            return null;
-        }
-
-        @Override public void readUnlock() {}
-
-        @Override public void writeLock() {}
-
-        @Override public void writeUnlock() {}
-
-        @Override public String userStackTrace() {
-            return null;
-        }
-
-        @Override public boolean tryWriteLock(long timeout) {
-            return false;
-        }
-
-        @Override public GridFutureAdapter<?> onDisconnected() {
-            return null;
-        }
-
-        @Override public void onReconnected() {
-            // No-op.
-        }
-    };
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
new file mode 100644
index 0000000..a255f15
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.cluster.ClusterProcessor;
+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;
+
+/**
+ */
+public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private String backup;
+
+    /** */
+    private boolean client;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        backup = System.getProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, backup);
+
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNotifierEnabledForCluster() throws Exception {
+        checkNotifierStatusForCluster(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNotifierDisabledForCluster() throws Exception {
+        checkNotifierStatusForCluster(false);
+    }
+
+    /**
+     * @param enabled Notifier status.
+     * @throws Exception If failed.
+     */
+    private void checkNotifierStatusForCluster(boolean enabled) throws Exception {
+        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, String.valueOf(enabled));
+
+        IgniteEx grid1 = startGrid(0);
+
+        checkNotifier(grid1, enabled);
+
+        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, String.valueOf(!enabled));
+
+        IgniteEx grid2 = startGrid(1);
+
+        checkNotifier(grid2, enabled);
+
+        client = true;
+
+        IgniteEx grid3 = startGrid(2);
+
+        checkNotifier(grid3, enabled);
+
+        // Failover.
+        stopGrid(0); // Kill oldest.
+
+        client = false;
+
+        IgniteEx grid4 = startGrid(3);
+
+        checkNotifier(grid4, enabled);
+
+        client = true;
+
+        IgniteEx grid5 = startGrid(4);
+
+        checkNotifier(grid5, enabled);
+    }
+
+    /**
+     * @param ignite Node.
+     * @param expEnabled Expected notifier status.
+     */
+    private void checkNotifier(Ignite ignite, boolean expEnabled) {
+        ClusterProcessor proc = ((IgniteKernal)ignite).context().cluster();
+
+        if (expEnabled)
+            assertNotNull(GridTestUtils.getFieldValue(proc, "updateNtfTimer"));
+        else
+            assertNull(GridTestUtils.getFieldValue(proc, "updateNtfTimer"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
new file mode 100644
index 0000000..21b91b6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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.cluster;
+
+import java.util.Collections;
+import java.util.Properties;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.internal.GridKernalGateway;
+import org.apache.ignite.internal.GridKernalState;
+import org.apache.ignite.internal.IgniteProperties;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteProductVersion;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * Update notifier test.
+ */
+@GridCommonTest(group = "Kernal Self")
+public class GridUpdateNotifierSelfTest extends GridCommonAbstractTest {
+    /** */
+    private String updateStatusParams;
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 120 * 1000;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "true");
+
+        Properties props = U.field(IgniteProperties.class, "PROPS");
+
+        updateStatusParams = props.getProperty("ignite.update.status.params");
+
+        props.setProperty("ignite.update.status.params", "ver=" + IgniteProperties.get("ignite.version"));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false");
+
+        Properties props = U.field(IgniteProperties.class, "PROPS");
+
+        props.setProperty("ignite.update.status.params", updateStatusParams);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNotifier() throws Exception {
+        String nodeVer = IgniteProperties.get("ignite.version");
+
+        GridUpdateNotifier ntf = new GridUpdateNotifier(null, nodeVer,
+            TEST_GATEWAY, Collections.<PluginProvider>emptyList(), false);
+
+        ntf.checkForNewVersion(log);
+
+        String ver = ntf.latestVersion();
+
+        // Wait 60 sec for response.
+        for (int i = 0; ver == null && i < 600; i++) {
+            Thread.sleep(100);
+
+            ver = ntf.latestVersion();
+        }
+
+        info("Notifier version [ver=" + ver + ", nodeVer=" + nodeVer + ']');
+
+        assertNotNull("Ignite latest version has not been detected.", ver);
+
+        byte nodeMaintenance = IgniteProductVersion.fromString(nodeVer).maintenance();
+
+        byte lastMaintenance = IgniteProductVersion.fromString(ver).maintenance();
+
+        assertTrue("Wrong latest version [nodeVer=" + nodeMaintenance + ", lastVer=" + lastMaintenance + ']',
+            (nodeMaintenance == 0 && lastMaintenance == 0) || (nodeMaintenance > 0 && lastMaintenance > 0));
+
+        ntf.reportStatus(log);
+    }
+
+    /**
+     * Test kernal gateway that always return uninitialized user stack trace.
+     */
+    private static final GridKernalGateway TEST_GATEWAY = new GridKernalGateway() {
+        @Override public void readLock() throws IllegalStateException {}
+
+        @Override public void readLockAnyway() {}
+
+        @Override public void setState(GridKernalState state) {}
+
+        @Override public GridKernalState getState() {
+            return null;
+        }
+
+        @Override public void readUnlock() {}
+
+        @Override public void writeLock() {}
+
+        @Override public void writeUnlock() {}
+
+        @Override public String userStackTrace() {
+            return null;
+        }
+
+        @Override public boolean tryWriteLock(long timeout) {
+            return false;
+        }
+
+        @Override public GridFutureAdapter<?> onDisconnected() {
+            return null;
+        }
+
+        @Override public void onReconnected() {
+            // No-op.
+        }
+    };
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7175a425/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 deb49b7..7197eb8 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
@@ -33,8 +33,9 @@ import org.apache.ignite.internal.GridNodeVisorAttributesSelfTest;
 import org.apache.ignite.internal.GridRuntimeExceptionSelfTest;
 import org.apache.ignite.internal.GridSameVmStartupSelfTest;
 import org.apache.ignite.internal.GridSpiExceptionSelfTest;
-import org.apache.ignite.internal.GridUpdateNotifierSelfTest;
+import org.apache.ignite.internal.processors.cluster.GridUpdateNotifierSelfTest;
 import org.apache.ignite.internal.GridVersionSelfTest;
+import org.apache.ignite.internal.IgniteUpdateNotifierPerClusterSettingSelfTest;
 import org.apache.ignite.internal.managers.GridManagerStopSelfTest;
 import org.apache.ignite.internal.managers.communication.GridCommunicationSendMessageSelfTest;
 import org.apache.ignite.internal.managers.deployment.GridDeploymentManagerStopSelfTest;
@@ -107,6 +108,7 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
         suite.addTestSuite(GridNodeLocalSelfTest.class);
         suite.addTestSuite(GridKernalConcurrentAccessStopSelfTest.class);
         suite.addTestSuite(GridUpdateNotifierSelfTest.class);
+        suite.addTestSuite(IgniteUpdateNotifierPerClusterSettingSelfTest.class);
         suite.addTestSuite(GridLocalEventListenerSelfTest.class);
         suite.addTestSuite(IgniteTopologyPrintFormatSelfTest.class);
 


[14/29] ignite git commit: Fixes: - allow 'committing' -> 'marked_rollback' tx state change only for thread committing transaction - fixed 'full_sync' mode for case when tx primary nodes fail - fixed race between statically configured cache start and

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
index 291c88a..1b40d6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
@@ -19,6 +19,9 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.ignite.IgniteCheckedException;
@@ -44,6 +47,7 @@ import org.apache.ignite.internal.util.future.GridCompoundIdentityFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.C1;
+import org.apache.ignite.internal.util.typedef.CI1;
 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.S;
@@ -64,6 +68,9 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
     public static final IgniteProductVersion FINISH_NEAR_ONE_PHASE_SINCE = IgniteProductVersion.fromString("1.4.0");
 
     /** */
+    public static final IgniteProductVersion WAIT_REMOTE_TXS_SINCE = IgniteProductVersion.fromString("1.5.0");
+
+    /** */
     private static final long serialVersionUID = 0L;
 
     /** Logger reference. */
@@ -122,22 +129,23 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override public boolean onNodeLeft(UUID nodeId) {
+        boolean found = false;
+
         for (IgniteInternalFuture<?> fut : futures())
             if (isMini(fut)) {
-                MiniFuture f = (MiniFuture)fut;
+                MinFuture f = (MinFuture)fut;
 
-                if (f.node().id().equals(nodeId)) {
+                if (f.onNodeLeft(nodeId)) {
                     // Remove previous mapping.
                     mappings.remove(nodeId);
 
-                    f.onResult(new ClusterTopologyCheckedException("Remote node left grid (will fail): " + nodeId));
-
-                    return true;
+                    found = true;
                 }
             }
 
-        return false;
+        return found;
     }
 
     /** {@inheritDoc} */
@@ -156,19 +164,32 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
      * @param nodeId Sender.
      * @param res Result.
      */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     public void onResult(UUID nodeId, GridNearTxFinishResponse res) {
-        if (!isDone())
-            for (IgniteInternalFuture<IgniteInternalTx> fut : futures()) {
-                if (isMini(fut)) {
-                    MiniFuture f = (MiniFuture)fut;
+        if (!isDone()) {
+            FinishMiniFuture finishFut = null;
 
-                    if (f.futureId().equals(res.miniId())) {
-                        assert f.node().id().equals(nodeId);
+            synchronized (futs) {
+                for (int i = 0; i < futs.size(); i++) {
+                    IgniteInternalFuture<IgniteInternalTx> fut = futs.get(i);
+
+                    if (fut.getClass() == FinishMiniFuture.class) {
+                        FinishMiniFuture f = (FinishMiniFuture)fut;
 
-                        f.onResult(res);
+                        if (f.futureId().equals(res.miniId())) {
+                            assert f.node().id().equals(nodeId);
+
+                            finishFut = f;
+
+                            break;
+                        }
                     }
                 }
             }
+
+            if (finishFut != null)
+                finishFut.onNearFinishResponse(res);
+        }
     }
 
     /**
@@ -178,15 +199,21 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
     public void onResult(UUID nodeId, GridDhtTxFinishResponse res) {
         if (!isDone())
             for (IgniteInternalFuture<IgniteInternalTx> fut : futures()) {
-                if (isMini(fut)) {
-                    MiniFuture f = (MiniFuture)fut;
+                if (fut.getClass() == CheckBackupMiniFuture.class) {
+                    CheckBackupMiniFuture f = (CheckBackupMiniFuture)fut;
 
                     if (f.futureId().equals(res.miniId())) {
                         assert f.node().id().equals(nodeId);
 
-                        f.onResult(res);
+                        f.onDhtFinishResponse(res);
                     }
                 }
+                else if (fut.getClass() == CheckRemoteTxMiniFuture.class) {
+                    CheckRemoteTxMiniFuture f = (CheckRemoteTxMiniFuture)fut;
+
+                    if (f.futureId().equals(res.miniId()))
+                        f.onDhtFinishResponse(nodeId);
+                }
             }
     }
 
@@ -204,9 +231,6 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
 
                 boolean marked = tx.setRollbackOnly();
 
-                if (err instanceof NodeStoppingException)
-                    return super.onDone(null, err);
-
                 if (err instanceof IgniteTxRollbackCheckedException) {
                     if (marked) {
                         try {
@@ -289,11 +313,13 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
     }
 
     /**
-     * @param f Future.
+     * @param fut Future.
      * @return {@code True} if mini-future.
      */
-    private boolean isMini(IgniteInternalFuture<?> f) {
-        return f.getClass().equals(MiniFuture.class);
+    private boolean isMini(IgniteInternalFuture<?> fut) {
+        return fut.getClass() == FinishMiniFuture.class ||
+            fut.getClass() == CheckBackupMiniFuture.class ||
+            fut.getClass() == CheckRemoteTxMiniFuture.class;
     }
 
     /**
@@ -393,7 +419,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
 
                 ClusterNode backup = cctx.discovery().node(backupId);
 
-                MiniFuture mini = new MiniFuture(backup, mapping);
+                final CheckBackupMiniFuture mini = new CheckBackupMiniFuture(backup, mapping);
 
                 add(mini);
 
@@ -414,8 +440,25 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
 
                     readyNearMappingFromBackup(mapping);
 
-                    if (committed)
+                    if (committed) {
+                        if (tx.syncCommit()) {
+                            GridCacheVersion nearXidVer = tx.nearXidVersion();
+
+                            assert nearXidVer != null : tx;
+
+                            IgniteInternalFuture<?> fut = cctx.tm().remoteTxFinishFuture(nearXidVer);
+
+                            fut.listen(new CI1<IgniteInternalFuture<?>>() {
+                                @Override public void apply(IgniteInternalFuture<?> fut) {
+                                    mini.onDone(tx);
+                                }
+                            });
+
+                            return;
+                        }
+
                         mini.onDone(tx);
+                    }
                     else {
                         ClusterTopologyCheckedException cause =
                             new ClusterTopologyCheckedException("Primary node left grid: " + nodeId);
@@ -427,46 +470,26 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
                     }
                 }
                 else {
-                    GridDhtTxFinishRequest finishReq = new GridDhtTxFinishRequest(
-                        cctx.localNodeId(),
-                        futureId(),
-                        mini.futureId(),
-                        tx.topologyVersion(),
-                        tx.xidVersion(),
-                        tx.commitVersion(),
-                        tx.threadId(),
-                        tx.isolation(),
-                        true,
-                        false,
-                        tx.system(),
-                        tx.ioPolicy(),
-                        false,
-                        true,
-                        true,
-                        null,
-                        null,
-                        null,
-                        null,
-                        0,
-                        null,
-                        0,
-                        tx.activeCachesDeploymentEnabled());
-
-                    finishReq.checkCommitted(true);
+                    GridDhtTxFinishRequest finishReq = checkCommittedRequest(mini.futureId());
+
+                    // Preserve old behavior, otherwise response is not sent.
+                    if (WAIT_REMOTE_TXS_SINCE.compareTo(backup.version()) > 0)
+                        finishReq.syncCommit(true);
 
                     try {
                         if (FINISH_NEAR_ONE_PHASE_SINCE.compareTo(backup.version()) <= 0)
                             cctx.io().send(backup, finishReq, tx.ioPolicy());
-                        else
+                        else {
                             mini.onDone(new IgniteTxHeuristicCheckedException("Failed to check for tx commit on " +
                                 "the backup node (node has an old Ignite version) [rmtNodeId=" + backup.id() +
                                 ", ver=" + backup.version() + ']'));
+                        }
                     }
                     catch (ClusterTopologyCheckedException e) {
-                        mini.onResult(e);
+                        mini.onNodeLeft(backupId);
                     }
                     catch (IgniteCheckedException e) {
-                        mini.onResult(e);
+                        mini.onDone(e);
                     }
                 }
             }
@@ -476,7 +499,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
     }
 
     /**
-     *
+     * @return {@code True} if need to send finish request for one phase commit transaction.
      */
     private boolean needFinishOnePhase() {
         if (tx.mappings().empty())
@@ -584,7 +607,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
                 add(fut);
         }
         else {
-            MiniFuture fut = new MiniFuture(m);
+            FinishMiniFuture fut = new FinishMiniFuture(m);
 
             req.miniId(fut.futureId());
 
@@ -604,11 +627,11 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
                 // Remove previous mapping.
                 mappings.remove(m.node().id());
 
-                fut.onResult(e);
+                fut.onNodeLeft(n.id());
             }
             catch (IgniteCheckedException e) {
                 // Fail the whole thing.
-                fut.onResult(e);
+                fut.onDone(e);
             }
         }
     }
@@ -618,10 +641,24 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
         Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
             @SuppressWarnings("unchecked")
             @Override public String apply(IgniteInternalFuture<?> f) {
-                if (isMini(f)) {
-                    MiniFuture m = (MiniFuture)f;
+                if (f.getClass() == FinishMiniFuture.class) {
+                    FinishMiniFuture fut = (FinishMiniFuture)f;
+
+                    return "FinishFuture[node=" + fut.node().id() +
+                        ", loc=" + fut.node().isLocal() +
+                        ", done=" + fut.isDone() + "]";
+                }
+                else if (f.getClass() == CheckBackupMiniFuture.class) {
+                    CheckBackupMiniFuture fut = (CheckBackupMiniFuture)f;
 
-                    return "[node=" + m.node().id() + ", loc=" + m.node().isLocal() + ", done=" + f.isDone() + "]";
+                    return "CheckBackupFuture[node=" + fut.node().id() +
+                        ", loc=" + fut.node().isLocal() +
+                        ", done=" + f.isDone() + "]";
+                }
+                else if (f.getClass() == CheckRemoteTxMiniFuture.class) {
+                    CheckRemoteTxMiniFuture fut = (CheckRemoteTxMiniFuture)f;
+
+                    return "CheckRemoteTxMiniFuture[nodes=" + fut.nodes() + ", done=" + f.isDone() + "]";
                 }
                 else
                     return "[loc=true, done=" + f.isDone() + "]";
@@ -634,108 +671,217 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
     }
 
     /**
+     * @param miniId Mini future ID.
+     * @return Finish request.
+     */
+    private GridDhtTxFinishRequest checkCommittedRequest(IgniteUuid miniId) {
+        GridDhtTxFinishRequest finishReq = new GridDhtTxFinishRequest(
+            cctx.localNodeId(),
+            futureId(),
+            miniId,
+            tx.topologyVersion(),
+            tx.xidVersion(),
+            tx.commitVersion(),
+            tx.threadId(),
+            tx.isolation(),
+            true,
+            false,
+            tx.system(),
+            tx.ioPolicy(),
+            false,
+            tx.syncCommit(),
+            tx.syncRollback(),
+            null,
+            null,
+            null,
+            null,
+            0,
+            null,
+            0,
+            tx.activeCachesDeploymentEnabled());
+
+        finishReq.checkCommitted(true);
+
+        return finishReq;
+    }
+
+    /**
+     *
+     */
+    private abstract class MinFuture extends GridFutureAdapter<IgniteInternalTx> {
+        /** */
+        private final IgniteUuid futId = IgniteUuid.randomUuid();
+
+        /**
+          * @param nodeId Node ID.
+         * @return {@code True} if future processed node failure.
+         */
+        abstract boolean onNodeLeft(UUID nodeId);
+
+        /**
+         * @return Future ID.
+         */
+        final IgniteUuid futureId() {
+            return futId;
+        }
+    }
+
+    /**
      * Mini-future for get operations. Mini-futures are only waiting on a single
      * node as opposed to multiple nodes.
      */
-    private class MiniFuture extends GridFutureAdapter<IgniteInternalTx> {
+    private class FinishMiniFuture extends MinFuture {
         /** */
         private static final long serialVersionUID = 0L;
 
-        /** */
-        private final IgniteUuid futId = IgniteUuid.randomUuid();
-
         /** Keys. */
         @GridToStringInclude
         private GridDistributedTxMapping m;
 
-        /** Backup check flag. */
-        private ClusterNode backup;
-
         /**
          * @param m Mapping.
          */
-        MiniFuture(GridDistributedTxMapping m) {
+        FinishMiniFuture(GridDistributedTxMapping m) {
             this.m = m;
         }
 
         /**
-         * @param backup Backup to check.
-         * @param m Mapping associated with the backup.
+         * @return Node ID.
          */
-        MiniFuture(ClusterNode backup, GridDistributedTxMapping m) {
-            this.backup = backup;
-            this.m = m;
+        ClusterNode node() {
+            return m.node();
         }
 
         /**
-         * @return Future ID.
+         * @return Keys.
          */
-        IgniteUuid futureId() {
-            return futId;
+        public GridDistributedTxMapping mapping() {
+            return m;
         }
 
         /**
-         * @return Node ID.
+         * @param nodeId Failed node ID.
          */
-        public ClusterNode node() {
-            assert m != null || backup != null;
+        boolean onNodeLeft(UUID nodeId) {
+            if (nodeId.equals(m.node().id())) {
+                if (log.isDebugEnabled())
+                    log.debug("Remote node left grid while sending or waiting for reply: " + this);
+
+                if (isSync()) {
+                    Map<UUID, Collection<UUID>> txNodes = tx.transactionNodes();
+
+                    if (txNodes != null) {
+                        Collection<UUID> backups = txNodes.get(nodeId);
+
+                        if (!F.isEmpty(backups)) {
+                            final CheckRemoteTxMiniFuture mini = new CheckRemoteTxMiniFuture(new HashSet<>(backups));
+
+                            add(mini);
+
+                            GridDhtTxFinishRequest req = checkCommittedRequest(mini.futureId());
+
+                            req.waitRemoteTransactions(true);
+
+                            for (UUID backupId : backups) {
+                                ClusterNode backup = cctx.discovery().node(backupId);
+
+                                if (backup != null && WAIT_REMOTE_TXS_SINCE.compareTo(backup.version()) <= 0) {
+                                    if (backup.isLocal()) {
+                                        IgniteInternalFuture<?> fut = cctx.tm().remoteTxFinishFuture(tx.nearXidVersion());
+
+                                        fut.listen(new CI1<IgniteInternalFuture<?>>() {
+                                            @Override public void apply(IgniteInternalFuture<?> fut) {
+                                                mini.onDhtFinishResponse(cctx.localNodeId());
+                                            }
+                                        });
+                                    }
+                                    else {
+                                        try {
+                                            cctx.io().send(backup, req, tx.ioPolicy());
+                                        }
+                                        catch (ClusterTopologyCheckedException e) {
+                                            mini.onNodeLeft(backupId);
+                                        }
+                                        catch (IgniteCheckedException e) {
+                                            mini.onDone(e);
+                                        }
+                                    }
+                                }
+                                else
+                                    mini.onDhtFinishResponse(backupId);
+                            }
+                        }
+                    }
+                }
 
-            return backup != null ? backup : m.node();
+                onDone(tx);
+
+                return true;
+            }
+
+            return false;
         }
 
         /**
-         * @return Keys.
+         * @param res Result callback.
          */
-        public GridDistributedTxMapping mapping() {
-            return m;
+        void onNearFinishResponse(GridNearTxFinishResponse res) {
+            if (res.error() != null)
+                onDone(res.error());
+            else
+                onDone(tx);
         }
 
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(FinishMiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
+        }
+    }
+
+    /**
+     *
+     */
+    private class CheckBackupMiniFuture extends MinFuture {
+        /** Keys. */
+        @GridToStringInclude
+        private GridDistributedTxMapping m;
+
+        /** Backup node to check. */
+        private ClusterNode backup;
+
         /**
-         * @param e Error.
+         * @param backup Backup to check.
+         * @param m Mapping associated with the backup.
          */
-        void onResult(Throwable e) {
-            if (log.isDebugEnabled())
-                log.debug("Failed to get future result [fut=" + this + ", err=" + e + ']');
-
-            // Fail.
-            onDone(e);
+        CheckBackupMiniFuture(ClusterNode backup, GridDistributedTxMapping m) {
+            this.backup = backup;
+            this.m = m;
         }
 
         /**
-         * @param e Node failure.
+         * @return Node ID.
          */
-        void onResult(ClusterTopologyCheckedException e) {
-            if (log.isDebugEnabled())
-                log.debug("Remote node left grid while sending or waiting for reply (will fail): " + this);
+        public ClusterNode node() {
+            return backup;
+        }
 
-            if (backup != null) {
+        /** {@inheritDoc} */
+        @Override boolean onNodeLeft(UUID nodeId) {
+            if (nodeId.equals(backup.id())) {
                 readyNearMappingFromBackup(m);
 
-                onDone(e);
-            }
-            else
-                // Complete future with tx.
-                onDone(tx);
-        }
+                onDone(new ClusterTopologyCheckedException("Remote node left grid: " + nodeId));
 
-        /**
-         * @param res Result callback.
-         */
-        void onResult(GridNearTxFinishResponse res) {
-            assert backup == null;
+                return true;
+            }
 
-            if (res.error() != null)
-                onDone(res.error());
-            else
-                onDone(tx);
+            return false;
         }
 
         /**
          * @param res Response.
          */
-        void onResult(GridDhtTxFinishResponse res) {
-            assert backup != null;
-
+        void onDhtFinishResponse(GridDhtTxFinishResponse res) {
             readyNearMappingFromBackup(m);
 
             Throwable err = res.checkCommittedError();
@@ -755,9 +901,67 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
                 onDone(tx);
         }
 
+    }
+
+    /**
+     *
+     */
+    private class CheckRemoteTxMiniFuture extends MinFuture {
+        /** */
+        private Set<UUID> nodes;
+
+        /**
+         * @param nodes Backup nodes.
+         */
+        public CheckRemoteTxMiniFuture(Set<UUID> nodes) {
+            this.nodes = nodes;
+        }
+
+        /**
+         * @return Backup nodes.
+         */
+        Set<UUID> nodes() {
+            synchronized (this) {
+                return new HashSet<>(nodes);
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override boolean onNodeLeft(UUID nodeId) {
+            return onResponse(nodeId);
+        }
+
+        /**
+         * @param nodeId Node ID.
+         */
+        void onDhtFinishResponse(UUID nodeId) {
+            onResponse(nodeId);
+        }
+
+        /**
+         * @param nodeId Node ID.
+         * @return {@code True} if processed node response.
+         */
+        private boolean onResponse(UUID nodeId) {
+            boolean done;
+
+            boolean ret;
+
+            synchronized (this) {
+                ret = nodes.remove(nodeId);
+
+                done = nodes.isEmpty();
+            }
+
+            if (done)
+                onDone(tx);
+
+            return ret;
+        }
+
         /** {@inheritDoc} */
         @Override public String toString() {
-            return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
+            return S.toString(CheckRemoteTxMiniFuture.class, this);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
index 3e5e28f..65eac63 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
@@ -70,6 +70,9 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
      * @param commit Commit flag.
      * @param invalidate Invalidate flag.
      * @param sys System flag.
+     * @param plc IO policy.
+     * @param syncCommit Sync commit flag.
+     * @param syncRollback Sync rollback flag.
      * @param explicitLock Explicit lock flag.
      * @param storeEnabled Store enabled flag.
      * @param topVer Topology version.
@@ -77,6 +80,8 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
      * @param committedVers Committed versions.
      * @param rolledbackVers Rolled back versions.
      * @param txSize Expected transaction size.
+     * @param subjId Subject ID.
+     * @param taskNameHash Task name hash.
      * @param addDepInfo Deployment info flag.
      */
     public GridNearTxFinishRequest(

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 4904ad8..b84d2fd 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
@@ -99,7 +99,7 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
         super.prepareMarshal(ctx);
 
-        if (err != null)
+        if (err != null && errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
     }
 
@@ -107,7 +107,7 @@ public class GridNearTxFinishResponse extends GridDistributedTxFinishResponse {
     @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
-        if (errBytes != null)
+        if (errBytes != null && err == null)
             err = ctx.marshaller().unmarshal(errBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 aa4e929f..b7b480e 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
@@ -202,7 +202,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public GridCacheVersion nearXidVersion() {
+    @Override public GridCacheVersion nearXidVersion() {
         return xidVer;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
index d886243..8812709 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
@@ -264,7 +264,7 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
         super.prepareMarshal(ctx);
 
-        if (ownedVals != null) {
+        if (ownedVals != null && ownedValKeys == null) {
             ownedValKeys = ownedVals.keySet();
 
             ownedValVals = ownedVals.values();
@@ -287,7 +287,7 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse
         }
 
         if (filterFailedKeys != null) {
-            for (IgniteTxKey key :filterFailedKeys) {
+            for (IgniteTxKey key : filterFailedKeys) {
                 GridCacheContext cctx = ctx.cacheContext(key.cacheId());
 
                 key.prepareMarshal(cctx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 59d8b5b..dc98eda 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
@@ -280,28 +280,28 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
 
         GridCacheContext cctx = ctx.cacheContext(cacheId);
 
-        if (keyValFilter != null) {
+        if (keyValFilter != null && keyValFilterBytes == null) {
             if (addDepInfo)
                 prepareObject(keyValFilter, cctx);
 
             keyValFilterBytes = CU.marshal(cctx, keyValFilter);
         }
 
-        if (rdc != null) {
+        if (rdc != null && rdcBytes == null) {
             if (addDepInfo)
                 prepareObject(rdc, cctx);
 
             rdcBytes = CU.marshal(cctx, rdc);
         }
 
-        if (trans != null) {
+        if (trans != null && transBytes == null) {
             if (addDepInfo)
                 prepareObject(trans, cctx);
 
             transBytes = CU.marshal(cctx, trans);
         }
 
-        if (!F.isEmpty(args)) {
+        if (!F.isEmpty(args) && argsBytes == null) {
             if (addDepInfo) {
                 for (Object arg : args)
                     prepareObject(arg, cctx);
@@ -317,16 +317,16 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
 
         Marshaller mrsh = ctx.marshaller();
 
-        if (keyValFilterBytes != null)
+        if (keyValFilterBytes != null && keyValFilter == null)
             keyValFilter = mrsh.unmarshal(keyValFilterBytes, ldr);
 
-        if (rdcBytes != null)
+        if (rdcBytes != null && rdc == null)
             rdc = mrsh.unmarshal(rdcBytes, ldr);
 
-        if (transBytes != null)
+        if (transBytes != null && trans == null)
             trans = mrsh.unmarshal(transBytes, ldr);
 
-        if (argsBytes != null)
+        if (argsBytes != null && args == null)
             args = mrsh.unmarshal(argsBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 cce465b..ab882d4 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
@@ -122,11 +122,14 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
 
         GridCacheContext cctx = ctx.cacheContext(cacheId);
 
-        if (err != null)
+        if (err != null && errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
 
-        metaDataBytes = marshalCollection(metadata, cctx);
-        dataBytes = marshalCollection(data, cctx);
+        if (metaDataBytes == null)
+            metaDataBytes = marshalCollection(metadata, cctx);
+
+        if (dataBytes == null)
+            dataBytes = marshalCollection(data, cctx);
 
         if (addDepInfo && !F.isEmpty(data)) {
             for (Object o : data) {
@@ -144,11 +147,14 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
     @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
-        if (errBytes != null)
+        if (errBytes != null && err == null)
             err = ctx.marshaller().unmarshal(errBytes, ldr);
 
-        metadata = unmarshalCollection(metaDataBytes, ctx, ldr);
-        data = unmarshalCollection(dataBytes, ctx, ldr);
+        if (metadata == null)
+            metadata = unmarshalCollection(metaDataBytes, ctx, ldr);
+
+        if (data == null)
+            data = unmarshalCollection(dataBytes, ctx, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
index f5f99f5..914b4ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
@@ -160,6 +160,12 @@ public interface IgniteInternalTx extends AutoCloseable, GridTimeoutObject {
     public long timeout(long timeout);
 
     /**
+     * Changes transaction state from COMMITTING to MARKED_ROLLBACK.
+     * Must be called only from thread committing transaction.
+     */
+    public void errorWhenCommitting();
+
+    /**
      * Modify the transaction associated with the current thread such that the
      * only possible outcome of the transaction is to roll back the
      * transaction.

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index 22e27c3..ed44c49 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -804,6 +804,22 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
     }
 
     /** {@inheritDoc} */
+    public final void errorWhenCommitting() {
+        synchronized (this) {
+            TransactionState prev = state;
+
+            assert prev == COMMITTING : prev;
+
+            state = MARKED_ROLLBACK;
+
+            if (log.isDebugEnabled())
+                log.debug("Changed transaction state [prev=" + prev + ", new=" + this.state + ", tx=" + this + ']');
+
+            notifyAll();
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean setRollbackOnly() {
         return state(MARKED_ROLLBACK);
     }
@@ -1083,7 +1099,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
                 }
 
                 case MARKED_ROLLBACK: {
-                    valid = prev == ACTIVE || prev == PREPARING || prev == PREPARED || prev == COMMITTING;
+                    valid = prev == ACTIVE || prev == PREPARING || prev == PREPARED;
 
                     break;
                 }
@@ -1705,6 +1721,11 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
         }
 
         /** {@inheritDoc} */
+        @Override public void errorWhenCommitting() {
+            throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
+        }
+
+        /** {@inheritDoc} */
         @Override public void commit() {
             throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 c42bc7f..f731975 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
@@ -828,7 +828,12 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
 
         val.marshal(ctx, context());
 
-        expiryPlcBytes = transferExpiryPlc ?  CU.marshal(this.ctx, new IgniteExternalizableExpiryPolicy(expiryPlc)) : null;
+        if (transferExpiryPlc) {
+            if (expiryPlcBytes == null)
+                expiryPlcBytes = CU.marshal(this.ctx, new IgniteExternalizableExpiryPolicy(expiryPlc));
+        }
+        else
+            expiryPlcBytes = null;
     }
 
     /**
@@ -871,8 +876,8 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
 
         val.unmarshal(this.ctx, clsLdr);
 
-        if (expiryPlcBytes != null)
-            expiryPlc =  ctx.marshaller().unmarshal(expiryPlcBytes, clsLdr);
+        if (expiryPlcBytes != null && expiryPlc == null)
+            expiryPlc = ctx.marshaller().unmarshal(expiryPlcBytes, clsLdr);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index b25baf8..547c018 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -721,14 +721,12 @@ public class IgniteTxHandler {
 
             IgniteInternalFuture<IgniteInternalTx> res = null;
 
-            if (tx != null) {
-                IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackAsync();
+            IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackAsync();
 
-                // Only for error logging.
-                rollbackFut.listen(CU.errorLogger(log));
+            // Only for error logging.
+            rollbackFut.listen(CU.errorLogger(log));
 
-                res = rollbackFut;
-            }
+            res = rollbackFut;
 
             if (e instanceof Error)
                 throw (Error)e;
@@ -875,7 +873,19 @@ public class IgniteTxHandler {
             log.debug("Processing dht tx finish request [nodeId=" + nodeId + ", req=" + req + ']');
 
         if (req.checkCommitted()) {
-            sendReply(nodeId, req, !ctx.tm().addRolledbackTx(null, req.version()));
+            boolean committed = req.waitRemoteTransactions() || !ctx.tm().addRolledbackTx(null, req.version());
+
+            if (!committed || !req.syncCommit())
+                sendReply(nodeId, req, committed);
+            else {
+                IgniteInternalFuture<?> fut = ctx.tm().remoteTxFinishFuture(req.version());
+
+                fut.listen(new CI1<IgniteInternalFuture<?>>() {
+                    @Override public void apply(IgniteInternalFuture<?> fut) {
+                        sendReply(nodeId, req, true);
+                    }
+                });
+            }
 
             return;
         }
@@ -1044,7 +1054,7 @@ public class IgniteTxHandler {
      * @param committed {@code True} if transaction committed on this node.
      */
     protected void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committed) {
-        if (req.replyRequired()) {
+        if (req.replyRequired() || req.checkCommitted()) {
             GridDhtTxFinishResponse res = new GridDhtTxFinishResponse(req.version(), req.futureId(), req.miniId());
 
             if (req.checkCommitted()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 21ff0cf..926eaf2 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
@@ -809,7 +809,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
             catch (IgniteCheckedException ex) {
                 commitError(ex);
 
-                setRollbackOnly();
+                errorWhenCommitting();
 
                 // Safe to remove transaction from committed tx list because nothing was committed yet.
                 cctx.tm().removeCommittedTx(this);
@@ -819,7 +819,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
             catch (Throwable ex) {
                 commitError(ex);
 
-                setRollbackOnly();
+                errorWhenCommitting();
 
                 // Safe to remove transaction from committed tx list because nothing was committed yet.
                 cctx.tm().removeCommittedTx(this);
@@ -1161,7 +1161,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                             // Set operation to NOOP.
                             txEntry.op(NOOP);
 
-                            setRollbackOnly();
+                            errorWhenCommitting();
 
                             throw ex;
                         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index d384e4e..ca15e20 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1063,6 +1063,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
         if (!((committed != null && committed) || tx.writeSet().isEmpty() || tx.isSystemInvalidate())) {
             uncommitTx(tx);
 
+            tx.errorWhenCommitting();
+
             throw new IgniteException("Missing commit version (consider increasing " +
                 IGNITE_MAX_COMPLETED_TX_COUNT + " system property) [ver=" + tx.xidVersion() +
                 ", tx=" + tx.getClass().getSimpleName() + ']');
@@ -1616,6 +1618,24 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
     }
 
     /**
+     * @param nearVer Near version.
+     * @return Finish future for related remote transactions.
+     */
+    @SuppressWarnings("unchecked")
+    public IgniteInternalFuture<?> remoteTxFinishFuture(GridCacheVersion nearVer) {
+        GridCompoundFuture<Void, Void> fut = new GridCompoundFuture<>();
+
+        for (final IgniteInternalTx tx : txs()) {
+            if (!tx.local() && nearVer.equals(tx.nearXidVersion()))
+                fut.add((IgniteInternalFuture) tx.finishFuture());
+        }
+
+        fut.markInitialized();
+
+        return fut;
+    }
+
+    /**
      * @param nearVer Near version ID.
      * @param txNum Number of transactions.
      * @param fut Result future.

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java
index 3d65304..77c802d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java
@@ -105,6 +105,7 @@ public class DataStreamerRequest implements Message {
      * @param entries Entries to put.
      * @param ignoreDepOwnership Ignore ownership.
      * @param skipStore Skip store flag.
+     * @param keepBinary Keep binary flag.
      * @param depMode Deployment mode.
      * @param sampleClsName Sample class name.
      * @param userVer User version.

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index cd783e4..98848ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -926,8 +926,15 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
 
         CacheConfiguration newCfg = cacheConfiguration(cfg, cacheName);
 
-        if (ctx.cache().cache(cacheName) == null)
-            ctx.cache().dynamicStartCache(newCfg, cacheName, null, CacheType.INTERNAL, false, true).get();
+        if (ctx.cache().cache(cacheName) == null) {
+            ctx.cache().dynamicStartCache(newCfg,
+                cacheName,
+                null,
+                CacheType.INTERNAL,
+                false,
+                true,
+                true).get();
+        }
 
         assert ctx.cache().cache(cacheName) != null : cacheName;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 f4a8fad..ecb892e 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
@@ -90,7 +90,7 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
     @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
         super.prepareMarshal(marsh);
 
-        if (err != null)
+        if (err != null && errBytes == null)
             errBytes = marsh.marshal(err);
     }
 
@@ -98,7 +98,7 @@ public class IgfsAckMessage extends IgfsCommunicationMessage {
     @Override public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(marsh, ldr);
 
-        if (errBytes != null)
+        if (errBytes != null && err == null)
             err = marsh.unmarshal(errBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index 65dca08..a89913f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -357,7 +357,8 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
 
             switch (cmd) {
                 case DESTROY_CACHE: {
-                    fut = ((IgniteKernal)ctx.grid()).destroyCacheAsync(cacheName).chain(
+                    // Do not check thread tx here since there can be active system cache txs.
+                    fut = ((IgniteKernal)ctx.grid()).destroyCacheAsync(cacheName, false).chain(
                         new CX1<IgniteInternalFuture<?>, GridRestResponse>() {
                             @Override public GridRestResponse applyx(IgniteInternalFuture<?> f)
                                 throws IgniteCheckedException {
@@ -369,7 +370,8 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
                 }
 
                 case GET_OR_CREATE_CACHE: {
-                    fut = ((IgniteKernal)ctx.grid()).getOrCreateCacheAsync(cacheName).chain(
+                    // Do not check thread tx here since there can be active system cache txs.
+                    fut = ((IgniteKernal)ctx.grid()).getOrCreateCacheAsync(cacheName, false).chain(
                         new CX1<IgniteInternalFuture<?>, GridRestResponse>() {
                             @Override public GridRestResponse applyx(IgniteInternalFuture<?> f)
                                 throws IgniteCheckedException {

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
index 1ea5014..8c23d92 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpi.java
@@ -104,6 +104,7 @@ public interface DiscoverySpi extends IgniteSpi {
      * Sets a handler for initial data exchange between Ignite nodes.
      *
      * @param exchange Discovery data exchange handler.
+     * @return {@code this} for chaining.
      */
     public TcpDiscoverySpi setDataExchange(DiscoverySpiDataExchange exchange);
 
@@ -113,6 +114,7 @@ public interface DiscoverySpi extends IgniteSpi {
      * dynamic metrics between nodes.
      *
      * @param metricsProvider Provider of metrics data.
+     * @return {@code this} for chaining.
      */
     public TcpDiscoverySpi setMetricsProvider(DiscoveryMetricsProvider metricsProvider);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 066a5fd..21204c7 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
@@ -204,7 +204,8 @@ public class SocketStreamer<T, K, V> extends StreamAdapter<T, K, V> {
      * Stops streamer.
      */
     public void stop() {
-        srv.stop();
+        if (srv != null)
+            srv.stop();
 
         if (log.isDebugEnabled())
             log.debug("Socket streaming server stopped");

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java
index 95ca9b5..9908b87 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java
@@ -324,10 +324,14 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
             @Override public void applyx(IgniteCache<String, Integer> cache) {
                 int rnd = random();
 
+                Set<Integer> ids = new HashSet<>(set);
+
                 cache.removeAll(rangeKeys(0, rnd));
 
-                for (int i = 0; i < rnd; i++)
-                    assert cache.localPeek("key" + i, CachePeekMode.ONHEAP) == null;
+                for (int i = 0; i < rnd; i++) {
+                    if (ids.contains(i))
+                        assertNull(cache.localPeek("key" + i));
+                }
             }
         });
     }
@@ -350,7 +354,7 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
 
                 for (int i = 0; i < rnd; i++) {
                     if (ids.contains(i))
-                        assert cache.localPeek("key" + i, CachePeekMode.ONHEAP) == null;
+                        assertNull(cache.localPeek("key" + i));
                 }
             }
         });
@@ -359,6 +363,7 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
     /**
      * @param cache Cache.
      * @param key Key.
+     * @return Removed value.
      */
     private <K, V> V removeAsync(IgniteCache<K, V> cache, K key) {
         IgniteCache<K, V> cacheAsync = cache.withAsync();
@@ -371,6 +376,8 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
     /**
      * @param cache Cache.
      * @param key Key.
+     * @param val Value.
+     * @return Remove result.
      */
     private <K, V> boolean removeAsync(IgniteCache<K, V> cache, K key, V val) {
         IgniteCache<K, V> cacheAsync = cache.withAsync();

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 0d9c541..1e0071e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -4337,7 +4337,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
                 log.info("Set iterators not cleared, will wait");
 
-                Thread.sleep(500);
+                Thread.sleep(1000);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java
index a34857f..e70c97b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java
@@ -299,7 +299,7 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest {
 
                         return null;
                     }
-                }));
+                }, "cache-thread"));
             }
 
             readyLatch.await();

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
index 8a5dfd4..c9cd750 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
@@ -158,7 +158,12 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
 
                 ccfg.setName(DYNAMIC_CACHE_NAME);
 
-                futs.add(kernal.context().cache().dynamicStartCache(ccfg, ccfg.getName(), null, true, true));
+                futs.add(kernal.context().cache().dynamicStartCache(ccfg,
+                    ccfg.getName(),
+                    null,
+                    true,
+                    true,
+                    true));
 
                 return null;
             }
@@ -190,7 +195,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
 
         GridTestUtils.runMultiThreaded(new Callable<Object>() {
             @Override public Object call() throws Exception {
-                futs.add(kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME));
+                futs.add(kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, true));
 
                 return null;
             }
@@ -218,7 +223,12 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
 
                 IgniteEx kernal = grid(ThreadLocalRandom.current().nextInt(nodeCount()));
 
-                futs.add(kernal.context().cache().dynamicStartCache(ccfg, ccfg.getName(), null, true, true));
+                futs.add(kernal.context().cache().dynamicStartCache(ccfg,
+                    ccfg.getName(),
+                    null,
+                    true,
+                    true,
+                    true));
 
                 return null;
             }
@@ -252,7 +262,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
             @Override public Object call() throws Exception {
                 IgniteEx kernal = grid(ThreadLocalRandom.current().nextInt(nodeCount()));
 
-                futs.add(kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME));
+                futs.add(kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, true));
 
                 return null;
             }
@@ -315,7 +325,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
         for (int g = 0; g < nodeCount(); g++)
             caches[g] = grid(g).cache(DYNAMIC_CACHE_NAME);
 
-        kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME).get();
+        kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, true).get();
 
         for (int g = 0; g < nodeCount(); g++) {
             final IgniteKernal kernal0 = (IgniteKernal) grid(g);
@@ -368,7 +378,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
             }
 
             // Undeploy cache.
-            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME).get();
+            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, true).get();
 
             startGrid(nodeCount() + 1);
 
@@ -445,7 +455,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
                     }, IllegalArgumentException.class, null);
             }
 
-            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME).get();
+            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, true).get();
 
             stopGrid(nodeCount() + 1);
             stopGrid(nodeCount());
@@ -512,7 +522,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
             for (int g = 0; g < nodeCount() + 1; g++)
                 assertEquals("1", ignite(g).cache(DYNAMIC_CACHE_NAME).get("1"));
 
-            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME).get();
+            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, true).get();
         }
         finally {
             stopGrid(nodeCount());
@@ -554,7 +564,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
             for (int g = 0; g < nodeCount() + 1; g++)
                 assertEquals("1", ignite(g).cache(DYNAMIC_CACHE_NAME).get("1"));
 
-            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME).get();
+            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, true).get();
         }
         finally {
             stopGrid(nodeCount());
@@ -600,7 +610,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
             for (int g = 0; g < nodeCount() + 1; g++)
                 assertEquals("1", ignite(g).cache(DYNAMIC_CACHE_NAME).get("1"));
 
-            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME).get();
+            kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, true).get();
         }
         finally {
             stopGrid(nodeCount());

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
index bf6dcda..34e7080 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java
@@ -30,6 +30,7 @@ import org.apache.ignite.configuration.CollectionConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.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;
@@ -59,6 +60,8 @@ public abstract class IgniteClientDataStructuresAbstractTest extends GridCommonA
 
         ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
 
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
         return cfg;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
index 84838db..a08d080 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -188,6 +188,9 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @param conc Transaction concurrency.
+     * @param backup Check backup flag.
+     * @param commit Check commit flag.
      * @throws Exception If failed.
      */
     private void checkPrimaryNodeFailureBackupCommit(
@@ -197,6 +200,7 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
     ) throws Exception {
         try {
             startGrids(gridCount());
+
             awaitPartitionMapExchange();
 
             for (int i = 0; i < gridCount(); i++)
@@ -290,7 +294,7 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
 
                     return null;
                 }
-            });
+            }, "tx-thread");
 
             commitLatch.await();
 
@@ -366,6 +370,7 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
 
     /**
      * @param ignite Ignite instance to generate key.
+     * @param backup Backup key flag.
      * @return Generated key that is not primary nor backup for {@code ignite(0)} and primary for
      *      {@code ignite(1)}.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCommitDelayTxRecoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCommitDelayTxRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCommitDelayTxRecoveryTest.java
new file mode 100644
index 0000000..c47401c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCommitDelayTxRecoveryTest.java
@@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.dht;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+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.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 static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ *
+ */
+public class IgniteCacheCommitDelayTxRecoveryTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final int SRVS = 4;
+
+    /** */
+    private static volatile boolean commit;
+
+    /** */
+    private static volatile CountDownLatch commitStartedLatch;
+
+    /** */
+    private static volatile CountDownLatch commitFinishLatch;
+
+    /** */
+    private boolean client;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+
+        super.afterTestsStopped();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        super.afterTest();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRecovery1() throws Exception {
+        checkRecovery(1, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRecovery2() throws Exception {
+        checkRecovery(2, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRecoveryStoreEnabled1() throws Exception {
+        checkRecovery(1, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRecoveryStoreEnabled2() throws Exception {
+        checkRecovery(2, true);
+    }
+
+    /**
+     * @param backups Number of cache backups.
+     * @param useStore If {@code true} tests cache with store configured.
+     * @throws Exception If failed.
+     */
+    private void checkRecovery(int backups, boolean useStore) throws Exception {
+        startGridsMultiThreaded(SRVS, false);
+
+        client = true;
+
+        Ignite clientNode = startGrid(SRVS);
+
+        assertTrue(clientNode.configuration().isClientMode());
+
+        client = false;
+
+        clientNode.createCache(cacheConfiguration(backups, useStore));
+
+        awaitPartitionMapExchange();
+
+        Ignite srv = ignite(0);
+
+        assertFalse(srv.configuration().isClientMode());
+
+        for (Boolean pessimistic : Arrays.asList(false, true)) {
+            checkRecovery(backupKey(srv.cache(null)), srv, pessimistic, useStore);
+
+            checkRecovery(nearKey(srv.cache(null)), srv, pessimistic, useStore);
+
+            checkRecovery(nearKey(clientNode.cache(null)), clientNode, pessimistic, useStore);
+
+            srv = ignite(0);
+
+            assertFalse(srv.configuration().isClientMode());
+        }
+    }
+
+    /**
+     * @param key Key.
+     * @param ignite Node executing update.
+     * @param pessimistic If {@code true} uses pessimistic transaction.
+     * @param useStore {@code True} if store is used.
+     * @throws Exception If failed.
+     */
+    private void checkRecovery(final Integer key,
+        final Ignite ignite,
+        final boolean pessimistic,
+        final boolean useStore) throws Exception {
+        Ignite primary = primaryNode(key, null);
+
+        assertNotSame(ignite, primary);
+
+        List<Ignite> backups = backupNodes(key, null);
+
+        assertFalse(backups.isEmpty());
+
+        final Set<String> backupNames = new HashSet<>();
+
+        for (Ignite node : backups)
+            backupNames.add(node.name());
+
+        log.info("Check recovery [key=" + key +
+            ", pessimistic=" + pessimistic +
+            ", primary=" + primary.name() +
+            ", backups=" + backupNames +
+            ", node=" + ignite.name() + ']');
+
+        final IgniteCache<Integer, Integer> cache = ignite.cache(null);
+
+        cache.put(key, 0);
+
+        commitStartedLatch = new CountDownLatch(backupNames.size());
+        commitFinishLatch = new CountDownLatch(1);
+
+        commit = false;
+
+        TestEntryProcessor.skipFirst = useStore ? ignite.name() : null;
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                log.info("Start update.");
+
+                if (pessimistic) {
+                    try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+                        cache.invoke(key, new TestEntryProcessor(backupNames));
+
+                        commit = true;
+
+                        log.info("Start commit.");
+
+                        assertEquals(backupNames.size(), commitStartedLatch.getCount());
+
+                        tx.commit();
+                    }
+                }
+                else {
+                    commit = true;
+
+                    cache.invoke(key, new TestEntryProcessor(backupNames));
+                }
+
+                log.info("End update, execute get.");
+
+                Integer val = cache.get(key);
+
+                log.info("Get value: " + val);
+
+                assertEquals(1, (Object)val);
+
+                return null;
+            }
+        }, "update-thread");
+
+        assertTrue(commitStartedLatch.await(30, SECONDS));
+
+        log.info("Stop node: " + primary.name());
+
+        primary.close();
+
+        commitFinishLatch.countDown();
+
+        fut.get();
+
+        for (Ignite node : G.allGrids())
+            assertEquals(1, node.cache(null).get(key));
+
+        cache.put(key, 2);
+
+        for (Ignite node : G.allGrids())
+            assertEquals(2, node.cache(null).get(key));
+
+        startGrid(primary.name());
+
+        for (Ignite node : G.allGrids())
+            assertEquals(2, node.cache(null).get(key));
+
+        cache.put(key, 3);
+
+        for (Ignite node : G.allGrids())
+            assertEquals(3, node.cache(null).get(key));
+
+        awaitPartitionMapExchange();
+    }
+
+    /**
+     *
+     */
+    static class TestEntryProcessor implements CacheEntryProcessor<Integer, Integer, Void> {
+        /** */
+        private Set<String> nodeNames;
+
+        /** Skips first call for given node (used to skip call for store update). */
+        private static String skipFirst;
+
+        /**
+         * @param nodeNames Node names where sleep will be called.
+         */
+        public TestEntryProcessor(Set<String> nodeNames) {
+            this.nodeNames = nodeNames;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void process(MutableEntry<Integer, Integer> entry, Object... args) {
+            Ignite ignite = entry.unwrap(Ignite.class);
+
+            System.out.println(Thread.currentThread().getName() + " process [node=" + ignite.name() +
+                ", commit=" + commit + ", skipFirst=" + skipFirst + ']');
+
+            boolean skip = false;
+
+            if (commit && ignite.name().equals(skipFirst)) {
+                skipFirst = null;
+
+                skip = true;
+            }
+
+            if (!skip && commit && nodeNames.contains(ignite.name())) {
+                try {
+                    System.out.println(Thread.currentThread().getName() + " start process invoke.");
+
+                    assertTrue(commitStartedLatch != null && commitStartedLatch.getCount() > 0);
+
+                    commitStartedLatch.countDown();
+
+                    assertTrue(commitFinishLatch.await(10, SECONDS));
+
+                    System.out.println(Thread.currentThread().getName() + " end process invoke.");
+                }
+                catch (InterruptedException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+            else
+                System.out.println(Thread.currentThread().getName() + " invoke set value.");
+
+            entry.setValue(1);
+
+            return null;
+        }
+    }
+
+    /**
+     * @param backups Number of backups.
+     * @param useStore If {@code true} adds cache store.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration<Object, Object> cacheConfiguration(int backups, boolean useStore) {
+        CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
+
+        ccfg.setAtomicityMode(TRANSACTIONAL);
+        ccfg.setBackups(backups);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg.setRebalanceMode(SYNC);
+
+        if (useStore) {
+            ccfg.setCacheStoreFactory(new TestStoreFactory());
+
+            ccfg.setWriteThrough(true);
+        }
+
+        return ccfg;
+    }
+
+    /**
+     *
+     */
+    private static class TestStoreFactory implements Factory<CacheStore<Object, Object>> {
+        /** {@inheritDoc} */
+        @Override public CacheStore<Object, Object> create() {
+            return new CacheStoreAdapter<Object, Object>() {
+                @Override public Object load(Object key) throws CacheLoaderException {
+                    return null;
+                }
+
+                @Override public void write(Cache.Entry entry) throws CacheWriterException {
+                    // No-op.
+                }
+
+                @Override public void delete(Object key) throws CacheWriterException {
+                    // No-op.
+                }
+            };
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
index 4eb8a6b..7532354 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
@@ -30,6 +30,8 @@ import javax.cache.integration.CacheLoaderException;
 import javax.cache.integration.CacheWriterException;
 import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
+
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
 import org.apache.ignite.cache.CacheAtomicityMode;
@@ -238,7 +240,7 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
      * @param store If {@code true} uses cache with store.
      * @throws Exception If failed.
      */
-    private void checkRetry(Test test, TestMemoryMode memMode, boolean store) throws Exception {
+    protected final void checkRetry(Test test, TestMemoryMode memMode, boolean store) throws Exception {
         ignite(0).createCache(cacheConfiguration(memMode, store));
 
         final AtomicBoolean finished = new AtomicBoolean();
@@ -259,7 +261,7 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
             }
         });
 
-        IgniteCache<Integer, Integer> cache = ignite(0).cache(null);
+        final IgniteCache<Integer, Integer> cache = ignite(0).cache(null);
 
         int iter = 0;
 
@@ -309,6 +311,31 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
                     break;
                 }
 
+                case TX_PUT: {
+                    while (System.currentTimeMillis() < stopTime) {
+                        final Integer val = ++iter;
+
+                        Ignite ignite = ignite(0);
+
+                        for (int i = 0; i < keysCnt; i++) {
+                            final Integer key = i;
+
+                            doInTransaction(ignite, new Callable<Void>() {
+                                @Override public Void call() throws Exception {
+                                    cache.put(key, val);
+
+                                    return null;
+                                }
+                            });
+                        }
+
+                        for (int i = 0; i < keysCnt; i++)
+                            assertEquals(val, cache.get(i));
+                    }
+
+                    break;
+                }
+
                 case PUT_ALL: {
                     while (System.currentTimeMillis() < stopTime) {
                         Integer val = ++iter;
@@ -541,7 +568,10 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
         INVOKE,
 
         /** */
-        INVOKE_ALL
+        INVOKE_ALL,
+
+        /** */
+        TX_PUT
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
index 7655464..9204bc8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
@@ -101,6 +101,20 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr
     /**
      * @throws Exception If failed.
      */
+    public void testExplicitTransactionRetriesSingleValue() throws Exception {
+        checkRetry(Test.TX_PUT, TestMemoryMode.HEAP, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testExplicitTransactionRetriesSingleValueStoreEnabled() throws Exception {
+        checkRetry(Test.TX_PUT, TestMemoryMode.HEAP, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testExplicitTransactionRetries() throws Exception {
         explicitTransactionRetries(TestMemoryMode.HEAP, false);
     }
@@ -108,6 +122,13 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr
     /**
      * @throws Exception If failed.
      */
+    public void testExplicitTransactionRetriesSingleOperation() throws Exception {
+        explicitTransactionRetries(TestMemoryMode.HEAP, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testExplicitTransactionRetriesStoreEnabled() throws Exception {
         explicitTransactionRetries(TestMemoryMode.HEAP, true);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
index d239ea8..91eecbb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
@@ -48,6 +48,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.resources.IgniteInstanceResource;
+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;
@@ -104,6 +105,8 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
 
         cfg.setDiscoverySpi(disc);
 
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
         if (include)
             cfg.setUserAttributes(F.asMap("include", true));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java
index 6089795..552dd28 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java
@@ -569,9 +569,9 @@ public class GridNioSelfTest extends GridCommonAbstractTest {
         GridNioServerListener lsnr,
         @Nullable Integer queueLimit) throws Exception {
         for (int i = 0; i < 10; i++) {
-            try {
-                int srvPort = port++;
+            int srvPort = port++;
 
+            try {
                 GridNioServer.Builder<?> builder = serverBuilder(srvPort, parser, lsnr);
 
                 if (queueLimit != null)
@@ -584,8 +584,11 @@ public class GridNioSelfTest extends GridCommonAbstractTest {
                 return srvr;
             }
             catch (IgniteCheckedException e) {
-                if (i < 9 && e.hasCause(BindException.class))
-                    log.error("Failed to start server, will try another port: " + e);
+                if (i < 9 && e.hasCause(BindException.class)) {
+                    log.error("Failed to start server, will try another port [err=" + e + ", port=" + srvPort + ']');
+
+                    U.sleep(5000);
+                }
                 else
                     throw e;
             }


[15/29] ignite git commit: Fixes: - allow 'committing' -> 'marked_rollback' tx state change only for thread committing transaction - fixed 'full_sync' mode for case when tx primary nodes fail - fixed race between statically configured cache start and

Posted by vo...@apache.org.
Fixes:
 - allow 'committing' -> 'marked_rollback' tx state change only for thread committing transaction
 - fixed 'full_sync' mode for case when tx primary nodes fail
 - fixed race between statically configured cache start and GridDhtAffinityAssignmentRequest
 - fixed 'prepareMarshal' methods to marshal only once (ignite-2219)


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

Branch: refs/heads/ignite-2236
Commit: 457a9ae4d3b0d6eef6e92a15f5ef79c15ccf1f95
Parents: 1d8c4e2
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jan 13 09:21:09 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jan 13 09:29:17 2016 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteTransactions.java   |   4 +-
 .../apache/ignite/internal/IgniteKernal.java    |  95 +++-
 .../cache/CacheEntrySerializablePredicate.java  |   3 +-
 .../cache/CacheInvokeDirectResult.java          |   4 +-
 .../processors/cache/GridCacheIoManager.java    |  23 +
 .../processors/cache/GridCacheProcessor.java    |  52 ++-
 .../processors/cache/GridCacheReturn.java       |   2 +
 .../processors/cache/IgniteCacheProxy.java      |   2 +-
 .../GridDistributedLockResponse.java            |   2 +-
 .../GridDistributedTxFinishRequest.java         |  11 +-
 .../GridDistributedTxPrepareRequest.java        |   2 +-
 .../GridDistributedTxPrepareResponse.java       |   4 +-
 .../dht/GridDhtAffinityAssignmentResponse.java  |   4 +-
 .../distributed/dht/GridDhtLockFuture.java      |  44 +-
 .../distributed/dht/GridDhtLockRequest.java     |   2 +-
 .../distributed/dht/GridDhtTxFinishRequest.java |  90 ++--
 .../dht/GridDhtTxFinishResponse.java            |   4 +-
 .../cache/distributed/dht/GridDhtTxLocal.java   |   1 +
 .../dht/GridDhtTxPrepareRequest.java            |   2 +-
 .../dht/atomic/GridDhtAtomicUpdateRequest.java  |  21 +-
 .../dht/atomic/GridDhtAtomicUpdateResponse.java |   6 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java |  22 +-
 .../atomic/GridNearAtomicUpdateResponse.java    |   4 +-
 .../dht/preloader/GridDhtForceKeysResponse.java |   6 +-
 .../GridDhtPartitionDemandMessage.java          |   6 +-
 .../GridDhtPartitionSupplyMessageV2.java        |   6 +-
 .../preloader/GridDhtPartitionsFullMessage.java |   2 +-
 .../GridDhtPartitionsSingleMessage.java         |   4 +-
 .../distributed/near/GridNearGetResponse.java   |   4 +-
 ...ridNearOptimisticTxPrepareFutureAdapter.java |   6 +-
 .../near/GridNearSingleGetResponse.java         |   2 +-
 .../near/GridNearTxFinishFuture.java            | 432 ++++++++++++++-----
 .../near/GridNearTxFinishRequest.java           |   5 +
 .../near/GridNearTxFinishResponse.java          |   4 +-
 .../cache/distributed/near/GridNearTxLocal.java |   2 +-
 .../near/GridNearTxPrepareResponse.java         |   4 +-
 .../cache/query/GridCacheQueryRequest.java      |  16 +-
 .../cache/query/GridCacheQueryResponse.java     |  18 +-
 .../cache/transactions/IgniteInternalTx.java    |   6 +
 .../cache/transactions/IgniteTxAdapter.java     |  23 +-
 .../cache/transactions/IgniteTxEntry.java       |  11 +-
 .../cache/transactions/IgniteTxHandler.java     |  26 +-
 .../transactions/IgniteTxLocalAdapter.java      |   6 +-
 .../cache/transactions/IgniteTxManager.java     |  20 +
 .../datastreamer/DataStreamerRequest.java       |   1 +
 .../datastructures/DataStructuresProcessor.java |  11 +-
 .../processors/igfs/IgfsAckMessage.java         |   4 +-
 .../handlers/cache/GridCacheCommandHandler.java |   6 +-
 .../ignite/spi/discovery/DiscoverySpi.java      |   2 +
 .../ignite/stream/socket/SocketStreamer.java    |   3 +-
 ...cheAbstractFullApiMultithreadedSelfTest.java |  13 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java |   2 +-
 .../processors/cache/GridCacheStopSelfTest.java |   2 +-
 .../cache/IgniteDynamicCacheStartSelfTest.java  |  30 +-
 .../IgniteClientDataStructuresAbstractTest.java |   3 +
 .../dht/GridCacheTxNodeFailureSelfTest.java     |   7 +-
 .../IgniteCacheCommitDelayTxRecoveryTest.java   | 376 ++++++++++++++++
 .../IgniteCachePutRetryAbstractSelfTest.java    |  36 +-
 ...gniteCachePutRetryTransactionalSelfTest.java |  21 +
 .../continuous/GridEventConsumeSelfTest.java    |   3 +
 .../internal/util/nio/GridNioSelfTest.java      |  11 +-
 ...dTcpCommunicationSpiRecoveryAckSelfTest.java |   1 -
 ...CommunicationRecoveryAckClosureSelfTest.java |  19 +-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java |   2 +
 .../junits/common/GridCommonAbstractTest.java   |  34 +-
 .../IgniteCacheTxRecoverySelfTestSuite.java     |   3 +
 .../tcp/ipfinder/zk/ZookeeperIpFinderTest.java  |  69 ++-
 67 files changed, 1314 insertions(+), 358 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java b/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
index 875b647..dfe6a1a 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
@@ -18,7 +18,7 @@
 package org.apache.ignite;
 
 import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.TransactionConfiguration;
 import org.apache.ignite.transactions.Transaction;
 import org.apache.ignite.transactions.TransactionConcurrency;
 import org.apache.ignite.transactions.TransactionIsolation;
@@ -54,7 +54,7 @@ import org.apache.ignite.transactions.TransactionMetrics;
 public interface IgniteTransactions {
     /**
      * Starts transaction with default isolation, concurrency, timeout, and invalidation policy.
-     * All defaults are set in {@link CacheConfiguration} at startup.
+     * All defaults are set in {@link TransactionConfiguration} at startup.
      *
      * @return New transaction
      * @throws IllegalStateException If transaction is already started by this thread.

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 14b5816..3def718 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
@@ -1424,8 +1424,11 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     }
 
     /** @throws IgniteCheckedException If registration failed. */
-    private void registerExecutorMBeans(ExecutorService execSvc, ExecutorService sysExecSvc, ExecutorService p2pExecSvc,
-        ExecutorService mgmtExecSvc, ExecutorService restExecSvc) throws IgniteCheckedException {
+    private void registerExecutorMBeans(ExecutorService execSvc,
+        ExecutorService sysExecSvc,
+        ExecutorService p2pExecSvc,
+        ExecutorService mgmtExecSvc,
+        ExecutorService restExecSvc) throws IgniteCheckedException {
         pubExecSvcMBean = registerExecutorMBean(execSvc, "GridExecutionExecutor");
         sysExecSvcMBean = registerExecutorMBean(sysExecSvc, "GridSystemExecutor");
         mgmtExecSvcMBean = registerExecutorMBean(mgmtExecSvc, "GridManagementExecutor");
@@ -2414,7 +2417,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         guard();
 
         try {
-            return ctx.cache().publicJCache(name, false);
+            return ctx.cache().publicJCache(name, false, true);
         }
         catch (IgniteCheckedException e) {
             throw CU.convertToCacheException(e);
@@ -2431,7 +2434,12 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         guard();
 
         try {
-            ctx.cache().dynamicStartCache(cacheCfg, cacheCfg.getName(), null, true, true).get();
+            ctx.cache().dynamicStartCache(cacheCfg,
+                cacheCfg.getName(),
+                null,
+                true,
+                true,
+                true).get();
 
             return ctx.cache().publicJCache(cacheCfg.getName());
         }
@@ -2467,8 +2475,14 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         guard();
 
         try {
-            if (ctx.cache().cache(cacheCfg.getName()) == null)
-                ctx.cache().dynamicStartCache(cacheCfg, cacheCfg.getName(), null, false, true).get();
+            if (ctx.cache().cache(cacheCfg.getName()) == null) {
+                ctx.cache().dynamicStartCache(cacheCfg,
+                    cacheCfg.getName(),
+                    null,
+                    false,
+                    true,
+                    true).get();
+            }
 
             return ctx.cache().publicJCache(cacheCfg.getName());
         }
@@ -2491,7 +2505,12 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         guard();
 
         try {
-            ctx.cache().dynamicStartCache(cacheCfg, cacheCfg.getName(), nearCfg, true, true).get();
+            ctx.cache().dynamicStartCache(cacheCfg,
+                cacheCfg.getName(),
+                nearCfg,
+                true,
+                true,
+                true).get();
 
             return ctx.cache().publicJCache(cacheCfg.getName());
         }
@@ -2514,11 +2533,23 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         try {
             IgniteInternalCache<Object, Object> cache = ctx.cache().cache(cacheCfg.getName());
 
-            if (cache == null)
-                ctx.cache().dynamicStartCache(cacheCfg, cacheCfg.getName(), nearCfg, false, true).get();
+            if (cache == null) {
+                ctx.cache().dynamicStartCache(cacheCfg,
+                    cacheCfg.getName(),
+                    nearCfg,
+                    false,
+                    true,
+                    true).get();
+            }
             else {
-                if (cache.configuration().getNearConfiguration() == null)
-                    ctx.cache().dynamicStartCache(cacheCfg, cacheCfg.getName(), nearCfg, false, true).get();
+                if (cache.configuration().getNearConfiguration() == null) {
+                    ctx.cache().dynamicStartCache(cacheCfg,
+                        cacheCfg.getName(),
+                        nearCfg,
+                        false,
+                        true,
+                        true).get();
+                }
             }
 
             return ctx.cache().publicJCache(cacheCfg.getName());
@@ -2538,7 +2569,12 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         guard();
 
         try {
-            ctx.cache().dynamicStartCache(null, cacheName, nearCfg, true, true).get();
+            ctx.cache().dynamicStartCache(null,
+                cacheName,
+                nearCfg,
+                true,
+                true,
+                true).get();
 
             IgniteCacheProxy<K, V> cache = ctx.cache().publicJCache(cacheName);
 
@@ -2564,11 +2600,23 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         try {
             IgniteInternalCache<Object, Object> internalCache = ctx.cache().cache(cacheName);
 
-            if (internalCache == null)
-                ctx.cache().dynamicStartCache(null, cacheName, nearCfg, false, true).get();
+            if (internalCache == null) {
+                ctx.cache().dynamicStartCache(null,
+                    cacheName,
+                    nearCfg,
+                    false,
+                    true,
+                    true).get();
+            }
             else {
-                if (internalCache.configuration().getNearConfiguration() == null)
-                    ctx.cache().dynamicStartCache(null, cacheName, nearCfg, false, true).get();
+                if (internalCache.configuration().getNearConfiguration() == null) {
+                    ctx.cache().dynamicStartCache(null,
+                        cacheName,
+                        nearCfg,
+                        false,
+                        true,
+                        true).get();
+                }
             }
 
             IgniteCacheProxy<K, V> cache = ctx.cache().publicJCache(cacheName);
@@ -2587,6 +2635,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
     /**
      * @param cache Cache.
+     * @throws IgniteCheckedException If cache without near cache was already started.
      */
     private void checkNearCacheStarted(IgniteCacheProxy<?, ?> cache) throws IgniteCheckedException {
         if (!cache.context().isNear())
@@ -2596,7 +2645,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
     /** {@inheritDoc} */
     @Override public void destroyCache(String cacheName) {
-        IgniteInternalFuture stopFut = destroyCacheAsync(cacheName);
+        IgniteInternalFuture stopFut = destroyCacheAsync(cacheName, true);
 
         try {
             stopFut.get();
@@ -2608,13 +2657,14 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
     /**
      * @param cacheName Cache name.
+     * @param checkThreadTx If {@code true} checks that current thread does not have active transactions.
      * @return Ignite future.
      */
-    public IgniteInternalFuture<?> destroyCacheAsync(String cacheName) {
+    public IgniteInternalFuture<?> destroyCacheAsync(String cacheName, boolean checkThreadTx) {
         guard();
 
         try {
-            return ctx.cache().dynamicDestroyCache(cacheName);
+            return ctx.cache().dynamicDestroyCache(cacheName, checkThreadTx);
         }
         finally {
             unguard();
@@ -2627,7 +2677,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
         try {
             if (ctx.cache().cache(cacheName) == null)
-                ctx.cache().getOrCreateFromTemplate(cacheName).get();
+                ctx.cache().getOrCreateFromTemplate(cacheName, true).get();
 
             return ctx.cache().publicJCache(cacheName);
         }
@@ -2641,14 +2691,15 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
 
     /**
      * @param cacheName Cache name.
+     * @param checkThreadTx If {@code true} checks that current thread does not have active transactions.
      * @return Future that will be completed when cache is deployed.
      */
-    public IgniteInternalFuture<?> getOrCreateCacheAsync(String cacheName) {
+    public IgniteInternalFuture<?> getOrCreateCacheAsync(String cacheName, boolean checkThreadTx) {
         guard();
 
         try {
             if (ctx.cache().cache(cacheName) == null)
-                return ctx.cache().getOrCreateFromTemplate(cacheName);
+                return ctx.cache().getOrCreateFromTemplate(cacheName, checkThreadTx);
 
             return new GridFinishedFuture<>();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 a243c4e..20cc005 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
@@ -86,7 +86,8 @@ public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
 
         p.prepareMarshal(ctx);
 
-        bytes = ctx.marshaller().marshal(p);
+        if (bytes == null)
+            bytes = ctx.marshaller().marshal(p);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 bee1427..fefa422 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
@@ -104,7 +104,7 @@ public class CacheInvokeDirectResult implements Message {
     public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException {
         key.prepareMarshal(ctx.cacheObjectContext());
 
-        if (err != null)
+        if (err != null && errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
 
         if (res != null)
@@ -119,7 +119,7 @@ public class CacheInvokeDirectResult implements Message {
     public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         key.finishUnmarshal(ctx.cacheObjectContext(), ldr);
 
-        if (errBytes != null)
+        if (errBytes != null && err == null)
             err = ctx.marshaller().unmarshal(errBytes, ldr);
 
         if (res != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 0aa8b1b..b297827 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.managers.communication.GridMessageListener;
 import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.distributed.dht.CacheGetFuture;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentRequest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockRequest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockResponse;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest;
@@ -122,6 +123,28 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
             IgniteInternalFuture<?> fut = null;
 
             if (cacheMsg.partitionExchangeMessage()) {
+                if (cacheMsg instanceof GridDhtAffinityAssignmentRequest) {
+                    assert cacheMsg.topologyVersion() != null : cacheMsg;
+
+                    AffinityTopologyVersion startTopVer = new AffinityTopologyVersion(cctx.localNode().order());
+
+                    assert cacheMsg.topologyVersion().compareTo(startTopVer) > 0 :
+                        "Invalid affinity request [startTopVer=" + startTopVer + ", msg=" + cacheMsg + ']';
+
+                    // Need to wait for initial exchange to avoid race between cache start and affinity request.
+                    fut = cctx.exchange().affinityReadyFuture(startTopVer);
+
+                    if (fut != null && !fut.isDone()) {
+                        cctx.kernalContext().closure().runLocalSafe(new Runnable() {
+                            @Override public void run() {
+                                lsnr.onMessage(nodeId, cacheMsg);
+                            }
+                        });
+
+                        return;
+                    }
+                }
+
                 long locTopVer = cctx.discovery().topologyVersion();
                 long rmtTopVer = cacheMsg.topologyVersion().topologyVersion();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 ff02e70..eb6d98e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -2030,7 +2030,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         try {
             CacheConfiguration cfg = createConfigFromTemplate(cacheName);
 
-            return dynamicStartCache(cfg, cacheName, null, true, true);
+            return dynamicStartCache(cfg, cacheName, null, true, true, true);
         }
         catch (IgniteCheckedException e) {
             throw U.convertException(e);
@@ -2041,16 +2041,17 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * Dynamically starts cache using template configuration.
      *
      * @param cacheName Cache name.
+     * @param checkThreadTx If {@code true} checks that current thread does not have active transactions.
      * @return Future that will be completed when cache is deployed.
      */
-    public IgniteInternalFuture<?> getOrCreateFromTemplate(String cacheName) {
+    public IgniteInternalFuture<?> getOrCreateFromTemplate(String cacheName, boolean checkThreadTx) {
         try {
-            if (publicJCache(cacheName, false) != null) // Cache with given name already started.
+            if (publicJCache(cacheName, false, checkThreadTx) != null) // Cache with given name already started.
                 return new GridFinishedFuture<>();
 
             CacheConfiguration cfg = createConfigFromTemplate(cacheName);
 
-            return dynamicStartCache(cfg, cacheName, null, false, true);
+            return dynamicStartCache(cfg, cacheName, null, false, true, checkThreadTx);
         }
         catch (IgniteCheckedException e) {
             return new GridFinishedFuture<>(e);
@@ -2060,6 +2061,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     /**
      * @param cacheName Cache name.
      * @return Cache configuration.
+     * @throws IgniteCheckedException If failed.
      */
     private CacheConfiguration createConfigFromTemplate(String cacheName) throws IgniteCheckedException {
         CacheConfiguration cfgTemplate = null;
@@ -2138,6 +2140,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @param cacheName Cache name.
      * @param nearCfg Near cache configuration.
      * @param failIfExists Fail if exists flag.
+     * @param failIfNotStarted If {@code true} fails if cache is not started.
+     * @param checkThreadTx If {@code true} checks that current thread does not have active transactions.
      * @return Future that will be completed when cache is deployed.
      */
     @SuppressWarnings("IfMayBeConditional")
@@ -2146,9 +2150,16 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         String cacheName,
         @Nullable NearCacheConfiguration nearCfg,
         boolean failIfExists,
-        boolean failIfNotStarted
+        boolean failIfNotStarted,
+        boolean checkThreadTx
     ) {
-        return dynamicStartCache(ccfg, cacheName, nearCfg, CacheType.USER, failIfExists, failIfNotStarted);
+        return dynamicStartCache(ccfg,
+            cacheName,
+            nearCfg,
+            CacheType.USER,
+            failIfExists,
+            failIfNotStarted,
+            checkThreadTx);
     }
 
     /**
@@ -2157,7 +2168,10 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @param ccfg Cache configuration.
      * @param cacheName Cache name.
      * @param nearCfg Near cache configuration.
+     * @param cacheType Cache type.
      * @param failIfExists Fail if exists flag.
+     * @param failIfNotStarted If {@code true} fails if cache is not started.
+     * @param checkThreadTx If {@code true} checks that current thread does not have active transactions.
      * @return Future that will be completed when cache is deployed.
      */
     @SuppressWarnings("IfMayBeConditional")
@@ -2167,9 +2181,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         @Nullable NearCacheConfiguration nearCfg,
         CacheType cacheType,
         boolean failIfExists,
-        boolean failIfNotStarted
+        boolean failIfNotStarted,
+        boolean checkThreadTx
     ) {
-        checkEmptyTransactions();
+        if (checkThreadTx)
+            checkEmptyTransactions();
 
         DynamicCacheDescriptor desc = registeredCaches.get(maskNull(cacheName));
 
@@ -2260,10 +2276,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
     /**
      * @param cacheName Cache name to destroy.
+     * @param checkThreadTx If {@code true} checks that current thread does not have active transactions.
      * @return Future that will be completed when cache is destroyed.
      */
-    public IgniteInternalFuture<?> dynamicDestroyCache(String cacheName) {
-        checkEmptyTransactions();
+    public IgniteInternalFuture<?> dynamicDestroyCache(String cacheName, boolean checkThreadTx) {
+        if (checkThreadTx)
+            checkEmptyTransactions();
 
         DynamicCacheChangeRequest t = new DynamicCacheChangeRequest(cacheName, ctx.localNodeId());
 
@@ -2898,7 +2916,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         IgniteCacheProxy<?, ?> cache = jCacheProxies.get(masked);
 
         if (cache == null) {
-            dynamicStartCache(null, name, null, false, true).get();
+            dynamicStartCache(null, name, null, false, true, true).get();
 
             cache = jCacheProxies.get(masked);
         }
@@ -3001,21 +3019,21 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException If failed.
      */
     public <K, V> IgniteCacheProxy<K, V> publicJCache(@Nullable String cacheName) throws IgniteCheckedException {
-        return publicJCache(cacheName, true);
+        return publicJCache(cacheName, true, true);
     }
 
     /**
      * @param cacheName Cache name.
      * @param failIfNotStarted If {@code true} throws {@link IllegalArgumentException} if cache is not started,
      *        otherwise returns {@code null} in this case.
-     * @param <K> type of keys.
-     * @param <V> type of values.
+     * @param checkThreadTx If {@code true} checks that current thread does not have active transactions.
      * @return Cache instance for given name.
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings({"unchecked", "ConstantConditions"})
-    @Nullable public <K, V> IgniteCacheProxy<K, V> publicJCache(@Nullable String cacheName, boolean failIfNotStarted)
-        throws IgniteCheckedException
+    @Nullable public <K, V> IgniteCacheProxy<K, V> publicJCache(@Nullable String cacheName,
+        boolean failIfNotStarted,
+        boolean checkThreadTx) throws IgniteCheckedException
     {
         if (log.isDebugEnabled())
             log.debug("Getting public cache for name: " + cacheName);
@@ -3030,7 +3048,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             throw new IllegalStateException("Failed to get cache because it is a system cache: " + cacheName);
 
         if (cache == null) {
-            dynamicStartCache(null, cacheName, null, false, failIfNotStarted).get();
+            dynamicStartCache(null, cacheName, null, false, failIfNotStarted, checkThreadTx).get();
 
             cache = jCacheProxies.get(masked);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
index 21154c9..a9edb95 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
@@ -169,6 +169,7 @@ public class GridCacheReturn implements Externalizable, Message {
      * @param cctx Cache context.
      * @param cacheObj Value to set.
      * @param success Success flag to set.
+     * @param keepBinary Keep binary flag.
      * @return This instance for chaining.
      */
     public GridCacheReturn set(
@@ -187,6 +188,7 @@ public class GridCacheReturn implements Externalizable, Message {
     /**
      * @param cctx Cache context.
      * @param cacheObj Cache object.
+     * @param keepBinary Keep binary flag.
      */
     private void initValue(GridCacheContext cctx, @Nullable CacheObject cacheObj, boolean keepBinary) {
         if (loc)

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 27a7587..b64c69c 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
@@ -1626,7 +1626,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
         IgniteInternalFuture<?> fut;
 
         try {
-            fut = ctx.kernalContext().cache().dynamicDestroyCache(ctx.name());
+            fut = ctx.kernalContext().cache().dynamicDestroyCache(ctx.name(), true);
         }
         finally {
             onLeave(gate);

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 bb3f9ff..f088e1e 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)
+        if (err != null && errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
index 34b3112..a761fec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
@@ -20,8 +20,6 @@ package org.apache.ignite.internal.processors.cache.distributed;
 import java.io.Externalizable;
 import java.nio.ByteBuffer;
 import java.util.Collection;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
 import org.apache.ignite.lang.IgniteUuid;
@@ -85,6 +83,8 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
      * @param invalidate Invalidate flag.
      * @param sys System transaction flag.
      * @param plc IO policy.
+     * @param syncCommit Sync commit flag.
+     * @param syncRollback Sync rollback flag.
      * @param baseVer Base version.
      * @param committedVers Committed versions.
      * @param rolledbackVers Rolled back versions.
@@ -184,6 +184,13 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
     }
 
     /**
+     * @param syncCommit Sync commit flag.
+     */
+    public void syncCommit(boolean syncCommit) {
+        this.syncCommit = syncCommit;
+    }
+
+    /**
      * @return Sync rollback flag.
      */
     public boolean syncRollback() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 e595942..0d26c84 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
@@ -317,7 +317,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
         if (reads != null)
             marshalTx(reads, ctx);
 
-        if (dhtVers != null) {
+        if (dhtVers != null && dhtVerKeys == null) {
             for (IgniteTxKey key : dhtVers.keySet()) {
                 GridCacheContext cctx = ctx.cacheContext(key.cacheId());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 d2c5aa4..4d22213 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
@@ -93,7 +93,7 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
         super.prepareMarshal(ctx);
 
-        if (err != null)
+        if (err != null && errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
     }
 
@@ -101,7 +101,7 @@ public class GridDistributedTxPrepareResponse extends GridDistributedBaseMessage
     @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
-        if (errBytes != null)
+        if (errBytes != null && err == null)
             err = ctx.marshaller().unmarshal(errBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 e731406..8e041c8 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
@@ -104,7 +104,7 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
         super.prepareMarshal(ctx);
 
-        if (affAssignment != null)
+        if (affAssignment != null && affAssignmentBytes == null)
             affAssignmentBytes = ctx.marshaller().marshal(affAssignment);
     }
 
@@ -113,7 +113,7 @@ public class GridDhtAffinityAssignmentResponse extends GridCacheMessage {
     @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
-        if (affAssignmentBytes != null) {
+        if (affAssignmentBytes != null && affAssignment == null) {
             affAssignment = ctx.marshaller().unmarshal(affAssignmentBytes, ldr);
 
             // TODO IGNITE-2110: setting 'local' for nodes not needed when IGNITE-2110 is implemented.

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index 98711b8..1c3e052 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -494,14 +494,12 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
         boolean found = false;
 
         for (IgniteInternalFuture<?> fut : futures()) {
-            if (isMini(fut)) {
-                MiniFuture f = (MiniFuture)fut;
+            MiniFuture f = (MiniFuture)fut;
 
-                if (f.node().id().equals(nodeId)) {
-                    f.onResult(new ClusterTopologyCheckedException("Remote node left grid (will ignore): " + nodeId));
+            if (f.node().id().equals(nodeId)) {
+                f.onResult(new ClusterTopologyCheckedException("Remote node left grid (will ignore): " + nodeId));
 
-                    found = true;
-                }
+                found = true;
             }
         }
 
@@ -551,12 +549,7 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
         synchronized (futs) {
             // Avoid iterator creation.
             for (int i = 0; i < futs.size(); i++) {
-                IgniteInternalFuture<Boolean> fut = futs.get(i);
-
-                if (!isMini(fut))
-                    continue;
-
-                MiniFuture mini = (MiniFuture)fut;
+                MiniFuture mini = (MiniFuture)futs.get(i);
 
                 if (mini.futureId().equals(miniId)) {
                     if (!mini.isDone())
@@ -772,14 +765,6 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
     }
 
     /**
-     * @param f Future.
-     * @return {@code True} if mini-future.
-     */
-    private boolean isMini(IgniteInternalFuture<?> f) {
-        return f.getClass().equals(MiniFuture.class);
-    }
-
-    /**
      *
      */
     public void map() {
@@ -1006,7 +991,24 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
 
     /** {@inheritDoc} */
     @Override public String toString() {
-        return S.toString(GridDhtLockFuture.class, this, super.toString());
+        Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
+            @Override public String apply(IgniteInternalFuture<?> f) {
+                MiniFuture m = (MiniFuture)f;
+
+                return "[node=" + m.node().id() + ", loc=" + m.node().isLocal() + ", done=" + f.isDone() + "]";
+            }
+        });
+
+        Collection<KeyCacheObject> locks;
+
+        synchronized (this) {
+            locks = new HashSet<>(pendingLocks);
+        }
+
+        return S.toString(GridDhtLockFuture.class, this,
+            "innerFuts", futs,
+            "pendingLocks", locks,
+            "super", super.toString());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
index 62cf69d..50167d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
@@ -311,7 +311,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
 
         prepareMarshalCacheObjects(nearKeys, ctx.cacheContext(cacheId));
 
-        if (owned != null) {
+        if (owned != null && ownedKeys == null) {
             ownedKeys = new KeyCacheObject[owned.size()];
             ownedValues = new GridCacheVersion[ownedKeys.length];
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
index 65f1cb4..2d98e0d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht;
 import java.io.Externalizable;
 import java.nio.ByteBuffer;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.UUID;
 import org.apache.ignite.internal.GridDirectCollection;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -44,6 +43,9 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
     /** */
     private static final long serialVersionUID = 0L;
 
+    /** */
+    public static final int WAIT_REMOTE_TX_FLAG_MASK = 0x01;
+
     /** Near node ID. */
     private UUID nearNodeId;
 
@@ -64,7 +66,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
     @GridDirectCollection(GridCacheVersion.class)
     private Collection<GridCacheVersion> pendingVers;
 
-    /** Check comitted flag. */
+    /** Check committed flag. */
     private boolean checkCommitted;
 
     /** Partition update counter. */
@@ -81,6 +83,9 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
     /** Task name hash. */
     private int taskNameHash;
 
+    /** */
+    private byte flags;
+
     /**
      * Empty constructor required for {@link Externalizable}.
      */
@@ -100,6 +105,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
      * @param commit Commit flag.
      * @param invalidate Invalidate flag.
      * @param sys System flag.
+     * @param plc IO policy.
      * @param sysInvalidate System invalidation flag.
      * @param syncCommit Synchronous commit flag.
      * @param syncRollback Synchronous rollback flag.
@@ -180,6 +186,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
      * @param commit Commit flag.
      * @param invalidate Invalidate flag.
      * @param sys System flag.
+     * @param plc IO policy.
      * @param sysInvalidate System invalidation flag.
      * @param syncCommit Synchronous commit flag.
      * @param syncRollback Synchronous rollback flag.
@@ -302,16 +309,6 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
     }
 
     /**
-     * Gets versions of not acquired locks with version less then one of transaction being committed.
-     *
-     * @return Versions of locks for entries participating in transaction that have not been acquired yet
-     *      have version less then one of transaction being committed.
-     */
-    public Collection<GridCacheVersion> pendingVersions() {
-        return pendingVers == null ? Collections.<GridCacheVersion>emptyList() : pendingVers;
-    }
-
-    /**
      * @return Check committed flag.
      */
     public boolean checkCommitted() {
@@ -325,6 +322,23 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
         this.checkCommitted = checkCommitted;
     }
 
+    /**
+     * @return {@code True}
+     */
+    public boolean waitRemoteTransactions() {
+        return (flags & WAIT_REMOTE_TX_FLAG_MASK) != 0;
+    }
+
+    /**
+     * @param waitRemoteTxs Wait remote transactions flag.
+     */
+    public void waitRemoteTransactions(boolean waitRemoteTxs) {
+        if (waitRemoteTxs)
+            flags = (byte)(flags | WAIT_REMOTE_TX_FLAG_MASK);
+        else
+            flags &= ~WAIT_REMOTE_TX_FLAG_MASK;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridDhtTxFinishRequest.class, this, super.toString());
@@ -352,60 +366,66 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
                 writer.incrementState();
 
             case 19:
-                if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
+                if (!writer.writeByte("flags", flags))
                     return false;
 
                 writer.incrementState();
 
             case 20:
-                if (!writer.writeIgniteUuid("miniId", miniId))
+                if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
                     return false;
 
                 writer.incrementState();
 
             case 21:
-                if (!writer.writeUuid("nearNodeId", nearNodeId))
+                if (!writer.writeIgniteUuid("miniId", miniId))
                     return false;
 
                 writer.incrementState();
 
             case 22:
-                if (!writer.writeMessage("partUpdateCnt", partUpdateCnt))
+                if (!writer.writeUuid("nearNodeId", nearNodeId))
                     return false;
 
                 writer.incrementState();
 
             case 23:
-                if (!writer.writeCollection("pendingVers", pendingVers, MessageCollectionItemType.MSG))
+                if (!writer.writeMessage("partUpdateCnt", partUpdateCnt))
                     return false;
 
                 writer.incrementState();
 
             case 24:
-                if (!writer.writeUuid("subjId", subjId))
+                if (!writer.writeCollection("pendingVers", pendingVers, MessageCollectionItemType.MSG))
                     return false;
 
                 writer.incrementState();
 
             case 25:
-                if (!writer.writeBoolean("sysInvalidate", sysInvalidate))
+                if (!writer.writeUuid("subjId", subjId))
                     return false;
 
                 writer.incrementState();
 
             case 26:
-                if (!writer.writeInt("taskNameHash", taskNameHash))
+                if (!writer.writeBoolean("sysInvalidate", sysInvalidate))
                     return false;
 
                 writer.incrementState();
 
             case 27:
-                if (!writer.writeMessage("topVer", topVer))
+                if (!writer.writeInt("taskNameHash", taskNameHash))
                     return false;
 
                 writer.incrementState();
 
             case 28:
+                if (!writer.writeMessage("topVer", topVer))
+                    return false;
+
+                writer.incrementState();
+
+            case 29:
                 if (!writer.writeMessage("writeVer", writeVer))
                     return false;
 
@@ -436,6 +456,14 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
                 reader.incrementState();
 
             case 19:
+                flags = reader.readByte("flags");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 20:
                 byte isolationOrd;
 
                 isolationOrd = reader.readByte("isolation");
@@ -447,7 +475,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 20:
+            case 21:
                 miniId = reader.readIgniteUuid("miniId");
 
                 if (!reader.isLastRead())
@@ -455,7 +483,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 21:
+            case 22:
                 nearNodeId = reader.readUuid("nearNodeId");
 
                 if (!reader.isLastRead())
@@ -463,7 +491,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 22:
+            case 23:
                 partUpdateCnt = reader.readMessage("partUpdateCnt");
 
                 if (!reader.isLastRead())
@@ -471,7 +499,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 23:
+            case 24:
                 pendingVers = reader.readCollection("pendingVers", MessageCollectionItemType.MSG);
 
                 if (!reader.isLastRead())
@@ -479,7 +507,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 24:
+            case 25:
                 subjId = reader.readUuid("subjId");
 
                 if (!reader.isLastRead())
@@ -487,7 +515,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 25:
+            case 26:
                 sysInvalidate = reader.readBoolean("sysInvalidate");
 
                 if (!reader.isLastRead())
@@ -495,7 +523,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 26:
+            case 27:
                 taskNameHash = reader.readInt("taskNameHash");
 
                 if (!reader.isLastRead())
@@ -503,7 +531,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 27:
+            case 28:
                 topVer = reader.readMessage("topVer");
 
                 if (!reader.isLastRead())
@@ -511,7 +539,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
                 reader.incrementState();
 
-            case 28:
+            case 29:
                 writeVer = reader.readMessage("writeVer");
 
                 if (!reader.isLastRead())
@@ -531,6 +559,6 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 29;
+        return 30;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 fb4d97d..626ad89 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
@@ -109,7 +109,7 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
         super.prepareMarshal(ctx);
 
-        if (checkCommittedErr != null)
+        if (checkCommittedErr != null && checkCommittedErrBytes == null)
             checkCommittedErrBytes = ctx.marshaller().marshal(checkCommittedErr);
     }
 
@@ -118,7 +118,7 @@ public class GridDhtTxFinishResponse extends GridDistributedTxFinishResponse {
         throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
-        if (checkCommittedErrBytes != null)
+        if (checkCommittedErrBytes != null && checkCommittedErr == null)
             checkCommittedErr = ctx.marshaller().unmarshal(checkCommittedErrBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
index e026b4e..ebf1002 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
@@ -421,6 +421,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
             if (!state(PREPARING)) {
                 if (state() == PREPARED && isSystemInvalidate())
                     fut.complete();
+
                 if (setRollbackOnly()) {
                     if (timedOut())
                         fut.onError(new IgniteTxTimeoutCheckedException("Transaction timed out and was rolled back: " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
index 394ff89..d31ecba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
@@ -281,7 +281,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
         super.prepareMarshal(ctx);
 
-        if (owned != null) {
+        if (owned != null && ownedKeys == null) {
             ownedKeys = owned.keySet();
 
             ownedVals = owned.values();

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
index 7bee5a3..7cc276f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
@@ -656,11 +656,14 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
             if (!addDepInfo && ctx.deploymentEnabled())
                 addDepInfo = true;
 
-            invokeArgsBytes = marshalInvokeArguments(invokeArgs, cctx);
+            if (invokeArgsBytes == null)
+                invokeArgsBytes = marshalInvokeArguments(invokeArgs, cctx);
 
-            entryProcessorsBytes = marshalCollection(entryProcessors, cctx);
+            if (entryProcessorsBytes == null)
+                entryProcessorsBytes = marshalCollection(entryProcessors, cctx);
 
-            nearEntryProcessorsBytes = marshalCollection(nearEntryProcessors, cctx);
+            if (nearEntryProcessorsBytes == null)
+                nearEntryProcessorsBytes = marshalCollection(nearEntryProcessors, cctx);
         }
     }
 
@@ -681,13 +684,15 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
         finishUnmarshalCacheObjects(prevVals, cctx, ldr);
 
         if (forceTransformBackups) {
-            entryProcessors = unmarshalCollection(entryProcessorsBytes, ctx, ldr);
+            if (entryProcessors == null)
+                entryProcessors = unmarshalCollection(entryProcessorsBytes, ctx, ldr);
 
-            invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);
-        }
+            if (invokeArgs == null)
+                invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);
 
-        if (forceTransformBackups)
-            nearEntryProcessors = unmarshalCollection(nearEntryProcessorsBytes, ctx, ldr);
+            if (nearEntryProcessors == null)
+                nearEntryProcessors = unmarshalCollection(nearEntryProcessorsBytes, ctx, ldr);
+        }
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 f1bb323..95fdeb6 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
@@ -165,7 +165,8 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
 
         prepareMarshalCacheObjects(nearEvicted, cctx);
 
-        errBytes = ctx.marshaller().marshal(err);
+        if (err != null && errBytes == null)
+            errBytes = ctx.marshaller().marshal(err);
     }
 
     /** {@inheritDoc} */
@@ -178,7 +179,8 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage implements Gri
 
         finishUnmarshalCacheObjects(nearEvicted, cctx, ldr);
 
-        err = ctx.marshaller().unmarshal(errBytes, ldr);
+        if (errBytes != null && err == null)
+            err = ctx.marshaller().unmarshal(errBytes, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 7c0aba5..9c4b486 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
@@ -184,6 +184,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
      * @param subjId Subject ID.
      * @param taskNameHash Task name hash code.
      * @param skipStore Skip write-through to a persistent storage.
+     * @param keepBinary Keep binary flag.
      * @param clientReq Client node request flag.
      * @param addDepInfo Deployment info flag.
      */
@@ -593,7 +594,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
                 filter = null;
         }
 
-        if (expiryPlc != null)
+        if (expiryPlc != null && expiryPlcBytes == null)
             expiryPlcBytes = CU.marshal(cctx, new IgniteExternalizableExpiryPolicy(expiryPlc));
 
         if (op == TRANSFORM) {
@@ -601,9 +602,11 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
             if (!addDepInfo && ctx.deploymentEnabled())
                 addDepInfo = true;
 
-            entryProcessorsBytes = marshalCollection(entryProcessors, cctx);
+            if (entryProcessorsBytes == null)
+                entryProcessorsBytes = marshalCollection(entryProcessors, cctx);
 
-            invokeArgsBytes = marshalInvokeArguments(invokeArgs, cctx);
+            if (invokeArgsBytes == null)
+                invokeArgsBytes = marshalInvokeArguments(invokeArgs, cctx);
         }
         else
             prepareMarshalCacheObjects(vals, cctx);
@@ -617,8 +620,13 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
         finishUnmarshalCacheObjects(keys, cctx, ldr);
 
-        if (op == TRANSFORM)
-            entryProcessors = unmarshalCollection(entryProcessorsBytes, ctx, ldr);
+        if (op == TRANSFORM) {
+            if (entryProcessors == null)
+                entryProcessors = unmarshalCollection(entryProcessorsBytes, ctx, ldr);
+
+            if (invokeArgs == null)
+                invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);
+        }
         else
             finishUnmarshalCacheObjects(vals, cctx, ldr);
 
@@ -629,9 +637,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
             }
         }
 
-        invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);
-
-        if (expiryPlcBytes != null)
+        if (expiryPlcBytes != null && expiryPlc == null)
             expiryPlc = ctx.marshaller().unmarshal(expiryPlcBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 b164e7e..3e3ac29 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
@@ -394,7 +394,7 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
         super.prepareMarshal(ctx);
 
-        if (err != null)
+        if (err != null && errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
 
         GridCacheContext cctx = ctx.cacheContext(cacheId);
@@ -413,7 +413,7 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage implements Gr
     @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
-        if (errBytes != null)
+        if (errBytes != null && err == null)
             err = ctx.marshaller().unmarshal(errBytes, ldr);
 
         GridCacheContext cctx = ctx.cacheContext(cacheId);

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 4cdecec..9c5238a 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
@@ -170,7 +170,8 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
                 info.marshal(cctx);
         }
 
-        errBytes = ctx.marshaller().marshal(err);
+        if (err != null && errBytes == null)
+            errBytes = ctx.marshaller().marshal(err);
     }
 
     /** {@inheritDoc} */
@@ -187,7 +188,8 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
                 info.unmarshal(cctx, ldr);
         }
 
-        err = ctx.marshaller().unmarshal(errBytes, ldr);
+        if (errBytes != null && err == null)
+            err = ctx.marshaller().unmarshal(errBytes, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 53c3d90..5cb84dc 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
@@ -66,6 +66,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
     /**
      * @param updateSeq Update sequence for this node.
      * @param topVer Topology version.
+     * @param cacheId Cache ID.
      */
     GridDhtPartitionDemandMessage(long updateSeq, @NotNull AffinityTopologyVersion topVer, int cacheId) {
         this.cacheId = cacheId;
@@ -75,6 +76,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
 
     /**
      * @param cp Message to copy from.
+     * @param parts Partitions.
      */
     GridDhtPartitionDemandMessage(GridDhtPartitionDemandMessage cp, Collection<Integer> parts) {
         cacheId = cp.cacheId;
@@ -181,7 +183,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
         super.prepareMarshal(ctx);
 
-        if (topic != null)
+        if (topic != null && topicBytes == null)
             topicBytes = ctx.marshaller().marshal(topic);
     }
 
@@ -189,7 +191,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
     @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
-        if (topicBytes != null)
+        if (topicBytes != null && topic == null)
             topic = ctx.marshaller().unmarshal(topicBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
index 41454f9..4451cbc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
@@ -75,9 +75,13 @@ public class GridDhtPartitionSupplyMessageV2 extends GridCacheMessage implements
     /**
      * @param updateSeq Update sequence for this node.
      * @param cacheId Cache ID.
+     * @param topVer Topology version.
      * @param addDepInfo Deployment info flag.
      */
-    GridDhtPartitionSupplyMessageV2(long updateSeq, int cacheId, AffinityTopologyVersion topVer, boolean addDepInfo) {
+    GridDhtPartitionSupplyMessageV2(long updateSeq,
+        int cacheId,
+        AffinityTopologyVersion topVer,
+        boolean addDepInfo) {
         this.cacheId = cacheId;
         this.updateSeq = updateSeq;
         this.topVer = topVer;

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 0cbdc91..6afb9b1 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
@@ -134,7 +134,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
         if (parts != null && partsBytes == null)
             partsBytes = ctx.marshaller().marshal(parts);
 
-        if (partCntrs != null)
+        if (partCntrs != null && partCntrsBytes == null)
             partCntrsBytes = ctx.marshaller().marshal(partCntrs);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 c07a508..1185913 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
@@ -138,7 +138,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
         if (partsBytes == null && parts != null)
             partsBytes = ctx.marshaller().marshal(parts);
 
-        if (partCntrs != null)
+        if (partCntrsBytes == null && partCntrs != null)
             partCntrsBytes = ctx.marshaller().marshal(partCntrs);
     }
 
@@ -149,7 +149,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
         if (partsBytes != null && parts == null)
             parts = ctx.marshaller().unmarshal(partsBytes, ldr);
 
-        if (partCntrsBytes != null)
+        if (partCntrsBytes != null && partCntrs == null)
             partCntrs = ctx.marshaller().unmarshal(partCntrsBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 15a791f..6ac91cd 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
@@ -188,7 +188,7 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
                 info.marshal(cctx);
         }
 
-        if (err != null)
+        if (err != null && errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
     }
 
@@ -203,7 +203,7 @@ public class GridNearGetResponse extends GridCacheMessage implements GridCacheDe
                 info.unmarshal(cctx, ldr);
         }
 
-        if (errBytes != null)
+        if (errBytes != null && err == null)
             err = ctx.marshaller().unmarshal(errBytes, ldr);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java
index fe6180a..7132567 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java
@@ -54,9 +54,13 @@ public abstract class GridNearOptimisticTxPrepareFutureAdapter extends GridNearT
 
         AffinityTopologyVersion topVer = null;
 
-        if (tx.system())
+        if (tx.system()) {
             topVer = tx.topologyVersionSnapshot();
 
+            if (topVer == null)
+                topVer = cctx.exchange().readyAffinityVersion();
+        }
+
         if (topVer == null)
             topVer = cctx.mvcc().lastExplicitLockTopologyVersion(threadId);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/457a9ae4/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 42ad7ed..314c35c 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
@@ -167,7 +167,7 @@ public class GridNearSingleGetResponse extends GridCacheMessage implements GridC
                 ((GridCacheEntryInfo)res).marshal(cctx);
         }
 
-        if (err != null)
+        if (err != null && errBytes == null)
             errBytes = ctx.marshaller().marshal(err);
     }
 


[22/29] ignite git commit: Added IgniteGetTxBenchmark (cache 'get' using transactional cache).

Posted by vo...@apache.org.
Added IgniteGetTxBenchmark (cache 'get' using transactional cache).


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

Branch: refs/heads/ignite-2236
Commit: d608ebdfd3f9088255dd6e32de6e90e1564569b1
Parents: 8b0c59a
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jan 15 10:06:02 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jan 15 10:06:02 2016 +0300

----------------------------------------------------------------------
 .../yardstick/cache/IgniteGetTxBenchmark.java   | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


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


[06/29] ignite git commit: IGNITE-2308: Fixed HadoopClassLoader dependency resolution. This closes #391.

Posted by vo...@apache.org.
IGNITE-2308: Fixed HadoopClassLoader dependency resolution. This closes #391.


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

Branch: refs/heads/ignite-2236
Commit: 012ca7308bf125d2c90d68ef7a8bc75aeb84bf53
Parents: ddbe2d5
Author: iveselovskiy <iv...@gridgain.com>
Authored: Mon Jan 4 10:47:28 2016 +0400
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Jan 4 10:47:28 2016 +0400

----------------------------------------------------------------------
 .../processors/hadoop/HadoopClassLoader.java    | 636 ++++++++++++++-----
 .../hadoop/HadoopClassLoaderTest.java           | 101 ++-
 .../hadoop/deps/CircularWIthHadoop.java         |  32 +
 .../hadoop/deps/CircularWithoutHadoop.java      |  27 +
 .../processors/hadoop/deps/WithCast.java        |  41 ++
 .../hadoop/deps/WithClassAnnotation.java        |  28 +
 .../hadoop/deps/WithConstructorInvocation.java  |  31 +
 .../processors/hadoop/deps/WithExtends.java     |  27 +
 .../processors/hadoop/deps/WithField.java       |  29 +
 .../processors/hadoop/deps/WithImplements.java  |  36 ++
 .../hadoop/deps/WithIndirectField.java          |  27 +
 .../processors/hadoop/deps/WithInitializer.java |  33 +
 .../processors/hadoop/deps/WithInnerClass.java  |  31 +
 .../hadoop/deps/WithLocalVariable.java          |  38 ++
 .../hadoop/deps/WithMethodAnnotation.java       |  32 +
 .../hadoop/deps/WithMethodArgument.java         |  31 +
 .../hadoop/deps/WithMethodCheckedException.java |  31 +
 .../hadoop/deps/WithMethodInvocation.java       |  31 +
 .../hadoop/deps/WithMethodReturnType.java       |  31 +
 .../hadoop/deps/WithMethodRuntimeException.java |  31 +
 .../processors/hadoop/deps/WithOuterClass.java  |  38 ++
 .../hadoop/deps/WithParameterAnnotation.java    |  31 +
 .../processors/hadoop/deps/WithStaticField.java |  29 +
 .../hadoop/deps/WithStaticInitializer.java      |  34 +
 .../processors/hadoop/deps/Without.java         |  25 +
 .../testsuites/IgniteHadoopTestSuite.java       |   3 +
 26 files changed, 1279 insertions(+), 185 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
index f12af46..735133f 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
@@ -30,7 +30,7 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
-import java.util.concurrent.atomic.AtomicBoolean;
+
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.hadoop.v2.HadoopDaemon;
 import org.apache.ignite.internal.processors.hadoop.v2.HadoopNativeCodeLoader;
@@ -40,13 +40,16 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Handle;
 import org.objectweb.asm.Label;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
 import org.objectweb.asm.commons.Remapper;
 import org.objectweb.asm.commons.RemappingClassAdapter;
 
@@ -125,10 +128,14 @@ public class HadoopClassLoader extends URLClassLoader {
      * @return {@code true} if we need to check this class.
      */
     private static boolean isHadoopIgfs(String cls) {
-        String ignitePackagePrefix = "org.apache.ignite";
-        int len = ignitePackagePrefix.length();
+        String ignitePkgPrefix = "org.apache.ignite";
+
+        int len = ignitePkgPrefix.length();
 
-        return cls.startsWith(ignitePackagePrefix) && (cls.indexOf("igfs.", len) != -1 || cls.indexOf(".fs.", len) != -1 || cls.indexOf("hadoop.", len) != -1);
+        return cls.startsWith(ignitePkgPrefix) && (
+            cls.indexOf("igfs.", len) != -1 ||
+            cls.indexOf(".fs.", len) != -1 ||
+            cls.indexOf("hadoop.", len) != -1);
     }
 
     /**
@@ -159,7 +166,7 @@ public class HadoopClassLoader extends URLClassLoader {
                 Boolean hasDeps = cache.get(name);
 
                 if (hasDeps == null) {
-                    hasDeps = hasExternalDependencies(name, new HashSet<String>());
+                    hasDeps = hasExternalDependencies(name);
 
                     cache.put(name, hasDeps);
                 }
@@ -266,10 +273,30 @@ public class HadoopClassLoader extends URLClassLoader {
     }
 
     /**
+     * Check whether class has external dependencies on Hadoop.
+     * 
      * @param clsName Class name.
+     * @return {@code True} if class has external dependencies.
+     */
+    boolean hasExternalDependencies(String clsName) {
+        CollectingContext ctx = new CollectingContext();
+
+        ctx.annVisitor = new CollectingAnnotationVisitor(ctx);
+        ctx.mthdVisitor = new CollectingMethodVisitor(ctx, ctx.annVisitor);
+        ctx.fldVisitor = new CollectingFieldVisitor(ctx, ctx.annVisitor);
+        ctx.clsVisitor = new CollectingClassVisitor(ctx, ctx.annVisitor, ctx.mthdVisitor, ctx.fldVisitor);
+        
+        return hasExternalDependencies(clsName, ctx);
+    }
+        
+    /**
+     * Check whether class has external dependencies on Hadoop.
+     * 
+     * @param clsName Class name.
+     * @param ctx Context.                
      * @return {@code true} If the class has external dependencies.
      */
-    boolean hasExternalDependencies(final String clsName, final Set<String> visited) {
+    boolean hasExternalDependencies(String clsName, CollectingContext ctx) {
         if (isHadoop(clsName)) // Hadoop must not be in classpath but Idea sucks, so filtering explicitly as external.
             return true;
 
@@ -291,157 +318,14 @@ public class HadoopClassLoader extends URLClassLoader {
             throw new RuntimeException("Failed to read class: " + clsName, e);
         }
 
-        visited.add(clsName);
-
-        final AtomicBoolean hasDeps = new AtomicBoolean();
-
-        rdr.accept(new ClassVisitor(Opcodes.ASM4) {
-            AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM4) {
-                // TODO
-            };
-
-            FieldVisitor fv = new FieldVisitor(Opcodes.ASM4) {
-                @Override public AnnotationVisitor visitAnnotation(String desc, boolean b) {
-                    onType(desc);
-
-                    return av;
-                }
-            };
-
-            MethodVisitor mv = new MethodVisitor(Opcodes.ASM4) {
-                @Override public AnnotationVisitor visitAnnotation(String desc, boolean b) {
-                    onType(desc);
-
-                    return av;
-                }
-
-                @Override public AnnotationVisitor visitParameterAnnotation(int i, String desc, boolean b) {
-                    onType(desc);
-
-                    return av;
-                }
-
-                @Override public AnnotationVisitor visitAnnotationDefault() {
-                    return av;
-                }
-
-                @Override public void visitFieldInsn(int i, String owner, String name, String desc) {
-                    onType(owner);
-                    onType(desc);
-                }
-
-                @Override public void visitFrame(int i, int i2, Object[] locTypes, int i3, Object[] stackTypes) {
-                    for (Object o : locTypes) {
-                        if (o instanceof String)
-                            onType((String)o);
-                    }
-
-                    for (Object o : stackTypes) {
-                        if (o instanceof String)
-                            onType((String)o);
-                    }
-                }
-
-                @Override public void visitLocalVariable(String name, String desc, String signature, Label lb,
-                    Label lb2, int i) {
-                    onType(desc);
-                }
-
-                @Override public void visitMethodInsn(int i, String owner, String name, String desc) {
-                    onType(owner);
-                }
-
-                @Override public void visitMultiANewArrayInsn(String desc, int dim) {
-                    onType(desc);
-                }
-
-                @Override public void visitTryCatchBlock(Label lb, Label lb2, Label lb3, String e) {
-                    onType(e);
-                }
-            };
-
-            void onClass(String depCls) {
-                assert validateClassName(depCls) : depCls;
-
-                if (depCls.startsWith("java.")) // Filter out platform classes.
-                    return;
-
-                if (visited.contains(depCls))
-                    return;
-
-                Boolean res = cache.get(depCls);
-
-                if (res == Boolean.TRUE || (res == null && hasExternalDependencies(depCls, visited)))
-                    hasDeps.set(true);
-            }
-
-            void onType(String type) {
-                if (type == null)
-                    return;
-
-                int off = 0;
-
-                while (type.charAt(off) == '[')
-                    off++; // Handle arrays.
-
-                if (off != 0)
-                    type = type.substring(off);
-
-                if (type.length() == 1)
-                    return; // Get rid of primitives.
-
-                if (type.charAt(type.length() - 1) == ';') {
-                    assert type.charAt(0) == 'L' : type;
-
-                    type = type.substring(1, type.length() - 1);
-                }
-
-                type = type.replace('/', '.');
-
-                onClass(type);
-            }
-
-            @Override public void visit(int i, int i2, String name, String signature, String superName,
-                String[] ifaces) {
-                onType(superName);
-
-                if (ifaces != null) {
-                    for (String iface : ifaces)
-                        onType(iface);
-                }
-            }
-
-            @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
-                onType(desc);
-
-                return av;
-            }
-
-            @Override public void visitInnerClass(String name, String outerName, String innerName, int i) {
-                onType(name);
-            }
-
-            @Override public FieldVisitor visitField(int i, String name, String desc, String signature, Object val) {
-                onType(desc);
+        ctx.visited.add(clsName);
 
-                return fv;
-            }
+        rdr.accept(ctx.clsVisitor, 0);
 
-            @Override public MethodVisitor visitMethod(int i, String name, String desc, String signature,
-                String[] exceptions) {
-                if (exceptions != null) {
-                    for (String e : exceptions)
-                        onType(e);
-                }
-
-                return mv;
-            }
-        }, 0);
-
-        if (hasDeps.get()) // We already know that we have dependencies, no need to check parent.
+        if (ctx.found) // We already know that we have dependencies, no need to check parent.
             return true;
 
-        // Here we are known to not have any dependencies but possibly we have a parent which have them.
+        // Here we are known to not have any dependencies but possibly we have a parent which has them.
         int idx = clsName.lastIndexOf('$');
 
         if (idx == -1) // No parent class.
@@ -449,13 +333,13 @@ public class HadoopClassLoader extends URLClassLoader {
 
         String parentCls = clsName.substring(0, idx);
 
-        if (visited.contains(parentCls))
+        if (ctx.visited.contains(parentCls))
             return false;
 
         Boolean res = cache.get(parentCls);
 
         if (res == null)
-            res = hasExternalDependencies(parentCls, visited);
+            res = hasExternalDependencies(parentCls, ctx);
 
         return res;
     }
@@ -616,4 +500,446 @@ public class HadoopClassLoader extends URLClassLoader {
     public String name() {
         return name;
     }
+
+    /**
+     * Context for dependencies collection.
+     */
+    private class CollectingContext {
+        /** Visited classes. */
+        private final Set<String> visited = new HashSet<>();
+
+        /** Whether dependency found. */
+        private boolean found;
+
+        /** Annotation visitor. */
+        private AnnotationVisitor annVisitor;
+
+        /** Method visitor. */
+        private MethodVisitor mthdVisitor;
+
+        /** Field visitor. */
+        private FieldVisitor fldVisitor;
+        
+        /** Class visitor. */
+        private ClassVisitor clsVisitor;
+
+        /**
+         * Processes a method descriptor
+         * @param methDesc The method desc String.
+         */
+        void onMethodsDesc(final String methDesc) {
+            // Process method return type:
+            onType(Type.getReturnType(methDesc));
+
+            if (found)
+                return;
+
+            // Process method argument types:
+            for (Type t: Type.getArgumentTypes(methDesc)) {
+                onType(t);
+
+                if (found)
+                    return;
+            }
+        }
+
+        /**
+         * Processes dependencies of a class.
+         *
+         * @param depCls The class name as dot-notated FQN.
+         */
+        void onClass(final String depCls) {
+            assert depCls.indexOf('/') == -1 : depCls; // class name should be fully converted to dot notation.
+            assert depCls.charAt(0) != 'L' : depCls;
+            assert validateClassName(depCls) : depCls;
+
+            if (depCls.startsWith("java.") || depCls.startsWith("javax.")) // Filter out platform classes.
+                return;
+
+            if (visited.contains(depCls))
+                return;
+
+            Boolean res = cache.get(depCls);
+
+            if (res == Boolean.TRUE || (res == null && hasExternalDependencies(depCls, this)))
+                found = true;
+        }
+
+        /**
+         * Analyses dependencies of given type.
+         *
+         * @param t The type to process.
+         */
+        void onType(Type t) {
+            if (t == null)
+                return;
+
+            int sort = t.getSort();
+
+            switch (sort) {
+                case Type.ARRAY:
+                    onType(t.getElementType());
+
+                    break;
+
+                case Type.OBJECT:
+                    onClass(t.getClassName());
+
+                    break;
+            }
+        }
+
+        /**
+         * Analyses dependencies of given object type.
+         *
+         * @param objType The object type to process.
+         */
+        void onInternalTypeName(String objType) {
+            if (objType == null)
+                return;
+
+            assert objType.length() > 1 : objType;
+
+            if (objType.charAt(0) == '[')
+                // handle array. In this case this is a type descriptor notation, like "[Ljava/lang/Object;"
+                onType(objType);
+            else {
+                assert objType.indexOf('.') == -1 : objType; // Must be slash-separated FQN.
+
+                String clsName = objType.replace('/', '.'); // Convert it to dot notation.
+
+                onClass(clsName); // Process.
+            }
+        }
+
+        /**
+         * Type description analyser.
+         *
+         * @param desc The description.
+         */
+        void onType(String desc) {
+            if (!F.isEmpty(desc)) {
+                if (desc.length() <= 1)
+                    return; // Optimization: filter out primitive types in early stage.
+
+                Type t = Type.getType(desc);
+
+                onType(t);
+            }
+        }
+    }    
+
+    /**
+     * Annotation visitor.
+     */
+    private static class CollectingAnnotationVisitor extends AnnotationVisitor {
+        /** */
+        final CollectingContext ctx;
+
+        /**
+         * Annotation visitor.
+         * 
+         * @param ctx The collector.
+         */
+        CollectingAnnotationVisitor(CollectingContext ctx) {
+            super(Opcodes.ASM4);
+
+            this.ctx = ctx;
+        }
+
+        /** {@inheritDoc} */
+        @Override public AnnotationVisitor visitAnnotation(String name, String desc) {
+            if (ctx.found)
+                return null;
+
+            ctx.onType(desc);
+
+            return this;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitEnum(String name, String desc, String val) {
+            if (ctx.found)
+                return;
+
+            ctx.onType(desc);
+        }
+
+        /** {@inheritDoc} */
+        @Override public AnnotationVisitor visitArray(String name) {
+            return ctx.found ? null : this;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visit(String name, Object val) {
+            if (ctx.found)
+                return;
+
+            if (val instanceof Type)
+                ctx.onType((Type)val);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitEnd() {
+            // No-op.
+        }
+    }
+
+    /**
+     * Field visitor.
+     */
+    private static class CollectingFieldVisitor extends FieldVisitor {
+        /** Collector. */
+        private final CollectingContext ctx;
+
+        /** Annotation visitor. */
+        private final AnnotationVisitor av;
+
+        /**
+         * Constructor.
+         */
+        CollectingFieldVisitor(CollectingContext ctx, AnnotationVisitor av) {
+            super(Opcodes.ASM4);
+
+            this.ctx = ctx;
+            this.av = av;
+        }
+
+        /** {@inheritDoc} */
+        @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+            if (ctx.found)
+                return null;
+
+            ctx.onType(desc);
+
+            return ctx.found ? null : av;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitAttribute(Attribute attr) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitEnd() {
+            // No-op.
+        }
+    }
+
+    /**
+     * Class visitor.
+     */
+    private static class CollectingClassVisitor extends ClassVisitor {
+        /** Collector. */
+        private final CollectingContext ctx;
+
+        /** Annotation visitor. */
+        private final AnnotationVisitor av;
+
+        /** Method visitor. */
+        private final MethodVisitor mv;
+
+        /** Field visitor. */
+        private final FieldVisitor fv;
+
+        /**
+         * Constructor.
+         *
+         * @param ctx Collector.
+         * @param av Annotation visitor.
+         * @param mv Method visitor.
+         * @param fv Field visitor.
+         */
+        CollectingClassVisitor(CollectingContext ctx, AnnotationVisitor av, MethodVisitor mv, FieldVisitor fv) {
+            super(Opcodes.ASM4);
+
+            this.ctx = ctx;
+            this.av = av;
+            this.mv = mv;
+            this.fv = fv;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visit(int i, int i2, String name, String signature, String superName, String[] ifaces) {
+            if (ctx.found)
+                return;
+
+            ctx.onInternalTypeName(superName);
+
+            if (ctx.found)
+                return;
+
+            if (ifaces != null) {
+                for (String iface : ifaces) {
+                    ctx.onInternalTypeName(iface);
+
+                    if (ctx.found)
+                        return;
+                }
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+            if (ctx.found)
+                return null;
+
+            ctx.onType(desc);
+
+            return ctx.found ? null : av;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitInnerClass(String name, String outerName, String innerName, int i) {
+            if (ctx.found)
+                return;
+
+            ctx.onInternalTypeName(name);
+        }
+
+        /** {@inheritDoc} */
+        @Override public FieldVisitor visitField(int i, String name, String desc, String signature, Object val) {
+            if (ctx.found)
+                return null;
+
+            ctx.onType(desc);
+
+            return ctx.found ? null : fv;
+        }
+
+        /** {@inheritDoc} */
+        @Override public MethodVisitor visitMethod(int i, String name, String desc, String signature,
+            String[] exceptions) {
+            if (ctx.found)
+                return null;
+
+            ctx.onMethodsDesc(desc);
+
+            // Process declared method exceptions:
+            if (exceptions != null) {
+                for (String e : exceptions)
+                    ctx.onInternalTypeName(e);
+            }
+
+            return ctx.found ? null : mv;
+        }
+    }
+
+    /**
+     * Method visitor.
+     */
+    private static class CollectingMethodVisitor extends MethodVisitor {
+        /** Collector. */
+        private final CollectingContext ctx;
+
+        /** Annotation visitor. */
+        private final AnnotationVisitor av;
+
+        /**
+         * Constructor.
+         *
+         * @param ctx Collector.
+         * @param av Annotation visitor.
+         */
+        private CollectingMethodVisitor(CollectingContext ctx, AnnotationVisitor av) {
+            super(Opcodes.ASM4);
+
+            this.ctx = ctx;
+            this.av = av;
+        }
+
+        /** {@inheritDoc} */
+        @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+            if (ctx.found)
+                return null;
+
+            ctx.onType(desc);
+
+            return ctx.found ? null : av;
+        }
+
+        /** {@inheritDoc} */
+        @Override public AnnotationVisitor visitParameterAnnotation(int i, String desc, boolean b) {
+            if (ctx.found)
+                return null;
+
+            ctx.onType(desc);
+
+            return ctx.found ? null : av;
+        }
+
+        /** {@inheritDoc} */
+        @Override public AnnotationVisitor visitAnnotationDefault() {
+            return ctx.found ? null : av;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitFieldInsn(int opcode, String owner, String name, String desc) {
+            if (ctx.found)
+                return;
+
+            ctx.onInternalTypeName(owner);
+
+            if (ctx.found)
+                return;
+
+            ctx.onType(desc);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitFrame(int type, int nLoc, Object[] locTypes, int nStack, Object[] stackTypes) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitLocalVariable(String name, String desc, String signature, Label lb,
+            Label lb2, int i) {
+            if (ctx.found)
+                return;
+
+            ctx.onType(desc);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitMethodInsn(int i, String owner, String name, String desc) {
+            if (ctx.found)
+                return;
+
+            ctx.onInternalTypeName(owner);
+
+            if (ctx.found)
+                return;
+
+            ctx.onMethodsDesc(desc);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitMultiANewArrayInsn(String desc, int dim) {
+            if (ctx.found)
+                return;
+
+            ctx.onType(desc);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitTryCatchBlock(Label start, Label end, Label hndl, String typeStr) {
+            if (ctx.found)
+                return;
+
+            ctx.onInternalTypeName(typeStr);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void visitTypeInsn(int opcode, String type) {
+            if (ctx.found)
+                return;
+
+            ctx.onInternalTypeName(type);
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java
index 085dd45..55fac2c 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoaderTest.java
@@ -17,53 +17,94 @@
 
 package org.apache.ignite.internal.processors.hadoop;
 
+import javax.security.auth.AuthPermission;
 import junit.framework.TestCase;
-import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.ignite.internal.processors.hadoop.deps.CircularWIthHadoop;
+import org.apache.ignite.internal.processors.hadoop.deps.CircularWithoutHadoop;
+import org.apache.ignite.internal.processors.hadoop.deps.WithIndirectField;
+import org.apache.ignite.internal.processors.hadoop.deps.WithCast;
+import org.apache.ignite.internal.processors.hadoop.deps.WithClassAnnotation;
+import org.apache.ignite.internal.processors.hadoop.deps.WithConstructorInvocation;
+import org.apache.ignite.internal.processors.hadoop.deps.WithMethodCheckedException;
+import org.apache.ignite.internal.processors.hadoop.deps.WithMethodRuntimeException;
+import org.apache.ignite.internal.processors.hadoop.deps.WithExtends;
+import org.apache.ignite.internal.processors.hadoop.deps.WithField;
+import org.apache.ignite.internal.processors.hadoop.deps.WithImplements;
+import org.apache.ignite.internal.processors.hadoop.deps.WithInitializer;
+import org.apache.ignite.internal.processors.hadoop.deps.WithInnerClass;
+import org.apache.ignite.internal.processors.hadoop.deps.WithLocalVariable;
+import org.apache.ignite.internal.processors.hadoop.deps.WithMethodAnnotation;
+import org.apache.ignite.internal.processors.hadoop.deps.WithMethodInvocation;
+import org.apache.ignite.internal.processors.hadoop.deps.WithMethodArgument;
+import org.apache.ignite.internal.processors.hadoop.deps.WithMethodReturnType;
+import org.apache.ignite.internal.processors.hadoop.deps.WithOuterClass;
+import org.apache.ignite.internal.processors.hadoop.deps.WithParameterAnnotation;
+import org.apache.ignite.internal.processors.hadoop.deps.WithStaticField;
+import org.apache.ignite.internal.processors.hadoop.deps.WithStaticInitializer;
+import org.apache.ignite.internal.processors.hadoop.deps.Without;
 
 /**
- *
+ * Tests for Hadoop classloader.
  */
 public class HadoopClassLoaderTest extends TestCase {
     /** */
-    HadoopClassLoader ldr = new HadoopClassLoader(null, "test");
+    final HadoopClassLoader ldr = new HadoopClassLoader(null, "test");
 
     /**
      * @throws Exception If failed.
      */
     public void testClassLoading() throws Exception {
-        assertNotSame(Test1.class, ldr.loadClass(Test1.class.getName()));
-        assertNotSame(Test2.class, ldr.loadClass(Test2.class.getName()));
-        assertSame(Test3.class, ldr.loadClass(Test3.class.getName()));
-    }
+        assertNotSame(CircularWIthHadoop.class, ldr.loadClass(CircularWIthHadoop.class.getName()));
+        assertNotSame(CircularWithoutHadoop.class, ldr.loadClass(CircularWithoutHadoop.class.getName()));
 
-//    public void testDependencySearch() {
-//        assertTrue(ldr.hasExternalDependencies(Test1.class.getName(), new HashSet<String>()));
-//        assertTrue(ldr.hasExternalDependencies(Test2.class.getName(), new HashSet<String>()));
-//    }
+        assertSame(Without.class, ldr.loadClass(Without.class.getName()));
+    }
 
     /**
-     *
+     * Test dependency search.
      */
-    private static class Test1 {
-        /** */
-        Test2 t2;
+    public void testDependencySearch() {
+        // Positive cases:
+        final Class[] positiveClasses = {
+            Configuration.class,
+            HadoopUtils.class,
+            WithStaticField.class,
+            WithCast.class,
+            WithClassAnnotation.class,
+            WithConstructorInvocation.class,
+            WithMethodCheckedException.class,
+            WithMethodRuntimeException.class,
+            WithExtends.class,
+            WithField.class,
+            WithImplements.class,
+            WithInitializer.class,
+            WithInnerClass.class,
+            WithOuterClass.InnerNoHadoop.class,
+            WithLocalVariable.class,
+            WithMethodAnnotation.class,
+            WithMethodInvocation.class,
+            WithMethodArgument.class,
+            WithMethodReturnType.class,
+            WithParameterAnnotation.class,
+            WithStaticField.class,
+            WithStaticInitializer.class,
+            WithIndirectField.class,
+            CircularWIthHadoop.class,
+            CircularWithoutHadoop.class,
+        };
 
-        /** */
-        Job[][] jobs = new Job[4][4];
-    }
+        for (Class c: positiveClasses)
+            assertTrue(c.getName(), ldr.hasExternalDependencies(c.getName()));
 
-    /**
-     *
-     */
-    private static abstract class Test2 {
-        /** */
-        abstract Test1 t1();
-    }
+        // Negative cases:
+        final Class[] negativeClasses = {
+            Object.class,
+            AuthPermission.class,
+            Without.class,
+        };
 
-    /**
-     *
-     */
-    private static class Test3 {
-        // No-op.
+        for (Class c: negativeClasses)
+            assertFalse(c.getName(), ldr.hasExternalDependencies(c.getName()));
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/CircularWIthHadoop.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/CircularWIthHadoop.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/CircularWIthHadoop.java
new file mode 100644
index 0000000..c3aa7d9
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/CircularWIthHadoop.java
@@ -0,0 +1,32 @@
+/*
+ * 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.deps;
+
+import org.apache.hadoop.mapreduce.Job;
+
+/**
+ * Class has a direct Hadoop dependency and a circular dependency on another class.
+ */
+@SuppressWarnings("unused")
+public class CircularWIthHadoop {
+    /** */
+    private Job[][] jobs = new Job[4][4];
+
+    /** */
+    private CircularWithoutHadoop y;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/CircularWithoutHadoop.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/CircularWithoutHadoop.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/CircularWithoutHadoop.java
new file mode 100644
index 0000000..93d659c
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/CircularWithoutHadoop.java
@@ -0,0 +1,27 @@
+/*
+ * 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.deps;
+
+/**
+ * Does not have direct Hadoop dependency, but has a circular
+ */
+@SuppressWarnings("unused")
+public class CircularWithoutHadoop {
+    /** */
+    private CircularWIthHadoop x;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithCast.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithCast.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithCast.java
new file mode 100644
index 0000000..5b1e8e0
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithCast.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.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * Class contains casting to a Hadoop type.
+ */
+@SuppressWarnings("unused")
+public abstract class WithCast<T> {
+    /** */
+    public abstract T create();
+
+    /** */
+    public void consume(T t) {
+        // noop
+    }
+
+    /** */
+    void test(WithCast<FileSystem> c) {
+        FileSystem fs = c.create();
+
+        c.consume(fs);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithClassAnnotation.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithClassAnnotation.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithClassAnnotation.java
new file mode 100644
index 0000000..a9ecae0
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithClassAnnotation.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+
+/**
+ * Class has Hadoop annotation.
+ */
+@SuppressWarnings("unused")
+@InterfaceAudience.Public
+public class WithClassAnnotation {
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithConstructorInvocation.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithConstructorInvocation.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithConstructorInvocation.java
new file mode 100644
index 0000000..98c8991
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithConstructorInvocation.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Invokes a Hadoop type constructor.
+ */
+@SuppressWarnings("unused")
+public class WithConstructorInvocation {
+    /** */
+    private void foo() {
+        Object x = new Configuration();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithExtends.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithExtends.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithExtends.java
new file mode 100644
index 0000000..80c99e1
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithExtends.java
@@ -0,0 +1,27 @@
+/*
+ * 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.deps;
+
+import org.apache.hadoop.fs.LocalFileSystem;
+
+/**
+ * Class extends a Hadoop class.
+ */
+public class WithExtends extends LocalFileSystem {
+    // noop
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithField.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithField.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithField.java
new file mode 100644
index 0000000..dd979db
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithField.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Has a Hadoop field.
+ */
+@SuppressWarnings("unused")
+public class WithField {
+    /** */
+    private Configuration conf;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithImplements.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithImplements.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithImplements.java
new file mode 100644
index 0000000..c2d8e5b
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithImplements.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.conf.Configurable;
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Implements a Hadoop interface.
+ */
+public class WithImplements implements Configurable {
+    /** {@inheritDoc} */
+    @Override public void setConf(Configuration conf) {
+        // noop
+    }
+
+    /** {@inheritDoc} */
+    @Override public Configuration getConf() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithIndirectField.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithIndirectField.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithIndirectField.java
new file mode 100644
index 0000000..ce078f1
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithIndirectField.java
@@ -0,0 +1,27 @@
+/*
+ * 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.deps;
+
+/**
+ * Has a unidirected dependency on Hadoop-dependent class.
+ */
+@SuppressWarnings("unused")
+public class WithIndirectField {
+    /** */
+    WithField x;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithInitializer.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithInitializer.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithInitializer.java
new file mode 100644
index 0000000..360986c
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithInitializer.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+/**
+ * Has a field initialized with an expression invoking Hadoop method.
+ */
+
+@SuppressWarnings({"ConstantConditions", "unused"})
+public class WithInitializer {
+    /** */
+    private final Object x = org.apache.hadoop.fs.FileSystem.getDefaultUri(null);
+
+    /** */
+    WithInitializer() throws Exception {
+        // noop
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithInnerClass.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithInnerClass.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithInnerClass.java
new file mode 100644
index 0000000..4a5a49c
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithInnerClass.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.conf.Configurable;
+
+/**
+ * Has a *static* inner class depending on Hadoop.
+ */
+@SuppressWarnings("unused")
+public class WithInnerClass {
+    /** */
+    private static abstract class Foo implements Configurable {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithLocalVariable.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithLocalVariable.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithLocalVariable.java
new file mode 100644
index 0000000..ea4a5de
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithLocalVariable.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Has a local variable of Hadoop type.
+ */
+@SuppressWarnings({"unused", "ConstantConditions"})
+public class WithLocalVariable {
+    /** */
+    void foo() {
+        Configuration c = null;
+
+        moo(c);
+    }
+
+    /** */
+    void moo(Object x) {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodAnnotation.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodAnnotation.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodAnnotation.java
new file mode 100644
index 0000000..ff9fbe0
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodAnnotation.java
@@ -0,0 +1,32 @@
+/*
+ * 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.deps;
+
+import org.apache.hadoop.classification.InterfaceStability;
+
+/**
+ * Method has a Hadoop annotation.
+ */
+@SuppressWarnings("unused")
+public class WithMethodAnnotation {
+    /** */
+    @InterfaceStability.Unstable
+    void foo() {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodArgument.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodArgument.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodArgument.java
new file mode 100644
index 0000000..7f639e4
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodArgument.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Contains a formal parameter of Hadoop type.
+ */
+@SuppressWarnings("unused")
+public class WithMethodArgument {
+    /** */
+    protected void paramaterMethod(Configuration c) {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodCheckedException.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodCheckedException.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodCheckedException.java
new file mode 100644
index 0000000..8fd12ae
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodCheckedException.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.fs.ChecksumException;
+
+/**
+ * Method declares a checked Hadoop Exception.
+ */
+@SuppressWarnings("unused")
+public class WithMethodCheckedException {
+    /** */
+    void foo() throws ChecksumException {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodInvocation.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodInvocation.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodInvocation.java
new file mode 100644
index 0000000..de8b306
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodInvocation.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * Method contains a Hadoop type method invocation.
+ */
+@SuppressWarnings("unused")
+public class WithMethodInvocation {
+    /** */
+    void foo(FileSystem fs) {
+        fs.getChildFileSystems();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodReturnType.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodReturnType.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodReturnType.java
new file mode 100644
index 0000000..0e0ea72
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodReturnType.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * Contains a method return value of Hadoop type.
+ */
+@SuppressWarnings("unused")
+public class WithMethodReturnType {
+    /** */
+    FileSystem fsMethod() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodRuntimeException.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodRuntimeException.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodRuntimeException.java
new file mode 100644
index 0000000..dcd471c
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithMethodRuntimeException.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.HadoopIllegalArgumentException;
+
+/**
+ * Method declares a runtime Hadoop Exception.
+ */
+@SuppressWarnings("unused")
+public class WithMethodRuntimeException {
+    /** */
+    void foo() throws HadoopIllegalArgumentException {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithOuterClass.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithOuterClass.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithOuterClass.java
new file mode 100644
index 0000000..cae1da7
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithOuterClass.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Outer class depends on Hadoop, but Inner *static* one does not.
+ */
+@SuppressWarnings("unused")
+public class WithOuterClass {
+    /** */
+    Configuration c;
+
+    /** */
+    public static class InnerNoHadoop {
+        /** */
+        int x;
+
+        /** */
+        void foo() {}
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithParameterAnnotation.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithParameterAnnotation.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithParameterAnnotation.java
new file mode 100644
index 0000000..9d3414e
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithParameterAnnotation.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.classification.InterfaceStability;
+
+/**
+ * Has a paramater annotated with a Hadoop annotation.
+ */
+@SuppressWarnings("unused")
+public class WithParameterAnnotation {
+    /** */
+    void foo(@InterfaceStability.Stable Object annotatedParam) {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithStaticField.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithStaticField.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithStaticField.java
new file mode 100644
index 0000000..301b912
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithStaticField.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.deps;
+
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * Has a static field of Hadoop type.
+ */
+@SuppressWarnings("unused")
+public class WithStaticField {
+    /** */
+    static FileSystem fs;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithStaticInitializer.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithStaticInitializer.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithStaticInitializer.java
new file mode 100644
index 0000000..e0fc2f3
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/WithStaticInitializer.java
@@ -0,0 +1,34 @@
+/*
+ * 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.deps;
+
+import java.util.List;
+import org.apache.hadoop.fs.FileSystem;
+
+/**
+ * Uses Hadoop type in a static initializer.
+ */
+@SuppressWarnings("unused")
+public class WithStaticInitializer {
+    /** */
+    static final List x;
+
+    static {
+        x = FileSystem.getAllStatistics();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/Without.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/Without.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/Without.java
new file mode 100644
index 0000000..ab84740
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/deps/Without.java
@@ -0,0 +1,25 @@
+/*
+ * 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.deps;
+
+/**
+ * Class that does not anyhow depend on Hadoop.
+ */
+public class Without {
+    // No-op.
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/012ca730/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 6641bc8..1831085 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
@@ -54,6 +54,7 @@ import org.apache.ignite.igfs.IgniteHadoopFileSystemLoopbackExternalPrimarySelfT
 import org.apache.ignite.igfs.IgniteHadoopFileSystemLoopbackExternalSecondarySelfTest;
 import org.apache.ignite.igfs.IgniteHadoopFileSystemSecondaryFileSystemInitializationSelfTest;
 import org.apache.ignite.igfs.IgniteHadoopFileSystemSecondaryModeSelfTest;
+import org.apache.ignite.internal.processors.hadoop.HadoopClassLoaderTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopCommandLineTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopDefaultMapReducePlannerSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopFileSystemsTest;
@@ -95,6 +96,8 @@ public class IgniteHadoopTestSuite extends TestSuite {
 
         TestSuite suite = new TestSuite("Ignite Hadoop MR Test Suite");
 
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopClassLoaderTest.class.getName())));
+
         suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfs20FileSystemLoopbackPrimarySelfTest.class.getName())));
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfsDualSyncSelfTest.class.getName())));


[28/29] ignite git commit: ignite-2386 Fixed DiscoverManager to do not increase minor topology version if exchange is not triggered.

Posted by vo...@apache.org.
ignite-2386 Fixed DiscoverManager to do not increase minor topology version if exchange is not triggered.


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

Branch: refs/heads/ignite-2236
Commit: d8814178c2f8e93a76336069772cc3aec42fda46
Parents: 3a0cb51
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jan 15 15:15:02 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jan 15 15:15:02 2016 +0300

----------------------------------------------------------------------
 .../managers/discovery/CustomEventListener.java |   4 +-
 .../discovery/DiscoveryCustomMessage.java       |   9 --
 .../discovery/GridDiscoveryManager.java         |  33 ++---
 .../cache/DynamicCacheChangeBatch.java          |   5 -
 .../processors/cache/GridCacheProcessor.java    |  42 +++++--
 .../continuous/AbstractContinuousMessage.java   |   5 -
 .../continuous/GridContinuousProcessor.java     |  13 +-
 ...niteDynamicCacheStartStopConcurrentTest.java | 119 +++++++++++++++++++
 .../ignite/testframework/GridTestUtils.java     |  27 +++++
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 10 files changed, 200 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/CustomEventListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/CustomEventListener.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/CustomEventListener.java
index 8db4e67..ab143fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/CustomEventListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/CustomEventListener.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.managers.discovery;
 
 import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 
 /**
  * Listener interface.
@@ -27,7 +26,6 @@ public interface CustomEventListener<T extends DiscoveryCustomMessage> {
     /**
      * @param snd Sender.
      * @param msg Message.
-     * @param topVer Current topology version.
      */
-    public void onCustomEvent(ClusterNode snd, T msg, AffinityTopologyVersion topVer);
+    public void onCustomEvent(ClusterNode snd, T msg);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryCustomMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryCustomMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryCustomMessage.java
index 2ff40bf..d85075e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryCustomMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryCustomMessage.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.managers.discovery;
 
 import java.io.Serializable;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.lang.IgniteUuid;
 import org.jetbrains.annotations.Nullable;
 
@@ -32,14 +31,6 @@ public interface DiscoveryCustomMessage extends Serializable {
     public IgniteUuid id();
 
     /**
-     * Whether or not minor version of topology should be increased on message receive.
-     *
-     * @return {@code true} if minor topology version should be increased.
-     * @see AffinityTopologyVersion#minorTopVer
-     */
-    public boolean incrementMinorTopologyVersion();
-
-    /**
      * Called when custom message has been handled by all nodes.
      *
      * @return Ack message or {@code null} if ack is not required.

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 23a85e4..29e85dd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -474,21 +474,11 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
 
                 if (type == EVT_NODE_METRICS_UPDATED)
                     verChanged = false;
-                else if (type == DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) {
-                    assert customMsg != null;
-
-                    if (customMsg.incrementMinorTopologyVersion()) {
-                        minorTopVer++;
-
-                        verChanged = true;
-                    }
-                    else
-                        verChanged = false;
-                }
                 else {
                     if (type != EVT_NODE_SEGMENTED &&
                         type != EVT_CLIENT_NODE_DISCONNECTED &&
-                        type != EVT_CLIENT_NODE_RECONNECTED) {
+                        type != EVT_CLIENT_NODE_RECONNECTED &&
+                        type != DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) {
                         minorTopVer = 0;
 
                         verChanged = true;
@@ -497,8 +487,6 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                         verChanged = false;
                 }
 
-                final AffinityTopologyVersion nextTopVer = new AffinityTopologyVersion(topVer, minorTopVer);
-
                 if (type == EVT_NODE_FAILED || type == EVT_NODE_LEFT) {
                     for (DiscoCache c : discoCacheHist.values())
                         c.updateAlives(node);
@@ -506,14 +494,27 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                     updateClientNodes(node.id());
                 }
 
+                final AffinityTopologyVersion nextTopVer;
+
                 if (type == DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) {
+                    assert customMsg != null;
+
+                    boolean incMinorTopVer = ctx.cache().onCustomEvent(customMsg,
+                        new AffinityTopologyVersion(topVer, minorTopVer));
+
+                    if (incMinorTopVer) {
+                        minorTopVer++;
+
+                        verChanged = true;
+                    }
+
                     for (Class cls = customMsg.getClass(); cls != null; cls = cls.getSuperclass()) {
                         List<CustomEventListener<DiscoveryCustomMessage>> list = customEvtLsnrs.get(cls);
 
                         if (list != null) {
                             for (CustomEventListener<DiscoveryCustomMessage> lsnr : list) {
                                 try {
-                                    lsnr.onCustomEvent(node, customMsg, nextTopVer);
+                                    lsnr.onCustomEvent(node, customMsg);
                                 }
                                 catch (Exception e) {
                                     U.error(log, "Failed to notify direct custom event listener: " + customMsg, e);
@@ -523,6 +524,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                     }
                 }
 
+                nextTopVer = new AffinityTopologyVersion(topVer, minorTopVer);
+
                 // Put topology snapshot into discovery history.
                 // There is no race possible between history maintenance and concurrent discovery
                 // event notifications, since SPI notifies manager about all events from this listener.

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeBatch.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeBatch.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeBatch.java
index c7af64f..e10e5aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeBatch.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeBatch.java
@@ -83,11 +83,6 @@ public class DynamicCacheChangeBatch implements DiscoveryCustomMessage {
     }
 
     /** {@inheritDoc} */
-    @Override public boolean incrementMinorTopologyVersion() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public DiscoveryCustomMessage ackMessage() {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/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 eb6d98e..16dfa7f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -69,8 +69,8 @@ import org.apache.ignite.internal.IgniteComponentType;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.IgniteTransactionsEx;
-import org.apache.ignite.internal.managers.discovery.CustomEventListener;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
@@ -580,15 +580,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     "Deployment mode for cache is not CONTINUOUS or SHARED.");
         }
 
-        ctx.discovery().setCustomEventListener(DynamicCacheChangeBatch.class,
-            new CustomEventListener<DynamicCacheChangeBatch>() {
-                @Override public void onCustomEvent(ClusterNode snd,
-                    DynamicCacheChangeBatch msg,
-                    AffinityTopologyVersion topVer) {
-                    onCacheChangeRequested(msg, topVer);
-                }
-            });
-
         Set<String> internalCaches = internalCachesNames();
 
         CacheConfiguration[] cfgs = ctx.config().getCacheConfiguration();
@@ -2424,12 +2415,28 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     }
 
     /**
-     * Callback invoked from discovery thread when cache deployment request is received.
+     * Callback invoked from discovery thread when discovery custom message  is received.
      *
+     * @param msg Customer message.
+     * @param topVer Current topology version.
+     * @return {@code True} if minor topology version should be increased.
+     */
+    public boolean onCustomEvent(DiscoveryCustomMessage msg,
+        AffinityTopologyVersion topVer) {
+        return msg instanceof DynamicCacheChangeBatch && onCacheChangeRequested((DynamicCacheChangeBatch) msg, topVer);
+    }
+
+    /**
      * @param batch Change request batch.
      * @param topVer Current topology version.
+     * @return {@code True} if minor topology version should be increased.
      */
-    private void onCacheChangeRequested(DynamicCacheChangeBatch batch, AffinityTopologyVersion topVer) {
+    private boolean onCacheChangeRequested(DynamicCacheChangeBatch batch,
+        AffinityTopologyVersion topVer) {
+        AffinityTopologyVersion newTopVer = null;
+
+        boolean incMinorTopVer = false;
+
         for (DynamicCacheChangeRequest req : batch.requests()) {
             if (req.template()) {
                 CacheConfiguration ccfg = req.startCacheConfiguration();
@@ -2486,7 +2493,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                         DynamicCacheDescriptor startDesc =
                             new DynamicCacheDescriptor(ctx, ccfg, req.cacheType(), false, req.deploymentId());
 
-                        startDesc.startTopologyVersion(topVer);
+                        if (newTopVer == null) {
+                            newTopVer = new AffinityTopologyVersion(topVer.topologyVersion(),
+                                topVer.minorTopologyVersion() + 1);
+                        }
+
+                        startDesc.startTopologyVersion(newTopVer);
 
                         DynamicCacheDescriptor old = registeredCaches.put(maskNull(ccfg.getName()), startDesc);
 
@@ -2562,7 +2574,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             }
 
             req.exchangeNeeded(needExchange);
+
+            incMinorTopVer |= needExchange;
         }
+
+        return incMinorTopVer;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/AbstractContinuousMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/AbstractContinuousMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/AbstractContinuousMessage.java
index d6e25f1..8aa683e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/AbstractContinuousMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/AbstractContinuousMessage.java
@@ -51,11 +51,6 @@ public abstract class AbstractContinuousMessage implements DiscoveryCustomMessag
     }
 
     /** {@inheritDoc} */
-    @Override public boolean incrementMinorTopologyVersion() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean isMutable() {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/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 9bc9a38..cb028f3 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
@@ -52,7 +52,6 @@ import org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean;
 import org.apache.ignite.internal.managers.discovery.CustomEventListener;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler;
@@ -193,8 +192,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
         ctx.discovery().setCustomEventListener(StartRoutineDiscoveryMessage.class,
             new CustomEventListener<StartRoutineDiscoveryMessage>() {
                 @Override public void onCustomEvent(ClusterNode snd,
-                    StartRoutineDiscoveryMessage msg,
-                    AffinityTopologyVersion topVer) {
+                    StartRoutineDiscoveryMessage msg) {
                     if (!snd.id().equals(ctx.localNodeId()) && !ctx.isStopping())
                         processStartRequest(snd, msg);
                 }
@@ -203,8 +201,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
         ctx.discovery().setCustomEventListener(StartRoutineAckDiscoveryMessage.class,
             new CustomEventListener<StartRoutineAckDiscoveryMessage>() {
                 @Override public void onCustomEvent(ClusterNode snd,
-                    StartRoutineAckDiscoveryMessage msg,
-                    AffinityTopologyVersion topVer) {
+                    StartRoutineAckDiscoveryMessage msg) {
                     StartFuture fut = startFuts.remove(msg.routineId());
 
                     if (fut != null) {
@@ -250,8 +247,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
         ctx.discovery().setCustomEventListener(StopRoutineDiscoveryMessage.class,
             new CustomEventListener<StopRoutineDiscoveryMessage>() {
                 @Override public void onCustomEvent(ClusterNode snd,
-                    StopRoutineDiscoveryMessage msg,
-                    AffinityTopologyVersion topVer) {
+                    StopRoutineDiscoveryMessage msg) {
                     if (!snd.id().equals(ctx.localNodeId())) {
                         UUID routineId = msg.routineId();
 
@@ -270,8 +266,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
         ctx.discovery().setCustomEventListener(StopRoutineAckDiscoveryMessage.class,
             new CustomEventListener<StopRoutineAckDiscoveryMessage>() {
                 @Override public void onCustomEvent(ClusterNode snd,
-                    StopRoutineAckDiscoveryMessage msg,
-                    AffinityTopologyVersion topVer) {
+                    StopRoutineAckDiscoveryMessage msg) {
                     StopFuture fut = stopFuts.remove(msg.routineId());
 
                     if (fut != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartStopConcurrentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartStopConcurrentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartStopConcurrentTest.java
new file mode 100644
index 0000000..a208b07
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartStopConcurrentTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.Ignite;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.lang.IgniteRunnable;
+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;
+
+/**
+ *
+ */
+public class IgniteDynamicCacheStartStopConcurrentTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final int NODES = 4;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGridsMultiThreaded(NODES);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+
+        super.afterTestsStopped();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConcurrentStartStop() throws Exception {
+        checkTopologyVersion(new AffinityTopologyVersion(NODES, 0));
+
+        int minorVer = 0;
+
+        for (int i = 0; i < 5; i++) {
+            log.info("Iteration: " + i);
+
+            GridTestUtils.runMultiThreaded(new IgniteInClosure<Integer>() {
+                @Override public void apply(Integer idx) {
+                    Ignite ignite = ignite(idx);
+
+                    ignite.getOrCreateCache(new CacheConfiguration<>());
+                }
+            }, NODES, "cache-thread");
+
+            minorVer++;
+
+            checkTopologyVersion(new AffinityTopologyVersion(NODES, minorVer));
+
+            ignite(0).compute().affinityRun(null, 1, new IgniteRunnable() {
+                @Override public void run() {
+                    // No-op.
+                }
+            });
+
+            GridTestUtils.runMultiThreaded(new IgniteInClosure<Integer>() {
+                @Override public void apply(Integer idx) {
+                    Ignite ignite = ignite(idx);
+
+                    ignite.destroyCache(null);
+                }
+            }, NODES, "cache-thread");
+
+            minorVer++;
+
+            checkTopologyVersion(new AffinityTopologyVersion(NODES, minorVer));
+        }
+    }
+
+    /**
+     * @param topVer Expected version.
+     */
+    private void checkTopologyVersion(AffinityTopologyVersion topVer) {
+        for (int i = 0; i < NODES; i++) {
+            IgniteKernal ignite = (IgniteKernal)ignite(i);
+
+            assertEquals(ignite.name(), topVer, ignite.context().discovery().topologyVersionEx());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/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 7116227..26a8994 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
@@ -93,6 +93,7 @@ import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
@@ -586,6 +587,32 @@ public final class GridTestUtils {
     }
 
     /**
+     * @param call Closure that receives thread index.
+     * @param threadNum Number of threads.
+     * @param threadName Thread names.
+     * @return Execution time in milliseconds.
+     * @throws Exception If failed.
+     */
+    public static long runMultiThreaded(final IgniteInClosure<Integer> call, int threadNum, String threadName)
+        throws Exception {
+        List<Callable<?>> calls = new ArrayList<>(threadNum);
+
+        for (int i = 0; i < threadNum; i++) {
+            final int idx = i;
+
+            calls.add(new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    call.apply(idx);
+
+                    return null;
+                }
+            });
+        }
+
+        return runMultiThreaded(calls, threadName);
+    }
+
+    /**
      * Runs callable object in specified number of threads.
      *
      * @param call Callable.

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8814178/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 1b8eeda..04d0881 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
@@ -71,6 +71,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheTxStoreValueTest;
 import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheFilterTest;
 import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheStartNoExchangeTimeoutTest;
 import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheStartSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheStartStopConcurrentTest;
 import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheWithConfigStartSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteDynamicClientCacheStartSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteExchangeFutureHistoryTest;
@@ -204,6 +205,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteDynamicCacheStartSelfTest.class);
         suite.addTestSuite(IgniteDynamicCacheWithConfigStartSelfTest.class);
         suite.addTestSuite(IgniteCacheDynamicStopSelfTest.class);
+        suite.addTestSuite(IgniteDynamicCacheStartStopConcurrentTest.class);
         suite.addTestSuite(IgniteCacheConfigurationTemplateTest.class);
         suite.addTestSuite(IgniteCacheConfigurationDefaultTemplateTest.class);
         suite.addTestSuite(IgniteDynamicClientCacheStartSelfTest.class);


[08/29] ignite git commit: IGNITE-2206: Hadoop file system creation is now abstracted out using factory interface.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
index 99ca1ec..0d7de86 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
@@ -17,22 +17,6 @@
 
 package org.apache.ignite.hadoop.fs.v2;
 
-import java.io.BufferedOutputStream;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -43,6 +27,7 @@ import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileChecksum;
 import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FsServerDefaults;
 import org.apache.hadoop.fs.FsStatus;
 import org.apache.hadoop.fs.InvalidPathException;
@@ -51,13 +36,14 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.util.DataChecksum;
 import org.apache.hadoop.util.Progressable;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
 import org.apache.ignite.igfs.IgfsBlockLocation;
 import org.apache.ignite.igfs.IgfsFile;
 import org.apache.ignite.igfs.IgfsMode;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.igfs.common.IgfsLogger;
-import org.apache.ignite.internal.processors.hadoop.SecondaryFileSystemProvider;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsEndpoint;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsInputStream;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsOutputStream;
@@ -74,8 +60,26 @@ 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.lifecycle.LifecycleAware;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.BufferedOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 import static org.apache.ignite.configuration.FileSystemConfiguration.DFLT_IGFS_LOG_BATCH_SIZE;
 import static org.apache.ignite.configuration.FileSystemConfiguration.DFLT_IGFS_LOG_DIR;
 import static org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem.getFsHadoopUser;
@@ -92,8 +96,6 @@ import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_GROUP_NAME;
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PREFER_LOCAL_WRITES;
 import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_USER_NAME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_CONFIG_PATH;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.SECONDARY_FS_URI;
 
 /**
  * {@code IGFS} Hadoop 2.x file system driver over file system API. To use
@@ -168,8 +170,8 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
     /** Mode resolver. */
     private IgfsModeResolver modeRslvr;
 
-    /** Secondary file system instance. */
-    private AbstractFileSystem secondaryFs;
+    /** The secondary file system factory. */
+    private HadoopFileSystemFactory factory;
 
     /** Whether custom sequential reads before prefetch value is provided. */
     private boolean seqReadsBeforePrefetchOverride;
@@ -335,20 +337,27 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
             }
 
             if (initSecondary) {
-                Map<String, String> props = paths.properties();
+                try {
+                    factory = (HadoopFileSystemFactory) paths.getPayload(getClass().getClassLoader());
+                }
+                catch (IgniteCheckedException e) {
+                    throw new IOException("Failed to get secondary file system factory.", e);
+                }
 
-                String secUri = props.get(SECONDARY_FS_URI);
-                String secConfPath = props.get(SECONDARY_FS_CONFIG_PATH);
+                assert factory != null;
+
+                if (factory instanceof LifecycleAware)
+                    ((LifecycleAware) factory).start();
 
                 try {
-                    SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(secUri, secConfPath);
+                    FileSystem secFs = factory.get(user);
 
-                    secondaryFs = secProvider.createAbstractFileSystem(user);
+                    secondaryUri = secFs.getUri();
 
-                    secondaryUri = secProvider.uri();
+                    A.ensure(secondaryUri != null, "Secondary file system uri should not be null.");
                 }
                 catch (IOException e) {
-                    throw new IOException("Failed to connect to the secondary file system: " + secUri, e);
+                    throw new IOException("Failed to connect to the secondary file system: " + secondaryUri, e);
                 }
             }
         }
@@ -368,6 +377,9 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
             if (clientLog.isLogEnabled())
                 clientLog.close();
 
+            if (factory instanceof LifecycleAware)
+                ((LifecycleAware) factory).stop();
+
             // Reset initialized resources.
             rmtClient = null;
         }
@@ -391,13 +403,13 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
 
     /** {@inheritDoc} */
     @Override public boolean setReplication(Path f, short replication) throws IOException {
-        return mode(f) == PROXY && secondaryFs.setReplication(f, replication);
+        return mode(f) == PROXY && secondaryFileSystem().setReplication(f, replication);
     }
 
     /** {@inheritDoc} */
     @Override public void setTimes(Path f, long mtime, long atime) throws IOException {
         if (mode(f) == PROXY)
-            secondaryFs.setTimes(f, mtime, atime);
+            secondaryFileSystem().setTimes(f, mtime, atime);
         else {
             if (mtime == -1 && atime == -1)
                 return;
@@ -421,7 +433,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
             A.notNull(p, "p");
 
             if (mode(p) == PROXY)
-                secondaryFs.setPermission(toSecondary(p), perm);
+                secondaryFileSystem().setPermission(toSecondary(p), perm);
             else {
                 if (rmtClient.update(convert(p), permission(perm)) == null)
                     throw new IOException("Failed to set file permission (file not found?)" +
@@ -443,7 +455,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
 
         try {
             if (mode(p) == PROXY)
-                secondaryFs.setOwner(toSecondary(p), usr, grp);
+                secondaryFileSystem().setOwner(toSecondary(p), usr, grp);
             else if (rmtClient.update(convert(p), F.asMap(PROP_USER_NAME, usr, PROP_GROUP_NAME, grp)) == null)
                 throw new IOException("Failed to set file permission (file not found?)" +
                     " [path=" + p + ", username=" + usr + ", grpName=" + grp + ']');
@@ -464,11 +476,11 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
             IgfsMode mode = modeRslvr.resolveMode(path);
 
             if (mode == PROXY) {
-                FSDataInputStream is = secondaryFs.open(toSecondary(f), bufSize);
+                FSDataInputStream is = secondaryFileSystem().open(toSecondary(f), bufSize);
 
                 if (clientLog.isLogEnabled()) {
                     // At this point we do not know file size, so we perform additional request to remote FS to get it.
-                    FileStatus status = secondaryFs.getFileStatus(toSecondary(f));
+                    FileStatus status = secondaryFileSystem().getFileStatus(toSecondary(f));
 
                     long size = status != null ? status.getLen() : -1;
 
@@ -543,8 +555,8 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
                     path + ", overwrite=" + overwrite + ", bufSize=" + bufSize + ']');
 
             if (mode == PROXY) {
-                FSDataOutputStream os = secondaryFs.createInternal(toSecondary(f), flag, perm, bufSize,
-                    replication, blockSize, progress, checksumOpt, createParent);
+                FSDataOutputStream os = secondaryFileSystem().create(toSecondary(f), perm, flag, bufSize,
+                    replication, blockSize, progress);
 
                 if (clientLog.isLogEnabled()) {
                     long logId = IgfsLogger.nextId();
@@ -641,7 +653,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
                 if (clientLog.isLogEnabled())
                     clientLog.logRename(srcPath, PROXY, dstPath);
 
-                secondaryFs.renameInternal(toSecondary(src), toSecondary(dst));
+                secondaryFileSystem().rename(toSecondary(src), toSecondary(dst));
             }
             else {
                 if (clientLog.isLogEnabled())
@@ -671,7 +683,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
                 if (clientLog.isLogEnabled())
                     clientLog.logDelete(path, PROXY, recursive);
 
-                return secondaryFs.delete(toSecondary(f), recursive);
+                return secondaryFileSystem().delete(toSecondary(f), recursive);
             }
 
             boolean res = rmtClient.delete(path, recursive);
@@ -689,14 +701,14 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
     /** {@inheritDoc} */
     @Override public void setVerifyChecksum(boolean verifyChecksum) throws IOException {
         // Checksum has effect for secondary FS only.
-        if (secondaryFs != null)
-            secondaryFs.setVerifyChecksum(verifyChecksum);
+        if (factory != null)
+            secondaryFileSystem().setVerifyChecksum(verifyChecksum);
     }
 
     /** {@inheritDoc} */
     @Override public FileChecksum getFileChecksum(Path f) throws IOException {
         if (mode(f) == PROXY)
-            return secondaryFs.getFileChecksum(f);
+            return secondaryFileSystem().getFileChecksum(f);
 
         return null;
     }
@@ -712,7 +724,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
             IgfsMode mode = modeRslvr.resolveMode(path);
 
             if (mode == PROXY) {
-                FileStatus[] arr = secondaryFs.listStatus(toSecondary(f));
+                FileStatus[] arr = secondaryFileSystem().listStatus(toSecondary(f));
 
                 if (arr == null)
                     throw new FileNotFoundException("File " + f + " does not exist.");
@@ -775,7 +787,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
                 if (clientLog.isLogEnabled())
                     clientLog.logMakeDirectory(path, PROXY);
 
-                secondaryFs.mkdir(toSecondary(f), perm, createParent);
+                secondaryFileSystem().mkdirs(toSecondary(f), perm);
             }
             else {
                 rmtClient.mkdirs(path, permission(perm));
@@ -797,7 +809,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
 
         try {
             if (mode(f) == PROXY)
-                return toPrimary(secondaryFs.getFileStatus(toSecondary(f)));
+                return toPrimary(secondaryFileSystem().getFileStatus(toSecondary(f)));
             else {
                 IgfsFile info = rmtClient.info(convert(f));
 
@@ -822,7 +834,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
 
         try {
             if (modeRslvr.resolveMode(igfsPath) == PROXY)
-                return secondaryFs.getFileBlockLocations(path, start, len);
+                return secondaryFileSystem().getFileBlockLocations(path, start, len);
             else {
                 long now = System.currentTimeMillis();
 
@@ -873,7 +885,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
      * @return Secondary file system path.
      */
     private Path toSecondary(Path path) {
-        assert secondaryFs != null;
+        assert factory != null;
         assert secondaryUri != null;
 
         return convertPath(path, secondaryUri);
@@ -1045,4 +1057,15 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
     public String user() {
         return user;
     }
+
+    /**
+     * Gets cached or creates a {@link FileSystem}.
+     *
+     * @return The secondary file system.
+     */
+    private FileSystem secondaryFileSystem() throws IOException{
+        assert factory != null;
+
+        return factory.get(user);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java
deleted file mode 100644
index d5be074..0000000
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java
+++ /dev/null
@@ -1,139 +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.hadoop;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.security.PrivilegedExceptionAction;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.AbstractFileSystem;
-import org.apache.hadoop.fs.CommonConfigurationKeys;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.ignite.internal.processors.hadoop.fs.HadoopFileSystemsUtils;
-import org.apache.ignite.internal.processors.igfs.IgfsUtils;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Encapsulates logic of secondary filesystem creation.
- */
-public class SecondaryFileSystemProvider {
-    /** Configuration of the secondary filesystem, never null. */
-    private final Configuration cfg = HadoopUtils.safeCreateConfiguration();
-
-    /** The secondary filesystem URI, never null. */
-    private final URI uri;
-
-    /**
-     * Creates new provider with given config parameters. The configuration URL is optional. The filesystem URI must be
-     * specified either explicitly or in the configuration provided.
-     *
-     * @param secUri the secondary Fs URI (optional). If not given explicitly, it must be specified as "fs.defaultFS"
-     * property in the provided configuration.
-     * @param secConfPath the secondary Fs path (file path on the local file system, optional).
-     * See {@link IgniteUtils#resolveIgniteUrl(String)} on how the path resolved.
-     * @throws IOException
-     */
-    public SecondaryFileSystemProvider(final @Nullable String secUri,
-        final @Nullable String secConfPath) throws IOException {
-        if (secConfPath != null) {
-            URL url = U.resolveIgniteUrl(secConfPath);
-
-            if (url == null) {
-                // If secConfPath is given, it should be resolvable:
-                throw new IllegalArgumentException("Failed to resolve secondary file system configuration path " +
-                    "(ensure that it exists locally and you have read access to it): " + secConfPath);
-            }
-
-            cfg.addResource(url);
-        }
-
-        // if secondary fs URI is not given explicitly, try to get it from the configuration:
-        if (secUri == null)
-            uri = FileSystem.getDefaultUri(cfg);
-        else {
-            try {
-                uri = new URI(secUri);
-            }
-            catch (URISyntaxException use) {
-                throw new IOException("Failed to resolve secondary file system URI: " + secUri);
-            }
-        }
-
-        // Disable caching:
-        String prop = HadoopFileSystemsUtils.disableFsCachePropertyName(uri.getScheme());
-
-        cfg.setBoolean(prop, true);
-    }
-
-    /**
-     * @return {@link org.apache.hadoop.fs.FileSystem}  instance for this secondary Fs.
-     * @throws IOException
-     */
-    public FileSystem createFileSystem(String userName) throws IOException {
-        userName = IgfsUtils.fixUserName(userName);
-
-        final FileSystem fileSys;
-
-        try {
-           fileSys = FileSystem.get(uri, cfg, userName);
-        }
-        catch (InterruptedException e) {
-           Thread.currentThread().interrupt();
-
-           throw new IOException("Failed to create file system due to interrupt.", e);
-        }
-
-        return fileSys;
-    }
-
-    /**
-     * @return {@link org.apache.hadoop.fs.AbstractFileSystem} instance for this secondary Fs.
-     * @throws IOException in case of error.
-     */
-    public AbstractFileSystem createAbstractFileSystem(String userName) throws IOException {
-        userName = IgfsUtils.fixUserName(userName);
-
-        String ticketCachePath = cfg.get(CommonConfigurationKeys.KERBEROS_TICKET_CACHE_PATH);
-
-        UserGroupInformation ugi = UserGroupInformation.getBestUGI(ticketCachePath, userName);
-
-        try {
-            return ugi.doAs(new PrivilegedExceptionAction<AbstractFileSystem>() {
-                @Override public AbstractFileSystem run() throws IOException {
-                    return AbstractFileSystem.get(uri, cfg);
-                }
-            });
-        } catch (InterruptedException ie) {
-            Thread.currentThread().interrupt();
-
-            throw new IOException("Failed to create file system due to interrupt.", ie);
-        }
-    }
-
-    /**
-     * @return the secondary fs URI, never null.
-     */
-    public URI uri() {
-        return uri;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopFileSystemCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopFileSystemCacheUtils.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopFileSystemCacheUtils.java
index 48ade79..1ecbee5 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopFileSystemCacheUtils.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopFileSystemCacheUtils.java
@@ -39,7 +39,7 @@ public class HadoopFileSystemCacheUtils {
     public static HadoopLazyConcurrentMap<FsCacheKey, FileSystem> createHadoopLazyConcurrentMap() {
         return new HadoopLazyConcurrentMap<>(
             new HadoopLazyConcurrentMap.ValueFactory<FsCacheKey, FileSystem>() {
-                @Override public FileSystem createValue(FsCacheKey key) {
+                @Override public FileSystem createValue(FsCacheKey key) throws IOException {
                     try {
                         assert key != null;
 
@@ -57,8 +57,10 @@ public class HadoopFileSystemCacheUtils {
 
                         return FileSystem.get(uri, cfg, key.user());
                     }
-                    catch (IOException | InterruptedException ioe) {
-                        throw new IgniteException(ioe);
+                    catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+
+                        throw new IOException("Failed to create file system due to interrupt.", e);
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java
index 89eaf73..681cddb 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.hadoop.fs;
 
 import java.io.Closeable;
+import java.io.IOException;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.ReadWriteLock;
@@ -204,8 +205,8 @@ public class HadoopLazyConcurrentMap<K, V extends Closeable> {
          *
          * @param key the key to create value for
          * @return the value.
-         * @throws IgniteException on failure.
+         * @throws IOException On failure.
          */
-        public V createValue(K key);
+        public V createValue(K key) throws IOException;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
index ea65464..10b1bcd 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
@@ -19,7 +19,7 @@ package org.apache.ignite.igfs;
 
 import java.io.IOException;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
+import org.apache.ignite.hadoop.fs.CachingHadoopFileSystemFactory;
 import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
 import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
 import org.apache.ignite.internal.processors.igfs.IgfsDualAbstractSelfTest;
@@ -74,12 +74,16 @@ public abstract class Hadoop1DualAbstractTest extends IgfsDualAbstractSelfTest {
 
         prepareConfiguration();
 
-        IgniteHadoopIgfsSecondaryFileSystem second =
-            new IgniteHadoopIgfsSecondaryFileSystem(secondaryUri, secondaryConfFullPath);
+        CachingHadoopFileSystemFactory factory = new CachingHadoopFileSystemFactory();
 
-        FileSystem fileSystem = second.fileSystem();
+        factory.setUri(secondaryUri);
+        factory.setConfigPaths(secondaryConfFullPath);
 
-        igfsSecondary = new HadoopFileSystemUniversalFileSystemAdapter(fileSystem);
+        IgniteHadoopIgfsSecondaryFileSystem second = new IgniteHadoopIgfsSecondaryFileSystem();
+
+        second.setFileSystemFactory(factory);
+
+        igfsSecondary = new HadoopFileSystemUniversalFileSystemAdapter(factory);
 
         return second;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
new file mode 100644
index 0000000..1d02f0f
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
@@ -0,0 +1,326 @@
+/*
+ * 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.igfs;
+
+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.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.hadoop.fs.CachingHadoopFileSystemFactory;
+import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
+import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
+import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
+import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
+import org.apache.ignite.internal.processors.igfs.IgfsEx;
+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.GridTestUtils;
+import org.jetbrains.annotations.Nullable;
+import java.io.Externalizable;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URI;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+
+/**
+ * Tests for Hadoop file system factory.
+ */
+public class HadoopFIleSystemFactorySelfTest extends IgfsCommonAbstractTest {
+    /** Amount of "start" invocations */
+    private static final AtomicInteger START_CNT = new AtomicInteger();
+
+    /** Amount of "stop" invocations */
+    private static final AtomicInteger STOP_CNT = new AtomicInteger();
+
+    /** Path to secondary file system configuration. */
+    private static final String SECONDARY_CFG_PATH = "/work/core-site-HadoopFIleSystemFactorySelfTest.xml";
+
+    /** IGFS path for DUAL mode. */
+    private static final Path PATH_DUAL = new Path("/ignite/sync/test_dir");
+
+    /** IGFS path for PROXY mode. */
+    private static final Path PATH_PROXY = new Path("/ignite/proxy/test_dir");
+
+    /** IGFS path for DUAL mode. */
+    private static final IgfsPath IGFS_PATH_DUAL = new IgfsPath("/ignite/sync/test_dir");
+
+    /** IGFS path for PROXY mode. */
+    private static final IgfsPath IGFS_PATH_PROXY = new IgfsPath("/ignite/proxy/test_dir");
+
+    /** Secondary IGFS. */
+    private IgfsEx secondary;
+
+    /** Primary IGFS. */
+    private IgfsEx primary;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        START_CNT.set(0);
+        STOP_CNT.set(0);
+
+        secondary = startSecondary();
+        primary = startPrimary();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        secondary = null;
+        primary = null;
+
+        stopAllGrids();
+    }
+
+    /**
+     * Test custom factory.
+     *
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+    public void testCustomFactory() throws Exception {
+        assert START_CNT.get() == 1;
+        assert STOP_CNT.get() == 0;
+
+        // Use IGFS directly.
+        primary.mkdirs(IGFS_PATH_DUAL);
+
+        assert primary.exists(IGFS_PATH_DUAL);
+        assert secondary.exists(IGFS_PATH_DUAL);
+
+        GridTestUtils.assertThrows(null, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                primary.mkdirs(IGFS_PATH_PROXY);
+
+                return null;
+            }
+        }, IgfsInvalidPathException.class, null);
+
+        // Create remote instance.
+        FileSystem fs = FileSystem.get(URI.create("igfs://primary:primary@127.0.0.1:10500/"), baseConfiguration());
+
+        // Ensure lifecycle callback was invoked.
+        assert START_CNT.get() == 2;
+        assert STOP_CNT.get() == 0;
+
+        // Check file system operations.
+        assert fs.exists(PATH_DUAL);
+
+        assert fs.delete(PATH_DUAL, true);
+        assert !primary.exists(IGFS_PATH_DUAL);
+        assert !secondary.exists(IGFS_PATH_DUAL);
+        assert !fs.exists(PATH_DUAL);
+
+        assert fs.mkdirs(PATH_DUAL);
+        assert primary.exists(IGFS_PATH_DUAL);
+        assert secondary.exists(IGFS_PATH_DUAL);
+        assert fs.exists(PATH_DUAL);
+
+        assert fs.mkdirs(PATH_PROXY);
+        assert secondary.exists(IGFS_PATH_PROXY);
+        assert fs.exists(PATH_PROXY);
+
+        // Close file system and ensure that associated factory was notified.
+        fs.close();
+
+        assert START_CNT.get() == 2;
+        assert STOP_CNT.get() == 1;
+
+        // Stop primary node and ensure that base factory was notified.
+        G.stop(primary.context().kernalContext().grid().name(), true);
+
+        assert START_CNT.get() == 2;
+        assert STOP_CNT.get() == 2;
+    }
+
+    /**
+     * Start secondary IGFS.
+     *
+     * @return IGFS.
+     * @throws Exception If failed.
+     */
+    private static IgfsEx startSecondary() throws Exception {
+        return start("secondary", 11500, IgfsMode.PRIMARY, null);
+    }
+
+    /**
+     * Start primary IGFS.
+     *
+     * @return IGFS.
+     * @throws Exception If failed.
+     */
+    private static IgfsEx startPrimary() throws Exception {
+        // Prepare configuration.
+        Configuration conf = baseConfiguration();
+
+        conf.set("fs.defaultFS", "igfs://secondary:secondary@127.0.0.1:11500/");
+
+        writeConfigurationToFile(conf);
+
+        // Configure factory.
+        TestFactory factory = new TestFactory();
+
+        factory.setUri("igfs://secondary:secondary@127.0.0.1:11500/");
+        factory.setConfigPaths(SECONDARY_CFG_PATH);
+
+        // Configure file system.
+        IgniteHadoopIgfsSecondaryFileSystem fs = new IgniteHadoopIgfsSecondaryFileSystem();
+
+        fs.setFileSystemFactory(factory);
+
+        // Start.
+        return start("primary", 10500, IgfsMode.PRIMARY, fs);
+    }
+
+    /**
+     * Start Ignite node with IGFS instance.
+     *
+     * @param name Node and IGFS name.
+     * @param endpointPort Endpoint port.
+     * @param dfltMode Default path mode.
+     * @param secondaryFs Secondary file system.
+     * @return Igfs instance.
+     */
+    private static IgfsEx start(String name, int endpointPort, IgfsMode dfltMode,
+        @Nullable IgfsSecondaryFileSystem secondaryFs) {
+        IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();
+
+        endpointCfg.setType(IgfsIpcEndpointType.TCP);
+        endpointCfg.setHost("127.0.0.1");
+        endpointCfg.setPort(endpointPort);
+
+        FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
+
+        igfsCfg.setDataCacheName("dataCache");
+        igfsCfg.setMetaCacheName("metaCache");
+        igfsCfg.setName(name);
+        igfsCfg.setDefaultMode(dfltMode);
+        igfsCfg.setIpcEndpointConfiguration(endpointCfg);
+        igfsCfg.setSecondaryFileSystem(secondaryFs);
+
+        CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
+
+        dataCacheCfg.setName("dataCache");
+        dataCacheCfg.setCacheMode(PARTITIONED);
+        dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
+        dataCacheCfg.setBackups(0);
+        dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
+        dataCacheCfg.setOffHeapMaxMemory(0);
+
+        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
+
+        metaCacheCfg.setName("metaCache");
+        metaCacheCfg.setCacheMode(REPLICATED);
+        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setGridName(name);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+
+        cfg.setDiscoverySpi(discoSpi);
+        cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
+        cfg.setFileSystemConfiguration(igfsCfg);
+
+        cfg.setLocalHost("127.0.0.1");
+        cfg.setConnectorConfiguration(null);
+
+        return (IgfsEx)G.start(cfg).fileSystem(name);
+    }
+
+    /**
+     * Create base FileSystem configuration.
+     *
+     * @return Configuration.
+     */
+    private static Configuration baseConfiguration() {
+        Configuration conf = new Configuration();
+
+        conf.set("fs.igfs.impl", IgniteHadoopFileSystem.class.getName());
+
+        return conf;
+    }
+
+    /**
+     * Write configuration to file.
+     *
+     * @param conf Configuration.
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ResultOfMethodCallIgnored")
+    private static void writeConfigurationToFile(Configuration conf) throws Exception {
+        final String path = U.getIgniteHome() + SECONDARY_CFG_PATH;
+
+        File file = new File(path);
+
+        file.delete();
+
+        assertFalse(file.exists());
+
+        try (FileOutputStream fos = new FileOutputStream(file)) {
+            conf.writeXml(fos);
+        }
+
+        assertTrue(file.exists());
+    }
+
+    /**
+     * Test factory.
+     */
+    private static class TestFactory extends CachingHadoopFileSystemFactory {
+        /**
+         * {@link Externalizable} support.
+         */
+        public TestFactory() {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void start() throws IgniteException {
+            START_CNT.incrementAndGet();
+
+            super.start();
+        }
+
+        /** {@inheritDoc} */
+        @Override public void stop() throws IgniteException {
+            STOP_CNT.incrementAndGet();
+
+            super.stop();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
index 608bd25..5b6fd81 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
@@ -26,6 +26,8 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils;
 import org.apache.ignite.internal.processors.igfs.IgfsEx;
 import org.apache.ignite.internal.processors.igfs.UniversalFileSystemAdapter;
@@ -34,55 +36,55 @@ import org.apache.ignite.internal.processors.igfs.UniversalFileSystemAdapter;
  * Universal adapter wrapping {@link org.apache.hadoop.fs.FileSystem} instance.
  */
 public class HadoopFileSystemUniversalFileSystemAdapter implements UniversalFileSystemAdapter {
-    /** The wrapped filesystem. */
-    private final FileSystem fileSys;
+    /** File system factory. */
+    private final HadoopFileSystemFactory factory;
 
     /**
      * Constructor.
-     * @param fs the filesystem to be wrapped.
+     * @param factory File system factory.
      */
-    public HadoopFileSystemUniversalFileSystemAdapter(FileSystem fs) {
-        this.fileSys = fs;
+    public HadoopFileSystemUniversalFileSystemAdapter(HadoopFileSystemFactory factory) {
+        assert factory != null;
+
+        this.factory = factory;
     }
 
     /** {@inheritDoc} */
-    @Override public String name() {
-        return fileSys.getUri().toString();
+    @Override public String name() throws IOException {
+        return get().getUri().toString();
     }
 
     /** {@inheritDoc} */
     @Override public boolean exists(String path) throws IOException {
-        return fileSys.exists(new Path(path));
+        return get().exists(new Path(path));
     }
 
     /** {@inheritDoc} */
     @Override public boolean delete(String path, boolean recursive) throws IOException {
-        boolean ok = fileSys.delete(new Path(path), recursive);
-        return ok;
+        return get().delete(new Path(path), recursive);
     }
 
     /** {@inheritDoc} */
     @Override public void mkdirs(String path) throws IOException {
-        boolean ok = fileSys.mkdirs(new Path(path));
+        boolean ok = get().mkdirs(new Path(path));
         if (!ok)
             throw new IOException("Failed to mkdirs: " + path);
     }
 
     /** {@inheritDoc} */
     @Override public void format() throws IOException {
-        HadoopIgfsUtils.clear(fileSys);
+        HadoopIgfsUtils.clear(get());
     }
 
     /** {@inheritDoc} */
     @Override public Map<String, String> properties(String path) throws IOException {
         Path p = new Path(path);
 
-        FileStatus status = fileSys.getFileStatus(p);
+        FileStatus status = get().getFileStatus(p);
 
         Map<String,String> m = new HashMap<>(3); // max size == 4
 
         m.put(IgfsEx.PROP_USER_NAME, status.getOwner());
-
         m.put(IgfsEx.PROP_GROUP_NAME, status.getGroup());
 
         FsPermission perm = status.getPermission();
@@ -95,7 +97,7 @@ public class HadoopFileSystemUniversalFileSystemAdapter implements UniversalFile
 
     /** {@inheritDoc} */
     @Override public InputStream openInputStream(String path) throws IOException {
-        return fileSys.open(new Path(path));
+        return get().open(new Path(path));
     }
 
     /** {@inheritDoc} */
@@ -103,16 +105,27 @@ public class HadoopFileSystemUniversalFileSystemAdapter implements UniversalFile
         Path p = new Path(path);
 
         if (append)
-            return fileSys.append(p);
+            return get().append(p);
         else
-            return fileSys.create(p, true/*overwrite*/);
+            return get().create(p, true/*overwrite*/);
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T getAdapter(Class<T> clazz) {
-        if (clazz == FileSystem.class)
-            return (T)fileSys;
+    @SuppressWarnings("unchecked")
+    @Override public <T> T unwrap(Class<T> cls) {
+        if (HadoopFileSystemFactory.class.isAssignableFrom(cls))
+            return (T)factory;
 
         return null;
     }
+
+    /**
+     * Create file system.
+     *
+     * @return File system.
+     * @throws IOException If failed.
+     */
+    private FileSystem get() throws IOException {
+        return factory.get(FileSystemConfiguration.DFLT_USER_NAME);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
index 4ddfb0d..d9b5d66 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
@@ -17,12 +17,6 @@
 
 package org.apache.ignite.igfs;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.Callable;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileStatus;
@@ -34,9 +28,9 @@ import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.hadoop.fs.CachingHadoopFileSystemFactory;
 import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
 import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
-import org.apache.ignite.internal.processors.hadoop.SecondaryFileSystemProvider;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils;
 import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
 import org.apache.ignite.internal.util.typedef.G;
@@ -48,6 +42,13 @@ 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 java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.util.concurrent.Callable;
+
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -173,12 +174,16 @@ public class HadoopSecondaryFileSystemConfigurationTest extends IgfsCommonAbstra
         else
             primaryConfFullPath = null;
 
-        SecondaryFileSystemProvider provider =
-            new SecondaryFileSystemProvider(primaryFsUriStr, primaryConfFullPath);
+        CachingHadoopFileSystemFactory fac = new CachingHadoopFileSystemFactory();
+
+        fac.setConfigPaths(primaryConfFullPath);
+        fac.setUri(primaryFsUriStr);
+
+        fac.start();
 
-        primaryFs = provider.createFileSystem(null);
+        primaryFs = fac.get(null); //provider.createFileSystem(null);
 
-        primaryFsUri = provider.uri();
+        primaryFsUri = primaryFs.getUri();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
index d368955..6617127 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
@@ -17,29 +17,6 @@
 
 package org.apache.ignite.igfs;
 
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.reflect.Field;
-import java.net.URI;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayDeque;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Deque;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.BlockLocation;
 import org.apache.hadoop.fs.ContentSummary;
@@ -59,6 +36,7 @@ import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.hadoop.fs.CachingHadoopFileSystemFactory;
 import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
 import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
 import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsEx;
@@ -70,6 +48,7 @@ import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.F;
 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.lang.IgniteBiTuple;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -79,6 +58,30 @@ import org.apache.ignite.testframework.GridTestUtils;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ThreadLocalRandom8;
 
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Deque;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -380,9 +383,20 @@ public abstract class IgniteHadoopFileSystemAbstractSelfTest extends IgfsCommonA
         cfg.setPrefetchBlocks(1);
         cfg.setDefaultMode(mode);
 
-        if (mode != PRIMARY)
-            cfg.setSecondaryFileSystem(new IgniteHadoopIgfsSecondaryFileSystem(
-                SECONDARY_URI, SECONDARY_CFG_PATH, SECONDARY_FS_USER));
+        if (mode != PRIMARY) {
+            CachingHadoopFileSystemFactory fac = new CachingHadoopFileSystemFactory();
+
+            fac.setUri(SECONDARY_URI);
+            fac.setConfigPaths(SECONDARY_CFG_PATH);
+
+            IgniteHadoopIgfsSecondaryFileSystem sec = new IgniteHadoopIgfsSecondaryFileSystem();
+
+            sec.setFileSystemFactory(fac);
+            sec.setDefaultUserName(SECONDARY_FS_USER);
+
+            // NB: start() will be invoked upon IgfsImpl init.
+            cfg.setSecondaryFileSystem(sec);
+        }
 
         cfg.setIpcEndpointConfiguration(primaryIpcEndpointConfiguration(gridName));
 
@@ -398,7 +412,8 @@ public abstract class IgniteHadoopFileSystemAbstractSelfTest extends IgfsCommonA
             @Override public Object call() throws Exception {
                 return new IgniteHadoopFileSystem().getUri();
             }
-        }, IllegalStateException.class, "URI is null (was IgniteHadoopFileSystem properly initialized?).");
+        }, IllegalStateException.class,
+            "URI is null (was IgniteHadoopFileSystem properly initialized?)");
     }
 
     /** @throws Exception If failed. */
@@ -506,7 +521,7 @@ public abstract class IgniteHadoopFileSystemAbstractSelfTest extends IgfsCommonA
                 // Ensure that IO is stopped when nobody else is need it.
                 fs.close();
 
-                assertEquals(initSize - 1, cache.size());
+                assert initSize >= cache.size();
 
                 assert (Boolean)stopField.get(io);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ed73b4a/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 6c542b5..9092f32 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
@@ -37,6 +37,7 @@ import org.apache.ignite.client.hadoop.HadoopClientProtocolEmbeddedSelfTest;
 import org.apache.ignite.client.hadoop.HadoopClientProtocolSelfTest;
 import org.apache.ignite.igfs.Hadoop1OverIgfsDualAsyncTest;
 import org.apache.ignite.igfs.Hadoop1OverIgfsDualSyncTest;
+import org.apache.ignite.igfs.HadoopFIleSystemFactorySelfTest;
 import org.apache.ignite.igfs.HadoopIgfs20FileSystemLoopbackPrimarySelfTest;
 import org.apache.ignite.igfs.HadoopIgfsDualAsyncSelfTest;
 import org.apache.ignite.igfs.HadoopIgfsDualSyncSelfTest;
@@ -113,6 +114,8 @@ public class IgniteHadoopTestSuite extends TestSuite {
         suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsDualSyncTest.class.getName())));
         suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsDualAsyncTest.class.getName())));
 
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopFIleSystemFactorySelfTest.class.getName())));
+
         suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalPrimarySelfTest.class.getName())));
         suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalSecondarySelfTest.class.getName())));
         suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalDualSyncSelfTest.class.getName())));


[18/29] ignite git commit: Changed copyright from 2015 to 2016

Posted by vo...@apache.org.
Changed copyright from 2015 to 2016


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

Branch: refs/heads/ignite-2236
Commit: 2d106303ab406aec98265b0ae2bd07c7862d0f23
Parents: 7175a42
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Jan 14 10:17:07 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Jan 14 10:17:07 2016 +0300

----------------------------------------------------------------------
 .../main/java/org/apache/ignite/internal/IgniteVersionUtils.java | 4 ++--
 .../org/apache/ignite/startup/GridRandomCommandLineLoader.java   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2d106303/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java
index 02cbc81..bd8726f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java
@@ -47,7 +47,7 @@ public class IgniteVersionUtils {
     public static final String ACK_VER_STR;
 
     /** Copyright blurb. */
-    public static final String COPYRIGHT = "2015 Copyright(C) Apache Software Foundation";
+    public static final String COPYRIGHT = "2016 Copyright(C) Apache Software Foundation";
 
     /**
      * Static initializer.
@@ -77,4 +77,4 @@ public class IgniteVersionUtils {
     private IgniteVersionUtils() {
         // No-op.
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2d106303/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java b/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java
index 20d1b32..13c38ef 100644
--- a/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java
+++ b/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java
@@ -61,7 +61,7 @@ public final class GridRandomCommandLineLoader {
     private static final String IGNITE_PROG_NAME = "IGNITE_PROG_NAME";
 
     /** Copyright text. Ant processed. */
-    private static final String COPYRIGHT = "2015 Copyright(C) Apache Software Foundation.";
+    private static final String COPYRIGHT = "2016 Copyright(C) Apache Software Foundation.";
 
     /** Version. Ant processed. */
     private static final String VER = "x.x.x";
@@ -408,4 +408,4 @@ public final class GridRandomCommandLineLoader {
 
         return options;
     }
-}
\ No newline at end of file
+}


[19/29] ignite git commit: fixes to javadoc

Posted by vo...@apache.org.
fixes to javadoc


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

Branch: refs/heads/ignite-2236
Commit: 59cfbfdea535539227fd02ac2966a8f5dc42ead6
Parents: 59a893c
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Jan 14 12:54:48 2016 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Jan 14 12:54:48 2016 +0300

----------------------------------------------------------------------
 .../discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java  | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/59cfbfde/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java
index 1e112c4..d277a3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java
@@ -61,9 +61,17 @@ public interface TcpDiscoveryIpFinder {
     /**
      * Checks whether IP finder is shared or not.
      * <p>
-     * If it is shared then only coordinator can unregister addresses.
+     * If this property is set to {@code true} then IP finder allows to add and remove
+     * addresses in runtime and this is how, for example, IP finder should work in
+     * Amazon EC2 environment or any other environment where IPs may not be known beforehand.
      * <p>
-     * All nodes should register their address themselves, as early as possible on node start.
+     * If this property is set to {@code false} then IP finder is immutable and all the addresses
+     * should be listed in configuration before Ignite start. This is the most use case for IP finders
+     * local to current VM. Since, usually such IP finders are created per each Ignite instance and
+     * all the known IPs are listed right away, but there is also an option to make such IP finders shared
+     * by setting this property to {@code true} and literally share it between local VM Ignite instances.
+     * This way user does not have to list any IPs before start, instead all starting nodes add their addresses
+     * to the finder, then get the registered addresses and continue with discovery procedure.
      *
      * @return {@code true} if IP finder is shared.
      */
@@ -95,4 +103,4 @@ public interface TcpDiscoveryIpFinder {
      * Closes this IP finder and releases any system resources associated with it.
      */
     public void close();
-}
\ No newline at end of file
+}


[10/29] ignite git commit: Merge branch 'ignite-1.5.1-2'

Posted by vo...@apache.org.
Merge branch 'ignite-1.5.1-2'


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

Branch: refs/heads/ignite-2236
Commit: 10012b4ef96f2ae727dc27c28185938d016ab9e3
Parents: 8ed73b4 cca90c7
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jan 5 11:03:06 2016 +0400
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jan 5 11:03:06 2016 +0400

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