You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2015/09/30 05:01:25 UTC

[01/41] ignite git commit: ignite-1524 Fixed processing of ClientReconnectMessage

Repository: ignite
Updated Branches:
  refs/heads/ignite-1168 124c492f6 -> 3a322c055


ignite-1524 Fixed processing of ClientReconnectMessage


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

Branch: refs/heads/ignite-1168
Commit: 04f4f54a7ff1d43fa3baf4fa07865a8163796a82
Parents: 1942d75
Author: sboikov <sb...@gridgain.com>
Authored: Wed Sep 23 09:31:59 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Sep 23 09:31:59 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 97 +++++++++++---------
 ...lientDiscoverySpiFailureTimeoutSelfTest.java | 33 +++++--
 2 files changed, 81 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/04f4f54a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 4ce46e8..8a205d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -2958,70 +2958,81 @@ class ServerImpl extends TcpDiscoveryImpl {
          * @param msg Client reconnect message.
          */
         private void processClientReconnectMessage(TcpDiscoveryClientReconnectMessage msg) {
+            UUID nodeId = msg.creatorNodeId();
+
             UUID locNodeId = getLocalNodeId();
 
             boolean isLocNodeRouter = locNodeId.equals(msg.routerNodeId());
 
             if (!msg.verified()) {
-                assert isLocNodeRouter;
-
-                msg.verify(locNodeId);
+                TcpDiscoveryNode node = ring.node(nodeId);
 
-                if (ring.hasRemoteNodes()) {
-                    sendMessageAcrossRing(msg);
+                assert node == null || node.isClient();
 
-                    return;
+                if (node != null) {
+                    node.clientRouterNodeId(msg.routerNodeId());
+                    node.aliveCheck(spi.maxMissedClientHbs);
                 }
-            }
-
-            UUID nodeId = msg.creatorNodeId();
 
-            TcpDiscoveryNode node = ring.node(nodeId);
+                if (isLocalNodeCoordinator()) {
+                    msg.verify(locNodeId);
 
-            assert node == null || node.isClient();
+                    if (node != null) {
+                        Collection<TcpDiscoveryAbstractMessage> pending = msgHist.messages(msg.lastMessageId(), node);
 
-            if (node != null) {
-                assert node.isClient();
+                        if (pending != null) {
+                            msg.pendingMessages(pending);
+                            msg.success(true);
 
-                node.clientRouterNodeId(msg.routerNodeId());
-                node.aliveCheck(spi.maxMissedClientHbs);
+                            if (log.isDebugEnabled())
+                                log.debug("Accept client reconnect, restored pending messages " +
+                                    "[locNodeId=" + locNodeId + ", clientNodeId=" + nodeId + ']');
+                        }
+                        else {
+                            if (log.isDebugEnabled())
+                                log.debug("Failing reconnecting client node because failed to restore pending " +
+                                    "messages [locNodeId=" + locNodeId + ", clientNodeId=" + nodeId + ']');
 
-                if (isLocalNodeCoordinator()) {
-                    Collection<TcpDiscoveryAbstractMessage> pending = msgHist.messages(msg.lastMessageId(), node);
+                            processNodeFailedMessage(new TcpDiscoveryNodeFailedMessage(locNodeId,
+                                node.id(), node.internalOrder()));
+                        }
+                    }
+                    else if (log.isDebugEnabled())
+                        log.debug("Reconnecting client node is already failed [nodeId=" + nodeId + ']');
 
-                    if (pending != null) {
-                        msg.pendingMessages(pending);
-                        msg.success(true);
+                    if (isLocNodeRouter) {
+                        ClientMessageWorker wrk = clientMsgWorkers.get(nodeId);
 
-                        if (log.isDebugEnabled())
-                            log.debug("Accept client reconnect, restored pending messages " +
-                                "[locNodeId=" + locNodeId + ", clientNodeId=" + nodeId + ']');
+                        if (wrk != null)
+                            wrk.addMessage(msg);
+                        else if (log.isDebugEnabled())
+                            log.debug("Failed to reconnect client node (disconnected during the process) [locNodeId=" +
+                                locNodeId + ", clientNodeId=" + nodeId + ']');
                     }
                     else {
-                        if (log.isDebugEnabled())
-                            log.debug("Failing reconnecting client node because failed to restore pending " +
-                                "messages [locNodeId=" + locNodeId + ", clientNodeId=" + nodeId + ']');
-
-                        processNodeFailedMessage(new TcpDiscoveryNodeFailedMessage(locNodeId,
-                            node.id(), node.internalOrder()));
+                        if (ring.hasRemoteNodes())
+                            sendMessageAcrossRing(msg);
                     }
                 }
-            }
-            else if (log.isDebugEnabled())
-                log.debug("Reconnecting client node is already failed [nodeId=" + nodeId + ']');
-
-            if (isLocNodeRouter) {
-                ClientMessageWorker wrk = clientMsgWorkers.get(nodeId);
-
-                if (wrk != null)
-                    wrk.addMessage(msg);
-                else if (log.isDebugEnabled())
-                    log.debug("Failed to reconnect client node (disconnected during the process) [locNodeId=" +
-                        locNodeId + ", clientNodeId=" + nodeId + ']');
+                else {
+                    if (ring.hasRemoteNodes())
+                        sendMessageAcrossRing(msg);
+                }
             }
             else {
-                if (ring.hasRemoteNodes())
-                    sendMessageAcrossRing(msg);
+                if (isLocNodeRouter) {
+                    ClientMessageWorker wrk = clientMsgWorkers.get(nodeId);
+
+                    if (wrk != null)
+                        wrk.addMessage(msg);
+                    else if (log.isDebugEnabled())
+                        log.debug("Failed to reconnect client node (disconnected during the process) [locNodeId=" +
+                            locNodeId + ", clientNodeId=" + nodeId + ']');
+                }
+                else {
+                    if (ring.hasRemoteNodes() && !locNodeId.equals(msg.verifierNodeId()))
+                        sendMessageAcrossRing(msg);
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/04f4f54a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java
index 14417c1..344efc0 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java
@@ -21,7 +21,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.Socket;
 import java.net.SocketTimeoutException;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
@@ -170,11 +172,26 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testClientReconnectOnCoordinatorRouterFail1() throws Exception {
+        clientReconnectOnCoordinatorRouterFail(1);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClientReconnectOnCoordinatorRouterFail2() throws Exception {
+        clientReconnectOnCoordinatorRouterFail(2);
+    }
+
+    /**
      * Test tries to provoke scenario when client sends reconnect message before router failure detected.
      *
+     * @param srvNodes Number of additional server nodes.
      * @throws Exception If failed.
      */
-    public void _testClientReconnectOnCoordinatorRouterFail() throws Exception {
+    public void clientReconnectOnCoordinatorRouterFail(int srvNodes) throws Exception {
         startServerNodes(1);
 
         Ignite srv = G.ignite("server-0");
@@ -189,24 +206,28 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
             Collections.singleton("localhost:" + srvNode.discoveryPort() + ".." + (srvNode.discoveryPort() + 1)));
 
         failureThreshold = 1000L;
-        netTimeout = 500L;
+        netTimeout = 1000L;
 
         startClientNodes(1); // Client should connect to coordinator.
 
         failureThreshold = 10_000L;
         netTimeout = 5000L;
 
-        for (int i = 0; i < 2; i++) {
+        List<String> nodes = new ArrayList<>();
+
+        for (int i = 0; i < srvNodes; i++) {
             Ignite g = startGrid("server-" + srvIdx.getAndIncrement());
 
+            nodes.add(g.name());
+
             srvNodeIds.add(g.cluster().localNode().id());
         }
 
-        checkNodes(3, 1);
+        checkNodes(1 + srvNodes, 1);
 
-        final CountDownLatch latch = new CountDownLatch(3);
+        nodes.add("client-0");
 
-        String nodes[] = {"server-1", "server-2", "client-0"};
+        final CountDownLatch latch = new CountDownLatch(nodes.size());
 
         final AtomicBoolean err = new AtomicBoolean();
 


[40/41] ignite git commit: ignite-1168 Fixed after review.

Posted by an...@apache.org.
ignite-1168 Fixed after review.


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

Branch: refs/heads/ignite-1168
Commit: 6acba08e07b581eb5066f0a03c31ef29e4723773
Parents: 66b91b9
Author: Andrey <an...@gridgain.com>
Authored: Wed Sep 30 10:01:15 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Wed Sep 30 10:01:15 2015 +0700

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 160 ++++++++++++++++++-
 .../discovery/GridDiscoveryManager.java         |  29 ++--
 .../processors/cache/GridCacheProcessor.java    |   8 +-
 .../handlers/cache/GridCacheCommandHandler.java |  40 ++++-
 .../top/GridTopologyCommandHandler.java         |  22 ++-
 5 files changed, 223 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6acba08e/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index cc28536..9aa10b7 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -24,6 +24,7 @@ import java.io.Serializable;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -31,15 +32,24 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.regex.Pattern;
+import net.sf.json.JSONNull;
 import net.sf.json.JSONObject;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
 import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.testframework.GridTestUtils;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT;
@@ -901,10 +911,16 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     }
 
     /**
+     * @param meta Metadata for Ignite cache.
      * @throws Exception If failed.
      */
-    public void testMetadata() throws Exception {
-        String ret = content(F.asMap("cmd", GridRestCommand.CACHE_METADATA.key()));
+    private void testMetadata(GridCacheSqlMetadata meta) throws Exception {
+        Map<String, String> params = F.asMap("cmd", GridRestCommand.CACHE_METADATA.key());
+
+        if (meta.cacheName() != null)
+            params.put("cacheName", meta.cacheName());
+
+        String ret = content(params);
 
         assertNotNull(ret);
         assertTrue(!ret.isEmpty());
@@ -912,6 +928,86 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         info("Cache metadata result: " + ret);
 
         jsonEquals(ret, pattern("\\{.+\\}", true));
+
+        Map res = (Map)JSONObject.fromObject(ret).get("response");
+
+        Collection types = (Collection)res.get("types");
+
+        assertNotNull(types);
+        assertEqualsCollections(meta.types(), types);
+
+        Map keyClasses = (Map)res.get("keyClasses");
+
+        assertNotNull(keyClasses);
+        assertTrue(meta.keyClasses().equals(keyClasses));
+
+        Map valClasses = (Map)res.get("valClasses");
+
+        assertNotNull(valClasses);
+        assertTrue(meta.valClasses().equals(valClasses));
+
+        Map fields = (Map)res.get("fields");
+
+        assertNotNull(fields);
+        assertTrue(meta.fields().equals(fields));
+
+        Map indexesByType = (Map)res.get("indexes");
+
+        assertNotNull(indexesByType);
+        assertEquals(meta.indexes().size(), indexesByType.size());
+
+        for (Map.Entry<String, Collection<GridCacheSqlIndexMetadata>> metaIndexes : meta.indexes().entrySet()) {
+            Collection<Map> indexes = (Collection<Map>)indexesByType.get(metaIndexes.getKey());
+
+            assertNotNull(indexes);
+            assertEquals(metaIndexes.getValue().size(), indexes.size());
+
+            for (final GridCacheSqlIndexMetadata metaIdx : metaIndexes.getValue()) {
+                Map idx = F.find(indexes, null, new IgnitePredicate<Map>() {
+                    @Override public boolean apply(Map map) {
+                        return metaIdx.name().equals(map.get("name"));
+                    }
+                });
+
+                assertNotNull(idx);
+
+                assertEqualsCollections(metaIdx.fields(), (Collection)idx.get("fields"));
+                assertEqualsCollections(metaIdx.descendings(), (Collection)idx.get("descendings"));
+                assertEquals(metaIdx.unique(), idx.get("unique"));
+            }
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMetadataLocal() throws Exception {
+        GridCacheProcessor cacheProc = grid(0).context().cache();
+
+        for (IgniteInternalCache<?, ?> cache : cacheProc.caches()) {
+            if (CU.isSystemCache(cache.name()))
+                continue;
+
+            GridCacheSqlMetadata meta = F.first(cache.context().queries().sqlMetadata());
+
+            testMetadata(meta);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMetadataRemote() throws Exception {
+        CacheConfiguration<Integer, String> partialCacheCfg = new CacheConfiguration<>("partial");
+
+        partialCacheCfg.setIndexedTypes(Integer.class, String.class);
+        partialCacheCfg.setNodeFilter(new NodeIdFilter(grid(1).localNode().id()));
+
+        IgniteCacheProxy<Integer, String> c = (IgniteCacheProxy<Integer, String>)grid(1).createCache(partialCacheCfg);
+
+        GridCacheSqlMetadata meta = F.first(c.context().queries().sqlMetadata());
+
+        testMetadata(meta);
     }
 
     /**
@@ -926,6 +1022,23 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         info("Topology command result: " + ret);
 
         jsonEquals(ret, pattern("\\[\\{.+\\}\\]", true));
+
+        JSONObject json = JSONObject.fromObject(ret);
+
+        Collection<Map> nodes = (Collection)json.get("response");
+
+        assertEquals(GRID_CNT, nodes.size());
+
+        for (Map node : nodes) {
+            assertEquals(JSONNull.getInstance(), node.get("attributes"));
+            assertEquals(JSONNull.getInstance(), node.get("metrics"));
+
+            assertEquals("PARTITIONED", node.get("defaultCacheMode"));
+
+            Map caches = (Map)node.get("caches");
+
+            assertEquals(F.asMap("person", "PARTITIONED"), caches);
+        }
     }
 
     /**
@@ -1069,6 +1182,29 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
         params.put("pageSize", "10");
         params.put("cacheName", "person");
+
+        String ret = content(params);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        JSONObject json = JSONObject.fromObject(ret);
+
+        List items = (List)((Map)json.get("response")).get("items");
+
+        assertEquals(4, items.size());
+
+        assertFalse(queryCursorFound());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFilterQueryScan() throws Exception {
+        Map<String, String> params = new HashMap<>();
+        params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
+        params.put("pageSize", "10");
+        params.put("cacheName", "person");
         params.put("classname", ScanFilter.class.getName());
 
         String ret = content(params);
@@ -1088,7 +1224,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     /**
      * @throws Exception If failed.
      */
-    public void testIncorrectQueryScan() throws Exception {
+    public void testIncorrectFilterQueryScan() throws Exception {
         Map<String, String> params = new HashMap<>();
         params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
         params.put("pageSize", "10");
@@ -1387,4 +1523,22 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
             return person.salary > 1000;
         }
     }
+
+    /** Filter by node ID. */
+    private static class NodeIdFilter implements IgnitePredicate<ClusterNode> {
+        /** */
+        private final UUID nid;
+
+        /**
+         * @param nid Node ID where cache should be started.
+         */
+        NodeIdFilter(UUID nid) {
+            this.nid = nid;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(ClusterNode n) {
+            return n.id().equals(nid);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6acba08e/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 a64e14c..8add472 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -56,6 +56,7 @@ import org.apache.ignite.IgniteClientDisconnectedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteInterruptedException;
 import org.apache.ignite.cache.CacheMetrics;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;
@@ -299,16 +300,16 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
      * @param cacheName Cache name.
      * @param filter Cache filter.
      * @param nearEnabled Near enabled flag.
-     * @param loc {@code True} if cache is local.
+     * @param cacheMode Cache mode.
      */
     public void setCacheFilter(
         String cacheName,
         IgnitePredicate<ClusterNode> filter,
         boolean nearEnabled,
-        boolean loc
+        CacheMode cacheMode
     ) {
         if (!registeredCaches.containsKey(cacheName))
-            registeredCaches.put(cacheName, new CachePredicate(filter, nearEnabled, loc));
+            registeredCaches.put(cacheName, new CachePredicate(filter, nearEnabled, cacheMode));
     }
 
     /**
@@ -1590,19 +1591,19 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
      * @param node Node to check.
      * @return Cache names accessible on the given node.
      */
-    public Collection<String> nodeCaches(ClusterNode node) {
-        Collection<String> cacheNames = new ArrayList<>(registeredCaches.size());
+    public Map<String, CacheMode> nodeCaches(ClusterNode node) {
+        Map<String, CacheMode> caches = U.newHashMap(registeredCaches.size());
 
         for (Map.Entry<String, CachePredicate> entry : registeredCaches.entrySet()) {
             String cacheName = entry.getKey();
 
-            CachePredicate filter = entry.getValue();
+            CachePredicate pred = entry.getValue();
 
-            if (filter != null && filter.cacheNode(node))
-                cacheNames.add(cacheName);
+            if (pred != null && pred.cacheNode(node))
+                caches.put(cacheName, pred.cacheMode);
         }
 
-        return cacheNames;
+        return caches;
     }
 
     /**
@@ -2846,8 +2847,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         /** If near cache is enabled on data nodes. */
         private final boolean nearEnabled;
 
-        /** Flag indicating if cache is local. */
-        private final boolean loc;
+        /** Cache mode. */
+        private final CacheMode cacheMode;
 
         /** Collection of client near nodes. */
         private final ConcurrentHashMap<UUID, Boolean> clientNodes;
@@ -2855,14 +2856,14 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         /**
          * @param cacheFilter Cache filter.
          * @param nearEnabled Near enabled flag.
-         * @param loc {@code True} if cache is local.
+         * @param cacheMode Cache mode.
          */
-        private CachePredicate(IgnitePredicate<ClusterNode> cacheFilter, boolean nearEnabled, boolean loc) {
+        private CachePredicate(IgnitePredicate<ClusterNode> cacheFilter, boolean nearEnabled, CacheMode cacheMode) {
             assert cacheFilter != null;
 
             this.cacheFilter = cacheFilter;
             this.nearEnabled = nearEnabled;
-            this.loc = loc;
+            this.cacheMode = cacheMode;
 
             clientNodes = new ConcurrentHashMap<>();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6acba08e/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 c86dfd9..c185c54 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
@@ -685,7 +685,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     cfg.getName(),
                     cfg.getNodeFilter(),
                     cfg.getNearConfiguration() != null && cfg.getCacheMode() == PARTITIONED,
-                    cfg.getCacheMode() == LOCAL);
+                    cfg.getCacheMode());
 
                 ctx.discovery().addClientNode(cfg.getName(),
                     ctx.localNodeId(),
@@ -1942,7 +1942,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                                     req.cacheName(),
                                     ccfg.getNodeFilter(),
                                     ccfg.getNearConfiguration() != null,
-                                    ccfg.getCacheMode() == LOCAL);
+                                    ccfg.getCacheMode());
                             }
                         }
                         else {
@@ -1965,7 +1965,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                                 req.cacheName(),
                                 ccfg.getNodeFilter(),
                                 ccfg.getNearConfiguration() != null,
-                                ccfg.getCacheMode() == LOCAL);
+                                ccfg.getCacheMode());
                         }
                     }
                 }
@@ -2434,7 +2434,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                             ccfg.getName(),
                             ccfg.getNodeFilter(),
                             ccfg.getNearConfiguration() != null,
-                            ccfg.getCacheMode() == LOCAL);
+                            ccfg.getCacheMode());
 
                         ctx.discovery().addClientNode(req.cacheName(),
                             req.initiatingNodeId(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/6acba08e/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 726f6ce..1c6d18d 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
@@ -228,11 +228,20 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
                 }
 
                 case CACHE_METADATA: {
-                    IgniteInternalCache<Object, Object> cache = localCache(cacheName);
+                    IgniteInternalCache<?, ?> cache = ctx.cache().cache(cacheName);
 
-                    GridCacheSqlMetadata res = F.first(cache.context().queries().sqlMetadata());
+                    if (cache != null) {
+                        GridCacheSqlMetadata res = F.first(cache.context().queries().sqlMetadata());
 
-                    fut = new GridFinishedFuture<>(new GridRestResponse(res));
+                        fut = new GridFinishedFuture<>(new GridRestResponse(res));
+                    }
+                    else {
+                        ClusterGroup prj = ctx.grid().cluster().forDataNodes(cacheName);
+
+                        ctx.task().setThreadContext(TC_NO_FAILOVER, true);
+
+                        fut = ctx.closure().callAsync(BALANCE, new MetadataCommand(cacheName), prj.nodes());
+                    }
 
                     break;
                 }
@@ -905,6 +914,31 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
     }
 
     /** */
+    private static class MetadataCommand implements Callable<GridRestResponse>, Serializable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        private final String cacheName;
+
+        /** */
+        @IgniteInstanceResource
+        private Ignite g;
+
+        /**
+         * @param cacheName Cache name.
+         */
+        private MetadataCommand(String cacheName) {
+            this.cacheName = cacheName;
+        }
+
+        /** {@inheritDoc} */
+        @Override public GridRestResponse call() throws Exception {
+            return  new GridRestResponse(F.first(cache(g, cacheName).context().queries().sqlMetadata()));
+        }
+    }
+
+    /** */
     private static class ContainsKeysCommand extends CacheProjectionCommand {
         /** */
         private static final long serialVersionUID = 0L;

http://git-wip-us.apache.org/repos/asf/ignite/blob/6acba08e/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 d217995..b68c7d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
@@ -27,12 +27,11 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.port.GridPortRecord;
 import org.apache.ignite.internal.processors.rest.GridRestCommand;
 import org.apache.ignite.internal.processors.rest.GridRestProtocol;
@@ -45,6 +44,7 @@ import org.apache.ignite.internal.processors.rest.request.GridRestTopologyReques
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.IgnitePortProtocol;
@@ -195,22 +195,20 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
         nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
         nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
 
-        Collection<String> cacheNames = ctx.discovery().nodeCaches(node);
+        Map<String, CacheMode> nodeCaches = ctx.discovery().nodeCaches(node);
 
-        Map<String, String> cacheMap = U.newHashMap(cacheNames.size());
+        Map<String, String> cacheMap = U.newHashMap(nodeCaches.size());
 
-        GridCacheProcessor cacheProc = ctx.cache();
+        for (Map.Entry<String, CacheMode> cache : nodeCaches.entrySet()) {
+            String cacheName = cache.getKey();
 
-        for (String cacheName : cacheNames) {
-            IgniteInternalCache<?, ?> cache = cacheProc.cache(cacheName);
-
-            if (cacheProc.systemCache(cache.name()))
+            if (CU.isSystemCache(cacheName))
                 continue;
 
-            String mode = cache.configuration().getCacheMode().toString();
+            String mode = cache.getValue().toString();
 
-            if (cache.name() != null)
-                cacheMap.put(cache.name(), mode);
+            if (cacheName != null)
+                cacheMap.put(cacheName, mode);
             else
                 nodeBean.setDefaultCacheMode(mode);
         }


[17/41] ignite git commit: Changed IgniteCacheProcessProxy.localEntries to avoid issues with Cache.Entry serialization.

Posted by an...@apache.org.
Changed IgniteCacheProcessProxy.localEntries to avoid issues with Cache.Entry serialization.


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

Branch: refs/heads/ignite-1168
Commit: bf7591b5eb6323011a03c424362ab68f994cffc9
Parents: 31c4405
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 24 16:33:05 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 24 16:33:05 2015 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/bf7591b5/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index dfbb0ae..ac8c5af 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -43,6 +43,7 @@ import org.apache.ignite.cache.query.Query;
 import org.apache.ignite.cache.query.QueryCursor;
 import org.apache.ignite.cache.query.QueryMetrics;
 import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
 import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteCallable;
@@ -209,7 +210,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
                 Collection<Entry> res = new ArrayList<>();
 
                 for (Entry e : cache().localEntries(peekModes))
-                    res.add(e);
+                    res.add(new CacheEntryImpl(e.getKey(), e.getValue()));
 
                 return res;
             }


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

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


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

Branch: refs/heads/ignite-1168
Commit: 3a322c0556c054a291ee5c28e6e853e700587f3a
Parents: 6acba08 7402918
Author: Andrey <an...@gridgain.com>
Authored: Wed Sep 30 10:01:28 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Wed Sep 30 10:01:28 2015 +0700

----------------------------------------------------------------------
 .../cache/GridCacheExplicitLockSpan.java        |  13 +-
 .../cache/GridCacheMvccCandidate.java           |   5 +-
 .../processors/cache/GridCacheMvccManager.java  |  47 ++--
 .../distributed/GridDistributedCacheEntry.java  |   2 +-
 .../dht/colocated/GridDhtColocatedCache.java    |  12 +-
 .../colocated/GridDhtColocatedLockFuture.java   |  16 +-
 .../dht/preloader/GridDhtPreloader.java         |   2 +-
 .../cache/distributed/near/GridNearTxLocal.java |   2 +-
 .../cache/local/GridLocalCacheEntry.java        |   2 +-
 .../ignite/internal/util/GridArgumentCheck.java |   5 +-
 .../processors/cache/CrossCacheLockTest.java    | 142 +++++++++++++
 .../GridCacheFinishPartitionsSelfTest.java      |   5 +-
 .../IgniteCacheCreatePutMultiNodeSelfTest.java  | 151 +++++++++++++
 .../IgniteCrossCacheTxNearEnabledSelfTest.java  |  28 +++
 .../dht/IgniteCrossCacheTxSelfTest.java         | 213 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |   7 +
 .../processors/query/h2/sql/GridSqlArray.java   |  52 +++++
 .../processors/query/h2/sql/GridSqlElement.java |   2 +-
 .../query/h2/sql/GridSqlFunction.java           |  60 ++++--
 .../query/h2/sql/GridSqlFunctionType.java       |   3 +
 .../query/h2/sql/GridSqlPlaceholder.java        |   7 +-
 .../query/h2/sql/GridSqlQueryParser.java        |  84 +++++---
 .../processors/query/h2/sql/GridSqlType.java    |  29 ++-
 .../query/h2/sql/GridQueryParsingTest.java      |  27 +++
 24 files changed, 798 insertions(+), 118 deletions(-)
----------------------------------------------------------------------



[23/41] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by an...@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/343191bc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/343191bc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/343191bc

Branch: refs/heads/ignite-1168
Commit: 343191bce46f9d745c1c0151ba86ac6032e76f16
Parents: a6306a5 a42750a
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 25 16:21:42 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 25 16:21:42 2015 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicUpdateFuture.java   |   5 +
 .../internal/GridUpdateNotifierSelfTest.java    |   1 +
 ...nedQueueFailoverDataConsistencySelfTest.java |   5 -
 .../GridCacheReplicatedInvalidateSelfTest.java  | 249 -------------------
 ...eCacheExpiryPolicyWithStoreAbstractTest.java |   5 +-
 .../multijvm/IgniteCacheProcessProxy.java       |   3 +-
 .../testsuites/IgniteCacheTestSuite3.java       |   2 -
 7 files changed, 12 insertions(+), 258 deletions(-)
----------------------------------------------------------------------



[37/41] ignite git commit: Added test.

Posted by an...@apache.org.
Added test.


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

Branch: refs/heads/ignite-1168
Commit: c517fcf5a7c9444e27e5f4d261702aaa2dfe726d
Parents: ce3f20b
Author: sboikov <sb...@gridgain.com>
Authored: Tue Sep 29 12:15:37 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Sep 29 12:15:37 2015 +0300

----------------------------------------------------------------------
 .../IgniteCacheCreatePutMultiNodeSelfTest.java  | 151 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 2 files changed, 153 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c517fcf5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutMultiNodeSelfTest.java
new file mode 100644
index 0000000..cf0e0d3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutMultiNodeSelfTest.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicReferenceArray;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+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 IgniteCacheCreatePutMultiNodeSelfTest extends GridCommonAbstractTest {
+    /** Grid count. */
+    private static final int GRID_CNT = 4;
+
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+        discoSpi.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        marsh.setRequireSerializable(false);
+
+        cfg.setMarshaller(marsh);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 6 * 60 * 1000L;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStartNodes() throws Exception {
+        try {
+            Collection<IgniteInternalFuture<?>> futs = new ArrayList<>(GRID_CNT);
+            int scale = 3;
+
+            final CyclicBarrier barrier = new CyclicBarrier(GRID_CNT * scale);
+            final AtomicReferenceArray<Exception> err = new AtomicReferenceArray<>(GRID_CNT * scale);
+
+            for (int i = 0; i < GRID_CNT * scale; i++) {
+                if (i < GRID_CNT)
+                    startGrid(i);
+
+                final int idx = i;
+
+                IgniteInternalFuture<Void> fut = GridTestUtils.runAsync(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        Ignite ignite = ignite(idx % GRID_CNT);
+
+                        try {
+                            for (int k = 0; k < 50; k++) {
+                                barrier.await();
+
+                                String cacheName = "cache-" + k;
+
+                                IgniteCache<Integer, Integer> cache = getCache(ignite, cacheName);
+
+                                for (int i = 0; i < 100; i++)
+                                    cache.getAndPut(i, i);
+
+                                barrier.await();
+
+                                ignite.destroyCache(cacheName);
+                            }
+                        }
+                        catch (Exception e) {
+                            err.set(idx, e);
+                        }
+
+                        return null;
+                    }
+                });
+
+                futs.add(fut);
+            }
+
+            for (IgniteInternalFuture<?> fut : futs)
+                fut.get(getTestTimeout());
+
+            info("Errors: " + err);
+
+            for (int i = 0; i < err.length(); i++) {
+                Exception ex = err.get(i);
+
+                if (ex != null)
+                    throw ex;
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param grid Grid.
+     * @param cacheName Cache name.
+     * @return Cache.
+     */
+    private IgniteCache<Integer, Integer> getCache(Ignite grid, String cacheName) {
+        CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(cacheName);
+
+        ccfg.setCacheMode(CacheMode.PARTITIONED);
+        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+        ccfg.setBackups(1);
+        ccfg.setNearConfiguration(null);
+
+        return grid.getOrCreateCache(ccfg);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c517fcf5/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 3842336..f8c9d26 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
@@ -78,6 +78,7 @@ import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransaction
 import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheAffinityEarlyTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest;
+import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheCreatePutMultiNodeSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtTxPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheLockFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheMultiTxLockSelfTest;
@@ -203,6 +204,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteDynamicClientCacheStartSelfTest.class);
         suite.addTestSuite(IgniteDynamicCacheStartNoExchangeTimeoutTest.class);
         suite.addTestSuite(CacheAffinityEarlyTest.class);
+        suite.addTestSuite(IgniteCacheCreatePutMultiNodeSelfTest.class);
 
         suite.addTestSuite(GridCacheTxLoadFromStoreOnLockSelfTest.class);
 


[12/41] ignite git commit: schema-import examples fix (cherry picked from commit b054fdc)

Posted by an...@apache.org.
schema-import examples fix
(cherry picked from commit b054fdc)


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

Branch: refs/heads/ignite-1168
Commit: 94f5248b0e03f04c53f0c264a880803e20de2d3a
Parents: 30f5b9e
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Sep 24 14:52:09 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Sep 24 15:16:20 2015 +0300

----------------------------------------------------------------------
 examples/schema-import/pom.xml | 2 +-
 pom.xml                        | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/94f5248b/examples/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/examples/schema-import/pom.xml b/examples/schema-import/pom.xml
index fdbd631..fce6f47 100644
--- a/examples/schema-import/pom.xml
+++ b/examples/schema-import/pom.xml
@@ -38,7 +38,7 @@
     </properties>
 
     <artifactId>ignite-schema-import-demo</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.3.3-p7-SNAPSHOT</version>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/94f5248b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b47958f..33689a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -466,6 +466,7 @@
             <id>examples</id>
             <modules>
                 <module>examples</module>
+                <module>examples/schema-import</module>
             </modules>
         </profile>
 


[04/41] ignite git commit: Merging IGNITE-1171 - fixed problems with custom events in discovery

Posted by an...@apache.org.
Merging IGNITE-1171 - fixed problems with custom events in discovery


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

Branch: refs/heads/ignite-1168
Commit: 6f3ef6a84ee1c3e77d32ca9930835d1720918e20
Parents: 517d0f5
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Sep 23 16:36:15 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Sep 23 16:36:15 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteAtomicLong.java     |   2 +-
 .../cache/DynamicCacheDescriptor.java           |  10 +-
 .../GridCachePartitionExchangeManager.java      |   6 +
 .../processors/cache/GridCacheProcessor.java    |  18 +-
 .../continuous/CacheContinuousQueryManager.java |  10 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   7 +-
 .../discovery/DiscoverySpiCustomMessage.java    |  12 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 301 ++++++++++++++----
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |   6 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   2 +-
 .../tcp/internal/TcpDiscoveryNodesRing.java     |  94 ++----
 .../messages/TcpDiscoveryDiscardMessage.java    |  15 +-
 .../TcpDiscoveryNodeAddFinishedMessage.java     |   2 +-
 .../messages/TcpDiscoveryNodeAddedMessage.java  |  19 +-
 .../distributed/CacheAffEarlySelfTest.java      | 245 ---------------
 .../distributed/CacheAffinityEarlyTest.java     | 168 ++++++++++
 ...GridCacheValueConsistencyAtomicSelfTest.java |   2 +-
 .../tcp/TcpDiscoveryMultiThreadedTest.java      |  53 ++--
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java | 315 ++++++++++++++++++-
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 20 files changed, 864 insertions(+), 425 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/IgniteAtomicLong.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteAtomicLong.java b/modules/core/src/main/java/org/apache/ignite/IgniteAtomicLong.java
index 83e2525..bac1a68 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteAtomicLong.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteAtomicLong.java
@@ -160,4 +160,4 @@ public interface IgniteAtomicLong extends Closeable {
      * @throws IgniteException If operation failed.
      */
     @Override public void close();
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
index f3c3be9..3cfc34e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
@@ -39,9 +39,6 @@ public class DynamicCacheDescriptor {
     @GridToStringExclude
     private CacheConfiguration cacheCfg;
 
-    /** Cancelled flag. */
-    private boolean cancelled;
-
     /** Locally configured flag. */
     private boolean locCfg;
 
@@ -156,6 +153,13 @@ public class DynamicCacheDescriptor {
     }
 
     /**
+     * @return Started flag.
+     */
+    public boolean started() {
+        return started;
+    }
+
+    /**
      * @return Cache configuration.
      */
     public CacheConfiguration cacheConfiguration() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/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 34c571c..eb76233 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
@@ -1435,6 +1435,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
         private static final long serialVersionUID = 0L;
 
         /** */
+        @GridToStringInclude
         private AffinityTopologyVersion topVer;
 
         /**
@@ -1455,5 +1456,10 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
 
             return done;
         }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(AffinityReadyFuture.class, this, super.toString());
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/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 e92ea57..74124bf 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
@@ -1522,10 +1522,15 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @return Collection of started cache names.
      */
     public Collection<String> cacheNames() {
-        return F.viewReadOnly(registeredCaches.keySet(),
-            new IgniteClosure<String, String>() {
-                @Override public String apply(String s) {
-                    return unmaskNull(s);
+        return F.viewReadOnly(registeredCaches.values(),
+            new IgniteClosure<DynamicCacheDescriptor, String>() {
+                @Override public String apply(DynamicCacheDescriptor desc) {
+                    return desc.cacheConfiguration().getName();
+                }
+            },
+            new IgnitePredicate<DynamicCacheDescriptor>() {
+                @Override public boolean apply(DynamicCacheDescriptor desc) {
+                    return desc.started();
                 }
             });
     }
@@ -1568,6 +1573,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 req.deploymentId(),
                 topVer
             );
+
+            DynamicCacheDescriptor desc = registeredCaches.get(maskNull(req.cacheName()));
+
+            if (desc != null)
+                desc.onStart();
         }
 
         // Start statically configured caches received from remote nodes during exchange.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index da02b97..c719f1e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -448,8 +448,12 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
             taskNameHash,
             skipPrimaryCheck);
 
-        UUID id = cctx.kernalContext().continuous().startRoutine(hnd, bufSize, timeInterval,
-            autoUnsubscribe, grp.predicate()).get();
+        UUID id = cctx.kernalContext().continuous().startRoutine(
+            hnd,
+            bufSize,
+            timeInterval,
+            autoUnsubscribe,
+            grp.predicate()).get();
 
         if (notifyExisting) {
             final Iterator<GridCacheEntryEx> it = cctx.cache().allEntries().iterator();
@@ -811,4 +815,4 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
             }
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/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 2594213..c93d5af 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
@@ -2126,8 +2126,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
 
                 if (failureDetectionTimeoutEnabled() && (e instanceof HandshakeTimeoutException ||
                     timeoutHelper.checkFailureTimeoutReached(e))) {
-                    log.debug("Handshake timed out (failure threshold reached) [failureDetectionTimeout=" +
-                        failureDetectionTimeout() + ", err=" + e.getMessage() + ", client=" + client + ']');
+                    if (log.isDebugEnabled())
+                        log.debug("Handshake timed out (failure threshold reached) [failureDetectionTimeout=" +
+                            failureDetectionTimeout() + ", err=" + e.getMessage() + ", client=" + client + ']');
 
                     throw e;
                 }
@@ -2700,7 +2701,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
      *
      * FOR TEST PURPOSES ONLY!!!
      */
-    void simulateNodeFailure() {
+    public void simulateNodeFailure() {
         if (nioSrvr != null)
             nioSrvr.stop();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpiCustomMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpiCustomMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpiCustomMessage.java
index 373c121..a0f9b75 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpiCustomMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoverySpiCustomMessage.java
@@ -5,9 +5,9 @@
  * 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.
@@ -18,13 +18,15 @@
 package org.apache.ignite.spi.discovery;
 
 import java.io.Serializable;
+
+import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
+import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
 import org.jetbrains.annotations.Nullable;
 
 /**
  * Message to send across ring.
  *
- * @see org.apache.ignite.internal.managers.discovery.GridDiscoveryManager#sendCustomEvent(
- * org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage)
+ * @see GridDiscoveryManager#sendCustomEvent(DiscoveryCustomMessage)
  */
 public interface DiscoverySpiCustomMessage extends Serializable {
     /**
@@ -36,4 +38,4 @@ public interface DiscoverySpiCustomMessage extends Serializable {
      * @return {@code true} if message can be modified during listener notification. Changes will be send to next nodes.
      */
     public boolean isMutable();
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 8a205d2..d8ee953 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -37,10 +37,13 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.NoSuchElementException;
 import java.util.Queue;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.UUID;
@@ -64,6 +67,7 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.events.DiscoveryCustomEvent;
 import org.apache.ignite.internal.processors.security.SecurityContext;
+import org.apache.ignite.internal.util.GridBoundedLinkedHashSet;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -145,7 +149,7 @@ import static org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusChe
 /**
  *
  */
-@SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext")
+@SuppressWarnings("All")
 class ServerImpl extends TcpDiscoveryImpl {
     /** */
     private final ThreadPoolExecutor utilityPool = new ThreadPoolExecutor(0, 1, 2000, TimeUnit.MILLISECONDS,
@@ -1368,8 +1372,13 @@ class ServerImpl extends TcpDiscoveryImpl {
      * @param msgs Messages to include.
      * @param discardMsgId Discarded message ID.
      */
-    private void prepareNodeAddedMessage(TcpDiscoveryAbstractMessage msg, UUID destNodeId,
-        @Nullable Collection<TcpDiscoveryAbstractMessage> msgs, @Nullable IgniteUuid discardMsgId) {
+    private void prepareNodeAddedMessage(
+        TcpDiscoveryAbstractMessage msg,
+        UUID destNodeId,
+        @Nullable Collection<TcpDiscoveryAbstractMessage> msgs,
+        @Nullable IgniteUuid discardMsgId,
+        @Nullable IgniteUuid discardCustomMsgId
+        ) {
         assert destNodeId != null;
 
         if (msg instanceof TcpDiscoveryNodeAddedMessage) {
@@ -1393,7 +1402,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                 }
 
                 nodeAddedMsg.topology(topToSnd);
-                nodeAddedMsg.messages(msgs, discardMsgId);
+                nodeAddedMsg.messages(msgs, discardMsgId, discardCustomMsgId);
 
                 Map<Long, Collection<ClusterNode>> hist;
 
@@ -1416,7 +1425,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             nodeAddedMsg.topology(null);
             nodeAddedMsg.topologyHistory(null);
-            nodeAddedMsg.messages(null, null);
+            nodeAddedMsg.messages(null, null, null);
         }
     }
 
@@ -1825,7 +1834,7 @@ class ServerImpl extends TcpDiscoveryImpl {
          */
         private TcpDiscoveryAbstractMessage prepare(TcpDiscoveryAbstractMessage msg, UUID destNodeId) {
             if (msg instanceof TcpDiscoveryNodeAddedMessage)
-                prepareNodeAddedMessage(msg, destNodeId, null, null);
+                prepareNodeAddedMessage(msg, destNodeId, null, null, null);
 
             return msg;
         }
@@ -1834,16 +1843,22 @@ class ServerImpl extends TcpDiscoveryImpl {
     /**
      * Pending messages container.
      */
-    private static class PendingMessages {
+    private static class PendingMessages implements Iterable<TcpDiscoveryAbstractMessage> {
         /** */
         private static final int MAX = 1024;
 
         /** Pending messages. */
         private final Queue<TcpDiscoveryAbstractMessage> msgs = new ArrayDeque<>(MAX * 2);
 
+        /** Processed custom message IDs. */
+        private Set<IgniteUuid> procCustomMsgs = new GridBoundedLinkedHashSet<IgniteUuid>(MAX * 2);
+
         /** Discarded message ID. */
         private IgniteUuid discardId;
 
+        /** Discarded message ID. */
+        private IgniteUuid customDiscardId;
+
         /**
          * Adds pending message and shrinks queue if it exceeds limit
          * (messages that were not discarded yet are never removed).
@@ -1869,31 +1884,118 @@ class ServerImpl extends TcpDiscoveryImpl {
          * @param msgs Message.
          * @param discardId Discarded message ID.
          */
-        void reset(@Nullable Collection<TcpDiscoveryAbstractMessage> msgs, @Nullable IgniteUuid discardId) {
+        void reset(
+            @Nullable Collection<TcpDiscoveryAbstractMessage> msgs,
+            @Nullable IgniteUuid discardId,
+            @Nullable IgniteUuid customDiscardId
+        ) {
             this.msgs.clear();
 
             if (msgs != null)
                 this.msgs.addAll(msgs);
 
             this.discardId = discardId;
+            this.customDiscardId = customDiscardId;
         }
 
         /**
-         * Clears pending messages.
+         * Discards message with provided ID and all before it.
+         *
+         * @param id Discarded message ID.
          */
-        void clear() {
-            msgs.clear();
+        void discard(IgniteUuid id, boolean custom) {
+            if (custom)
+                customDiscardId = id;
+            else
+                discardId = id;
+        }
 
-            discardId = null;
+        /**
+         * Gets iterator for non-discarded messages.
+         *
+         * @return Non-discarded messages iterator.
+         */
+        public Iterator<TcpDiscoveryAbstractMessage> iterator() {
+            return new SkipIterator();
         }
 
         /**
-         * Discards message with provided ID and all before it.
          *
-         * @param id Discarded message ID.
          */
-        void discard(IgniteUuid id) {
-            discardId = id;
+        private class SkipIterator implements Iterator<TcpDiscoveryAbstractMessage> {
+            /** Skip non-custom messages flag. */
+            private boolean skipMsg = discardId != null;
+
+            /** Skip custom messages flag. */
+            private boolean skipCustomMsg;
+
+            /** Internal iterator. */
+            private Iterator<TcpDiscoveryAbstractMessage> msgIt = msgs.iterator();
+
+            /** Next message. */
+            private TcpDiscoveryAbstractMessage next;
+
+            {
+                advance();
+            }
+
+            /** {@inheritDoc} */
+            @Override public boolean hasNext() {
+                return next != null;
+            }
+
+            /** {@inheritDoc} */
+            @Override public TcpDiscoveryAbstractMessage next() {
+                if (next == null)
+                    throw new NoSuchElementException();
+
+                TcpDiscoveryAbstractMessage next0 = next;
+
+                advance();
+
+                return next0;
+            }
+
+            /** {@inheritDoc} */
+            @Override public void remove() {
+                throw new UnsupportedOperationException();
+            }
+
+            /**
+             * Advances iterator to the next available item.
+             */
+            private void advance() {
+                next = null;
+
+                while (msgIt.hasNext()) {
+                    TcpDiscoveryAbstractMessage msg0 = msgIt.next();
+
+                    if (msg0 instanceof TcpDiscoveryCustomEventMessage) {
+                        if (skipCustomMsg) {
+                            assert customDiscardId != null;
+
+                            if (F.eq(customDiscardId, msg0.id()))
+                                skipCustomMsg = false;
+
+                            continue;
+                        }
+                    }
+                    else {
+                        if (skipMsg) {
+                            assert discardId != null;
+
+                            if (F.eq(discardId, msg0.id()))
+                                skipMsg = false;
+
+                            continue;
+                        }
+                    }
+
+                    next = msg0;
+
+                    break;
+                }
+            }
         }
     }
 
@@ -1941,6 +2043,12 @@ class ServerImpl extends TcpDiscoveryImpl {
         /** Connection check threshold. */
         private long connCheckThreshold;
 
+        /** Pending custom messages that should not be sent between NodeAdded and NodeAddFinished messages. */
+        private Queue<TcpDiscoveryCustomEventMessage> pendingCustomMsgs = new ArrayDeque<>();
+
+        /** Collection to track joining nodes. */
+        private Set<UUID> joiningNodes = new HashSet<>();
+
         /**
          */
         protected RingMessageWorker() {
@@ -2046,6 +2154,8 @@ class ServerImpl extends TcpDiscoveryImpl {
             sendHeartbeatMessage();
 
             checkHeartbeatsReceiving();
+
+            checkPendingCustomMessages();
         }
 
         /**
@@ -2323,20 +2433,11 @@ class ServerImpl extends TcpDiscoveryImpl {
                                     debugLog("Pending messages will be sent [failure=" + failure +
                                         ", forceSndPending=" + forceSndPending + ']');
 
-                                boolean skip = pendingMsgs.discardId != null;
-
-                                for (TcpDiscoveryAbstractMessage pendingMsg : pendingMsgs.msgs) {
-                                    if (skip) {
-                                        if (pendingMsg.id().equals(pendingMsgs.discardId))
-                                            skip = false;
-
-                                        continue;
-                                    }
-
+                                for (TcpDiscoveryAbstractMessage pendingMsg : pendingMsgs) {
                                     long tstamp = U.currentTimeMillis();
 
                                     prepareNodeAddedMessage(pendingMsg, next.id(), pendingMsgs.msgs,
-                                        pendingMsgs.discardId);
+                                        pendingMsgs.discardId, pendingMsgs.customDiscardId);
 
                                     if (timeoutHelper == null)
                                         timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi);
@@ -2354,13 +2455,13 @@ class ServerImpl extends TcpDiscoveryImpl {
                                     int res = spi.readReceipt(sock, timeoutHelper.nextTimeoutChunk(ackTimeout0));
 
                                     if (log.isDebugEnabled())
-                                        log.debug("Pending message has been sent to next node [msg=" + msg.id() +
-                                            ", pendingMsgId=" + pendingMsg + ", next=" + next.id() +
+                                        log.debug("Pending message has been sent to next node [msgId=" + msg.id() +
+                                            ", pendingMsgId=" + pendingMsg.id() + ", next=" + next.id() +
                                             ", res=" + res + ']');
 
                                     if (debugMode)
-                                        debugLog("Pending message has been sent to next node [msg=" + msg.id() +
-                                            ", pendingMsgId=" + pendingMsg + ", next=" + next.id() +
+                                        debugLog("Pending message has been sent to next node [msgId=" + msg.id() +
+                                            ", pendingMsgId=" + pendingMsg.id() + ", next=" + next.id() +
                                             ", res=" + res + ']');
 
                                     // Resetting timeout control object to create a new one for the next bunch of
@@ -2377,7 +2478,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                                     msg = new TcpDiscoveryStatusCheckMessage(locNode, null);
                             }
                             else
-                                prepareNodeAddedMessage(msg, next.id(), pendingMsgs.msgs, pendingMsgs.discardId);
+                                prepareNodeAddedMessage(msg, next.id(), pendingMsgs.msgs, pendingMsgs.discardId,
+                                    pendingMsgs.customDiscardId);
 
                             try {
                                 long tstamp = U.currentTimeMillis();
@@ -2478,21 +2580,6 @@ class ServerImpl extends TcpDiscoveryImpl {
                         }
                     }
 
-                    if (msg instanceof TcpDiscoveryStatusCheckMessage) {
-                        TcpDiscoveryStatusCheckMessage msg0 = (TcpDiscoveryStatusCheckMessage)msg;
-
-                        if (next.id().equals(msg0.failedNodeId())) {
-                            next = null;
-
-                            if (log.isDebugEnabled())
-                                log.debug("Discarding status check since next node has indeed failed [next=" + next +
-                                    ", msg=" + msg + ']');
-
-                            // Discard status check message by exiting loop and handle failure.
-                            break;
-                        }
-                    }
-
                     next = null;
 
                     searchNext = true;
@@ -2524,6 +2611,29 @@ class ServerImpl extends TcpDiscoveryImpl {
                 for (TcpDiscoveryNode n : failedNodes)
                     msgWorker.addMessage(new TcpDiscoveryNodeFailedMessage(locNodeId, n.id(), n.internalOrder()));
 
+                if (!sent) {
+                    if (log.isDebugEnabled())
+                        log.debug("Pending messages will be resent to local node");
+
+                    if (debugMode)
+                        log.debug("Pending messages will be resent to local node");
+
+                    for (TcpDiscoveryAbstractMessage pendingMsg : pendingMsgs) {
+                        prepareNodeAddedMessage(pendingMsg, locNodeId, pendingMsgs.msgs, pendingMsgs.discardId,
+                            pendingMsgs.customDiscardId);
+
+                        msgWorker.addMessage(pendingMsg);
+
+                        if (log.isDebugEnabled())
+                            log.debug("Pending message has been sent to local node [msg=" + msg.id() +
+                                ", pendingMsgId=" + pendingMsg + ", next=" + next.id() + ']');
+
+                        if (debugMode)
+                            debugLog("Pending message has been sent to local node [msg=" + msg.id() +
+                                ", pendingMsgId=" + pendingMsg + ", next=" + next.id() + ']');
+                    }
+                }
+
                 LT.warn(log, null, "Local node has detected failed nodes and started cluster-wide procedure. " +
                         "To speed up failure detection please see 'Failure Detection' section under javadoc" +
                         " for 'TcpDiscoverySpi'");
@@ -3077,7 +3187,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                     processNodeAddFinishedMessage(addFinishMsg);
 
-                    addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id()));
+                    addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id(), false));
 
                     return;
                 }
@@ -3118,6 +3228,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                     return;
                 }
 
+                joiningNodes.add(node.id());
+
                 if (!isLocalNodeCoordinator() && spi.nodeAuth != null && spi.nodeAuth.isGlobalNodeAuthentication()) {
                     boolean authFailed = true;
 
@@ -3222,6 +3334,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                                 n.visible(true);
                             }
 
+                            joiningNodes.clear();
+
                             locNode.setAttributes(node.attributes());
 
                             locNode.visible(true);
@@ -3237,10 +3351,11 @@ class ServerImpl extends TcpDiscoveryImpl {
                             topHist.clear();
                             topHist.putAll(msg.topologyHistory());
 
-                            pendingMsgs.discard(msg.discardedMessageId());
+                            pendingMsgs.reset(msg.messages(), msg.discardedMessageId(),
+                                msg.discardedCustomMessageId());
 
                             // Clear data to minimize message size.
-                            msg.messages(null, null);
+                            msg.messages(null, null, null);
                             msg.topology(null);
                             msg.topologyHistory(null);
                             msg.clearDiscoveryData();
@@ -3307,7 +3422,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                 if (msg.verified()) {
                     spi.stats.onRingMessageReceived(msg);
 
-                    addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id()));
+                    addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id(), false));
 
                     return;
                 }
@@ -3342,7 +3457,11 @@ class ServerImpl extends TcpDiscoveryImpl {
                 }
             }
 
-            if (msg.verified() && !locNodeId.equals(nodeId) && spiStateCopy() == CONNECTED && fireEvt) {
+            joiningNodes.remove(nodeId);
+
+            TcpDiscoverySpiState state = spiStateCopy();
+
+            if (msg.verified() && !locNodeId.equals(nodeId) && state != CONNECTING && fireEvt) {
                 spi.stats.onNodeJoined();
 
                 // Make sure that node with greater order will never get EVT_NODE_JOINED
@@ -3357,7 +3476,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                     boolean b = ring.topologyVersion(topVer);
 
                     assert b : "Topology version has not been updated: [ring=" + ring + ", msg=" + msg +
-                        ", lastMsg=" + lastMsg + ", spiState=" + spiStateCopy() + ']';
+                        ", lastMsg=" + lastMsg + ", spiState=" + state + ']';
 
                     if (log.isDebugEnabled())
                         log.debug("Topology version has been updated: [ring=" + ring + ", msg=" + msg + ']');
@@ -3365,7 +3484,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                     lastMsg = msg;
                 }
 
-                notifyDiscovery(EVT_NODE_JOINED, topVer, node);
+                if (state == CONNECTED)
+                    notifyDiscovery(EVT_NODE_JOINED, topVer, node);
 
                 try {
                     if (spi.ipFinder.isShared() && locNodeCoord)
@@ -3381,7 +3501,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                 }
             }
 
-            if (msg.verified() && locNodeId.equals(nodeId) && spiStateCopy() == CONNECTING) {
+            if (msg.verified() && locNodeId.equals(nodeId) && state == CONNECTING) {
                 assert node != null;
 
                 assert topVer > 0 : "Invalid topology version: " + msg;
@@ -3402,6 +3522,8 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             if (ring.hasRemoteNodes())
                 sendMessageAcrossRing(msg);
+
+            checkPendingCustomMessages();
         }
 
         /**
@@ -3481,7 +3603,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                 if (msg.verified()) {
                     spi.stats.onRingMessageReceived(msg);
 
-                    addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id()));
+                    addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id(), false));
 
                     return;
                 }
@@ -3553,6 +3675,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                     }
                 }
 
+                joiningNodes.remove(leftNode.id());
+
                 spi.stats.onNodeLeft();
 
                 notifyDiscovery(EVT_NODE_LEFT, topVer, leftNode);
@@ -3580,6 +3704,8 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                 U.closeQuiet(sock);
             }
+
+            checkPendingCustomMessages();
         }
 
         /**
@@ -3650,7 +3776,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                 if (msg.verified()) {
                     spi.stats.onRingMessageReceived(msg);
 
-                    addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id()));
+                    addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id(), false));
 
                     return;
                 }
@@ -3707,6 +3833,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                         ", msg=" + msg.warning() + ']');
                 }
 
+                joiningNodes.remove(node.id());
+
                 notifyDiscovery(EVT_NODE_FAILED, topVer, node);
 
                 spi.stats.onNodeFailed();
@@ -3720,6 +3848,8 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                 U.closeQuiet(sock);
             }
+
+            checkPendingCustomMessages();
         }
 
         /**
@@ -4046,7 +4176,7 @@ class ServerImpl extends TcpDiscoveryImpl {
             }
 
             if (msg.verified())
-                pendingMsgs.discard(msgId);
+                pendingMsgs.discard(msgId, msg.customMessageDiscard());
 
             if (ring.hasRemoteNodes())
                 sendMessageAcrossRing(msg);
@@ -4098,18 +4228,23 @@ class ServerImpl extends TcpDiscoveryImpl {
          */
         private void processCustomMessage(TcpDiscoveryCustomEventMessage msg) {
             if (isLocalNodeCoordinator()) {
-                boolean sndNext;
+                if (!joiningNodes.isEmpty()) {
+                    pendingCustomMsgs.add(msg);
 
-                if (!msg.verified()) {
+                    return;
+                }
+
+                boolean sndNext = !msg.verified();
+
+                if (sndNext) {
                     msg.verify(getLocalNodeId());
                     msg.topologyVersion(ring.topologyVersion());
 
-                    notifyDiscoveryListener(msg);
-
-                    sndNext = true;
+                    if (pendingMsgs.procCustomMsgs.add(msg.id()))
+                        notifyDiscoveryListener(msg);
+                    else
+                        sndNext = false;
                 }
-                else
-                    sndNext = false;
 
                 if (sndNext && ring.hasRemoteNodes())
                     sendMessageAcrossRing(msg);
@@ -4139,12 +4274,30 @@ class ServerImpl extends TcpDiscoveryImpl {
                         }
                     }
 
-                    addMessage(new TcpDiscoveryDiscardMessage(getLocalNodeId(), msg.id()));
+                    addMessage(new TcpDiscoveryDiscardMessage(getLocalNodeId(), msg.id(), true));
                 }
             }
             else {
-                if (msg.verified())
+                TcpDiscoverySpiState state0;
+
+                synchronized (mux) {
+                    state0 = spiState;
+                }
+
+                if (msg.verified() && msg.topologyVersion() != ring.topologyVersion()) {
+                    if (log.isDebugEnabled())
+                        log.debug("Discarding custom event message [msg=" + msg + ", ring=" + ring + ']');
+
+                    return;
+                }
+
+                if (msg.verified() && state0 == CONNECTED && pendingMsgs.procCustomMsgs.add(msg.id())) {
+                    assert joiningNodes.isEmpty() : "Joining nodes: " + joiningNodes + ", msg=" + msg + ", loc=" + locNode.id() +
+                        ", topver=" + ring.topologyVersion();
+                    assert msg.topologyVersion() == ring.topologyVersion() : "msg: " + msg + ", topver=" + ring.topologyVersion();
+
                     notifyDiscoveryListener(msg);
+                }
 
                 if (ring.hasRemoteNodes())
                     sendMessageAcrossRing(msg);
@@ -4152,6 +4305,18 @@ class ServerImpl extends TcpDiscoveryImpl {
         }
 
         /**
+         * Checks and flushes custom event messages if no nodes are attempting to join the grid.
+         */
+        private void checkPendingCustomMessages() {
+            if (joiningNodes.isEmpty() && isLocalNodeCoordinator()) {
+                TcpDiscoveryCustomEventMessage msg;
+
+                while ((msg = pendingCustomMsgs.poll()) != null)
+                    processCustomMessage(msg);
+            }
+        }
+
+        /**
          * @param msg Custom message.
          */
         private void notifyDiscoveryListener(TcpDiscoveryCustomEventMessage msg) {
@@ -5081,7 +5246,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                             log.debug("Redirecting message to client [sock=" + sock + ", locNodeId="
                                 + getLocalNodeId() + ", rmtNodeId=" + clientNodeId + ", msg=" + msg + ']');
 
-                        prepareNodeAddedMessage(msg, clientNodeId, null, null);
+                        prepareNodeAddedMessage(msg, clientNodeId, null, null, null);
 
                         writeToSocket(sock, msg, spi.failureDetectionTimeoutEnabled() ?
                             spi.failureDetectionTimeout() : spi.getSocketTimeout());

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
index e5be530..2786d0b 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
@@ -5,9 +5,9 @@
  * 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.
@@ -313,4 +313,4 @@ abstract class TcpDiscoveryImpl {
 
         return res;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 80fcc46..6254605 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -2038,4 +2038,4 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
             return S.toString(SocketTimeoutObject.class, this);
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java
index 2b17696..7ca092c 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNodesRing.java
@@ -17,7 +17,17 @@
 
 package org.apache.ignite.spi.discovery.tcp.internal;
 
-import java.util.ArrayList;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.PN;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.jetbrains.annotations.Nullable;
+
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -29,16 +39,6 @@ import java.util.TreeSet;
 import java.util.UUID;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.P1;
-import org.apache.ignite.internal.util.typedef.PN;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * Convenient way to represent topology for {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi}
@@ -81,6 +81,9 @@ public class TcpDiscoveryNodesRing {
     /** */
     private long nodeOrder;
 
+    /** */
+    private long maxInternalOrder;
+
     /** Lock. */
     @GridToStringExclude
     private final ReadWriteLock rwLock = new ReentrantReadWriteLock();
@@ -99,6 +102,8 @@ public class TcpDiscoveryNodesRing {
             this.locNode = locNode;
 
             clear();
+
+            maxInternalOrder = locNode.internalOrder();
         }
         finally {
             rwLock.writeLock().unlock();
@@ -204,7 +209,9 @@ public class TcpDiscoveryNodesRing {
             if (nodesMap.containsKey(node.id()))
                 return false;
 
-            assert node.internalOrder() > maxInternalOrder() : "Adding node to the middle of the ring " +
+            long maxInternalOrder0 = maxInternalOrder();
+
+            assert node.internalOrder() > maxInternalOrder0 : "Adding node to the middle of the ring " +
                 "[ring=" + this + ", node=" + node + ']';
 
             nodesMap.put(node.id(), node);
@@ -216,6 +223,8 @@ public class TcpDiscoveryNodesRing {
             nodes.add(node);
 
             nodeOrder = node.internalOrder();
+
+            maxInternalOrder = node.internalOrder();
         }
         finally {
             rwLock.writeLock().unlock();
@@ -231,9 +240,13 @@ public class TcpDiscoveryNodesRing {
         rwLock.readLock().lock();
 
         try {
-            TcpDiscoveryNode last = nodes.last();
+            if (maxInternalOrder == 0) {
+                TcpDiscoveryNode last = nodes.last();
+
+                return last != null ? maxInternalOrder = last.internalOrder() : -1;
+            }
 
-            return last != null ? last.internalOrder() : -1;
+            return maxInternalOrder;
         }
         finally {
             rwLock.readLock().unlock();
@@ -336,47 +349,6 @@ public class TcpDiscoveryNodesRing {
     }
 
     /**
-     * Removes nodes from the topology.
-     *
-     * @param nodeIds IDs of the nodes to remove.
-     * @return Collection of removed nodes.
-     */
-    public Collection<TcpDiscoveryNode> removeNodes(Collection<UUID> nodeIds) {
-        assert !F.isEmpty(nodeIds);
-
-        rwLock.writeLock().lock();
-
-        try {
-            boolean firstRmv = true;
-
-            Collection<TcpDiscoveryNode> res = null;
-
-            for (UUID id : nodeIds) {
-                TcpDiscoveryNode rmv = nodesMap.remove(id);
-
-                if (rmv != null) {
-                    if (firstRmv) {
-                        nodes = new TreeSet<>(nodes);
-
-                        res = new ArrayList<>(nodeIds.size());
-
-                        firstRmv = false;
-                    }
-
-                    nodes.remove(rmv);
-
-                    res.add(rmv);
-                }
-            }
-
-            return res == null ? Collections.<TcpDiscoveryNode>emptyList() : res;
-        }
-        finally {
-            rwLock.writeLock().unlock();
-        }
-    }
-
-    /**
      * Removes all remote nodes, leaves only local node.
      * <p>
      * This should be called when SPI should be disconnected from topology and
@@ -397,6 +369,7 @@ public class TcpDiscoveryNodesRing {
                 nodesMap.put(locNode.id(), locNode);
 
             nodeOrder = 0;
+            maxInternalOrder = 0;
 
             topVer = 0;
         }
@@ -622,13 +595,8 @@ public class TcpDiscoveryNodesRing {
         rwLock.writeLock().lock();
 
         try {
-            if (nodeOrder == 0) {
-                TcpDiscoveryNode last = nodes.last();
-
-                assert last != null;
-
-                nodeOrder = last.internalOrder();
-            }
+            if (nodeOrder == 0)
+                nodeOrder = maxInternalOrder();
 
             return ++nodeOrder;
         }
@@ -681,4 +649,4 @@ public class TcpDiscoveryNodesRing {
             rwLock.readLock().unlock();
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java
index 1e1fa6b..145f19e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java
@@ -32,16 +32,20 @@ public class TcpDiscoveryDiscardMessage extends TcpDiscoveryAbstractMessage {
     /** ID of the message to discard (this and all preceding). */
     private final IgniteUuid msgId;
 
+    /** True if this is discard ID for custom event message. */
+    private final boolean customMsgDiscard;
+
     /**
      * Constructor.
      *
      * @param creatorNodeId Creator node ID.
      * @param msgId Message ID.
      */
-    public TcpDiscoveryDiscardMessage(UUID creatorNodeId, IgniteUuid msgId) {
+    public TcpDiscoveryDiscardMessage(UUID creatorNodeId, IgniteUuid msgId, boolean customMsgDiscard) {
         super(creatorNodeId);
 
         this.msgId = msgId;
+        this.customMsgDiscard = customMsgDiscard;
     }
 
     /**
@@ -53,6 +57,15 @@ public class TcpDiscoveryDiscardMessage extends TcpDiscoveryAbstractMessage {
         return msgId;
     }
 
+    /**
+     * Flag indicating whether the ID to discard is for a custom message or not.
+     *
+     * @return Custom message flag.
+     */
+    public boolean customMessageDiscard() {
+        return customMsgDiscard;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(TcpDiscoveryDiscardMessage.class, this, "super", super.toString());

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java
index c6a469f..1b99a56 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java
@@ -101,4 +101,4 @@ public class TcpDiscoveryNodeAddFinishedMessage extends TcpDiscoveryAbstractMess
     @Override public String toString() {
         return S.toString(TcpDiscoveryNodeAddFinishedMessage.class, this, "super", super.toString());
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java
index 01c6789..5a7146d 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java
@@ -48,6 +48,9 @@ public class TcpDiscoveryNodeAddedMessage extends TcpDiscoveryAbstractMessage {
     /** Discarded message ID. */
     private IgniteUuid discardMsgId;
 
+    /** Discarded message ID. */
+    private IgniteUuid discardCustomMsgId;
+
     /** Current topology. Initialized by coordinator. */
     @GridToStringInclude
     private Collection<TcpDiscoveryNode> top;
@@ -117,14 +120,28 @@ public class TcpDiscoveryNodeAddedMessage extends TcpDiscoveryAbstractMessage {
     }
 
     /**
+     * Gets discarded custom message ID.
+     *
+     * @return Discarded message ID.
+     */
+    @Nullable public IgniteUuid discardedCustomMessageId() {
+        return discardCustomMsgId;
+    }
+
+    /**
      * Sets pending messages to send to new node.
      *
      * @param msgs Pending messages to send to new node.
      * @param discardMsgId Discarded message ID.
      */
-    public void messages(@Nullable Collection<TcpDiscoveryAbstractMessage> msgs, @Nullable IgniteUuid discardMsgId) {
+    public void messages(
+        @Nullable Collection<TcpDiscoveryAbstractMessage> msgs,
+        @Nullable IgniteUuid discardMsgId,
+        @Nullable IgniteUuid discardCustomMsgId
+    ) {
         this.msgs = msgs;
         this.discardMsgId = discardMsgId;
+        this.discardCustomMsgId = discardCustomMsgId;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java
deleted file mode 100644
index 7f0ca11..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.distributed;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Random;
-import java.util.UUID;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteFutureTimeoutException;
-import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class CacheAffEarlySelfTest extends GridCommonAbstractTest {
-    /** Grid count. */
-    private static int GRID_CNT = 8;
-
-    /** Operation timeout. */
-    private static long OP_TIMEOUT = 5000;
-
-    /** Always dump threads or only once per operation. */
-    private static boolean ALWAYS_DUMP_THREADS = false;
-
-    /** Stopped. */
-    private volatile boolean stopped;
-
-    /** Iteration. */
-    private int iters = 10;
-
-    /** Concurrent. */
-    private boolean concurrent = true;
-
-    /** Futs. */
-    private Collection<IgniteInternalFuture<?>> futs = new ArrayList<>(GRID_CNT);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder(true);
-        finder.setAddresses(Collections.singletonList("127.0.0.1:47500..47510"));
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-        discoSpi.setIpFinder(finder);
-
-        cfg.setDiscoverySpi(discoSpi);
-
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
-        marsh.setRequireSerializable(false);
-
-        cfg.setMarshaller(marsh);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long getTestTimeout() {
-        return 6 * 60 * 1000L;
-    }
-
-    /**
-     *
-     */
-    public void testStartNodes() throws Exception {
-        for (int i = 0; i < iters; i++) {
-            try {
-                System.out.println("*** Iteration " + (i + 1) + '/' + iters);
-
-                IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-                    @Override public void run() {
-                        try {
-                            doTest();
-                        }
-                        catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
-                }, 1);
-
-                fut.get(30000);
-            }
-            catch (IgniteFutureTimeoutCheckedException e) {
-                // No-op.
-            }
-            finally {
-                stopAllGrids(true);
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    public void doTest() throws Exception {
-        for (int i = 0; i < GRID_CNT; i++) {
-            final int idx = i;
-
-            final Ignite grid = concurrent ? null : startGrid(idx);
-
-            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-                @Override public void run() {
-                    Random rnd = new Random();
-
-                    try {
-                        final Ignite ignite = grid == null ? startGrid(idx) : grid;
-
-                        final IgniteCache<UUID, UUID> cache = getCache(ignite).withAsync();
-
-                        CacheAffEarlySelfTest.this.execute(cache, new IgniteInClosure<IgniteCache<UUID,UUID>>() {
-                            @Override public void apply(IgniteCache<UUID, UUID> entries) {
-                                cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
-                            }
-                        });
-
-                        while (!stopped) {
-                            int val = Math.abs(rnd.nextInt(100));
-                            if (val >= 0 && val < 40)
-                                execute(cache, new IgniteInClosure<IgniteCache<UUID, UUID>>() {
-                                    @Override public void apply(IgniteCache<UUID, UUID> entries) {
-                                        cache.containsKey(ignite.cluster().localNode().id());
-                                    }
-                                });
-                            else if (val >= 40 && val < 80)
-                                execute(cache, new IgniteInClosure<IgniteCache<UUID, UUID>>() {
-                                    @Override public void apply(IgniteCache<UUID, UUID> entries) {
-                                        cache.get(ignite.cluster().localNode().id());
-                                    }
-                                });
-                            else
-                                execute(cache, new IgniteInClosure<IgniteCache<UUID, UUID>>() {
-                                    @Override public void apply(IgniteCache<UUID, UUID> entries) {
-                                        cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
-                                    }
-                                });
-
-                            Thread.sleep(50);
-                        }
-                    }
-                    catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                }
-            }, 1);
-
-            futs.add(fut);
-        }
-
-        Thread.sleep(10000);
-
-        stopped = true;
-
-        for (IgniteInternalFuture<?> fut : futs)
-            fut.get();
-    }
-
-    /**
-     * @param cache Cache.
-     * @param c Closure.
-     */
-    private void execute(IgniteCache<UUID, UUID> cache, IgniteInClosure<IgniteCache<UUID, UUID>> c) {
-        c.apply(cache);
-
-        IgniteFuture<Object> fut = cache.future();
-
-        boolean success = false;
-
-        int iter = 0;
-
-        while (!success) {
-            try {
-                fut.get(OP_TIMEOUT);
-
-                success = true;
-            }
-            catch (IgniteFutureTimeoutException e) {
-                debug(iter == 0 || ALWAYS_DUMP_THREADS);
-            }
-
-            iter++;
-        }
-    }
-
-    /**
-     *
-     */
-    private void debug(boolean dumpThreads) {
-        log.info("DUMPING DEBUG INFO:");
-
-        for (Ignite ignite : G.allGrids())
-            ((IgniteKernal)ignite).dumpDebugInfo();
-
-        if (dumpThreads) {
-            U.dumpThreads(null);
-
-            U.dumpThreads(log);
-        }
-    }
-
-    /**
-     * @param grid Grid.
-     */
-    private IgniteCache<UUID, UUID> getCache(Ignite grid) {
-        CacheConfiguration<UUID, UUID> ccfg = defaultCacheConfiguration();
-
-        ccfg.setCacheMode(CacheMode.PARTITIONED);
-        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
-        ccfg.setBackups(1);
-        ccfg.setNearConfiguration(null);
-
-        return grid.getOrCreateCache(ccfg);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java
new file mode 100644
index 0000000..6b67139
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+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 CacheAffinityEarlyTest extends GridCommonAbstractTest {
+    /** Grid count. */
+    private static int GRID_CNT = 8;
+
+    /** Stopped. */
+    private volatile boolean stopped;
+
+    /** Iteration. */
+    private static final int iters = 10;
+
+    /** Concurrent. */
+    private static final boolean concurrent = true;
+
+    /** Futs. */
+    private Collection<IgniteInternalFuture<?>> futs = new ArrayList<>(GRID_CNT);
+
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+        discoSpi.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        marsh.setRequireSerializable(false);
+
+        cfg.setMarshaller(marsh);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 6 * 60 * 1000L;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStartNodes() throws Exception {
+        for (int i = 0; i < iters; i++) {
+            try {
+                log.info("Iteration: " + (i + 1) + '/' + iters);
+
+                doTest();
+            }
+            finally {
+                stopAllGrids(true);
+            }
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void doTest() throws Exception {
+        final AtomicBoolean failed = new AtomicBoolean();
+
+        for (int i = 0; i < GRID_CNT; i++) {
+            final int idx = i;
+
+            final Ignite grid = concurrent ? null : startGrid(idx);
+
+            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+                @Override public void run() {
+                    Random rnd = new Random();
+
+                    try {
+                        Ignite ignite = grid == null ? startGrid(idx) : grid;
+
+                        IgniteCache<Object, Object> cache = getCache(ignite);
+
+                        cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
+
+                        while (!stopped) {
+                            int val = Math.abs(rnd.nextInt(100));
+
+                            if (val >= 0 && val < 40)
+                                cache.containsKey(ignite.cluster().localNode().id());
+                            else if (val >= 40 && val < 80)
+                                cache.get(ignite.cluster().localNode().id());
+                            else
+                                cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
+
+                            Thread.sleep(50);
+                        }
+                    }
+                    catch (Exception e) {
+                        log.error("Unexpected error: " + e, e);
+
+                        failed.set(true);
+                    }
+                }
+            }, 1);
+
+            futs.add(fut);
+        }
+
+        Thread.sleep(10_000);
+
+        stopped = true;
+
+        for (IgniteInternalFuture<?> fut : futs)
+            fut.get();
+
+        assertFalse(failed.get());
+    }
+
+    /**
+     * @param grid Grid.
+     * @return Cache.
+     */
+    private IgniteCache getCache(Ignite grid) {
+        CacheConfiguration ccfg = defaultCacheConfiguration();
+
+        ccfg.setCacheMode(CacheMode.PARTITIONED);
+        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+        ccfg.setBackups(1);
+        ccfg.setNearConfiguration(null);
+
+        return grid.getOrCreateCache(ccfg);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheValueConsistencyAtomicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheValueConsistencyAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheValueConsistencyAtomicSelfTest.java
index 7451911..18c8d8e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheValueConsistencyAtomicSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheValueConsistencyAtomicSelfTest.java
@@ -35,4 +35,4 @@ public class GridCacheValueConsistencyAtomicSelfTest extends GridCacheValueConsi
     @Override protected int iterationCount() {
         return 100_000;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
index 16fa662..1ccbe1f 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
@@ -102,7 +102,7 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected long getTestTimeout() {
-        return 3 * 60 * 1000;
+        return 5 * 60 * 1000;
     }
 
     /**
@@ -249,35 +249,48 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
      * @throws Exception If any error occurs.
      */
     public void testMultipleStartOnCoordinatorStop() throws Exception{
-        clientFlagGlobal = false;
+        for (int k = 0; k < 3; k++) {
+            log.info("Iteration: " + k);
 
-        startGrids(GRID_CNT);
+            clientFlagGlobal = false;
 
-        final CyclicBarrier barrier = new CyclicBarrier(GRID_CNT + 4);
+            final int START_NODES = 5;
+            final int JOIN_NODES = 10;
 
-        final AtomicInteger startIdx = new AtomicInteger(GRID_CNT);
+            startGrids(START_NODES);
 
-        IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                barrier.await();
+            final CyclicBarrier barrier = new CyclicBarrier(JOIN_NODES + 1);
 
-                Ignite ignite = startGrid(startIdx.getAndIncrement());
+            final AtomicInteger startIdx = new AtomicInteger(START_NODES);
 
-                assertFalse(ignite.configuration().isClientMode());
+            IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    int idx = startIdx.getAndIncrement();
 
-                log.info("Started node: " + ignite.name());
+                    Thread.currentThread().setName("start-thread-" + idx);
 
-                return null;
-            }
-        }, GRID_CNT + 3, "start-thread");
+                    barrier.await();
 
-        barrier.await();
+                    Ignite ignite = startGrid(idx);
 
-        U.sleep(ThreadLocalRandom.current().nextInt(10, 100));
+                    assertFalse(ignite.configuration().isClientMode());
 
-        for (int i = 0; i < GRID_CNT; i++)
-            stopGrid(i);
+                    log.info("Started node: " + ignite.name());
+
+                    return null;
+                }
+            }, JOIN_NODES, "start-thread");
 
-        fut.get();
+            barrier.await();
+
+            U.sleep(ThreadLocalRandom.current().nextInt(10, 100));
+
+            for (int i = 0; i < START_NODES; i++)
+                stopGrid(i);
+
+            fut.get();
+
+            stopAllGrids();
+        }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/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 981f649..0280e9c 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
@@ -35,8 +35,10 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.events.Event;
@@ -45,6 +47,7 @@ import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.port.GridPortRecord;
+import org.apache.ignite.internal.util.io.GridByteArrayOutputStream;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.X;
@@ -52,11 +55,14 @@ 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.spi.IgniteSpiException;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.spi.discovery.DiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddedMessage;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeLeftMessage;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingResponse;
@@ -87,6 +93,9 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
     /** */
     private UUID nodeId;
 
+    /** */
+    private TcpDiscoverySpi nodeSpi;
+
     /**
      * @throws Exception If fails.
      */
@@ -99,8 +108,11 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        TcpDiscoverySpi spi = gridName.contains("testPingInterruptedOnNodeFailedFailingNode") ?
-            new TestTcpDiscoverySpi() : new TcpDiscoverySpi();
+        TcpDiscoverySpi spi = nodeSpi;
+
+        if (spi == null)
+            spi = gridName.contains("testPingInterruptedOnNodeFailedFailingNode") ?
+                new TestTcpDiscoverySpi() : new TcpDiscoverySpi();
 
         discoMap.put(gridName, spi);
 
@@ -1164,6 +1176,305 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed
+     */
+    public void testCustomEventRace1_1() throws Exception {
+        try {
+            customEventRace1(true, false);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If failed
+     */
+    public void testCustomEventRace1_2() throws Exception {
+        try {
+            customEventRace1(false, false);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If failed
+     */
+    public void testCustomEventRace1_3() throws Exception {
+        try {
+            customEventRace1(true, true);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param cacheStartFrom1 If {code true} starts cache from node1.
+     * @param stopCrd If {@code true} stops coordinator.
+     * @throws Exception If failed
+     */
+    private void customEventRace1(final boolean cacheStartFrom1, boolean stopCrd) throws Exception {
+        TestCustomEventRaceSpi spi0 = new TestCustomEventRaceSpi();
+
+        nodeSpi = spi0;
+
+        final Ignite ignite0 = startGrid(0);
+
+        nodeSpi = new TestCustomEventRaceSpi();
+
+        final Ignite ignite1 = startGrid(1);
+
+        CountDownLatch latch1 = new CountDownLatch(1);
+        CountDownLatch latch2 = new CountDownLatch(1);
+
+        spi0.nodeAdded1 = latch1;
+        spi0.nodeAdded2 = latch2;
+        spi0.debug = true;
+
+        IgniteInternalFuture<?> fut1 = GridTestUtils.runAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                log.info("Start 2");
+
+                nodeSpi = new TestCustomEventRaceSpi();
+
+                Ignite ignite2 = startGrid(2);
+
+                return null;
+            }
+        });
+
+        latch1.await();
+
+        final String CACHE_NAME = "cache";
+
+        IgniteInternalFuture<?> fut2 = GridTestUtils.runAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                CacheConfiguration ccfg = new CacheConfiguration();
+
+                ccfg.setName(CACHE_NAME);
+
+                Ignite ignite = cacheStartFrom1 ? ignite1 : ignite0;
+
+                ignite.createCache(ccfg);
+
+                return null;
+            }
+        });
+
+        if (stopCrd) {
+            spi0.stop = true;
+
+            latch2.countDown();
+
+            ignite0.close();
+        }
+        else {
+            U.sleep(500);
+
+            latch2.countDown();
+        }
+
+        fut1.get();
+        fut2.get();
+
+        IgniteCache<Object, Object> cache = grid(2).cache(CACHE_NAME);
+
+        assertNotNull(cache);
+
+        cache.put(1, 1);
+
+        assertEquals(1, cache.get(1));
+
+        nodeSpi = new TestCustomEventRaceSpi();
+
+        Ignite ignite = startGrid(3);
+
+        cache = ignite.cache(CACHE_NAME);
+
+        cache.put(2, 2);
+
+        assertEquals(1, cache.get(1));
+        assertEquals(2, cache.get(2));
+    }
+
+    /**
+     * @throws Exception If failed
+     */
+    public void testCustomEventCoordinatorFailure1() throws Exception {
+        try {
+            customEventCoordinatorFailure(true);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If failed
+     */
+    public void testCustomEventCoordinatorFailure2() throws Exception {
+        try {
+            customEventCoordinatorFailure(false);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param twoNodes If {@code true} starts two nodes, otherwise three.
+     * @throws Exception If failed
+     */
+    private void customEventCoordinatorFailure(boolean twoNodes) throws Exception {
+        TestCustomEventCoordinatorFailureSpi spi0 = new TestCustomEventCoordinatorFailureSpi();
+
+        nodeSpi = spi0;
+
+        Ignite ignite0 = startGrid(0);
+
+        nodeSpi = new TestCustomEventCoordinatorFailureSpi();
+
+        Ignite ignite1 = startGrid(1);
+
+        nodeSpi = new TestCustomEventCoordinatorFailureSpi();
+
+        Ignite ignite2 = twoNodes ? null : startGrid(2);
+
+        final Ignite createCacheNode = ignite2 != null ? ignite2 : ignite1;
+
+        CountDownLatch latch = new CountDownLatch(1);
+
+        spi0.latch = latch;
+
+        final String CACHE_NAME = "test-cache";
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                log.info("Create test cache");
+
+                CacheConfiguration ccfg = new CacheConfiguration();
+
+                ccfg.setName(CACHE_NAME);
+
+                createCacheNode.createCache(ccfg);
+
+                return null;
+            }
+        }, "create-cache-thread");
+
+        ((TcpCommunicationSpi)ignite0.configuration().getCommunicationSpi()).simulateNodeFailure();
+
+        latch.await();
+
+        ignite0.close();
+
+        fut.get();
+
+        IgniteCache<Object, Object> cache = grid(1).cache(CACHE_NAME);
+
+        assertNotNull(cache);
+
+        cache.put(1, 1);
+
+        assertEquals(1, cache.get(1));
+
+        log.info("Try start one more node.");
+
+        nodeSpi = new TestCustomEventCoordinatorFailureSpi();
+
+        Ignite ignite = startGrid(twoNodes ? 2 : 3);
+
+        cache = ignite.cache(CACHE_NAME);
+
+        assertNotNull(cache);
+
+        cache.put(2, 2);
+
+        assertEquals(1, cache.get(1));
+        assertEquals(2, cache.get(2));
+    }
+
+    /**
+     *
+     */
+    private static class TestCustomEventCoordinatorFailureSpi extends TcpDiscoverySpi {
+        /** */
+        private volatile CountDownLatch latch;
+
+        /** */
+        private boolean stop;
+
+        /** {@inheritDoc} */
+        @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg,
+            GridByteArrayOutputStream bout, long timeout) throws IOException, IgniteCheckedException {
+            if (msg instanceof TcpDiscoveryCustomEventMessage && latch != null) {
+                log.info("Stop node on custom event: " + msg);
+
+                latch.countDown();
+
+                stop = true;
+            }
+
+            if (stop)
+                return;
+
+            super.writeToSocket(sock, msg, bout, timeout);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class TestCustomEventRaceSpi extends TcpDiscoverySpi {
+        /** */
+        private volatile CountDownLatch nodeAdded1;
+
+        /** */
+        private volatile CountDownLatch nodeAdded2;
+
+        /** */
+        private volatile boolean stop;
+
+        /** */
+        private boolean debug;
+
+        /** {@inheritDoc} */
+        @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg,
+            GridByteArrayOutputStream bout, long timeout) throws IOException, IgniteCheckedException {
+            if (msg instanceof TcpDiscoveryNodeAddedMessage) {
+                if (nodeAdded1 != null) {
+                    nodeAdded1.countDown();
+
+                    if (debug)
+                        log.info("--- Wait node added: " + msg);
+
+                    U.await(nodeAdded2);
+
+                    nodeAdded1 = null;
+                    nodeAdded2 = null;
+                }
+
+                if (stop)
+                    return;
+
+                if (debug)
+                    log.info("--- Send node added: " + msg);
+            }
+
+            if (debug && msg instanceof TcpDiscoveryNodeAddFinishedMessage)
+                log.info("--- Send node finished: " + msg);
+
+            if (debug && msg instanceof TcpDiscoveryCustomEventMessage)
+                log.info("--- Send custom event: " + msg);
+
+            super.writeToSocket(sock, msg, bout, timeout);
+        }
+    }
+
+    /**
      * Starts new grid with given index. Method optimize is not invoked.
      *
      * @param idx Index of the grid to start.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f3ef6a8/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 88977fb..289da3d 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
@@ -74,6 +74,7 @@ import org.apache.ignite.internal.processors.cache.IgniteInternalCacheTypesTest;
 import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionAtomicSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest;
+import org.apache.ignite.internal.processors.cache.distributed.CacheAffinityEarlyTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheLockFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheMultiTxLockSelfTest;
@@ -195,6 +196,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteCacheConfigurationDefaultTemplateTest.class);
         suite.addTestSuite(IgniteDynamicClientCacheStartSelfTest.class);
         suite.addTestSuite(IgniteDynamicCacheStartNoExchangeTimeoutTest.class);
+        suite.addTestSuite(CacheAffinityEarlyTest.class);
 
         suite.addTestSuite(GridCacheTxLoadFromStoreOnLockSelfTest.class);
 


[18/41] ignite git commit: Enabled test for atomic cache.

Posted by an...@apache.org.
Enabled test for atomic cache.


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

Branch: refs/heads/ignite-1168
Commit: 03a8fe587e46404461bff6f118ccbb8539f3f39a
Parents: bf7591b
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 25 13:12:11 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 25 13:12:11 2015 +0300

----------------------------------------------------------------------
 .../expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/03a8fe58/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
index 99af872..78c59ac 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
@@ -25,6 +25,7 @@ import javax.cache.integration.CompletionListenerFuture;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -141,7 +142,8 @@ public abstract class IgniteCacheExpiryPolicyWithStoreAbstractTest extends Ignit
      * @throws Exception If failed.
      */
     public void testReadThrough() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-821");
+        if (atomicityMode() == CacheAtomicityMode.TRANSACTIONAL)
+            fail("https://issues.apache.org/jira/browse/IGNITE-821");
 
         IgniteCache<Integer, Integer> cache = jcache(0);
 
@@ -185,6 +187,7 @@ public abstract class IgniteCacheExpiryPolicyWithStoreAbstractTest extends Ignit
     /**
      * @param key Key.
      * @param ttl TTL.
+     * @param primaryOnly If {@code true} expect entries only on primary node.
      * @throws Exception If failed.
      */
     private void checkTtl(Object key, final long ttl, boolean primaryOnly) throws Exception {


[25/41] ignite git commit: IGNITE-1554 Fix igniterouter scripts.

Posted by an...@apache.org.
IGNITE-1554 Fix igniterouter scripts.


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

Branch: refs/heads/ignite-1168
Commit: dc379fe14179a819818e31b190a68982f4dd24a7
Parents: cdc5b49
Author: Raul Kripalani <ra...@apache.org>
Authored: Sat Sep 26 11:31:11 2015 +0100
Committer: Raul Kripalani <ra...@apache.org>
Committed: Sat Sep 26 11:34:55 2015 +0100

----------------------------------------------------------------------
 bin/igniterouter.bat | 2 +-
 bin/igniterouter.sh  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dc379fe1/bin/igniterouter.bat
----------------------------------------------------------------------
diff --git a/bin/igniterouter.bat b/bin/igniterouter.bat
index b1f9148..0a9775e 100644
--- a/bin/igniterouter.bat
+++ b/bin/igniterouter.bat
@@ -27,7 +27,7 @@ if "%OS%" == "Windows_NT" setlocal
 :: Set router service environment.
 ::
 set "DEFAULT_CONFIG=config\router\default-router.xml"
-set MAIN_CLASS=org.apache.ignite.client.router.impl.GridRouterCommandLineStartup
+set MAIN_CLASS=org.apache.ignite.internal.client.router.impl.GridRouterCommandLineStartup
 
 ::
 :: Start router service.

http://git-wip-us.apache.org/repos/asf/ignite/blob/dc379fe1/bin/igniterouter.sh
----------------------------------------------------------------------
diff --git a/bin/igniterouter.sh b/bin/igniterouter.sh
index 9ab848e..af27f8b 100755
--- a/bin/igniterouter.sh
+++ b/bin/igniterouter.sh
@@ -45,7 +45,7 @@ setIgniteHome
 # Set router service environment.
 #
 export DEFAULT_CONFIG=config/router/default-router.xml
-export MAIN_CLASS=org.apache.ignite.client.router.impl.GridRouterCommandLineStartup
+export MAIN_CLASS=org.apache.ignite.internal.client.router.impl.GridRouterCommandLineStartup
 
 #
 # Start router service.


[36/41] ignite git commit: Added tests.

Posted by an...@apache.org.
Added tests.


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

Branch: refs/heads/ignite-1168
Commit: ce3f20be6d1950fa182f1622b92984b465ae27cd
Parents: c6bb01b
Author: sboikov <sb...@gridgain.com>
Authored: Tue Sep 29 09:52:46 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Sep 29 09:52:46 2015 +0300

----------------------------------------------------------------------
 .../IgniteCrossCacheTxNearEnabledSelfTest.java  |  28 +++
 .../dht/IgniteCrossCacheTxSelfTest.java         | 213 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 3 files changed, 243 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ce3f20be/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxNearEnabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxNearEnabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxNearEnabledSelfTest.java
new file mode 100644
index 0000000..f70cedf
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxNearEnabledSelfTest.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.cache.distributed.dht;
+
+/**
+ *
+ */
+public class IgniteCrossCacheTxNearEnabledSelfTest extends IgniteCrossCacheTxSelfTest {
+    /** {@inheritDoc} */
+    @Override protected boolean nearEnabled() {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ce3f20be/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxSelfTest.java
new file mode 100644
index 0000000..bf9b1c6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxSelfTest.java
@@ -0,0 +1,213 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jsr166.ThreadLocalRandom8;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ * Tests specific combinations of cross-cache transactions.
+ */
+public class IgniteCrossCacheTxSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final String FIRST_CACHE = "FirstCache";
+
+    /** */
+    private static final String SECOND_CACHE = "SecondCache";
+
+    /** */
+    private static final int TX_CNT = 500;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        return cfg;
+    }
+
+    /**
+     * @return Node count for this test.
+     */
+    private int nodeCount() {
+        return 4;
+    }
+
+    /**
+     * @return {@code True} if near cache should be enabled.
+     */
+    protected boolean nearEnabled() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGridsMultiThreaded(nodeCount());
+
+        CacheConfiguration firstCfg = new CacheConfiguration(FIRST_CACHE);
+        firstCfg.setBackups(1);
+        firstCfg.setAtomicityMode(TRANSACTIONAL);
+        firstCfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        grid(0).createCache(firstCfg);
+
+        CacheConfiguration secondCfg = new CacheConfiguration(SECOND_CACHE);
+        secondCfg.setBackups(1);
+        secondCfg.setAtomicityMode(TRANSACTIONAL);
+        secondCfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        if (nearEnabled())
+            secondCfg.setNearConfiguration(new NearCacheConfiguration());
+
+        grid(0).createCache(secondCfg);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticReadCommitted() throws Exception {
+        checkTxsSingleOp(PESSIMISTIC, READ_COMMITTED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticRepeatableRead() throws Exception {
+        checkTxsSingleOp(PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticReadCommitted() throws Exception {
+        checkTxsSingleOp(OPTIMISTIC, READ_COMMITTED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticRepeatableRead() throws Exception {
+        checkTxsSingleOp(OPTIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @param concurrency Concurrency.
+     * @param isolation Isolation.
+     * @throws Exception If failed.
+     */
+    private void checkTxsSingleOp(TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception {
+        Map<Integer, String> firstCheck = new HashMap<>();
+        Map<Integer, String> secondCheck = new HashMap<>();
+
+        for (int i = 0; i < TX_CNT; i++) {
+            int grid = ThreadLocalRandom8.current().nextInt(nodeCount());
+
+            try (Transaction tx = grid(grid).transactions().txStart(concurrency, isolation)) {
+                try {
+                    IgniteCache<Integer, String> first = grid(grid).cache(FIRST_CACHE);
+                    IgniteCache<Integer, String> second = grid(grid).cache(SECOND_CACHE);
+
+                    int size = ThreadLocalRandom8.current().nextInt(24) + 1;
+
+                    for (int k = 0; k < size; k++) {
+                        boolean rnd = ThreadLocalRandom8.current().nextBoolean();
+
+                        IgniteCache<Integer, String> cache = rnd ? first : second;
+                        Map<Integer, String> check = rnd ? firstCheck : secondCheck;
+
+                        String val = rnd ? "first" + i : "second" + i;
+
+                        cache.put(k, val);
+                        check.put(k, val);
+                    }
+
+                    tx.commit();
+                }
+                catch (Throwable e) {
+                    e.printStackTrace();
+
+                    throw e;
+                }
+            }
+
+            if (i > 0 && i % 100 == 0)
+                info("Finished iteration: " + i);
+        }
+
+        for (int g = 0; g < nodeCount(); g++) {
+            IgniteEx grid = grid(g);
+
+            assertEquals(0, grid.context().cache().context().tm().idMapSize());
+
+            ClusterNode locNode = grid.localNode();
+
+            IgniteCache<Object, Object> firstCache = grid.cache(FIRST_CACHE);
+
+            for (Map.Entry<Integer, String> entry : firstCheck.entrySet()) {
+                boolean primary = grid.affinity(FIRST_CACHE).isPrimary(locNode, entry.getKey());
+
+                boolean backup = grid.affinity(FIRST_CACHE).isBackup(locNode, entry.getKey());
+
+                assertEquals("Invalid value found first cache [primary=" + primary + ", backup=" + backup +
+                        ", node=" + locNode.id() + ", key=" + entry.getKey() + ']',
+                    entry.getValue(), firstCache.get(entry.getKey()));
+            }
+
+            for (Map.Entry<Integer, String> entry : secondCheck.entrySet()) {
+                boolean primary = grid.affinity(SECOND_CACHE).isPrimary(locNode, entry.getKey());
+
+                boolean backup = grid.affinity(SECOND_CACHE).isBackup(locNode, entry.getKey());
+
+                assertEquals("Invalid value found second cache [primary=" + primary + ", backup=" + backup +
+                        ", node=" + locNode.id() + ", key=" + entry.getKey() + ']',
+                    entry.getValue(), grid.cache(SECOND_CACHE).get(entry.getKey()));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ce3f20be/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 80d53e9..3842336 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
@@ -81,6 +81,7 @@ import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClass
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtTxPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheLockFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheMultiTxLockSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCrossCacheTxSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearTxPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheNearReadCommittedTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridReplicatedTxPreloadTest;
@@ -273,6 +274,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteDynamicCacheFilterTest.class);
 
         suite.addTestSuite(CrossCacheLockTest.class);
+        suite.addTestSuite(IgniteCrossCacheTxSelfTest.class);
 
         return suite;
     }


[19/41] ignite git commit: Enabled test.

Posted by an...@apache.org.
Enabled test.


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

Branch: refs/heads/ignite-1168
Commit: 27cf5016a5c859c877a95d793c622926bafb2f9f
Parents: 03a8fe5
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 25 13:33:27 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 25 13:33:27 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/GridUpdateNotifierSelfTest.java  | 1 +
 ...ridCachePartitionedQueueFailoverDataConsistencySelfTest.java | 5 -----
 2 files changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/27cf5016/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
index 61c2085..93fd916 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridUpdateNotifierSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridUpdateNotifierSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonTest;
  */
 @GridCommonTest(group = "Kernal Self")
 public class GridUpdateNotifierSelfTest extends GridCommonAbstractTest {
+    /** */
     private String updateStatusParams;
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/27cf5016/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java
index 0d3634f..bef2b22 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java
@@ -30,11 +30,6 @@ import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
 public class GridCachePartitionedQueueFailoverDataConsistencySelfTest extends
     GridCacheAbstractQueueFailoverDataConsistencySelfTest {
     /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-264");
-    }
-
-    /** {@inheritDoc} */
     @Override protected CacheMemoryMode collectionMemoryMode() {
         return ONHEAP_TIERED;
     }


[32/41] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by an...@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/04930caa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/04930caa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/04930caa

Branch: refs/heads/ignite-1168
Commit: 04930caa238ae974e037d9705e7b329fbde9ae52
Parents: 040f0f3 13629ce
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon Sep 28 15:31:03 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Mon Sep 28 15:31:03 2015 +0300

----------------------------------------------------------------------
 .../managers/discovery/CustomEventListener.java |  4 +++-
 .../discovery/GridDiscoveryManager.java         |  2 +-
 .../cache/DynamicCacheChangeRequest.java        | 19 +++++++++++++++++++
 .../cache/DynamicCacheDescriptor.java           | 19 +++++++++++++++++++
 .../GridCachePartitionExchangeManager.java      | 20 +++++++++++++++++---
 .../processors/cache/GridCacheProcessor.java    | 15 +++++++++++----
 .../continuous/CacheContinuousQueryHandler.java | 10 +++-------
 .../continuous/GridContinuousProcessor.java     | 17 +++++++++++++----
 .../datastructures/DataStructuresProcessor.java |  6 +++++-
 ...omicOffheapQueueCreateMultiNodeSelfTest.java |  5 -----
 ...ionedAtomicQueueCreateMultiNodeSelfTest.java |  5 -----
 ...PartitionedQueueCreateMultiNodeSelfTest.java | 16 ++++++++++------
 12 files changed, 101 insertions(+), 37 deletions(-)
----------------------------------------------------------------------



[39/41] ignite git commit: IGNITE-1552 - Fixed parsing for SQL table function

Posted by an...@apache.org.
IGNITE-1552 - Fixed parsing for SQL table function


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

Branch: refs/heads/ignite-1168
Commit: 740291871013bef818edf3faf19c8d4c6eab1ba5
Parents: c2cedb0
Author: S.Vladykin <sv...@gridgain.com>
Authored: Tue Sep 29 17:04:52 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Sep 29 17:04:52 2015 -0700

----------------------------------------------------------------------
 .../processors/query/h2/sql/GridSqlArray.java   | 52 ++++++++++++
 .../processors/query/h2/sql/GridSqlElement.java |  2 +-
 .../query/h2/sql/GridSqlFunction.java           | 60 ++++++++------
 .../query/h2/sql/GridSqlFunctionType.java       |  3 +
 .../query/h2/sql/GridSqlPlaceholder.java        |  7 +-
 .../query/h2/sql/GridSqlQueryParser.java        | 84 ++++++++++++--------
 .../processors/query/h2/sql/GridSqlType.java    | 29 ++++++-
 .../query/h2/sql/GridQueryParsingTest.java      | 27 +++++++
 8 files changed, 199 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/74029187/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.java
new file mode 100644
index 0000000..69e98bf
--- /dev/null
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlArray.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.internal.processors.query.h2.sql;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import org.h2.util.StatementBuilder;
+
+/**
+ * SQL Array: (1, 2, ?, 'abc')
+ */
+public class GridSqlArray extends GridSqlElement {
+    /**
+     * @param size Array size.
+     */
+    public GridSqlArray(int size) {
+        super(size == 0 ? Collections.<GridSqlElement>emptyList() : new ArrayList<GridSqlElement>(size));
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getSQL() {
+        if (size() == 0)
+            return "()";
+
+        StatementBuilder buff = new StatementBuilder("(");
+
+        for (GridSqlElement e : children) {
+            buff.appendExceptFirst(", ");
+            buff.append(e.getSQL());
+        }
+
+        if (size() == 1)
+            buff.append(',');
+
+        return buff.append(')').toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/74029187/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
index 41b7ba4..57d3c57 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
@@ -25,7 +25,7 @@ import java.util.List;
  */
 public abstract class GridSqlElement implements Iterable<GridSqlElement> {
     /** */
-    protected List<GridSqlElement> children;
+    protected final List<GridSqlElement> children;
 
     /** */
     private GridSqlType resultType;

http://git-wip-us.apache.org/repos/asf/ignite/blob/74029187/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
index 51433c0..7cd7a6b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
@@ -27,7 +27,6 @@ import org.h2.value.ValueString;
 
 import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlFunctionType.CASE;
 import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlFunctionType.CAST;
-import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlFunctionType.CONVERT;
 import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlFunctionType.UNKNOWN_FUNCTION;
 
 /**
@@ -70,7 +69,7 @@ public class GridSqlFunction extends GridSqlElement {
         super(new ArrayList<GridSqlElement>());
 
         if (name == null)
-            throw new NullPointerException();
+            throw new NullPointerException("name");
 
         if (type == null)
             type = UNKNOWN_FUNCTION;
@@ -113,31 +112,46 @@ public class GridSqlFunction extends GridSqlElement {
 
         buff.append('(');
 
-        if (type == CAST) {
-            String castType = resultType().sql();
+        switch (type) {
+            case CAST:
+            case CONVERT:
+                assert size() == 1;
 
-            assert !F.isEmpty(castType) : castType;
-            assert size() == 1;
+                String castType = resultType().sql();
 
-            buff.append(child().getSQL()).append(" AS ").append(castType);
-        }
-        else if (type == CONVERT) {
-            String castType = resultType().sql();
+                assert !F.isEmpty(castType) : castType;
 
-            assert !F.isEmpty(castType) : castType;
-            assert size() == 1;
+                buff.append(child().getSQL());
+                buff.append(type == CAST ? " AS " : ",");
+                buff.append(castType);
 
-            buff.append(child().getSQL()).append(',').append(castType);
-        }
-        else if (type == GridSqlFunctionType.EXTRACT) {
-            ValueString v = (ValueString)((GridSqlConst)child(0)).value();
-            buff.append(v.getString()).append(" FROM ").append(child(1).getSQL());
-        }
-        else {
-            for (GridSqlElement e : children) {
-                buff.appendExceptFirst(", ");
-                buff.append(e.getSQL());
-            }
+                break;
+
+            case EXTRACT:
+                ValueString v = (ValueString)((GridSqlConst)child(0)).value();
+                buff.append(v.getString()).append(" FROM ").append(child(1).getSQL());
+
+                break;
+
+            case TABLE:
+                for (GridSqlElement e : children) {
+                    buff.appendExceptFirst(", ");
+
+                    // id int = ?, name varchar = ('aaa', 'bbb')
+                    buff.append(((GridSqlAlias)e).alias())
+                        .append(' ')
+                        .append(e.resultType().sql())
+                        .append('=')
+                        .append(e.child().getSQL());
+                }
+
+                break;
+
+            default:
+                for (GridSqlElement e : children) {
+                    buff.appendExceptFirst(", ");
+                    buff.append(e.getSQL());
+                }
         }
 
         return buff.append(')').toString();

http://git-wip-us.apache.org/repos/asf/ignite/blob/74029187/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunctionType.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunctionType.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunctionType.java
index 7b78d7a..8e56d33 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunctionType.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunctionType.java
@@ -61,6 +61,9 @@ public enum GridSqlFunctionType {
     /** */
     SYSTEM_RANGE,
 
+    /** TABLE and TABLE_DISTINCT */
+    TABLE,
+
     /** Constant for all other functions. */
     UNKNOWN_FUNCTION;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/74029187/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlPlaceholder.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlPlaceholder.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlPlaceholder.java
index aa00c69..0bb69a8 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlPlaceholder.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlPlaceholder.java
@@ -44,12 +44,7 @@ public class GridSqlPlaceholder extends GridSqlElement {
     }
 
     /** {@inheritDoc} */
-    @Override public GridSqlElement addChild(GridSqlElement expr) {
-        throw new IllegalStateException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridSqlElement child(int idx) {
+    @Override public GridSqlElement resultType(GridSqlType type) {
         throw new IllegalStateException();
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/74029187/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
index bffa36e..2789796 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
@@ -19,10 +19,8 @@ package org.apache.ignite.internal.processors.query.h2.sql;
 
 import java.lang.reflect.Field;
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.IdentityHashMap;
 import java.util.List;
-import java.util.Set;
 import org.apache.ignite.IgniteException;
 import org.h2.command.Command;
 import org.h2.command.Prepared;
@@ -42,11 +40,13 @@ import org.h2.expression.ConditionInSelect;
 import org.h2.expression.ConditionNot;
 import org.h2.expression.Expression;
 import org.h2.expression.ExpressionColumn;
+import org.h2.expression.ExpressionList;
 import org.h2.expression.Function;
 import org.h2.expression.JavaFunction;
 import org.h2.expression.Operation;
 import org.h2.expression.Parameter;
 import org.h2.expression.Subquery;
+import org.h2.expression.TableFunction;
 import org.h2.expression.ValueExpression;
 import org.h2.jdbc.JdbcPreparedStatement;
 import org.h2.result.SortOrder;
@@ -57,7 +57,6 @@ import org.h2.table.Table;
 import org.h2.table.TableBase;
 import org.h2.table.TableFilter;
 import org.h2.table.TableView;
-import org.h2.value.Value;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlOperationType.AND;
@@ -83,6 +82,8 @@ import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlOperatio
 import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlOperationType.SMALLER;
 import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlOperationType.SMALLER_EQUAL;
 import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlOperationType.SPATIAL_INTERSECTS;
+import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlType.fromColumn;
+import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlType.fromExpression;
 
 /**
  * H2 Query parser.
@@ -155,6 +156,9 @@ public class GridSqlQueryParser {
         getter(ConditionInConstantSet.class, "valueList");
 
     /** */
+    private static final Getter<ExpressionList, Expression[]> EXPR_LIST = getter(ExpressionList.class, "list");
+
+    /** */
     private static final Getter<ConditionInSelect, Expression> LEFT_CIS = getter(ConditionInSelect.class, "left");
 
     /** */
@@ -198,6 +202,9 @@ public class GridSqlQueryParser {
     private static final Getter<FunctionTable, Expression> FUNC_EXPR = getter(FunctionTable.class, "functionExpr");
 
     /** */
+    private static final Getter<TableFunction, Column[]> FUNC_TBL_COLS = getter(TableFunction.class, "columnList");
+
+    /** */
     private static final Getter<JavaFunction, FunctionAlias> FUNC_ALIAS = getter(JavaFunction.class, "functionAlias");
 
     /** */
@@ -293,8 +300,6 @@ public class GridSqlQueryParser {
         Expression where = CONDITION.get(select);
         res.where(parseExpression(where, false));
 
-        Set<TableFilter> allFilters = new HashSet<>(select.getTopFilters());
-
         GridSqlElement from = null;
 
         TableFilter filter = select.getTopTableFilter();
@@ -308,16 +313,12 @@ public class GridSqlQueryParser {
             from = from == null ? gridFilter : new GridSqlJoin(from, gridFilter, filter.isJoinOuter(),
                 parseExpression(filter.getJoinCondition(), false));
 
-            allFilters.remove(filter);
-
             filter = filter.getJoin();
         }
         while (filter != null);
 
         res.from(from);
 
-        assert allFilters.isEmpty();
-
         ArrayList<Expression> expressions = select.getExpressions();
 
         for (int i = 0; i < expressions.size(); i++)
@@ -419,18 +420,8 @@ public class GridSqlQueryParser {
         if (res == null) {
             res = parseExpression0(expression, calcTypes);
 
-            if (calcTypes) {
-                GridSqlType type = GridSqlType.UNKNOWN;
-
-                if (expression.getType() != Value.UNKNOWN) {
-                    Column c = new Column(null, expression.getType(), expression.getPrecision(), expression.getScale(),
-                        expression.getDisplaySize());
-
-                    type = new GridSqlType(c.getType(), c.getScale(), c.getPrecision(), c.getDisplaySize(), c.getCreateSQL());
-                }
-
-                res.resultType(type);
-            }
+            if (calcTypes)
+                res.resultType(fromExpression(expression));
 
             h2ObjToGridObj.put(expression, res);
         }
@@ -577,24 +568,38 @@ public class GridSqlQueryParser {
             GridSqlFunction res = new GridSqlFunction(null, f.getName());
 
             if (f.getArgs() != null) {
-                for (Expression arg : f.getArgs()) {
-                    if (arg == null) {
-                        if (f.getFunctionType() != Function.CASE)
-                            throw new IllegalStateException("Function type with null arg: " + f.getFunctionType());
+                if (f.getFunctionType() == Function.TABLE || f.getFunctionType() == Function.TABLE_DISTINCT) {
+                    Column[] cols = FUNC_TBL_COLS.get((TableFunction)f);
+                    Expression[] args = f.getArgs();
+
+                    assert cols.length == args.length;
 
-                        res.addChild(GridSqlPlaceholder.EMPTY);
+                    for (int i = 0; i < cols.length; i++) {
+                        GridSqlElement arg = parseExpression(args[i], calcTypes);
+
+                        GridSqlAlias alias = new GridSqlAlias(cols[i].getName(), arg, false);
+
+                        alias.resultType(fromColumn(cols[i]));
+
+                        res.addChild(alias);
+                    }
+                }
+                else {
+                    for (Expression arg : f.getArgs()) {
+                        if (arg == null) {
+                            if (f.getFunctionType() != Function.CASE)
+                                throw new IllegalStateException("Function type with null arg: " + f.getFunctionType());
+
+                            res.addChild(GridSqlPlaceholder.EMPTY);
+                        }
+                        else
+                            res.addChild(parseExpression(arg, calcTypes));
                     }
-                    else
-                        res.addChild(parseExpression(arg, calcTypes));
                 }
             }
 
-            if (f.getFunctionType() == Function.CAST || f.getFunctionType() == Function.CONVERT) {
-                Column c = new Column(null, f.getType(), f.getPrecision(), f.getScale(), f.getDisplaySize());
-
-                res.resultType(new GridSqlType(c.getType(), c.getScale(), c.getPrecision(),
-                    c.getDisplaySize(), c.getCreateSQL()));
-            }
+            if (f.getFunctionType() == Function.CAST || f.getFunctionType() == Function.CONVERT)
+                res.resultType(fromExpression(f));
 
             return res;
         }
@@ -629,6 +634,17 @@ public class GridSqlQueryParser {
             return res;
         }
 
+        if (expression instanceof ExpressionList) {
+            Expression[] exprs = EXPR_LIST.get((ExpressionList)expression);
+
+            GridSqlArray res = new GridSqlArray(exprs.length);
+
+            for (Expression expr : exprs)
+                res.addChild(parseExpression(expr, calcTypes));
+
+            return res;
+        }
+
         throw new IgniteException("Unsupported expression: " + expression + " [type=" +
             expression.getClass().getSimpleName() + ']');
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/74029187/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
index 6ff3231..febf174 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
@@ -17,7 +17,10 @@
 
 package org.apache.ignite.internal.processors.query.h2.sql;
 
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.h2.expression.Expression;
+import org.h2.table.Column;
 import org.h2.value.Value;
 import org.h2.value.ValueDouble;
 import org.h2.value.ValueLong;
@@ -62,7 +65,9 @@ public final class GridSqlType {
      * @param displaySize Display size.
      * @param sql SQL definition of the type.
      */
-    public GridSqlType(int type, int scale, long precision, int displaySize, String sql) {
+    private GridSqlType(int type, int scale, long precision, int displaySize, String sql) {
+        assert !F.isEmpty(sql) || type == Value.UNKNOWN;
+
         this.type = type;
         this.scale = scale;
         this.precision = precision;
@@ -71,6 +76,28 @@ public final class GridSqlType {
     }
 
     /**
+     * @param c Column to take type definition from.
+     * @return Type.
+     */
+    public static GridSqlType fromColumn(Column c) {
+        if (c.getName() != null)
+            c = new Column(null, c.getType(), c.getPrecision(), c.getScale(), c.getDisplaySize());
+
+        return new GridSqlType(c.getType(), c.getScale(), c.getPrecision(), c.getDisplaySize(), c.getCreateSQL());
+    }
+
+    /**
+     * @param e Expression to take type from.
+     * @return Type.
+     */
+    public static GridSqlType fromExpression(Expression e) {
+        if (e.getType() == Value.UNKNOWN)
+            return UNKNOWN;
+
+        return fromColumn(new Column(null, e.getType(), e.getPrecision(), e.getScale(), e.getDisplaySize()));
+    }
+
+    /**
      * @return Get H2 type.
      */
     public int type() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/74029187/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index f969a48..2be5d1a 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -98,6 +98,33 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testAllExamples() throws Exception {
+        checkQuery("select 42");
+        checkQuery("select ()");
+        checkQuery("select (1)");
+        checkQuery("select (1 + 1)");
+        checkQuery("select (1,)");
+        checkQuery("select (?)");
+        checkQuery("select (?,)");
+        checkQuery("select (1, 2)");
+        checkQuery("select (?, ? + 1, 2 + 2) as z");
+        checkQuery("select (1,(1,(1,(1,(1,?)))))");
+        checkQuery("select (select 1)");
+        checkQuery("select (select 1, select ?)");
+        checkQuery("select ((select 1), select ? + ?)");
+
+        checkQuery("select extract(year from ?)");
+        checkQuery("select convert(?, timestamp)");
+
+        checkQuery("select * from table(id bigint = 1)");
+        checkQuery("select * from table(id bigint = (1))");
+        checkQuery("select * from table(id bigint = (1,))");
+        checkQuery("select * from table(id bigint = (1,), name varchar = 'asd')");
+        checkQuery("select * from table(id bigint = (1,2), name varchar = 'asd')");
+        checkQuery("select * from table(id bigint = (1,2), name varchar = ('asd',))");
+        checkQuery("select * from table(id bigint = (1,2), name varchar = ?)");
+        checkQuery("select * from table(id bigint = (1,2), name varchar = (?,))");
+        checkQuery("select * from table(id bigint = ?, name varchar = ('abc', 'def', 100, ?)) t");
+
         checkQuery("select ? limit ? offset ?");
 
         checkQuery("select cool1()");


[26/41] ignite git commit: ignite-808 Fixed GridDhtTxPrepareFuture.onEntriesLocked

Posted by an...@apache.org.
ignite-808 Fixed GridDhtTxPrepareFuture.onEntriesLocked


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

Branch: refs/heads/ignite-1168
Commit: 8fea96ea1bba43bdc702e6096bb5492bdb745b67
Parents: dc379fe
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 28 11:44:12 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 28 11:44:12 2015 +0300

----------------------------------------------------------------------
 .../distributed/dht/GridDhtTxPrepareFuture.java |  6 ++-
 .../IgniteTxPreloadAbstractTest.java            | 43 ++++++++++++--------
 .../replicated/GridReplicatedTxPreloadTest.java |  2 -
 .../testsuites/IgniteCacheTestSuite4.java       |  7 ++++
 4 files changed, 37 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8fea96ea/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 81cc272..761bbb0 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
@@ -318,7 +318,11 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
     private void onEntriesLocked() {
         ret = new GridCacheReturn(null, tx.localResult(), null, true);
 
-        for (IgniteTxEntry txEntry : tx.optimisticLockEntries()) {
+        for (IgniteTxEntry writeEntry : writes) {
+            IgniteTxEntry txEntry = tx.entry(writeEntry.txKey());
+
+            assert txEntry != null : writeEntry;
+
             GridCacheContext cacheCtx = txEntry.context();
 
             GridCacheEntryEx cached = txEntry.cached();

http://git-wip-us.apache.org/repos/asf/ignite/blob/8fea96ea/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
index 939b4a6..0a7845b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
@@ -24,6 +24,7 @@ import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteTransactions;
@@ -65,6 +66,7 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
+        // No-op.
     }
 
     /** {@inheritDoc} */
@@ -78,7 +80,7 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT
     public void testRemoteTxPreloading() throws Exception {
         IgniteCache<String, Integer> cache = jcache(0);
 
-        for (int i = 0; i < 10000; i++)
+        for (int i = 0; i < 10_000; i++)
             cache.put(String.valueOf(i), 0);
 
         final AtomicInteger gridIdx = new AtomicInteger(1);
@@ -104,31 +106,36 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT
         for (int i = 0; i < 10; i++)
             keys.add(String.valueOf(i * 1000));
 
-        cache.invokeAll(keys, new EntryProcessor<String, Integer, Void>() {
-            @Override public Void process(MutableEntry<String, Integer> e, Object... args) {
-                Integer val = e.getValue();
+        Map<String, EntryProcessorResult<Integer>> resMap = cache.invokeAll(keys,
+            new EntryProcessor<String, Integer, Integer>() {
+                @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+                    Integer val = e.getValue();
 
-                if (val == null) {
-                    keyNotLoaded = true;
+                    if (val == null) {
+                        keyNotLoaded = true;
 
-                    e.setValue(1);
+                        e.setValue(1);
 
-                    return null;
-                }
+                        return null;
+                    }
 
-                e.setValue(val + 1);
+                    e.setValue(val + 1);
 
-                return null;
+                    return val;
+                }
             }
-        });
+        );
 
         assertFalse(keyNotLoaded);
 
-        fut.get();
+        for (String key : keys) {
+            EntryProcessorResult<Integer> res = resMap.get(key);
 
-        for (int i = 0; i < GRID_CNT; i++)
-            // Wait for preloader.
-            jcache(i).rebalance().get();
+            assertNotNull(res);
+            assertEquals(0, (Object)res.get());
+        }
+
+        fut.get();
 
         for (int i = 0; i < GRID_CNT; i++) {
             for (String key : keys)
@@ -217,10 +224,10 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT
         CacheConfiguration cfg = super.cacheConfiguration(gridName);
 
         cfg.setRebalanceMode(ASYNC);
-
         cfg.setWriteSynchronizationMode(FULL_SYNC);
-
         cfg.setCacheStoreFactory(null);
+        cfg.setReadThrough(false);
+        cfg.setWriteThrough(false);
 
         return cfg;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8fea96ea/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
index e3ce612..4da7734 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
@@ -24,8 +24,6 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED;
 
 /**
  * Tests cache transaction during preloading.
- *
- * TODO: IGNITE-808.
  */
 public class GridReplicatedTxPreloadTest extends IgniteTxPreloadAbstractTest {
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8fea96ea/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 289da3d..0ebcc81 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
@@ -76,9 +76,12 @@ import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransaction
 import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheAffinityEarlyTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtTxPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheLockFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheMultiTxLockSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearTxPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheNearReadCommittedTest;
+import org.apache.ignite.internal.processors.cache.distributed.replicated.GridReplicatedTxPreloadTest;
 import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLoadAllTest;
 import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLoaderWriterTest;
 import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLocalLoadAllTest;
@@ -261,6 +264,10 @@ public class IgniteCacheTestSuite4 extends TestSuite {
 
         suite.addTestSuite(CacheSwapUnswapGetTest.class);
 
+        suite.addTestSuite(GridCacheDhtTxPreloadSelfTest.class);
+        suite.addTestSuite(GridCacheNearTxPreloadSelfTest.class);
+        suite.addTestSuite(GridReplicatedTxPreloadTest.class);
+
         return suite;
     }
 }
\ No newline at end of file


[06/41] ignite git commit: IGNITE-1536 - Removed duplicated continuous query notifications in REPLICATED cache

Posted by an...@apache.org.
IGNITE-1536 - Removed duplicated continuous query notifications in REPLICATED cache


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

Branch: refs/heads/ignite-1168
Commit: 7db44f11f7925b5a29a0a3e017baa93b52fb2982
Parents: 70a8a92
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Sep 23 18:53:06 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Sep 23 18:53:06 2015 -0700

----------------------------------------------------------------------
 .../processors/cache/IgniteCacheProxy.java      |   4 +-
 .../continuous/CacheContinuousQueryManager.java |  58 +++------
 .../continuous/GridContinuousProcessor.java     |   3 +-
 ...ontinuousQueryReplicatedOneNodeSelfTest.java | 120 +++++++++++++++++++
 .../IgniteCacheQuerySelfTestSuite.java          |   4 +-
 5 files changed, 144 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7db44f11/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 cc6c19a..ae96f23 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
@@ -556,7 +556,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
                 qry.getPageSize(),
                 qry.getTimeInterval(),
                 qry.isAutoUnsubscribe(),
-                loc ? ctx.grid().cluster().forLocal() : null);
+                loc);
 
             final QueryCursor<Cache.Entry<K, V>> cur =
                 qry.getInitialQuery() != null ? query(qry.getInitialQuery()) : null;
@@ -1896,4 +1896,4 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
     @Override public String toString() {
         return S.toString(IgniteCacheProxy.class, this);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7db44f11/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index c719f1e..6a151a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -43,10 +43,9 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.query.ContinuousQuery;
-import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -55,6 +54,7 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.continuous.GridContinuousHandler;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.plugin.security.SecurityPermission;
 import org.apache.ignite.resources.LoggerResource;
 import org.jsr166.ConcurrentHashMap8;
@@ -271,7 +271,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
      * @param bufSize Buffer size.
      * @param timeInterval Time interval.
      * @param autoUnsubscribe Auto unsubscribe flag.
-     * @param grp Cluster group.
+     * @param loc Local flag.
      * @return Continuous routine ID.
      * @throws IgniteCheckedException In case of error.
      */
@@ -280,7 +280,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
         int bufSize,
         long timeInterval,
         boolean autoUnsubscribe,
-        ClusterGroup grp) throws IgniteCheckedException
+        boolean loc) throws IgniteCheckedException
     {
         return executeQuery0(
             locLsnr,
@@ -293,7 +293,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
             true,
             false,
             true,
-            grp);
+            loc);
     }
 
     /**
@@ -321,7 +321,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
             true,
             false,
             true,
-            loc ? cctx.grid().cluster().forLocal() : null);
+            loc);
     }
 
     /**
@@ -383,7 +383,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
      * @param oldValRequired Old value required flag.
      * @param sync Synchronous flag.
      * @param ignoreExpired Ignore expired event flag.
-     * @param grp Cluster group.
+     * @param loc Local flag.
      * @return Continuous routine ID.
      * @throws IgniteCheckedException In case of error.
      */
@@ -397,44 +397,15 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
         boolean oldValRequired,
         boolean sync,
         boolean ignoreExpired,
-        ClusterGroup grp) throws IgniteCheckedException
+        boolean loc) throws IgniteCheckedException
     {
         cctx.checkSecurity(SecurityPermission.CACHE_READ);
 
-        if (grp == null)
-            grp = cctx.kernalContext().grid().cluster();
-
-        Collection<ClusterNode> nodes = grp.nodes();
-
-        if (nodes.isEmpty())
-            throw new ClusterTopologyException("Failed to execute continuous query (empty cluster group is " +
-                "provided).");
-
-        boolean skipPrimaryCheck = false;
-
-        switch (cctx.config().getCacheMode()) {
-            case LOCAL:
-                if (!nodes.contains(cctx.localNode()))
-                    throw new ClusterTopologyException("Continuous query for LOCAL cache can be executed " +
-                        "only locally (provided projection contains remote nodes only).");
-                else if (nodes.size() > 1)
-                    U.warn(log, "Continuous query for LOCAL cache will be executed locally (provided projection is " +
-                        "ignored).");
-
-                grp = grp.forNode(cctx.localNode());
-
-                break;
-
-            case REPLICATED:
-                if (nodes.size() == 1 && F.first(nodes).equals(cctx.localNode()))
-                    skipPrimaryCheck = cctx.affinityNode();
-
-                break;
-        }
-
         int taskNameHash = !internal && cctx.kernalContext().security().enabled() ?
             cctx.kernalContext().job().currentTaskNameHash() : 0;
 
+        boolean skipPrimaryCheck = loc && cctx.config().getCacheMode() == CacheMode.REPLICATED && cctx.affinityNode();
+
         GridContinuousHandler hnd = new CacheContinuousQueryHandler(
             cctx.name(),
             TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
@@ -448,12 +419,17 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
             taskNameHash,
             skipPrimaryCheck);
 
+        IgnitePredicate<ClusterNode> pred = null;
+
+        if (loc || cctx.config().getCacheMode() == CacheMode.LOCAL)
+            pred = F.nodeForNodeId(cctx.localNodeId());
+
         UUID id = cctx.kernalContext().continuous().startRoutine(
             hnd,
             bufSize,
             timeInterval,
             autoUnsubscribe,
-            grp.predicate()).get();
+            pred).get();
 
         if (notifyExisting) {
             final Iterator<GridCacheEntryEx> it = cctx.cache().allEntries().iterator();
@@ -635,7 +611,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
                 cfg.isOldValueRequired(),
                 cfg.isSynchronous(),
                 false,
-                null);
+                false);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7db44f11/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 18c1f36..e29bdd4 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
@@ -795,7 +795,8 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
             try {
                 IgnitePredicate<ClusterNode> prjPred = data.projectionPredicate();
 
-                ctx.resource().injectGeneric(prjPred);
+                if (prjPred != null)
+                    ctx.resource().injectGeneric(prjPred);
 
                 if (prjPred == null || prjPred.apply(ctx.discovery().node(ctx.localNodeId()))) {
                     registered = registerHandler(node.id(), routineId, hnd, data.bufferSize(), data.interval(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/7db44f11/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
new file mode 100644
index 0000000..8152b2a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test for replicated cache with one node.
+ */
+public class GridCacheContinuousQueryReplicatedOneNodeSelfTest extends GridCommonAbstractTest {
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        CacheConfiguration cacheCfg = defaultCacheConfiguration();
+
+        cacheCfg.setCacheMode(CacheMode.REPLICATED);
+        cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+        cfg.setCacheConfiguration(cacheCfg);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLocal() throws Exception {
+        doTest(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDistributed() throws Exception {
+        doTest(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void doTest(boolean loc) throws Exception {
+        try {
+            IgniteCache<String, Integer> cache = startGrid(0).cache(null);
+
+            ContinuousQuery<String, Integer> qry = new ContinuousQuery<>();
+
+            final AtomicInteger cnt = new AtomicInteger();
+            final CountDownLatch latch = new CountDownLatch(10);
+
+            qry.setLocalListener(new CacheEntryUpdatedListener<String, Integer>() {
+                @Override
+                public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends Integer>> evts)
+                        throws CacheEntryListenerException {
+                    for (CacheEntryEvent<? extends String, ? extends Integer> evt : evts) {
+                        cnt.incrementAndGet();
+                        latch.countDown();
+                    }
+                }
+            });
+
+            cache.query(qry.setLocal(loc));
+
+            startGrid(1);
+
+            awaitPartitionMapExchange();
+
+            for (int i = 0; i < 10; i++)
+                cache.put("key" + i, i);
+
+            assert latch.await(5000, TimeUnit.MILLISECONDS);
+
+            assertEquals(10, cnt.get());
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7db44f11/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 41670d1..fe54b63 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -73,6 +73,7 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedP2PDisabledSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedOneNodeSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedP2PDisabledSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest;
@@ -158,6 +159,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class);
         suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class);
         suite.addTestSuite(IgniteCacheContinuousQueryClientTest.class);
+        suite.addTestSuite(GridCacheContinuousQueryReplicatedOneNodeSelfTest.class);
 
         // Reduce fields queries.
         suite.addTestSuite(GridCacheReduceFieldsQueryLocalSelfTest.class);
@@ -187,4 +189,4 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
 
         return suite;
     }
-}
\ No newline at end of file
+}


[05/41] ignite git commit: Exposed IgniteKernal.dumpDebugInfo() to MX bean

Posted by an...@apache.org.
Exposed IgniteKernal.dumpDebugInfo() to MX bean


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

Branch: refs/heads/ignite-1168
Commit: 70a8a92da3cf39b0ed1cf18effd8fae1478cb2bd
Parents: 6f3ef6a
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Sep 23 17:23:31 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Sep 23 17:23:31 2015 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/ignite/internal/IgniteKernal.java   | 4 +---
 .../src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java | 8 +++++++-
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/70a8a92d/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 82db059..60725e4 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
@@ -3153,9 +3153,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         return ctx.isDaemon() && U.hasAnnotation(comp.getClass(), SkipDaemon.class);
     }
 
-    /**
-     *
-     */
+    /** {@inheritDoc} */
     public void dumpDebugInfo() {
         U.warn(log, "Dumping debug info for node [id=" + ctx.localNodeId() +
             ", name=" + ctx.gridName() +

http://git-wip-us.apache.org/repos/asf/ignite/blob/70a8a92d/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java b/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
index 4755bf2..c30e0e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
@@ -366,4 +366,10 @@ public interface IgniteMXBean {
      */
     @MXBeanDescription("Prints last suppressed errors.")
     public void printLastErrors();
-}
\ No newline at end of file
+
+    /**
+     * Dumps debug information for the current node.
+     */
+    @MXBeanDescription("Dumps debug information for the current node.")
+    public void dumpDebugInfo();
+}


[09/41] ignite git commit: Fixed test.

Posted by an...@apache.org.
Fixed test.


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

Branch: refs/heads/ignite-1168
Commit: f6ba3c3b4575c60f94ae4742b5d2d7bd2183f938
Parents: 4b0c029
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 24 12:56:19 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 24 12:56:19 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheVariableTopologySelfTest.java       | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f6ba3c3b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java
index 7078843..80103c3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
 
 import java.util.Random;
 import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.CacheException;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
@@ -146,7 +147,7 @@ public class GridCacheVariableTopologySelfTest extends GridCommonAbstractTest {
                     catch (TransactionRollbackException | ClusterTopologyException e) {
                         info("Caught exception: " + e);
                     }
-                    catch (IgniteException e) {
+                    catch (CacheException | IgniteException e) {
                         if (X.hasCause(e, ClusterTopologyCheckedException.class))
                             info("Caught cache exception: " + e);
                         else


[08/41] ignite git commit: Added test.

Posted by an...@apache.org.
Added test.


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

Branch: refs/heads/ignite-1168
Commit: 4b0c029cef4b351f0d389a171c30b7dcf8c1ca22
Parents: b56b15c
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 24 12:19:28 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 24 12:19:28 2015 +0300

----------------------------------------------------------------------
 .../near/NearCacheMultithreadedUpdateTest.java  | 217 +++++++++++++++++++
 1 file changed, 217 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4b0c029c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheMultithreadedUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheMultithreadedUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheMultithreadedUpdateTest.java
new file mode 100644
index 0000000..9d92724
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheMultithreadedUpdateTest.java
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.near;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+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.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class NearCacheMultithreadedUpdateTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private boolean client;
+
+    /** */
+    private final int SRV_CNT = 3;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGridsMultiThreaded(SRV_CNT);
+
+        client = true;
+
+        startGrid(SRV_CNT);
+
+        client = false;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testUpdateMultithreadedTx() throws Exception {
+        updateMultithreaded(TRANSACTIONAL, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testUpdateMultithreadedTxRestart() throws Exception {
+        updateMultithreaded(TRANSACTIONAL, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testUpdateMultithreadedAtomic() throws Exception {
+        updateMultithreaded(ATOMIC, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testUpdateMultithreadedAtomicRestart() throws Exception {
+        updateMultithreaded(ATOMIC, true);
+    }
+
+    /**
+     * @param atomicityMode Cache atomicity mode.
+     * @param restart If {@code true} restarts one node.
+     * @throws Exception If failed.
+     */
+    private void updateMultithreaded(CacheAtomicityMode atomicityMode, boolean restart) throws Exception {
+        Ignite srv = ignite(0);
+
+        srv.destroyCache(null);
+
+        IgniteCache<Integer, Integer> srvCache = srv.createCache(cacheConfiguration(atomicityMode));
+
+        Ignite client = ignite(SRV_CNT);
+
+        assertTrue(client.configuration().isClientMode());
+
+        final IgniteCache<Integer, Integer> clientCache =
+            client.createNearCache(null, new NearCacheConfiguration<Integer, Integer>());
+
+        final AtomicBoolean stop = new AtomicBoolean();
+
+        IgniteInternalFuture<?> restartFut = null;
+
+        // Primary key for restarted node.
+        final Integer key0 = primaryKey(ignite(SRV_CNT - 1).cache(null));
+
+        if (restart) {
+            restartFut = GridTestUtils.runAsync(new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    while (!stop.get()) {
+                        Thread.sleep(300);
+
+                        log.info("Stop node.");
+
+                        stopGrid(SRV_CNT - 1);
+
+                        Thread.sleep(300);
+
+                        log.info("Start node.");
+
+                        startGrid(SRV_CNT - 1);
+                    }
+
+                    return null;
+                }
+            }, "restart-thread");
+        }
+
+        try {
+            long stopTime = System.currentTimeMillis() + 30_000;
+
+            int iter = 0;
+
+            while (System.currentTimeMillis() < stopTime) {
+                if (iter % 100 == 0)
+                    log.info("Iteration: " + iter);
+
+                final Integer key = iter++;
+
+                final AtomicInteger val = new AtomicInteger();
+
+                GridTestUtils.runMultiThreaded(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        clientCache.put(key0, val.incrementAndGet());
+
+                        for (int i = 0; i < 10; i++)
+                            clientCache.put(key, val.incrementAndGet());
+
+                        return null;
+                    }
+                }, 20, "update-thread");
+
+                if (restart) {
+                    assertEquals(srvCache.get(key), clientCache.get(key));
+                    assertEquals(srvCache.get(key0), clientCache.get(key0));
+                }
+                else {
+                    assertEquals(srvCache.get(key), clientCache.localPeek(key));
+                    assertEquals(srvCache.get(key0), clientCache.localPeek(key0));
+                }
+            }
+
+            stop.set(true);
+
+            if (restartFut != null)
+                restartFut.get();
+        }
+        finally {
+            stop.set(true);
+        }
+    }
+
+    /**
+     * @param atomicityMode Cache atomicity mode.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration<Integer, Integer> cacheConfiguration(CacheAtomicityMode atomicityMode) {
+        CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>();
+
+        ccfg.setAtomicityMode(atomicityMode);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg.setBackups(1);
+
+        return ccfg;
+    }
+}


[35/41] ignite git commit: ignite-1279 Fixed mvcc code to use IgniteTxKey instead of KeyCacheObject

Posted by an...@apache.org.
ignite-1279 Fixed mvcc code to use IgniteTxKey instead of KeyCacheObject


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

Branch: refs/heads/ignite-1168
Commit: c6bb01b49cfef14310355148c4937aab8489da13
Parents: e5c3ca3
Author: sboikov <sb...@gridgain.com>
Authored: Tue Sep 29 09:20:25 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Sep 29 09:20:25 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheExplicitLockSpan.java        |  13 +-
 .../cache/GridCacheMvccCandidate.java           |   5 +-
 .../processors/cache/GridCacheMvccManager.java  |  47 +++---
 .../distributed/GridDistributedCacheEntry.java  |   2 +-
 .../dht/colocated/GridDhtColocatedCache.java    |  12 +-
 .../colocated/GridDhtColocatedLockFuture.java   |  16 ++-
 .../dht/preloader/GridDhtPreloader.java         |   2 +-
 .../cache/distributed/near/GridNearTxLocal.java |   2 +-
 .../cache/local/GridLocalCacheEntry.java        |   2 +-
 .../processors/cache/CrossCacheLockTest.java    | 142 +++++++++++++++++++
 .../GridCacheFinishPartitionsSelfTest.java      |   5 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   3 +
 12 files changed, 201 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java
index 2261c7d..df32e77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.concurrent.locks.ReentrantLock;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -46,7 +47,7 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {
 
     /** Pending candidates. */
     @GridToStringInclude
-    private final Map<KeyCacheObject, Deque<GridCacheMvccCandidate>> cands = new HashMap<>();
+    private final Map<IgniteTxKey, Deque<GridCacheMvccCandidate>> cands = new HashMap<>();
 
     /** Span lock release future. */
     @GridToStringExclude
@@ -77,7 +78,7 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {
             if (cands.isEmpty())
                 return false;
 
-            assert this.topVer.equals(this.topVer);
+            assert this.topVer.equals(topVer);
 
             Deque<GridCacheMvccCandidate> deque = ensureDeque(cand.key());
 
@@ -137,7 +138,7 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {
      * @param ver Version (or {@code null} if any candidate should be removed.)
      * @return Removed candidate if matches given parameters.
      */
-    public GridCacheMvccCandidate removeCandidate(KeyCacheObject key, @Nullable GridCacheVersion ver) {
+    public GridCacheMvccCandidate removeCandidate(IgniteTxKey key, @Nullable GridCacheVersion ver) {
         lock();
 
         try {
@@ -187,7 +188,7 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {
      *
      * @param key Key.
      */
-    public void markOwned(KeyCacheObject key) {
+    public void markOwned(IgniteTxKey key) {
         lock();
 
         try {
@@ -210,7 +211,7 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {
      * @param ver Version to lookup (if {@code null} - return any).
      * @return Last added explicit lock candidate, if any, or {@code null}.
      */
-    @Nullable public GridCacheMvccCandidate candidate(KeyCacheObject key, @Nullable final GridCacheVersion ver) {
+    @Nullable public GridCacheMvccCandidate candidate(IgniteTxKey key, @Nullable final GridCacheVersion ver) {
         lock();
 
         try {
@@ -257,7 +258,7 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {
      * @param key Key to look up.
      * @return Deque.
      */
-    private Deque<GridCacheMvccCandidate> ensureDeque(KeyCacheObject key) {
+    private Deque<GridCacheMvccCandidate> ensureDeque(IgniteTxKey key) {
         Deque<GridCacheMvccCandidate> deque = cands.get(key);
 
         if (deque == null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
index e784f42..f19a054 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
@@ -27,6 +27,7 @@ import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -554,13 +555,13 @@ public class GridCacheMvccCandidate implements Externalizable,
     /**
      * @return Key.
      */
-    public KeyCacheObject key() {
+    public IgniteTxKey key() {
         GridCacheEntryEx parent0 = parent;
 
         if (parent0 == null)
             throw new IllegalStateException("Parent entry was not initialized for MVCC candidate: " + this);
 
-        return parent0.key();
+        return parent0.txKey();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index e2d0302..dd51da2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -698,8 +698,8 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @return {@code True} if added.
      */
     public boolean addLocal(GridCacheMvccCandidate cand) {
-        assert cand.key() != null;
-        assert cand.local();
+        assert cand.key() != null : cand;
+        assert cand.local() : cand;
 
         if (cand.dhtLocal() && dhtLocCands.add(cand)) {
             if (log.isDebugEnabled())
@@ -717,8 +717,8 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @return {@code True} if removed.
      */
     public boolean removeLocal(GridCacheMvccCandidate cand) {
-        assert cand.key() != null;
-        assert cand.local();
+        assert cand.key() != null : cand;
+        assert cand.local() : cand;
 
         if (cand.dhtLocal() && dhtLocCands.remove(cand)) {
             if (log.isDebugEnabled())
@@ -825,7 +825,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @param threadId Thread id. If -1, all threads will be checked.
      * @return {@code True} if locked by any or given thread (depending on {@code threadId} value).
      */
-    public boolean isLockedByThread(KeyCacheObject key, long threadId) {
+    public boolean isLockedByThread(IgniteTxKey key, long threadId) {
         if (threadId < 0) {
             for (GridCacheExplicitLockSpan span : pendingExplicit.values()) {
                 GridCacheMvccCandidate cand = span.candidate(key, null);
@@ -853,7 +853,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @param key Key.
      * @param threadId Thread id.
      */
-    public void markExplicitOwner(KeyCacheObject key, long threadId) {
+    public void markExplicitOwner(IgniteTxKey key, long threadId) {
         assert threadId > 0;
 
         GridCacheExplicitLockSpan span = pendingExplicit.get(threadId);
@@ -871,7 +871,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @return Candidate.
      */
     public GridCacheMvccCandidate removeExplicitLock(long threadId,
-        KeyCacheObject key,
+        IgniteTxKey key,
         @Nullable GridCacheVersion ver)
     {
         assert threadId > 0;
@@ -897,7 +897,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @return Last added explicit lock candidate for given thread id and key or {@code null} if
      *      no such candidate.
      */
-    @Nullable public GridCacheMvccCandidate explicitLock(long threadId, KeyCacheObject key) {
+    @Nullable public GridCacheMvccCandidate explicitLock(long threadId, IgniteTxKey key) {
         if (threadId < 0)
             return explicitLock(key, null);
         else {
@@ -914,7 +914,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @param ver Version.
      * @return Lock candidate that satisfies given criteria or {@code null} if no such candidate.
      */
-    @Nullable public GridCacheMvccCandidate explicitLock(KeyCacheObject key, @Nullable GridCacheVersion ver) {
+    @Nullable public GridCacheMvccCandidate explicitLock(IgniteTxKey key, @Nullable GridCacheVersion ver) {
         for (GridCacheExplicitLockSpan span : pendingExplicit.values()) {
             GridCacheMvccCandidate cand = span.candidate(key, ver);
 
@@ -1019,45 +1019,40 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
 
     /**
      * @param keys Key for which locks should be released.
+     * @param cacheId Cache ID.
      * @param topVer Topology version.
      * @return Future that signals when all locks for given keys are released.
      */
     @SuppressWarnings("unchecked")
-    public IgniteInternalFuture<?> finishKeys(Collection<KeyCacheObject> keys, AffinityTopologyVersion topVer) {
+    public IgniteInternalFuture<?> finishKeys(Collection<KeyCacheObject> keys,
+        final int cacheId,
+        AffinityTopologyVersion topVer) {
         if (!(keys instanceof Set))
             keys = new HashSet<>(keys);
 
         final Collection<KeyCacheObject> keys0 = keys;
 
-        return finishLocks(new P1<KeyCacheObject>() {
-            @Override public boolean apply(KeyCacheObject key) {
-                return keys0.contains(key);
+        return finishLocks(new P1<GridDistributedCacheEntry>() {
+            @Override public boolean apply(GridDistributedCacheEntry e) {
+                return e.context().cacheId() == cacheId && keys0.contains(e.key());
             }
         }, topVer);
     }
 
     /**
-     * @param keyFilter Key filter.
+     * @param filter Entry filter.
      * @param topVer Topology version.
      * @return Future that signals when all locks for given partitions will be released.
      */
-    private IgniteInternalFuture<?> finishLocks(@Nullable final IgnitePredicate<KeyCacheObject> keyFilter, AffinityTopologyVersion topVer) {
+    private IgniteInternalFuture<?> finishLocks(@Nullable final IgnitePredicate<GridDistributedCacheEntry> filter,
+        AffinityTopologyVersion topVer) {
         assert topVer.topologyVersion() != 0;
 
         if (topVer.equals(AffinityTopologyVersion.NONE))
             return new GridFinishedFuture();
 
-        final FinishLockFuture finishFut = new FinishLockFuture(
-            keyFilter == null ?
-                locked() :
-                F.view(locked(),
-                    new P1<GridDistributedCacheEntry>() {
-                        @Override public boolean apply(GridDistributedCacheEntry e) {
-                            return F.isAll(e.key(), keyFilter);
-                        }
-                    }
-                ),
-            topVer);
+        final FinishLockFuture finishFut =
+            new FinishLockFuture(filter == null ? locked() : F.view(locked(), filter), topVer);
 
         finishFuts.add(finishFut);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
index 6904e56..d4f0d6c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
@@ -849,7 +849,7 @@ public class GridDistributedCacheEntry extends GridCacheMapEntry {
                     GridCacheContext cctx0 = cand.parent().context();
 
                     GridDistributedCacheEntry e =
-                        (GridDistributedCacheEntry)cctx0.cache().peekEx(cand.key());
+                        (GridDistributedCacheEntry)cctx0.cache().peekEx(cand.parent().key());
 
                     if (e != null)
                         e.recheck();

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index c8425e9..f38126d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -59,6 +59,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLock
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -172,14 +173,14 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
     @Override public boolean isLocked(K key) {
         KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
 
-        return ctx.mvcc().isLockedByThread(cacheKey, -1);
+        return ctx.mvcc().isLockedByThread(ctx.txKey(cacheKey), -1);
     }
 
     /** {@inheritDoc} */
     @Override public boolean isLockedByThread(K key) {
         KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
 
-        return ctx.mvcc().isLockedByThread(cacheKey, Thread.currentThread().getId());
+        return ctx.mvcc().isLockedByThread(ctx.txKey(cacheKey), Thread.currentThread().getId());
     }
 
     /** {@inheritDoc} */
@@ -450,11 +451,12 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
 
             for (K key : keys) {
                 KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
+                IgniteTxKey txKey = ctx.txKey(cacheKey);
 
                 GridDistributedCacheEntry entry = peekExx(cacheKey);
 
                 GridCacheMvccCandidate lock =
-                    ctx.mvcc().removeExplicitLock(Thread.currentThread().getId(), cacheKey, null);
+                    ctx.mvcc().removeExplicitLock(Thread.currentThread().getId(), txKey, null);
 
                 if (lock != null) {
                     final AffinityTopologyVersion topVer = lock.topologyVersion();
@@ -566,7 +568,9 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
             Collection<KeyCacheObject> locKeys = new LinkedList<>();
 
             for (KeyCacheObject key : keys) {
-                GridCacheMvccCandidate lock = ctx.mvcc().removeExplicitLock(threadId, key, ver);
+                IgniteTxKey txKey = ctx.txKey(key);
+
+                GridCacheMvccCandidate lock = ctx.mvcc().removeExplicitLock(threadId, txKey, ver);
 
                 if (lock != null) {
                     AffinityTopologyVersion topVer = lock.topologyVersion();

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index 1a08265..33a5cbd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -293,10 +293,12 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
      * @throws IgniteCheckedException If failed to add entry due to external locking.
      */
     @Nullable private GridCacheMvccCandidate addEntry(GridDistributedCacheEntry entry) throws IgniteCheckedException {
-        GridCacheMvccCandidate cand = cctx.mvcc().explicitLock(threadId, entry.key());
+        IgniteTxKey txKey = entry.txKey();
+
+        GridCacheMvccCandidate cand = cctx.mvcc().explicitLock(threadId, txKey);
 
         if (inTx()) {
-            IgniteTxEntry txEntry = tx.entry(entry.txKey());
+            IgniteTxEntry txEntry = tx.entry(txKey);
 
             txEntry.cached(entry);
 
@@ -317,7 +319,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
                     lockVer,
                     timeout,
                     true,
-                    tx.entry(entry.txKey()).locked(),
+                    tx.entry(txKey).locked(),
                     inTx(),
                     inTx() && tx.implicitSingle(),
                     false,
@@ -1045,7 +1047,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
                     }
                     else {
                         for (KeyCacheObject key : keys)
-                            cctx.mvcc().markExplicitOwner(key, threadId);
+                            cctx.mvcc().markExplicitOwner(cctx.txKey(key), threadId);
                     }
 
                     try {
@@ -1084,7 +1086,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
             if (!cctx.affinity().primary(cctx.localNode(), key, topVer)) {
                 // Remove explicit locks added so far.
                 for (KeyCacheObject k : keys)
-                    cctx.mvcc().removeExplicitLock(threadId, k, lockVer);
+                    cctx.mvcc().removeExplicitLock(threadId, cctx.txKey(k), lockVer);
 
                 return false;
             }
@@ -1409,7 +1411,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
                                 log.debug("Processed response for entry [res=" + res + ", entry=" + entry + ']');
                         }
                         else
-                            cctx.mvcc().markExplicitOwner(k, threadId);
+                            cctx.mvcc().markExplicitOwner(cctx.txKey(k), threadId);
 
                         if (retval && cctx.events().isRecordable(EVT_CACHE_OBJECT_READ)) {
                             cctx.events().addEvent(cctx.affinity().partition(k),
@@ -1448,7 +1450,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
             undoLocks(false, false);
 
             for (KeyCacheObject key : GridDhtColocatedLockFuture.this.keys)
-                cctx.mvcc().removeExplicitLock(threadId, key, lockVer);
+                cctx.mvcc().removeExplicitLock(threadId, cctx.txKey(key), lockVer);
 
             mapOnTopology(true, new Runnable() {
                 @Override public void run() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index 36c80a9..9d5fdca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -339,7 +339,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
      * @param msg Force keys message.
      */
     private void processForceKeysRequest(final ClusterNode node, final GridDhtForceKeysRequest msg) {
-        IgniteInternalFuture<?> fut = cctx.mvcc().finishKeys(msg.keys(), msg.topologyVersion());
+        IgniteInternalFuture<?> fut = cctx.mvcc().finishKeys(msg.keys(), msg.cacheId(), msg.topologyVersion());
 
         if (fut.isDone())
             processForceKeysRequest0(node, msg);

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/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 8975b4a..ea96649 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
@@ -421,7 +421,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
     @Override protected void updateExplicitVersion(IgniteTxEntry txEntry, GridCacheEntryEx entry)
         throws GridCacheEntryRemovedException {
         if (entry.detached()) {
-            GridCacheMvccCandidate cand = cctx.mvcc().explicitLock(threadId(), entry.key());
+            GridCacheMvccCandidate cand = cctx.mvcc().explicitLock(threadId(), entry.txKey());
 
             if (cand != null && !xidVersion().equals(cand.version())) {
                 GridCacheVersion candVer = cand.version();

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
index a4f6c92..cacac13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
@@ -270,7 +270,7 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
                 if (!cand.used()) {
                     GridCacheContext cctx0 = cand.parent().context();
 
-                    GridLocalCacheEntry e = (GridLocalCacheEntry)cctx0.cache().peekEx(cand.key());
+                    GridLocalCacheEntry e = (GridLocalCacheEntry)cctx0.cache().peekEx(cand.parent().key());
 
                     // At this point candidate may have been removed and entry destroyed,
                     // so we check for null.

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheLockTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheLockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheLockTest.java
new file mode 100644
index 0000000..9fa13bc
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheLockTest.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.concurrent.locks.Lock;
+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.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+
+/**
+ *
+ */
+public class CrossCacheLockTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final int GRID_CNT = 4;
+
+    /** */
+    private static final String CACHE1 = "cache1";
+
+    /** */
+    private static final String CACHE2 = "cache2";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        if (gridName.equals(getTestGridName(GRID_CNT - 1)))
+            cfg.setClientMode(true);
+
+        CacheConfiguration ccfg1 = new CacheConfiguration();
+        ccfg1.setName(CACHE1);
+        ccfg1.setBackups(1);
+        ccfg1.setAtomicityMode(TRANSACTIONAL);
+
+        CacheConfiguration ccfg2 = new CacheConfiguration();
+        ccfg2.setName(CACHE2);
+        ccfg2.setAtomicityMode(TRANSACTIONAL);
+
+        cfg.setCacheConfiguration(ccfg1, ccfg2);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGridsMultiThreaded(GRID_CNT - 1);
+
+        startGrid(GRID_CNT - 1);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLockUnlock() throws Exception {
+        for (int i = 0; i < GRID_CNT; i++) {
+            Ignite ignite = ignite(i);
+
+            log.info("Check node: " + ignite.name());
+
+            IgniteCache<Integer, Integer> cache1 = ignite.cache(CACHE1);
+            IgniteCache<Integer, Integer> cache2 = ignite.cache(CACHE2);
+
+            for (int k = 0; k < 1000; k++) {
+                Lock lock1 = null;
+                Lock lock2 = null;
+
+                try {
+                    lock1 = cache1.lock(k);
+
+                    assertTrue(lock1.tryLock());
+
+                    assertTrue(cache1.isLocalLocked(k, true));
+                    assertFalse(cache2.isLocalLocked(k, true));
+
+                    lock2 = cache2.lock(k);
+
+                    assertTrue(lock2.tryLock());
+
+                    assertTrue(cache1.isLocalLocked(k, true));
+                    assertTrue(cache2.isLocalLocked(k, true));
+
+                    lock2.unlock();
+
+                    lock2 = null;
+
+                    assertTrue(cache1.isLocalLocked(k, true));
+                    assertFalse(cache2.isLocalLocked(k, true));
+
+                    lock1.unlock();
+
+                    lock1 = null;
+
+                    assertFalse(cache1.isLocalLocked(k, true));
+                    assertFalse(cache2.isLocalLocked(k, true));
+                }
+                finally {
+                    if (lock1 != null)
+                        lock1.unlock();
+
+                    if (lock2 != null)
+                        lock2.unlock();
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
index d61394f..f6877cc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
@@ -206,10 +206,13 @@ public class GridCacheFinishPartitionsSelfTest extends GridCacheAbstractSelfTest
             KeyCacheObject cacheKey = internal.context().toCacheKeyObject(key);
 
             IgniteInternalFuture<?> nearFut = internal.context().mvcc().finishKeys(Collections.singletonList(cacheKey),
+                internal.context().cacheId(),
                 new AffinityTopologyVersion(2));
 
             IgniteInternalFuture<?> dhtFut = internal.context().near().dht().context().mvcc().finishKeys(
-                Collections.singletonList(cacheKey), new AffinityTopologyVersion(2));
+                Collections.singletonList(cacheKey),
+                internal.context().cacheId(),
+                new AffinityTopologyVersion(2));
 
             assert !nearFut.isDone();
             assert !dhtFut.isDone();

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6bb01b4/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 959ceb1..80d53e9 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
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeDynam
 import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartAtomicTest;
 import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartTxTest;
 import org.apache.ignite.internal.processors.cache.CacheSwapUnswapGetTest;
+import org.apache.ignite.internal.processors.cache.CrossCacheLockTest;
 import org.apache.ignite.internal.processors.cache.GridCacheMarshallingNodeJoinSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateAtomicNearEnabledSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateAtomicSelfTest;
@@ -271,6 +272,8 @@ public class IgniteCacheTestSuite4 extends TestSuite {
 
         suite.addTestSuite(IgniteDynamicCacheFilterTest.class);
 
+        suite.addTestSuite(CrossCacheLockTest.class);
+
         return suite;
     }
 }
\ No newline at end of file


[14/41] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by an...@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/3c5758ba
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3c5758ba
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3c5758ba

Branch: refs/heads/ignite-1168
Commit: 3c5758bab14b30b1dad7eb39d1c388e5f6956e0f
Parents: dd7d4fa ece3400
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Sep 24 15:17:46 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Sep 24 15:17:46 2015 +0300

----------------------------------------------------------------------
 .../socket/WordsSocketStreamerServer.java       |   5 +-
 .../org/apache/ignite/IgniteAtomicLong.java     |   2 +-
 .../org/apache/ignite/IgniteFileSystem.java     |   2 +-
 .../apache/ignite/cache/CacheAtomicityMode.java |  17 +-
 .../configuration/CacheConfiguration.java       |  17 +-
 .../apache/ignite/internal/IgniteKernal.java    |   4 +-
 .../cache/DynamicCacheDescriptor.java           |  10 +-
 .../processors/cache/GridCacheAdapter.java      |   8 +-
 .../processors/cache/GridCacheMapEntry.java     |  51 +-
 .../GridCachePartitionExchangeManager.java      |   6 +
 .../processors/cache/GridCacheProcessor.java    |  28 +-
 .../cache/GridCacheSwapEntryImpl.java           |  31 +-
 .../processors/cache/GridCacheSwapManager.java  |  80 ++-
 .../processors/cache/IgniteCacheProxy.java      |   4 +-
 .../continuous/CacheContinuousQueryManager.java |  66 +-
 .../continuous/GridContinuousProcessor.java     |   3 +-
 .../datastreamer/DataStreamerImpl.java          |   2 -
 .../internal/processors/igfs/IgfsImpl.java      |  87 +--
 .../processors/igfs/IgfsMetaManager.java        | 193 +++++-
 .../org/apache/ignite/mxbean/IgniteMXBean.java  |   8 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   7 +-
 .../discovery/DiscoverySpiCustomMessage.java    |  12 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 410 +++++++++----
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |   6 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   2 +-
 .../tcp/internal/TcpDiscoveryNodesRing.java     |  94 +--
 .../messages/TcpDiscoveryDiscardMessage.java    |  15 +-
 .../TcpDiscoveryNodeAddFinishedMessage.java     |   2 +-
 .../messages/TcpDiscoveryNodeAddedMessage.java  |  19 +-
 .../org/apache/ignite/stream/StreamAdapter.java | 104 +++-
 .../stream/StreamMultipleTupleExtractor.java    |  38 ++
 .../stream/StreamSingleTupleExtractor.java      |  40 ++
 .../ignite/stream/StreamTupleExtractor.java     |  20 +-
 .../ignite/stream/socket/SocketStreamer.java    |   3 +-
 .../GridCacheAbstractRemoveFailureTest.java     |   6 +-
 .../GridCacheVariableTopologySelfTest.java      |   3 +-
 .../IgniteCacheEntryListenerAbstractTest.java   |  65 +-
 .../distributed/CacheAffEarlySelfTest.java      | 245 --------
 .../distributed/CacheAffinityEarlyTest.java     | 168 +++++
 .../IgniteCachePutRetryAbstractSelfTest.java    |  33 +
 ...GridCacheValueConsistencyAtomicSelfTest.java |   2 +-
 .../near/NearCacheMultithreadedUpdateTest.java  | 217 +++++++
 ...ontinuousQueryReplicatedOneNodeSelfTest.java | 120 ++++
 .../processors/igfs/IgfsAbstractSelfTest.java   | 201 ++++--
 .../igfs/IgfsClientCacheSelfTest.java           |  15 +-
 .../igfs/IgfsMetaManagerSelfTest.java           | 106 ++--
 ...lientDiscoverySpiFailureTimeoutSelfTest.java | 139 ++++-
 .../tcp/TcpClientDiscoverySpiSelfTest.java      |  13 +-
 .../tcp/TcpDiscoveryMultiThreadedTest.java      |  53 +-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java | 315 +++++++++-
 .../stream/socket/SocketStreamerSelfTest.java   | 112 +++-
 .../IgniteCacheFailoverTestSuite.java           |   4 -
 .../IgniteCacheFailoverTestSuite3.java          |  23 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 .../testsuites/IgniteHadoopTestSuite.java       |  19 +-
 .../processors/query/h2/IgniteH2Indexing.java   |  19 +-
 .../query/h2/opt/GridH2AbstractKeyValueRow.java |  54 +-
 .../query/h2/opt/GridH2KeyValueRowOffheap.java  |  11 +-
 .../query/h2/opt/GridH2RowDescriptor.java       |   5 +
 .../processors/query/h2/opt/GridH2Table.java    |  10 +-
 .../cache/CacheIndexStreamerTest.java           |  37 +-
 .../processors/cache/GridCacheSwapSelfTest.java |   4 +-
 .../IgniteCacheQuerySelfTestSuite.java          |   4 +-
 .../IgniteCacheWithIndexingTestSuite.java       |   2 +
 modules/mqtt/pom.xml                            | 114 ++++
 .../apache/ignite/stream/mqtt/MqttStreamer.java | 611 +++++++++++++++++++
 .../stream/mqtt/IgniteMqttStreamerTest.java     | 553 +++++++++++++++++
 .../mqtt/IgniteMqttStreamerTestSuite.java       |  34 ++
 .../Apache.Ignite.Core/Impl/IgniteManager.cs    |   2 -
 modules/yardstick/config/ignite-base-config.xml |   2 +-
 pom.xml                                         |   1 +
 71 files changed, 3762 insertions(+), 958 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3c5758ba/pom.xml
----------------------------------------------------------------------


[16/41] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by an...@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/31c44054
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/31c44054
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/31c44054

Branch: refs/heads/ignite-1168
Commit: 31c44054c25e03e95fb4a3e237bfa6bf273c59dd
Parents: 1056a31 3c5758b
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 24 15:52:40 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 24 15:52:40 2015 +0300

----------------------------------------------------------------------
 examples/schema-import/pom.xml | 10 ++++++++--
 pom.xml                        |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[10/41] ignite git commit: Fixed imports.

Posted by an...@apache.org.
Fixed imports.


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

Branch: refs/heads/ignite-1168
Commit: ece3400438709b2bac2ad9d206028b4bdb897073
Parents: f6ba3c3
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 24 13:09:15 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 24 13:09:15 2015 +0300

----------------------------------------------------------------------
 .../IgniteCacheFailoverTestSuite.java           |  4 ----
 .../IgniteCacheFailoverTestSuite3.java          | 23 +++-----------------
 2 files changed, 3 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ece34004/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
index abc8765..c9e507d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
@@ -33,18 +33,14 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtR
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheTxNodeFailureSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridNearCacheTxNodeFailureSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteAtomicLongChangingTopologySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryTransactionalSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicClientInvalidPartitionHandlingSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicClientRemoveFailureTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicInvalidPartitionHandlingSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicPrimaryWriteOrderRemoveFailureTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicRemoveFailureTest;
-import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.IgniteCachePutRetryAtomicPrimaryWriteOrderSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearRemoveFailureTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicPrimaryWriteOrderNearRemoveFailureTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearRemoveFailureTest;
-import org.apache.ignite.spi.communication.tcp.IgniteCacheSslStartStopSelfTest;
 import org.apache.ignite.testframework.GridTestUtils;
 
 /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/ece34004/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java
index 318db9e..0bde89a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java
@@ -18,18 +18,10 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
-import org.apache.ignite.internal.processors.cache.GridCacheIncrementTransformTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheTopologySafeGetSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.*;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearRemoveFailureTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicPrimaryWriteOrderNearRemoveFailureTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearRemoveFailureTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryAtomicSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryTransactionalSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.IgniteCachePutRetryAtomicPrimaryWriteOrderSelfTest;
 import org.apache.ignite.spi.communication.tcp.IgniteCacheSslStartStopSelfTest;
-import org.apache.ignite.testframework.GridTestUtils;
-
-import java.util.Set;
 
 /**
  * Test suite.
@@ -40,15 +32,6 @@ public class IgniteCacheFailoverTestSuite3 extends TestSuite {
      * @throws Exception Thrown in case of the failure.
      */
     public static TestSuite suite() throws Exception {
-        return suite(null);
-    }
-
-    /**
-     * @param ignoredTests Tests don't include in the execution.
-     * @return Test suite.
-     * @throws Exception Thrown in case of the failure.
-     */
-    public static TestSuite suite(Set<Class> ignoredTests) throws Exception {
         TestSuite suite = new TestSuite("Cache Failover Test Suite3");
 
         suite.addTestSuite(IgniteCachePutRetryAtomicSelfTest.class);


[11/41] ignite git commit: schema-import examples fix (cherry picked from commit 169066b)

Posted by an...@apache.org.
schema-import examples fix
(cherry picked from commit 169066b)


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

Branch: refs/heads/ignite-1168
Commit: 30f5b9ef82fe9216fd89827977c601b8eb17db50
Parents: 1021d4e
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Sep 24 14:33:26 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Sep 24 15:16:17 2015 +0300

----------------------------------------------------------------------
 examples/schema-import/pom.xml | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/30f5b9ef/examples/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/examples/schema-import/pom.xml b/examples/schema-import/pom.xml
index d302606..fdbd631 100644
--- a/examples/schema-import/pom.xml
+++ b/examples/schema-import/pom.xml
@@ -26,13 +26,19 @@
     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>
+
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
 
-    <groupId>org.apache.ignite</groupId>
     <artifactId>ignite-schema-import-demo</artifactId>
-    <version>${project.version}</version>
+    <version>1.0.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>


[28/41] ignite git commit: IGNITE-1557

Posted by an...@apache.org.
IGNITE-1557


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

Branch: refs/heads/ignite-1168
Commit: 00e61e52678aefc2fcad0179fb3e05b46265b102
Parents: 8fea96e
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Sep 28 14:00:23 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Sep 28 14:00:23 2015 +0300

----------------------------------------------------------------------
 pom.xml | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/00e61e52/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index fad8807..5194a72 100644
--- a/pom.xml
+++ b/pom.xml
@@ -897,6 +897,22 @@
                     </execution>
                 </executions>
             </plugin>
+
+            <plugin><!-- skipping generates dependencies licenses -->
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-remote-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>ignite-dependencies</id>
+                        <goals>
+                            <goal>process</goal>
+                        </goals>
+                        <configuration>
+                           <skip>true</skip>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>


[33/41] ignite git commit: Disabled SSL test for old JDKs.

Posted by an...@apache.org.
Disabled SSL test for old JDKs.


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

Branch: refs/heads/ignite-1168
Commit: e5c3ca3a952c3595bf240bf0adea8117dd4db116
Parents: 04930ca
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 28 16:35:59 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 28 16:35:59 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e5c3ca3a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java
index 0bde89a..1f94f9e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryAtomicSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryTransactionalSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.IgniteCachePutRetryAtomicPrimaryWriteOrderSelfTest;
+import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.spi.communication.tcp.IgniteCacheSslStartStopSelfTest;
 
 /**
@@ -38,7 +39,9 @@ public class IgniteCacheFailoverTestSuite3 extends TestSuite {
         suite.addTestSuite(IgniteCachePutRetryAtomicPrimaryWriteOrderSelfTest.class);
         suite.addTestSuite(IgniteCachePutRetryTransactionalSelfTest.class);
 
-        suite.addTestSuite(IgniteCacheSslStartStopSelfTest.class);
+        // Disable SSL test with old JDK because of https://bugs.openjdk.java.net/browse/JDK-8013809.
+        if (!IgniteUtils.isHotSpot() || IgniteUtils.isJavaVersionAtLeast("1.7.0_65"))
+            suite.addTestSuite(IgniteCacheSslStartStopSelfTest.class);
 
         return suite;
     }


[27/41] ignite git commit: Added test.

Posted by an...@apache.org.
Added test.


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

Branch: refs/heads/ignite-1168
Commit: 2575cf33a4b8389aa84e9cf0ee68d48c3a48bfa7
Parents: 8fea96e
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 28 13:07:59 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 28 13:07:59 2015 +0300

----------------------------------------------------------------------
 .../cache/IgniteDynamicCacheFilterTest.java     | 150 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |   3 +
 2 files changed, 153 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2575cf33/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheFilterTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheFilterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheFilterTest.java
new file mode 100644
index 0000000..4d543e0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheFilterTest.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import 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 IgniteDynamicCacheFilterTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final String ATTR_NAME = "cacheAttr";
+
+    /** */
+    private String attrVal;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg.setCacheMode(REPLICATED);
+        ccfg.setRebalanceMode(SYNC);
+
+        ccfg.setNodeFilter(new TestNodeFilter("A"));
+
+        if (attrVal != null) {
+            Map<String, Object> attrs = new HashMap<>();
+
+            attrs.put(ATTR_NAME, attrVal);
+
+            cfg.setUserAttributes(attrs);
+        }
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCofiguredCacheFilter() throws Exception {
+        attrVal = "A";
+
+        Ignite ignite0 = startGrid(0);
+
+        IgniteCache<Integer, Integer> cache0 = ignite0.cache(null);
+
+        assertNotNull(cache0);
+
+        cache0.put(1, 1);
+
+        attrVal = null;
+
+        Ignite ignite1 = startGrid(1);
+
+        IgniteCache<Integer, Integer> cache1 = ignite1.cache(null);
+
+        assertNotNull(cache1);
+
+        attrVal = "B";
+
+        Ignite ignite2 = startGrid(2);
+
+        IgniteCache<Integer, Integer> cache2 = ignite2.cache(null);
+
+        assertNotNull(cache2);
+
+        attrVal = "A";
+
+        Ignite ignite3 = startGrid(3);
+
+        IgniteCache<Integer, Integer> cache3 = ignite3.cache(null);
+
+        assertNotNull(cache3);
+
+        assertNotNull(cache0.localPeek(1));
+        assertNotNull(cache3.localPeek(1));
+
+        assertNull(cache1.localPeek(1));
+        assertNull(cache2.localPeek(1));
+    }
+
+    /**
+     *
+     */
+    private static class TestNodeFilter implements IgnitePredicate<ClusterNode> {
+        /** */
+        private String val;
+
+        /**
+         * @param val Attribute value.
+         */
+        public TestNodeFilter(String val) {
+            assert val != null;
+
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(ClusterNode node) {
+            return val.equals(node.attribute(ATTR_NAME));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2575cf33/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 0ebcc81..959ceb1 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
@@ -65,6 +65,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheTxPeekModesTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheTxPreloadNoWriteTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheTxReplicatedPeekModesTest;
 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.IgniteDynamicCacheWithConfigStartSelfTest;
@@ -268,6 +269,8 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(GridCacheNearTxPreloadSelfTest.class);
         suite.addTestSuite(GridReplicatedTxPreloadTest.class);
 
+        suite.addTestSuite(IgniteDynamicCacheFilterTest.class);
+
         return suite;
     }
 }
\ No newline at end of file


[38/41] ignite git commit: minor (style)

Posted by an...@apache.org.
minor (style)


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

Branch: refs/heads/ignite-1168
Commit: c2cedb0ed5f54cdbdc60635043555c7c47c04bea
Parents: c517fcf
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Sep 29 16:20:26 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Sep 29 16:20:26 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/internal/util/GridArgumentCheck.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c2cedb0e/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java
index 8be3610..f96773e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java
@@ -157,8 +157,7 @@ public class GridArgumentCheck {
     public static void notNullOrEmpty(String value, String name) {
         notNull(value, name);
 
-        if (value.trim().length() == 0) {
+        if (value.trim().length() == 0)
             throw new IllegalArgumentException(INVALID_ARG_MSG_PREFIX + name + NOT_NULL_OR_EMPTY_SUFFIX);
-        }
     }
-}
\ No newline at end of file
+}


[22/41] ignite git commit: fixed sha1 & md5, again (cherry picked from commit 7752aa9)

Posted by an...@apache.org.
fixed sha1 & md5, again
(cherry picked from commit 7752aa9)


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

Branch: refs/heads/ignite-1168
Commit: a6306a5471a189fd4bbdabb9c1ccd9a8f0c38cb5
Parents: 3c5758b
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 25 16:01:40 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 25 16:21:23 2015 +0300

----------------------------------------------------------------------
 pom.xml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a6306a54/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 462d4a0..fad8807 100644
--- a/pom.xml
+++ b/pom.xml
@@ -622,7 +622,15 @@
                                             </fileset>
                                         </copy>
 
-                                        <!-- appending filename to md5 and sha1 files. to be improved. -->
+                                        <!-- appending filename to md5 and sha1 files. to be improved!! -->
+                                        <!-- update versions task will replace "  " to " ", so additional echo added. -->
+                                        <echo file="${basedir}/target/site/${project.artifactId}-fabric-${project.version}-bin.zip.md5" append="true" message=" " />
+                                        <echo file="${basedir}/target/site/${project.artifactId}-fabric-${project.version}-bin.zip.sha1" append="true" message=" " />
+                                        <echo file="${basedir}/target/site/${project.artifactId}-hadoop-${project.version}-bin.zip.md5" append="true" message=" " />
+                                        <echo file="${basedir}/target/site/${project.artifactId}-hadoop-${project.version}-bin.zip.sha1" append="true" message=" " />
+                                        <echo file="${basedir}/target/site/${project.artifactId}-${project.version}-src.zip.md5" append="true" message=" " />
+                                        <echo file="${basedir}/target/site/${project.artifactId}-${project.version}-src.zip.sha1" append="true" message=" " />
+
                                         <echo file="${basedir}/target/site/${project.artifactId}-fabric-${project.version}-bin.zip.md5" append="true" message=" ${project.artifactId}-fabric-${project.version}-bin.zip" />
                                         <echo file="${basedir}/target/site/${project.artifactId}-fabric-${project.version}-bin.zip.sha1" append="true" message=" ${project.artifactId}-fabric-${project.version}-bin.zip" />
                                         <echo file="${basedir}/target/site/${project.artifactId}-hadoop-${project.version}-bin.zip.md5" append="true" message=" ${project.artifactId}-hadoop-${project.version}-bin.zip" />


[24/41] ignite git commit: IGNITE-257 - Fixed and uncommented tests.

Posted by an...@apache.org.
IGNITE-257 - Fixed and uncommented tests.


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

Branch: refs/heads/ignite-1168
Commit: cdc5b49f31973d4c973dc465f7c01ce2eb4c8c89
Parents: 343191b
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Sep 25 17:58:51 2015 -0700
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Sep 25 17:58:51 2015 -0700

----------------------------------------------------------------------
 .../near/GridNearTxFinishFuture.java            |  4 +--
 .../cache/distributed/near/GridNearTxLocal.java | 19 +++++++++--
 .../transactions/IgniteTxLocalAdapter.java      | 35 ++++++++++++++------
 .../IgniteTxExceptionAbstractSelfTest.java      |  3 ++
 .../GridCacheColocatedTxExceptionSelfTest.java  |  5 ---
 .../near/GridCacheNearTxExceptionSelfTest.java  |  5 ---
 .../GridCacheReplicatedTxExceptionSelfTest.java |  5 ---
 .../GridCacheLocalTxExceptionSelfTest.java      |  5 ---
 8 files changed, 47 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cdc5b49f/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 ab6dc3c..85311cc 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
@@ -268,7 +268,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
             if (tx.onePhaseCommit()) {
                 finishOnePhase();
 
-                tx.tmFinish(err == null);
+                tx.tmFinish(commit && err == null);
             }
 
             Throwable th = this.err.get();
@@ -333,7 +333,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
      * Initializes future.
      */
     void finish() {
-        if (tx.needCheckBackup()) {
+        if (tx.onNeedCheckBackup()) {
             assert tx.onePhaseCommit();
 
             checkBackup();

http://git-wip-us.apache.org/repos/asf/ignite/blob/cdc5b49f/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 a4e06c3..8975b4a 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
@@ -114,7 +114,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
     private Map<IgniteTxKey, IgniteCacheExpiryPolicy> accessMap;
 
     /** */
-    private boolean needCheckBackup;
+    private Boolean needCheckBackup;
 
     /** */
     private boolean hasRemoteLocks;
@@ -255,8 +255,23 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
     /**
      * @return If need to check tx commit on backup.
      */
+    public boolean onNeedCheckBackup() {
+        Boolean check = needCheckBackup;
+
+        if (check != null && check) {
+            needCheckBackup = false;
+
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * @return If backup check was requested.
+     */
     public boolean needCheckBackup() {
-        return needCheckBackup;
+        return needCheckBackup != null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/cdc5b49f/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 6ca1f72..aa0ffe8 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
@@ -1120,11 +1120,13 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
 
             state(commit ? COMMITTED : ROLLED_BACK);
 
-            boolean needsCompletedVersions = commit && needsCompletedVersions();
+            if (commit) {
+                boolean needsCompletedVersions = needsCompletedVersions();
 
-            assert !needsCompletedVersions || completedBase != null;
-            assert !needsCompletedVersions || committedVers != null;
-            assert !needsCompletedVersions || rolledbackVers != null;
+                assert !needsCompletedVersions || completedBase != null : "Missing completed base for transaction: " + this;
+                assert !needsCompletedVersions || committedVers != null : "Missing committed versions for transaction: " + this;
+                assert !needsCompletedVersions || rolledbackVers != null : "Missing rolledback versions for transaction: " + this;
+            }
         }
     }
 
@@ -2895,11 +2897,17 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                     }
 
                     return nonInterruptable(commitAsync().chain(new CX1<IgniteInternalFuture<IgniteInternalTx>, GridCacheReturn>() {
-                        @Override
-                        public GridCacheReturn applyx(IgniteInternalFuture<IgniteInternalTx> txFut) throws IgniteCheckedException {
-                            txFut.get();
+                        @Override public GridCacheReturn applyx(IgniteInternalFuture<IgniteInternalTx> txFut) throws IgniteCheckedException {
+                            try {
+                                txFut.get();
+
+                                return implicitRes;
+                            }
+                            catch (IgniteCheckedException | RuntimeException e) {
+                                rollbackAsync();
 
-                            return implicitRes;
+                                throw e;
+                            }
                         }
                     }));
                 }
@@ -3118,9 +3126,16 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                     return nonInterruptable(commitAsync().chain(new CX1<IgniteInternalFuture<IgniteInternalTx>, GridCacheReturn>() {
                         @Override public GridCacheReturn applyx(IgniteInternalFuture<IgniteInternalTx> txFut)
                             throws IgniteCheckedException {
-                            txFut.get();
+                            try {
+                                txFut.get();
 
-                            return implicitRes;
+                                return implicitRes;
+                            }
+                            catch (IgniteCheckedException | RuntimeException e) {
+                                rollbackAsync();
+
+                                throw e;
+                            }
                         }
                     }));
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cdc5b49f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
index 10b47fe..3311608 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
@@ -368,6 +368,9 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
 
         for (Integer key : keys)
             checkUnlocked(key);
+
+        for (int i = 0; i < gridCount(); i++)
+            assertEquals(0, ((IgniteKernal)ignite(0)).internalCache(null).context().tm().idMapSize());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/cdc5b49f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
index 5514ff6..b5d79e1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxExceptionSelfTest.java
@@ -28,11 +28,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
  */
 public class GridCacheColocatedTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
     /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-257");
-    }
-
-    /** {@inheritDoc} */
     @Override protected CacheMode cacheMode() {
         return PARTITIONED;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cdc5b49f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
index 67bccac..d6e3804 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
@@ -27,11 +27,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
  */
 public class GridCacheNearTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
     /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-257");
-    }
-
-    /** {@inheritDoc} */
     @Override protected CacheMode cacheMode() {
         return PARTITIONED;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cdc5b49f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
index c2799db..1c96a4d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxExceptionSelfTest.java
@@ -28,11 +28,6 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED;
  */
 public class GridCacheReplicatedTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
     /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-257");
-    }
-
-    /** {@inheritDoc} */
     @Override protected CacheMode cacheMode() {
         return REPLICATED;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cdc5b49f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
index 2fae99b..63a900d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java
@@ -27,11 +27,6 @@ import static org.apache.ignite.cache.CacheMode.LOCAL;
  */
 public class GridCacheLocalTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
     /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-257");
-    }
-
-    /** {@inheritDoc} */
     @Override protected int gridCount() {
         return 1;
     }


[31/41] ignite git commit: minor (blank line)

Posted by an...@apache.org.
minor (blank line)


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

Branch: refs/heads/ignite-1168
Commit: 040f0f33994533b8acdaad5c41a6fa37c105e658
Parents: c001d47
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon Sep 28 15:30:37 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Mon Sep 28 15:30:37 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/examples/computegrid/ComputeClosureExample.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/040f0f33/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java
index eaa54a4..43a18e2 100644
--- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClosureExample.java
@@ -76,4 +76,4 @@ public class ComputeClosureExample {
             System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
         }
     }
-}
\ No newline at end of file
+}


[30/41] ignite git commit: ignite-80 Fixed dynamic cache start future completion

Posted by an...@apache.org.
ignite-80 Fixed dynamic cache start future completion


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

Branch: refs/heads/ignite-1168
Commit: 13629ce89c71e5a1e1c447885ce0be9d3efb5a6c
Parents: c001d47
Author: sboikov <sb...@gridgain.com>
Authored: Mon Sep 28 15:17:15 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Sep 28 15:17:15 2015 +0300

----------------------------------------------------------------------
 .../managers/discovery/CustomEventListener.java |  4 +++-
 .../discovery/GridDiscoveryManager.java         |  2 +-
 .../cache/DynamicCacheChangeRequest.java        | 19 +++++++++++++++++++
 .../cache/DynamicCacheDescriptor.java           | 19 +++++++++++++++++++
 .../GridCachePartitionExchangeManager.java      | 20 +++++++++++++++++---
 .../processors/cache/GridCacheProcessor.java    | 15 +++++++++++----
 .../continuous/CacheContinuousQueryHandler.java | 10 +++-------
 .../continuous/GridContinuousProcessor.java     | 17 +++++++++++++----
 .../datastructures/DataStructuresProcessor.java |  6 +++++-
 ...omicOffheapQueueCreateMultiNodeSelfTest.java |  5 -----
 ...ionedAtomicQueueCreateMultiNodeSelfTest.java |  5 -----
 ...PartitionedQueueCreateMultiNodeSelfTest.java | 16 ++++++++++------
 12 files changed, 101 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/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 3a09b2c..785613d 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
@@ -527,7 +527,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                         if (list != null) {
                             for (CustomEventListener<DiscoveryCustomMessage> lsnr : list) {
                                 try {
-                                    lsnr.onCustomEvent(node, customMsg);
+                                    lsnr.onCustomEvent(node, customMsg, nextTopVer);
                                 }
                                 catch (Exception e) {
                                     U.error(log, "Failed to notify direct custom event listener: " + customMsg, e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
index 583e346..b23be41 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
@@ -21,9 +21,11 @@ import java.io.Serializable;
 import java.util.UUID;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Cache start/stop request.
@@ -69,6 +71,9 @@ public class DynamicCacheChangeRequest implements Serializable {
     /** */
     private transient boolean exchangeNeeded;
 
+    /** */
+    private transient AffinityTopologyVersion cacheFutTopVer;
+
     /**
      * Constructor creates cache stop request.
      *
@@ -88,6 +93,20 @@ public class DynamicCacheChangeRequest implements Serializable {
     }
 
     /**
+     * @param cacheFutTopVer Ready topology version when dynamic cache future should be completed.
+     */
+    public void cacheFutureTopologyVersion(AffinityTopologyVersion cacheFutTopVer) {
+        this.cacheFutTopVer = cacheFutTopVer;
+    }
+
+    /**
+     * @return Ready topology version when dynamic cache future should be completed.
+     */
+    @Nullable public AffinityTopologyVersion cacheFutureTopologyVersion() {
+        return cacheFutTopVer;
+    }
+
+    /**
      * @param exchangeNeeded {@code True} if request should trigger partition exchange.
      */
     public void exchangeNeeded(boolean exchangeNeeded) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
index 3cfc34e..24df7e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
@@ -22,11 +22,13 @@ import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.plugin.CachePluginManager;
 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.jetbrains.annotations.Nullable;
 
 /**
  * Cache start descriptor.
@@ -63,6 +65,9 @@ public class DynamicCacheDescriptor {
     /** */
     private boolean updatesAllowed = true;
 
+    /** */
+    private AffinityTopologyVersion startTopVer;
+
     /**
      * @param ctx Context.
      * @param cacheCfg Cache configuration.
@@ -84,6 +89,20 @@ public class DynamicCacheDescriptor {
     }
 
     /**
+     * @return Start topology version.
+     */
+    @Nullable public AffinityTopologyVersion startTopologyVersion() {
+        return startTopVer;
+    }
+
+    /**
+     * @param startTopVer Start topology version.
+     */
+    public void startTopologyVersion(AffinityTopologyVersion startTopVer) {
+        this.startTopVer = startTopVer;
+    }
+
+    /**
      * @return {@code True} if this is template configuration.
      */
     public boolean template() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/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 eb76233..3e77e0d 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
@@ -199,11 +199,25 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
                         Collection<DynamicCacheChangeRequest> valid = new ArrayList<>(batch.requests().size());
 
                         // Validate requests to check if event should trigger partition exchange.
-                        for (DynamicCacheChangeRequest req : batch.requests()) {
+                        for (final DynamicCacheChangeRequest req : batch.requests()) {
                             if (req.exchangeNeeded())
                                 valid.add(req);
-                            else
-                                cctx.cache().completeStartFuture(req);
+                            else {
+                                IgniteInternalFuture<?> fut = null;
+
+                                if (req.cacheFutureTopologyVersion() != null)
+                                    fut = affinityReadyFuture(req.cacheFutureTopologyVersion());
+
+                                if (fut == null || fut.isDone())
+                                    cctx.cache().completeStartFuture(req);
+                                else {
+                                    fut.listen(new CI1<IgniteInternalFuture<?>>() {
+                                        @Override public void apply(IgniteInternalFuture<?> fut) {
+                                            cctx.cache().completeStartFuture(req);
+                                        }
+                                    });
+                                }
+                            }
                         }
 
                         if (!F.isEmpty(valid)) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/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 74124bf..c86dfd9 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
@@ -115,7 +115,6 @@ import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.lifecycle.LifecycleAware;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import org.apache.ignite.internal.portable.api.PortableMarshaller;
 import org.apache.ignite.spi.IgniteNodeValidationResult;
 import org.jetbrains.annotations.Nullable;
 
@@ -615,8 +614,10 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         ctx.discovery().setCustomEventListener(DynamicCacheChangeBatch.class,
             new CustomEventListener<DynamicCacheChangeBatch>() {
-                @Override public void onCustomEvent(ClusterNode snd, DynamicCacheChangeBatch msg) {
-                    onCacheChangeRequested(msg);
+                @Override public void onCustomEvent(ClusterNode snd,
+                    DynamicCacheChangeBatch msg,
+                    AffinityTopologyVersion topVer) {
+                    onCacheChangeRequested(msg, topVer);
                 }
             });
 
@@ -2363,8 +2364,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * Callback invoked from discovery thread when cache deployment request is received.
      *
      * @param batch Change request batch.
+     * @param topVer Current topology version.
      */
-    private void onCacheChangeRequested(DynamicCacheChangeBatch batch) {
+    private void onCacheChangeRequested(DynamicCacheChangeBatch batch, AffinityTopologyVersion topVer) {
         for (DynamicCacheChangeRequest req : batch.requests()) {
             if (req.template()) {
                 CacheConfiguration ccfg = req.startCacheConfiguration();
@@ -2421,6 +2423,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                         DynamicCacheDescriptor startDesc =
                             new DynamicCacheDescriptor(ctx, ccfg, req.cacheType(), false, req.deploymentId());
 
+                        startDesc.startTopologyVersion(topVer);
+
                         DynamicCacheDescriptor old = registeredCaches.put(maskNull(ccfg.getName()), startDesc);
 
                         assert old == null :
@@ -2469,6 +2473,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                         }
                     }
                 }
+
+                if (!needExchange && desc != null)
+                    req.cacheFutureTopologyVersion(desc.startTopologyVersion());
             }
             else {
                 assert req.stop() ^ req.close() : req;

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index c99e07f..1990e18 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -30,7 +30,6 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
-import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.CacheQueryExecutedEvent;
 import org.apache.ignite.events.CacheQueryReadEvent;
 import org.apache.ignite.internal.GridKernalContext;
@@ -234,13 +233,10 @@ class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler {
                         locLsnr.onUpdated(F.<CacheEntryEvent<? extends K, ? extends V>>asList(evt));
                     else {
                         try {
-                            ClusterNode node = ctx.discovery().node(nodeId);
-
-                            if (ctx.config().isPeerClassLoadingEnabled() && node != null) {
+                            if (ctx.config().isPeerClassLoadingEnabled() && ctx.discovery().node(nodeId) != null) {
                                 evt.entry().prepareMarshal(cctx);
 
-                                GridCacheDeploymentManager depMgr =
-                                    ctx.cache().internalCache(cacheName).context().deploy();
+                                GridCacheDeploymentManager depMgr = cctx.deploy();
 
                                 depMgr.prepare(evt.entry());
                             }
@@ -320,7 +316,7 @@ class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler {
         assert routineId != null;
         assert ctx != null;
 
-        GridCacheAdapter<K, V> cache = ctx.cache().<K, V>internalCache(cacheName);
+        GridCacheAdapter<K, V> cache = ctx.cache().internalCache(cacheName);
 
         if (cache != null)
             cache.context().continuousQueries().unregisterListener(internal, routineId);

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/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 e29bdd4..d1cb3a9 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
@@ -51,6 +51,7 @@ 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.GridCacheContext;
 import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -186,7 +187,9 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
 
         ctx.discovery().setCustomEventListener(StartRoutineDiscoveryMessage.class,
             new CustomEventListener<StartRoutineDiscoveryMessage>() {
-                @Override public void onCustomEvent(ClusterNode snd, StartRoutineDiscoveryMessage msg) {
+                @Override public void onCustomEvent(ClusterNode snd,
+                    StartRoutineDiscoveryMessage msg,
+                    AffinityTopologyVersion topVer) {
                     if (!snd.id().equals(ctx.localNodeId()) && !ctx.isStopping())
                         processStartRequest(snd, msg);
                 }
@@ -194,7 +197,9 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
 
         ctx.discovery().setCustomEventListener(StartRoutineAckDiscoveryMessage.class,
             new CustomEventListener<StartRoutineAckDiscoveryMessage>() {
-                @Override public void onCustomEvent(ClusterNode snd, StartRoutineAckDiscoveryMessage msg) {
+                @Override public void onCustomEvent(ClusterNode snd,
+                    StartRoutineAckDiscoveryMessage msg,
+                    AffinityTopologyVersion topVer) {
                     StartFuture fut = startFuts.remove(msg.routineId());
 
                     if (fut != null) {
@@ -213,7 +218,9 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
 
         ctx.discovery().setCustomEventListener(StopRoutineDiscoveryMessage.class,
             new CustomEventListener<StopRoutineDiscoveryMessage>() {
-                @Override public void onCustomEvent(ClusterNode snd, StopRoutineDiscoveryMessage msg) {
+                @Override public void onCustomEvent(ClusterNode snd,
+                    StopRoutineDiscoveryMessage msg,
+                    AffinityTopologyVersion topVer) {
                     if (!snd.id().equals(ctx.localNodeId())) {
                         UUID routineId = msg.routineId();
 
@@ -231,7 +238,9 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
 
         ctx.discovery().setCustomEventListener(StopRoutineAckDiscoveryMessage.class,
             new CustomEventListener<StopRoutineAckDiscoveryMessage>() {
-                @Override public void onCustomEvent(ClusterNode snd, StopRoutineAckDiscoveryMessage msg) {
+                @Override public void onCustomEvent(ClusterNode snd,
+                    StopRoutineAckDiscoveryMessage msg,
+                    AffinityTopologyVersion topVer) {
                     StopFuture fut = stopFuts.remove(msg.routineId());
 
                     if (fut != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/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 a5561e9..ef2c543 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
@@ -883,7 +883,9 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException If failed.
      */
     private String compatibleConfiguration(CollectionConfiguration cfg) throws IgniteCheckedException {
-        List<CacheCollectionInfo> caches = utilityDataCache.localPeek(DATA_STRUCTURES_CACHE_KEY, null, null);
+        List<CacheCollectionInfo> caches = utilityDataCache.context().affinityNode() ?
+            utilityDataCache.localPeek(DATA_STRUCTURES_CACHE_KEY, null, null) :
+            utilityDataCache.get(DATA_STRUCTURES_CACHE_KEY);
 
         String cacheName = findCompatibleConfiguration(cfg, caches);
 
@@ -897,6 +899,8 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
         if (ctx.cache().cache(cacheName) == null)
             ctx.cache().dynamicStartCache(newCfg, cacheName, null, CacheType.INTERNAL, false, true).get();
 
+        assert ctx.cache().cache(cacheName) != null : cacheName;
+
         return cacheName;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicOffheapQueueCreateMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicOffheapQueueCreateMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicOffheapQueueCreateMultiNodeSelfTest.java
index 7a31363..49d5092 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicOffheapQueueCreateMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicOffheapQueueCreateMultiNodeSelfTest.java
@@ -26,11 +26,6 @@ import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
 public class GridCachePartitionedAtomicOffheapQueueCreateMultiNodeSelfTest
     extends GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest {
     /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-80");
-    }
-
-    /** {@inheritDoc} */
     @Override protected CacheMemoryMode collectionMemoryMode() {
         return OFFHEAP_TIERED;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest.java
index e334ad6..caeb9b6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest.java
@@ -29,11 +29,6 @@ import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
 public class GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest
     extends GridCachePartitionedQueueCreateMultiNodeSelfTest {
     /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-80");
-    }
-
-    /** {@inheritDoc} */
     @Override protected CacheMemoryMode collectionMemoryMode() {
         return ONHEAP_TIERED;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/13629ce8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java
index 181682f..2146fc1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.processors.cache.datastructures.IgniteCollectionAbstractTest;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.transactions.Transaction;
 
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -48,11 +49,6 @@ import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_REA
  */
 public class GridCachePartitionedQueueCreateMultiNodeSelfTest extends IgniteCollectionAbstractTest {
     /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-80");
-    }
-
-    /** {@inheritDoc} */
     @Override protected int gridCount() {
         return 1;
     }
@@ -127,7 +123,7 @@ public class GridCachePartitionedQueueCreateMultiNodeSelfTest extends IgniteColl
 
                     Thread.currentThread().setName("createQueue-" + idx0);
 
-                    Ignite ignite = startGrid(idx0);
+                    final Ignite ignite = startGrid(idx0);
 
                     UUID locNodeId = ignite.cluster().localNode().id();
 
@@ -135,6 +131,14 @@ public class GridCachePartitionedQueueCreateMultiNodeSelfTest extends IgniteColl
 
                     info("Creating queue: " + locNodeId);
 
+                    GridTestUtils.runMultiThreaded(new Callable<Void>() {
+                        @Override public Void call() throws Exception {
+                            ignite.queue("queue", 1, config(true));
+
+                            return null;
+                        }
+                    }, 10, "create-queue-" + ignite.name());
+
                     IgniteQueue<String> q = ignite.queue("queue", 1, config(true));
 
                     assert q != null;


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

Posted by an...@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/c001d472
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c001d472
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c001d472

Branch: refs/heads/ignite-1168
Commit: c001d47206ec4c63d757925742b7083854bd9c2f
Parents: 00e61e5 2575cf3
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Sep 28 14:00:45 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Sep 28 14:00:45 2015 +0300

----------------------------------------------------------------------
 .../cache/IgniteDynamicCacheFilterTest.java     | 150 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |   3 +
 2 files changed, 153 insertions(+)
----------------------------------------------------------------------



[21/41] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by an...@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/a42750ae
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a42750ae
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a42750ae

Branch: refs/heads/ignite-1168
Commit: a42750ae0465cb79c39d9e8875c11cafd91fd8a3
Parents: d7b36d8 27cf501
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 25 14:08:41 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 25 14:08:41 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/GridUpdateNotifierSelfTest.java  | 1 +
 ...ridCachePartitionedQueueFailoverDataConsistencySelfTest.java | 5 -----
 .../expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java    | 5 ++++-
 3 files changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------



[13/41] ignite git commit: schema-import examples fix (cherry picked from commit b054fdc)

Posted by an...@apache.org.
schema-import examples fix
(cherry picked from commit b054fdc)


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

Branch: refs/heads/ignite-1168
Commit: dd7d4fac3a5f391b23c196a5d9951de9d3a762fa
Parents: 94f5248
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Sep 24 15:17:15 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Sep 24 15:17:15 2015 +0300

----------------------------------------------------------------------
 examples/schema-import/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dd7d4fac/examples/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/examples/schema-import/pom.xml b/examples/schema-import/pom.xml
index fce6f47..32ce869 100644
--- a/examples/schema-import/pom.xml
+++ b/examples/schema-import/pom.xml
@@ -38,7 +38,7 @@
     </properties>
 
     <artifactId>ignite-schema-import-demo</artifactId>
-    <version>1.3.3-p7-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>


[34/41] ignite git commit: Merge branches 'ignite-1168' and 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1168

Posted by an...@apache.org.
Merge branches 'ignite-1168' and 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1168


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

Branch: refs/heads/ignite-1168
Commit: 66b91b9af6fcfe04a6de2874b375d8f7c51ec693
Parents: 124c492 e5c3ca3
Author: Andrey <an...@gridgain.com>
Authored: Tue Sep 29 09:23:49 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Sep 29 09:23:49 2015 +0700

----------------------------------------------------------------------
 bin/igniterouter.bat                            |   2 +-
 bin/igniterouter.sh                             |   2 +-
 examples/schema-import/pom.xml                  |  10 +-
 .../computegrid/ComputeClosureExample.java      |   2 +-
 .../org/apache/ignite/IgniteAtomicLong.java     |   2 +-
 .../org/apache/ignite/IgniteFileSystem.java     |   2 +-
 .../configuration/CacheConfiguration.java       |   2 +-
 .../apache/ignite/internal/IgniteKernal.java    |   4 +-
 .../managers/discovery/CustomEventListener.java |   4 +-
 .../discovery/GridDiscoveryManager.java         |   2 +-
 .../cache/DynamicCacheChangeRequest.java        |  19 +
 .../cache/DynamicCacheDescriptor.java           |  29 +-
 .../GridCachePartitionExchangeManager.java      |  26 +-
 .../processors/cache/GridCacheProcessor.java    |  33 +-
 .../processors/cache/IgniteCacheProxy.java      |   4 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |   6 +-
 .../dht/atomic/GridDhtAtomicUpdateFuture.java   |   5 +
 .../near/GridNearTxFinishFuture.java            |   4 +-
 .../cache/distributed/near/GridNearTxLocal.java |  19 +-
 .../continuous/CacheContinuousQueryHandler.java |  10 +-
 .../continuous/CacheContinuousQueryManager.java |  66 ++-
 .../transactions/IgniteTxLocalAdapter.java      |  35 +-
 .../continuous/GridContinuousProcessor.java     |  20 +-
 .../datastructures/DataStructuresProcessor.java |   6 +-
 .../internal/processors/igfs/IgfsImpl.java      |  87 +---
 .../processors/igfs/IgfsMetaManager.java        | 193 ++++++++-
 .../org/apache/ignite/mxbean/IgniteMXBean.java  |   8 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   7 +-
 .../discovery/DiscoverySpiCustomMessage.java    |  12 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 398 +++++++++++++------
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |   6 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   2 +-
 .../tcp/internal/TcpDiscoveryNodesRing.java     |  94 ++---
 .../messages/TcpDiscoveryDiscardMessage.java    |  15 +-
 .../TcpDiscoveryNodeAddFinishedMessage.java     |   2 +-
 .../messages/TcpDiscoveryNodeAddedMessage.java  |  19 +-
 .../internal/GridUpdateNotifierSelfTest.java    |   1 +
 .../GridCacheAbstractRemoveFailureTest.java     |   6 +-
 .../GridCacheVariableTopologySelfTest.java      |   3 +-
 .../cache/IgniteDynamicCacheFilterTest.java     | 150 +++++++
 .../IgniteTxExceptionAbstractSelfTest.java      |   3 +
 ...omicOffheapQueueCreateMultiNodeSelfTest.java |   5 -
 ...ionedAtomicQueueCreateMultiNodeSelfTest.java |   5 -
 ...PartitionedQueueCreateMultiNodeSelfTest.java |  16 +-
 ...nedQueueFailoverDataConsistencySelfTest.java |   5 -
 .../distributed/CacheAffEarlySelfTest.java      | 245 ------------
 .../distributed/CacheAffinityEarlyTest.java     | 168 ++++++++
 .../IgniteTxPreloadAbstractTest.java            |  43 +-
 .../GridCacheColocatedTxExceptionSelfTest.java  |   5 -
 ...GridCacheValueConsistencyAtomicSelfTest.java |   2 +-
 .../near/GridCacheNearTxExceptionSelfTest.java  |   5 -
 .../near/NearCacheMultithreadedUpdateTest.java  | 217 ++++++++++
 .../GridCacheReplicatedInvalidateSelfTest.java  | 249 ------------
 .../GridCacheReplicatedTxExceptionSelfTest.java |   5 -
 .../replicated/GridReplicatedTxPreloadTest.java |   2 -
 ...eCacheExpiryPolicyWithStoreAbstractTest.java |   5 +-
 .../GridCacheLocalTxExceptionSelfTest.java      |   5 -
 ...ontinuousQueryReplicatedOneNodeSelfTest.java | 120 ++++++
 .../processors/igfs/IgfsAbstractSelfTest.java   | 201 +++++++---
 .../igfs/IgfsClientCacheSelfTest.java           |  15 +-
 .../igfs/IgfsMetaManagerSelfTest.java           | 106 ++---
 ...lientDiscoverySpiFailureTimeoutSelfTest.java |  33 +-
 .../tcp/TcpDiscoveryMultiThreadedTest.java      |  53 ++-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java | 315 ++++++++++++++-
 .../multijvm/IgniteCacheProcessProxy.java       |   3 +-
 .../IgniteCacheFailoverTestSuite.java           |   4 -
 .../IgniteCacheFailoverTestSuite3.java          |  28 +-
 .../testsuites/IgniteCacheTestSuite3.java       |   2 -
 .../testsuites/IgniteCacheTestSuite4.java       |  12 +
 .../testsuites/IgniteHadoopTestSuite.java       |  19 +-
 .../IgniteCacheQuerySelfTestSuite.java          |   4 +-
 pom.xml                                         |  27 +-
 72 files changed, 2121 insertions(+), 1123 deletions(-)
----------------------------------------------------------------------


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


[03/41] ignite git commit: Fixed test.

Posted by an...@apache.org.
Fixed test.


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

Branch: refs/heads/ignite-1168
Commit: 517d0f584f67e9291b7f6f2efe3f42b7131f6a25
Parents: 04f4f54
Author: sboikov <sb...@gridgain.com>
Authored: Wed Sep 23 15:43:13 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Sep 23 15:43:13 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAbstractRemoveFailureTest.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/517d0f58/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
index 647746e..a3d9948 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
@@ -365,13 +365,13 @@ public abstract class GridCacheAbstractRemoveFailureTest extends GridCommonAbstr
 
         U.sleep(random(START_DELAY.get1(), START_DELAY.get2()));
 
-        if (stop.get())
-            return;
-
         log.info("Restarting node " + idx);
 
         startGrid(idx);
 
+        if (stop.get())
+            return;
+
         U.sleep(1000);
     }
 


[15/41] ignite git commit: ignite-1540 Handle error in GridDhtAtomicUpdateFuture.onDone

Posted by an...@apache.org.
ignite-1540 Handle error in GridDhtAtomicUpdateFuture.onDone


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

Branch: refs/heads/ignite-1168
Commit: 1056a31fc72ea25c8790e37f2621f3d6e1908c89
Parents: ece3400
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 24 15:52:17 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 24 15:52:17 2015 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1056a31f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
index 0cbad48..35b8e27 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
@@ -311,6 +311,11 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
         if (super.onDone(res, err)) {
             cctx.mvcc().removeAtomicFuture(version());
 
+            if (err != null) {
+                for (KeyCacheObject key : keys)
+                    updateRes.addFailedKey(key, err);
+            }
+
             if (updateReq.writeSynchronizationMode() == FULL_SYNC)
                 completionCb.apply(updateReq, updateRes);
 


[20/41] ignite git commit: Removed test.

Posted by an...@apache.org.
Removed test.


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

Branch: refs/heads/ignite-1168
Commit: d7b36d8bd804f9d5abadf230b2f24bfc14ce4b74
Parents: bf7591b
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 25 14:08:13 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 25 14:08:13 2015 +0300

----------------------------------------------------------------------
 .../GridCacheReplicatedInvalidateSelfTest.java  | 249 -------------------
 .../testsuites/IgniteCacheTestSuite3.java       |   2 -
 2 files changed, 251 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d7b36d8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedInvalidateSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedInvalidateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedInvalidateSelfTest.java
deleted file mode 100644
index a0c2fca..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedInvalidateSelfTest.java
+++ /dev/null
@@ -1,249 +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.cache.distributed.replicated;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-import java.util.UUID;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.managers.communication.GridIoMessage;
-import org.apache.ignite.internal.processors.clock.GridClockDeltaSnapshotMessage;
-import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.plugin.extensions.communication.Message;
-import org.apache.ignite.spi.IgniteSpiException;
-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.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.transactions.Transaction;
-import org.apache.ignite.transactions.TransactionConcurrency;
-import org.apache.ignite.transactions.TransactionIsolation;
-
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.cache.CacheRebalanceMode.NONE;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
-import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
-import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
-
-/**
- *
- */
-public class GridCacheReplicatedInvalidateSelfTest extends GridCommonAbstractTest {
-    /** Random number generator. */
-    private static final Random RAND = new Random();
-
-    /** Grid count. */
-    private static final int GRID_CNT = 3;
-
-    /** */
-    private static final Integer KEY = 1;
-
-    /** */
-    private static final String VAL = "test";
-
-    /** */
-    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /**
-     * Don't start grid by default.
-     */
-    public GridCacheReplicatedInvalidateSelfTest() {
-        super(false);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration c = super.getConfiguration(gridName);
-
-        c.getTransactionConfiguration().setTxSerializableEnabled(true);
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        disco.setIpFinder(ipFinder);
-
-        c.setDiscoverySpi(disco);
-
-        c.setCommunicationSpi(new TestCommunicationSpi());
-
-        CacheConfiguration cc = defaultCacheConfiguration();
-
-        cc.setRebalanceMode(NONE);
-        cc.setCacheMode(REPLICATED);
-        cc.setWriteSynchronizationMode(FULL_SYNC);
-
-        c.setCacheConfiguration(cc);
-
-        return c;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @Override protected void beforeTestsStarted() throws Exception {
-        for (int i = 0; i < GRID_CNT; i++)
-            startGrid(i);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @Override protected void beforeTest() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-601");
-
-        for (int i = 0; i < GRID_CNT; i++)
-            ioSpi(i).clearCounts();
-    }
-
-    /**
-     * @param i Index.
-     * @return IO SPI.
-     */
-    private TestCommunicationSpi ioSpi(int i) {
-        return (TestCommunicationSpi)grid(i).configuration().getCommunicationSpi();
-    }
-
-    /**
-     * @throws IgniteCheckedException If test failed.
-     */
-    public void testOptimisticReadCommitted() throws Throwable {
-        checkCommit(OPTIMISTIC, READ_COMMITTED);
-    }
-
-    /**
-     * @throws IgniteCheckedException If test failed.
-     */
-    public void testOptimisticRepeatableRead() throws Throwable {
-        checkCommit(OPTIMISTIC, REPEATABLE_READ);
-    }
-
-    /**
-     * @throws IgniteCheckedException If test failed.
-     */
-    public void testOptimisticSerializable() throws Throwable {
-        checkCommit(OPTIMISTIC, SERIALIZABLE);
-    }
-
-    /**
-     * @param concurrency Concurrency.
-     * @param isolation Isolation.
-     * @throws Throwable If check failed.
-     */
-    private void checkCommit(TransactionConcurrency concurrency,
-        TransactionIsolation isolation) throws Throwable {
-        int idx = RAND.nextInt(GRID_CNT);
-
-        IgniteCache<Integer, String> cache = jcache(idx);
-
-        Transaction tx = grid(idx).transactions().txStart(concurrency, isolation, 0, 0);
-
-        try {
-            cache.put(KEY, VAL);
-
-            tx.commit();
-        }
-        catch (Throwable e) {
-            error("Transaction failed (will rollback): " + tx, e);
-
-            tx.rollback();
-
-            throw e;
-        }
-
-        TestCommunicationSpi ioSpi = ioSpi(idx);
-
-        int checkIdx = RAND.nextInt(GRID_CNT);
-
-        while (checkIdx == idx)
-            checkIdx = RAND.nextInt(GRID_CNT);
-
-        Ignite checkIgnite = grid(checkIdx);
-
-        int msgCnt = ioSpi.getMessagesCount(checkIgnite.cluster().localNode().id());
-
-        info("Checked node: " + checkIgnite.cluster().localNode().id());
-
-        assertEquals("Invalid message count for grid: " + checkIgnite.cluster().localNode().id(), 2, msgCnt);
-    }
-
-    /**
-     *
-     */
-    private class TestCommunicationSpi extends TcpCommunicationSpi {
-        /** */
-        private final Map<UUID, Integer> msgCntMap = new HashMap<>();
-
-        /**
-         * @param destNodeId Node id to check.
-         * @return Number of messages that was sent to node.
-         */
-        public int getMessagesCount(UUID destNodeId) {
-            synchronized (msgCntMap) {
-                Integer cnt = msgCntMap.get(destNodeId);
-
-                return cnt == null ? 0 : cnt;
-            }
-        }
-
-        /**
-         *  Clear message counts.
-         */
-        public void clearCounts() {
-            synchronized (msgCntMap) {
-                msgCntMap.clear();
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public void sendMessage(ClusterNode destNode, Message msg,
-            IgniteInClosure<IgniteException> ackClosure)
-            throws IgniteSpiException {
-            Object msg0 = ((GridIoMessage)msg).message();
-
-            if (!(msg0 instanceof GridClockDeltaSnapshotMessage)) {
-                info("Sending message [locNodeId=" + ignite.cluster().localNode().id() +
-                    ", destNodeId= " + destNode.id()
-                    + ", msg=" + msg + ']');
-
-                synchronized (msgCntMap) {
-                    Integer cnt = msgCntMap.get(destNode.id());
-
-                    msgCntMap.put(destNode.id(), cnt == null ? 1 : cnt + 1);
-                }
-            }
-
-            super.sendMessage(destNode, msg, ackClosure);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d7b36d8b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
index 5a2815d..02a7f7f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
@@ -54,7 +54,6 @@ import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCa
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedEventSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedEvictionEventSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedGetAndTransformStoreSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedInvalidateSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedLockSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedMultiNodeLockSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedMultiNodeSelfTest;
@@ -104,7 +103,6 @@ public class IgniteCacheTestSuite3 extends TestSuite {
         suite.addTestSuite(GridCacheReplicatedEventSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedSynchronousCommitTest.class);
 
-        suite.addTestSuite(GridCacheReplicatedInvalidateSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedLockSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedMultiNodeLockSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedMultiNodeSelfTest.class);


[02/41] ignite git commit: IGNITE-586: Fixed IGFS rename problem causing corrupted file system structure.

Posted by an...@apache.org.
IGNITE-586: Fixed IGFS rename problem causing corrupted file system structure.


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

Branch: refs/heads/ignite-1168
Commit: b3bcf4aeecf9aa1bd6d19e94c8da7b09741f5410
Parents: 0a41ae5
Author: iveselovskiy <iv...@gridgain.com>
Authored: Wed Sep 23 13:45:01 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Sep 23 13:45:01 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteFileSystem.java     |   2 +-
 .../configuration/CacheConfiguration.java       |   2 +-
 .../internal/processors/igfs/IgfsImpl.java      |  87 ++------
 .../processors/igfs/IgfsMetaManager.java        | 193 ++++++++++++++++--
 .../processors/igfs/IgfsAbstractSelfTest.java   | 201 ++++++++++++++-----
 .../igfs/IgfsClientCacheSelfTest.java           |  15 +-
 .../igfs/IgfsMetaManagerSelfTest.java           | 106 +++++-----
 .../testsuites/IgniteHadoopTestSuite.java       |  19 +-
 8 files changed, 409 insertions(+), 216 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b3bcf4ae/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
index b02d0f1..a187a90 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
@@ -451,7 +451,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
      * @return File information for specified path or {@code null} if such path does not exist.
      * @throws IgniteException In case of error.
      */
-    public IgfsFile info(IgfsPath path) throws IgniteException;
+    @Nullable public IgfsFile info(IgfsPath path) throws IgniteException;
 
     /**
      * Gets used space in bytes.

http://git-wip-us.apache.org/repos/asf/ignite/blob/b3bcf4ae/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 44a3fa9..6ac2b64 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -436,7 +436,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * @return {@code this} for chaining.
      */
     public CacheConfiguration<K, V> setName(String name) {
-        A.ensure(name == null || !name.isEmpty(), "Name cannot be null or empty.");
+        A.ensure(name == null || !name.isEmpty(), "Name cannot be empty.");
 
         this.name = name;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b3bcf4ae/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 695db38..0dd0307 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
@@ -472,8 +472,7 @@ public final class IgfsImpl implements IgfsEx {
     @SuppressWarnings("ConstantConditions")
     @Override public IgfsStatus globalSpace() {
         return safeOp(new Callable<IgfsStatus>() {
-            @Override
-            public IgfsStatus call() throws Exception {
+            @Override public IgfsStatus call() throws Exception {
                 IgniteBiTuple<Long, Long> space = igfsCtx.kernalContext().grid().compute().execute(
                     new IgfsGlobalSpaceTask(name()), null);
 
@@ -560,7 +559,7 @@ public final class IgfsImpl implements IgfsEx {
     }
 
     /** {@inheritDoc} */
-    @Override public IgfsFile info(final IgfsPath path) {
+    @Override @Nullable public IgfsFile info(final IgfsPath path) {
         A.notNull(path, "path");
 
         return safeOp(new Callable<IgfsFile>() {
@@ -692,64 +691,12 @@ public final class IgfsImpl implements IgfsEx {
                     return null;
                 }
 
-                IgfsPath destParent = dest.parent();
+                IgfsFileInfo info = meta.move(src, dest);
 
-                // Resolve source file info.
-                FileDescriptor srcDesc = getFileDescriptor(src);
+                int evtTyp = info.isFile() ? EVT_IGFS_FILE_RENAMED : EVT_IGFS_DIR_RENAMED;
 
-                // File not found.
-                if (srcDesc == null || srcDesc.parentId == null) {
-                    if (mode == PRIMARY)
-                        checkConflictWithPrimary(src);
-
-                    throw new IgfsPathNotFoundException("Failed to rename (source path not found): " + src);
-                }
-
-                String srcFileName = src.name();
-
-                // Resolve destination file info.
-                FileDescriptor destDesc = getFileDescriptor(dest);
-
-                String destFileName;
-
-                boolean newDest = destDesc == null;
-
-                if (newDest) {
-                    assert destParent != null;
-
-                    // Use parent directory for destination parent and destination path name as destination name.
-                    destDesc = getFileDescriptor(destParent);
-
-                    // Destination directory doesn't exist.
-                    if (destDesc == null)
-                        throw new IgfsPathNotFoundException("Failed to rename (destination directory does not " +
-                            "exist): " + dest);
-
-                    destFileName = dest.name();
-                }
-                else
-                    // Use destination directory for destination parent and source path name as destination name.
-                    destFileName = srcFileName;
-
-                // Can move only into directory, but not into file.
-                if (destDesc.isFile)
-                    throw new IgfsParentNotDirectoryException("Failed to rename (destination is not a directory): "
-                        + dest);
-
-                meta.move(srcDesc.fileId, srcFileName, srcDesc.parentId, destFileName, destDesc.fileId);
-
-                if (srcDesc.isFile) { // Renamed a file.
-                    if (evts.isRecordable(EVT_IGFS_FILE_RENAMED))
-                        evts.record(new IgfsEvent(
-                            src,
-                            newDest ? dest : new IgfsPath(dest, destFileName),
-                            localNode(),
-                            EVT_IGFS_FILE_RENAMED));
-                }
-                else { // Renamed a directory.
-                    if (evts.isRecordable(EVT_IGFS_DIR_RENAMED))
-                        evts.record(new IgfsEvent(src, dest, localNode(), EVT_IGFS_DIR_RENAMED));
-                }
+                if (evts.isRecordable(evtTyp))
+                    evts.record(new IgfsEvent(src, info.path(), localNode(), evtTyp));
 
                 return null;
             }
@@ -967,8 +914,7 @@ public final class IgfsImpl implements IgfsEx {
                 }
 
                 return F.viewReadOnly(files, new C1<String, IgfsPath>() {
-                    @Override
-                    public IgfsPath apply(String e) {
+                    @Override public IgfsPath apply(String e) {
                         return new IgfsPath(path, e);
                     }
                 });
@@ -981,8 +927,7 @@ public final class IgfsImpl implements IgfsEx {
         A.notNull(path, "path");
 
         return safeOp(new Callable<Collection<IgfsFile>>() {
-            @Override
-            public Collection<IgfsFile> call() throws Exception {
+            @Override public Collection<IgfsFile> call() throws Exception {
                 if (log.isDebugEnabled())
                     log.debug("List directory details: " + path);
 
@@ -1058,8 +1003,7 @@ public final class IgfsImpl implements IgfsEx {
         A.ensure(seqReadsBeforePrefetch >= 0, "seqReadsBeforePrefetch >= 0");
 
         return safeOp(new Callable<IgfsInputStreamAdapter>() {
-            @Override
-            public IgfsInputStreamAdapter call() throws Exception {
+            @Override public IgfsInputStreamAdapter call() throws Exception {
                 if (log.isDebugEnabled())
                     log.debug("Open file for reading [path=" + path + ", bufSize=" + bufSize + ']');
 
@@ -1146,8 +1090,7 @@ public final class IgfsImpl implements IgfsEx {
         A.ensure(bufSize >= 0, "bufSize >= 0");
 
         return safeOp(new Callable<IgfsOutputStream>() {
-            @Override
-            public IgfsOutputStream call() throws Exception {
+            @Override public IgfsOutputStream call() throws Exception {
                 if (log.isDebugEnabled())
                     log.debug("Open file for writing [path=" + path + ", bufSize=" + bufSize + ", overwrite=" +
                         overwrite + ", props=" + props + ']');
@@ -1250,8 +1193,7 @@ public final class IgfsImpl implements IgfsEx {
         A.ensure(bufSize >= 0, "bufSize >= 0");
 
         return safeOp(new Callable<IgfsOutputStream>() {
-            @Override
-            public IgfsOutputStream call() throws Exception {
+            @Override public IgfsOutputStream call() throws Exception {
                 if (log.isDebugEnabled())
                     log.debug("Open file for appending [path=" + path + ", bufSize=" + bufSize + ", create=" + create +
                         ", props=" + props + ']');
@@ -1373,8 +1315,7 @@ public final class IgfsImpl implements IgfsEx {
         A.ensure(len >= 0, "len >= 0");
 
         return safeOp(new Callable<Collection<IgfsBlockLocation>>() {
-            @Override
-            public Collection<IgfsBlockLocation> call() throws Exception {
+            @Override public Collection<IgfsBlockLocation> call() throws Exception {
                 if (log.isDebugEnabled())
                     log.debug("Get affinity for file block [path=" + path + ", start=" + start + ", len=" + len + ']');
 
@@ -1407,8 +1348,7 @@ public final class IgfsImpl implements IgfsEx {
     /** {@inheritDoc} */
     @Override public IgfsMetrics metrics() {
         return safeOp(new Callable<IgfsMetrics>() {
-            @Override
-            public IgfsMetrics call() throws Exception {
+            @Override public IgfsMetrics call() throws Exception {
                 IgfsPathSummary sum = new IgfsPathSummary();
 
                 summary0(ROOT_ID, sum);
@@ -1587,6 +1527,7 @@ public final class IgfsImpl implements IgfsEx {
      */
     @Nullable private FileDescriptor getFileDescriptor(IgfsPath path) throws IgniteCheckedException {
         List<IgniteUuid> ids = meta.fileIds(path);
+
         IgfsFileInfo fileInfo = meta.info(ids.get(ids.size() - 1));
 
         if (fileInfo == null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/b3bcf4ae/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 5611f33..d283b64 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -26,13 +26,16 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
+import java.util.TreeSet;
 import java.util.concurrent.CountDownLatch;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.MutableEntry;
@@ -584,23 +587,29 @@ public class IgfsMetaManager extends IgfsManager {
         assert validTxState(true);
         assert fileIds != null && fileIds.length > 0;
 
-        // Always sort file IDs participating in transaction to escape cache transaction deadlocks.
         Arrays.sort(fileIds);
 
-        // Wrap array as collection (1) to escape superfluous check in projection and (2) to check assertions.
-        Collection<IgniteUuid> keys = Arrays.asList(fileIds);
+        return lockIds(Arrays.asList(fileIds));
+    }
 
+    /**
+     * Lock file IDs.
+     * @param fileIds File IDs (sorted).
+     * @return Map with lock info.
+     * @throws IgniteCheckedException If failed.
+     */
+    private Map<IgniteUuid, IgfsFileInfo> lockIds(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
         if (log.isDebugEnabled())
-            log.debug("Locking file ids: " + keys);
+            log.debug("Locking file ids: " + fileIds);
 
         // Lock files and get their infos.
-        Map<IgniteUuid, IgfsFileInfo> map = id2InfoPrj.getAll(keys);
+        Map<IgniteUuid, IgfsFileInfo> map = id2InfoPrj.getAll(fileIds);
 
         if (log.isDebugEnabled())
-            log.debug("Locked file ids: " + keys);
+            log.debug("Locked file ids: " + fileIds);
 
         // Force root ID always exist in cache.
-        if (keys.contains(ROOT_ID) && !map.containsKey(ROOT_ID)) {
+        if (fileIds.contains(ROOT_ID) && !map.containsKey(ROOT_ID)) {
             IgfsFileInfo info = new IgfsFileInfo();
 
             id2InfoPrj.putIfAbsent(ROOT_ID, info);
@@ -807,27 +816,131 @@ public class IgfsMetaManager extends IgfsManager {
     }
 
     /**
-     * Move or rename file.
+     * Move routine.
      *
-     * @param fileId File ID to move or rename.
-     * @param srcFileName Original file name in the parent's listing.
-     * @param srcParentId Parent directory ID.
-     * @param destFileName New file name in the parent's listing after moving.
-     * @param destParentId New parent directory ID.
-     * @throws IgniteCheckedException If failed.
+     * @param srcPath Source path.
+     * @param dstPath Destinatoin path.
+     * @return File info of renamed entry.
+     * @throws IgniteCheckedException In case of exception.
      */
-    public void move(IgniteUuid fileId, String srcFileName, IgniteUuid srcParentId, String destFileName,
-        IgniteUuid destParentId) throws IgniteCheckedException {
+    public IgfsFileInfo move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
                 assert validTxState(false);
 
+                // 1. First get source and destination path IDs.
+                List<IgniteUuid> srcPathIds = fileIds(srcPath);
+                List<IgniteUuid> dstPathIds = fileIds(dstPath);
+
+                final Set<IgniteUuid> allIds = new TreeSet<>(new Comparator<IgniteUuid>() {
+                    @Override
+                    public int compare(IgniteUuid u1, IgniteUuid u2) {
+                        if (u1 == u2)
+                            return 0;
+
+                        if (u1 == null)
+                            return -1;
+
+                        return u1.compareTo(u2);
+                    }
+                });
+
+                allIds.addAll(srcPathIds);
+
+                final IgniteUuid dstLeafId = dstPathIds.get(dstPathIds.size() - 1);
+
+                if (dstLeafId == null) {
+                    // Delete null entry for the unexisting destination element:
+                    dstPathIds.remove(dstPathIds.size() - 1);
+                }
+
+                allIds.addAll(dstPathIds);
+
+                if (allIds.remove(null)) {
+                    throw new IgfsPathNotFoundException("Failed to perform move because some path component was " +
+                            "not found. [src=" + srcPath + ", dst=" + dstPath + ']');
+                }
+
+                // 2. Start transaction.
                 IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
 
                 try {
-                    moveNonTx(fileId, srcFileName, srcParentId, destFileName, destParentId);
+                    // 3. Obtain the locks.
+                    final Map<IgniteUuid, IgfsFileInfo> allInfos = lockIds(allIds);
+
+                    // 4. Verify integrity of source directory.
+                    if (!verifyPathIntegrity(srcPath, srcPathIds, allInfos)) {
+                        throw new IgfsPathNotFoundException("Failed to perform move because source directory " +
+                            "structure changed concurrently [src=" + srcPath + ", dst=" + dstPath + ']');
+                    }
+
+                    // 5. Verify integrity of destination directory.
+                    final IgfsPath dstDirPath = dstLeafId != null ? dstPath : dstPath.parent();
+
+                    if (!verifyPathIntegrity(dstDirPath, dstPathIds, allInfos)) {
+                        throw new IgfsPathNotFoundException("Failed to perform move because destination directory " +
+                            "structure changed concurrently [src=" + srcPath + ", dst=" + dstPath + ']');
+                    }
+
+                    // 6. Calculate source and destination targets which will be changed.
+                    IgniteUuid srcTargetId = srcPathIds.get(srcPathIds.size() - 2);
+                    IgfsFileInfo srcTargetInfo = allInfos.get(srcTargetId);
+                    String srcName = srcPath.name();
+
+                    IgniteUuid dstTargetId;
+                    IgfsFileInfo dstTargetInfo;
+                    String dstName;
+
+                    if (dstLeafId != null) {
+                        // Destination leaf exists. Check if it is an empty directory.
+                        IgfsFileInfo dstLeafInfo = allInfos.get(dstLeafId);
+
+                        assert dstLeafInfo != null;
+
+                        if (dstLeafInfo.isDirectory()) {
+                            // Destination is a directory.
+                            dstTargetId = dstLeafId;
+                            dstTargetInfo = dstLeafInfo;
+                            dstName = srcPath.name();
+                        }
+                        else {
+                            // Error, destination is existing file.
+                            throw new IgfsPathAlreadyExistsException("Failed to perform move " +
+                                "because destination points to " +
+                                "existing file [src=" + srcPath + ", dst=" + dstPath + ']');
+                        }
+                    }
+                    else {
+                        // Destination leaf doesn't exist, so we operate on parent.
+                        dstTargetId = dstPathIds.get(dstPathIds.size() - 1);
+                        dstTargetInfo = allInfos.get(dstTargetId);
+                        dstName = dstPath.name();
+                    }
+
+                    assert dstTargetInfo != null;
+                    assert dstTargetInfo.isDirectory();
+
+                    // 7. Last check: does destination target already have listing entry with the same name?
+                    if (dstTargetInfo.listing().containsKey(dstName)) {
+                        throw new IgfsPathAlreadyExistsException("Failed to perform move because destination already " +
+                            "contains entry with the same name existing file [src=" + srcPath +
+                            ", dst=" + dstPath + ']');
+                    }
+
+                    // 8. Actual move: remove from source parent and add to destination target.
+                    IgfsListingEntry entry = srcTargetInfo.listing().get(srcName);
+
+                    id2InfoPrj.invoke(srcTargetId, new UpdateListing(srcName, entry, true));
+                    id2InfoPrj.invoke(dstTargetId, new UpdateListing(dstName, entry, false));
 
                     tx.commit();
+
+                    IgfsPath realNewPath = new IgfsPath(dstDirPath, dstName);
+
+                    IgfsFileInfo moved = allInfos.get(srcPathIds.get(srcPathIds.size() - 1));
+
+                    // Set the new path to the info to simplify event creation:
+                    return IgfsFileInfo.builder(moved).path(realNewPath).build();
                 }
                 finally {
                     tx.close();
@@ -838,9 +951,49 @@ public class IgfsMetaManager extends IgfsManager {
             }
         }
         else
-            throw new IllegalStateException("Failed to move file system entry because Grid is stopping [fileId=" +
-                fileId + ", srcFileName=" + srcFileName + ", srcParentId=" + srcParentId + ", destFileName=" +
-                destFileName + ", destParentId=" + destParentId + ']');
+            throw new IllegalStateException("Failed to perform move because Grid is stopping [srcPath=" +
+                srcPath + ", dstPath=" + dstPath + ']');
+    }
+
+    /**
+     * Verify path integrity.
+     *
+     * @param path Path to verify.
+     * @param expIds Expected IDs for this path. Might contain additional elements, e.g. because they were created
+     *     on a child path.
+     * @param infos Locked infos.
+     * @return
+     */
+    private static boolean verifyPathIntegrity(IgfsPath path, List<IgniteUuid> expIds,
+        Map<IgniteUuid, IgfsFileInfo> infos) {
+        List<String> pathParts = path.components();
+
+        assert pathParts.size() < expIds.size();
+
+        for (int i = 0; i < pathParts.size(); i++) {
+            IgniteUuid parentId = expIds.get(i);
+
+            // If parent ID is null, it doesn't exist.
+            if (parentId != null) {
+                IgfsFileInfo parentInfo = infos.get(parentId);
+
+                // If parent info is null, it doesn't exist.
+                if (parentInfo != null) {
+                    IgfsListingEntry childEntry = parentInfo.listing().get(pathParts.get(i));
+
+                    // If expected child exists.
+                    if (childEntry != null) {
+                        // If child ID matches expected ID.
+                        if (F.eq(childEntry.fileId(), expIds.get(i + 1)))
+                            continue;
+                    }
+                }
+            }
+
+            return false;
+        }
+
+        return true;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b3bcf4ae/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 0a1e626..cfa99ff 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
@@ -43,6 +43,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteFileSystem;
 import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.FileSystemConfiguration;
@@ -59,13 +60,17 @@ import org.apache.ignite.igfs.IgfsOutputStream;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.igfs.IgfsPathNotFoundException;
 import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
+import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
+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.lang.IgniteUuid;
@@ -101,6 +106,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     /** Concurrent operations count. */
     protected static final int OPS_CNT = 16;
 
+    /** Seed. */
+    protected static final long SEED = System.currentTimeMillis();
+
     /** Amount of blocks to prefetch. */
     protected static final int PREFETCH_BLOCKS = 1;
 
@@ -203,11 +211,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     /**
      * Data chunk.
      *
-     * @param length Length.
+     * @param len Length.
      * @return Data chunk.
      */
-    static byte[] createChunk(int length) {
-        byte[] chunk = new byte[length];
+    static byte[] createChunk(int len) {
+        byte[] chunk = new byte[len];
 
         for (int i = 0; i < chunk.length; i++)
             chunk[i] = (byte)i;
@@ -224,6 +232,12 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         igfs = (IgfsImpl) ignite.fileSystem("igfs");
     }
 
+    /**
+     * Creates secondary file system stack.
+     *
+     * @return The secondary file system.
+     * @throws Exception On error.
+     */
     protected IgfsSecondaryFileSystem createSecondaryFileSystemStack() throws Exception {
         Ignite igniteSecondary = startGridWithIgfs("ignite-secondary", "igfs-secondary", PRIMARY, null,
             SECONDARY_REST_CFG);
@@ -845,17 +859,16 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     /**
      * Ensure that formatting is not propagated to the secondary file system.
      *
-     * TODO: IGNITE-586.
-     *
      * @throws Exception If failed.
      */
     @SuppressWarnings("ConstantConditions")
     public void testFormat() throws Exception {
-        // Test works too long and fails.
-        fail("https://issues.apache.org/jira/browse/IGNITE-586");
+        final GridCacheAdapter<IgfsBlockKey, byte[]> dataCache = getDataCache(igfs);
 
-        IgniteKernal grid = (IgniteKernal)G.ignite("grid");
-        GridCacheAdapter cache = grid.internalCache("dataCache");
+        assert dataCache != null;
+
+        int size0 = dataCache.size(new CachePeekMode[] {CachePeekMode.ALL});
+        assert size0 == 0 : "Initial data cache size = " + size0;
 
         if (dual)
             create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE, FILE_NEW));
@@ -873,23 +886,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         assert igfs.info(FILE).length() == 10 * 1024 * 1024;
 
-        int size = cache.size();
-        int primarySize = cache.primarySize();
-        int primaryKeySetSize = cache.primaryKeySet().size();
-
-        int primaryPartSize = 0;
-
-        for (int p : cache.affinity().primaryPartitions(grid.localNode())) {
-            Set set = cache.entrySet(p);
-
-            if (set != null)
-                primaryPartSize += set.size();
-        }
-
-        assert size > 0;
-        assert primarySize > 0;
-        assert primarySize == primaryKeySetSize;
-        assert primarySize == primaryPartSize;
+        assert dataCache.size(new CachePeekMode[] {CachePeekMode.ALL}) > 0;
 
         igfs.format();
 
@@ -903,27 +900,26 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         // Ensure entries deletion in the primary file system.
         checkNotExist(igfs, DIR, SUBDIR, FILE);
 
-        int sizeNew = cache.size();
-        int primarySizeNew = cache.primarySize();
-        int primaryKeySetSizeNew = cache.primaryKeySet().size();
-
-        int primaryPartSizeNew = 0;
-
-        for (int p : cache.affinity().primaryPartitions(grid.localNode())) {
-            Set set = cache.entrySet(p);
-
-            if (set != null) {
-                for (Object entry : set)
-                    System.out.println(entry);
-
-                primaryPartSizeNew += set.size();
+        if (!GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                try {
+                    return dataCache.size(new CachePeekMode[] {CachePeekMode.ALL}) == 0;
+                } catch (IgniteCheckedException ice) {
+                    throw new IgniteException(ice);
+                }
+            }
+        }, 10_000)) {
+            Set<GridCacheEntryEx> set = dataCache.allEntries();
+
+            for (GridCacheEntryEx e: set) {
+                X.println("deleted = " + e.deleted());
+                X.println("detached = " + e.detached());
+                X.println("info = " + e.info());
+                X.println("k = " + e.key() + ", v = " + e.valueBytes());
             }
-        }
 
-        assert sizeNew == 0;
-        assert primarySizeNew == 0;
-        assert primaryKeySetSizeNew == 0;
-        assert primaryPartSizeNew == 0;
+            assert false;
+        }
     }
 
     /**
@@ -1885,14 +1881,18 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testDeadlocksRename() throws Exception {
         for (int i = 0; i < REPEAT_CNT; i++) {
             try {
+                info(">>>>>> Start deadlock test.");
+
                 checkDeadlocks(5, 2, 2, 2, OPS_CNT, 0, 0, 0, 0);
+
+                info(">>>>>> End deadlock test.");
             }
             finally {
-                info(">>>>>> Start deadlock test");
+                info(">>>>>> Start cleanup.");
 
                 clear(igfs, igfsSecondary);
 
-                info(">>>>>> End deadlock test");
+                info(">>>>>> End cleanup.");
             }
         }
     }
@@ -1903,6 +1903,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testDeadlocksDelete() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1515");
+
         for (int i = 0; i < REPEAT_CNT; i++) {
             try {
                 checkDeadlocks(5, 2, 2, 2, 0, OPS_CNT, 0, 0, 0);
@@ -1967,6 +1969,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testDeadlocks() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1515");
+
         for (int i = 0; i < REPEAT_CNT; i++) {
             try {
                 checkDeadlocks(5, 2, 2, 2, OPS_CNT, OPS_CNT, OPS_CNT, OPS_CNT, OPS_CNT);
@@ -2038,7 +2042,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         }
 
         // Now as we have all paths defined, plan operations on them.
-        final Random rand = new Random(U.currentTimeMillis());
+        final Random rand = new Random(SEED);
 
         int totalOpCnt = renCnt + delCnt + updateCnt + mkdirsCnt + createCnt;
 
@@ -2194,7 +2198,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
             threads.add(new Thread(r));
         }
 
-        // Create folder structure.
+        // Create file/directory structure.
         for (int i = 0; i < lvlCnt; i++) {
             int lvl = i + 1;
 
@@ -2252,6 +2256,14 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         }
     }
 
+    /**
+     * Creates specified files/directories
+     *
+     * @param uni The file system to operate on.
+     * @param dirs The directories to create.
+     * @param files The files to create.
+     * @throws Exception On error.
+     */
     @SuppressWarnings("EmptyTryBlock")
     public void create(UniversalFileSystemAdapter uni, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files) throws Exception {
         if (dirs != null) {
@@ -2646,6 +2658,34 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     }
 
     /**
+     * Gets the data cache instance for this IGFS instance.
+     *
+     * @param igfs The IGFS unstance.
+     * @return The data cache.
+     */
+    protected static GridCacheAdapter<IgfsBlockKey, byte[]> getDataCache(IgniteFileSystem igfs) {
+        String dataCacheName = igfs.configuration().getDataCacheName();
+
+        IgniteEx igniteEx = ((IgfsEx)igfs).context().kernalContext().grid();
+
+        return ((IgniteKernal)igniteEx).internalCache(dataCacheName);
+    }
+
+    /**
+     * Gets meta cache.
+     *
+     * @param igfs The IGFS instance.
+     * @return The data cache.
+     */
+    protected static GridCacheAdapter<IgniteUuid, IgfsFileInfo> getMetaCache(IgniteFileSystem igfs) {
+        String dataCacheName = igfs.configuration().getMetaCacheName();
+
+        IgniteEx igniteEx = ((IgfsEx)igfs).context().kernalContext().grid();
+
+        return ((IgniteKernal)igniteEx).internalCache(dataCacheName);
+    }
+
+    /**
      * Clear particular IGFS.
      *
      * @param igfs IGFS.
@@ -2674,6 +2714,69 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         // Clear igfs.
         igfs.format();
+
+        final IgniteFileSystem igfs0 = igfs;
+
+        if (!GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                return isEmpty(igfs0);
+            }
+        }, 10_000L)) {
+            dumpCache("MetaCache" , getMetaCache(igfs));
+
+            dumpCache("DataCache" , getDataCache(igfs));
+
+            assert false;
+        }
+    }
+
+    /**
+     * Dumps given cache for diagnostic purposes.
+     *
+     * @param cacheName Name.
+     * @param cache The cache.
+     */
+    private static void dumpCache(String cacheName, GridCacheAdapter<?,?> cache) {
+        X.println("=============================== " + cacheName + " cache dump: ");
+
+        Set<GridCacheEntryEx> set = cache.entries();
+
+        for (GridCacheEntryEx e: set)
+            X.println("Lost " + cacheName + " entry = " + e);
+    }
+
+    /**
+     * Answers if the given IGFS is empty.
+     *
+     * @param igfs IGFS to operate on.
+     * @return True if IGFS is empty.
+     */
+    private static boolean isEmpty(IgniteFileSystem igfs) {
+        GridCacheAdapter dataCache = getDataCache(igfs);
+
+        assert dataCache != null;
+
+        int size1 = dataCache.size();
+
+        if (size1 > 0) {
+            X.println("Data cache size = " + size1);
+
+            return false;
+        }
+
+        GridCacheAdapter metaCache = getMetaCache(igfs);
+
+        assert metaCache != null;
+
+        int size2 = metaCache.size();
+
+        if (size2 > 2) {
+            X.println("Meta cache size = " + size2);
+
+            return false;
+        }
+
+        return true;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b3bcf4ae/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsClientCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsClientCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsClientCacheSelfTest.java
index f2394fc..8e8eac1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsClientCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsClientCacheSelfTest.java
@@ -47,9 +47,6 @@ public class IgfsClientCacheSelfTest extends IgfsAbstractSelfTest {
     /** Data cache name. */
     private static final String DATA_CACHE_NAME = null;
 
-    /** Regular cache name. */
-    private static final String CACHE_NAME = "cache";
-
     /**
      * Constructor.
      */
@@ -61,9 +58,9 @@ public class IgfsClientCacheSelfTest extends IgfsAbstractSelfTest {
     @Override protected void beforeTestsStarted() throws Exception {
         igfsSecondaryFileSystem = createSecondaryFileSystemStack();
 
-        Ignite ignite1 = G.start(getConfiguration(getTestGridName(1)));
+        Ignite ignitePrimary = G.start(getConfiguration(getTestGridName(1)));
 
-        igfs = (IgfsImpl) ignite1.fileSystem("igfs");
+        igfs = (IgfsImpl) ignitePrimary.fileSystem("igfs");
     }
 
     /**{@inheritDoc} */
@@ -86,8 +83,10 @@ public class IgfsClientCacheSelfTest extends IgfsAbstractSelfTest {
     protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        cfg.setCacheConfiguration(cacheConfiguration(META_CACHE_NAME), cacheConfiguration(DATA_CACHE_NAME),
-            cacheConfiguration(CACHE_NAME));
+        cfg.setCacheConfiguration(
+            cacheConfiguration(META_CACHE_NAME),
+            cacheConfiguration(DATA_CACHE_NAME)
+        );
 
         TcpDiscoverySpi disco = new TcpDiscoverySpi();
 
@@ -117,7 +116,7 @@ public class IgfsClientCacheSelfTest extends IgfsAbstractSelfTest {
      * @return Cache configuration.
      */
     protected CacheConfiguration cacheConfiguration(String cacheName) {
-        CacheConfiguration cacheCfg = defaultCacheConfiguration();
+        CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();
 
         cacheCfg.setName(cacheName);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b3bcf4ae/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index 75423f1..206c9fe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -152,8 +152,6 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         assertEquals(F.asMap("dir", new IgfsListingEntry(dir), "file", new IgfsListingEntry(file)),
             mgr.directoryListing(ROOT_ID));
 
-        //IgfsFileInfo tmp = mgr.info(dir.id());
-
         assertEquals(dir, mgr.info(dir.id()));
         assertEquals(file, mgr.info(file.id()));
 
@@ -215,6 +213,9 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
 
         IgfsFileInfo a = new IgfsFileInfo(true, null);
         IgfsFileInfo b = new IgfsFileInfo(true, null);
+        IgfsFileInfo k = new IgfsFileInfo(true, null);
+        IgfsFileInfo z = new IgfsFileInfo(true, null);
+
         IgfsFileInfo f1 = new IgfsFileInfo(400, null, false, null);
         IgfsFileInfo f2 = new IgfsFileInfo(new IgfsFileInfo(400, null, false, null), 0);
         IgfsFileInfo f3 = new IgfsFileInfo(new IgfsFileInfo(400, null, false, null), 200000L);
@@ -223,6 +224,8 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         assertNull(mgr.putIfAbsent(ROOT_ID, "a", a));
         assertNull(mgr.putIfAbsent(ROOT_ID, "f1", f1));
         assertNull(mgr.putIfAbsent(a.id(), "b", b));
+        assertNull(mgr.putIfAbsent(a.id(), "k", z));
+        assertNull(mgr.putIfAbsent(b.id(), "k", k));
         assertNull(mgr.putIfAbsent(a.id(), "f2", f2));
         assertNull(mgr.putIfAbsent(b.id(), "f3", f3));
 
@@ -232,15 +235,15 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
             mgr.directoryListing(ROOT_ID));
 
-        assertEquals(F.asMap("b", new IgfsListingEntry(b), "f2", new IgfsListingEntry(f2)),
+        assertEquals(F.asMap("b", new IgfsListingEntry(b), "f2", new IgfsListingEntry(f2), "k", new IgfsListingEntry(z)),
             mgr.directoryListing(a.id()));
 
-        assertEquals(F.asMap("f3", new IgfsListingEntry(f3)), mgr.directoryListing(b.id()));
+        assertEquals(F.asMap("f3", new IgfsListingEntry(f3),
+            "k", new IgfsListingEntry(k)), mgr.directoryListing(b.id()));
 
         // Validate empty files listings.
-        for (IgfsFileInfo info : Arrays.asList(f1, f2, f3)) {
+        for (IgfsFileInfo info : Arrays.asList(f1, f2, f3))
             assertEmpty(mgr.directoryListing(info.id()));
-        }
 
         // Validate 'file info' operations.
         for (IgfsFileInfo info : Arrays.asList(rootInfo, a, b, f1, f2, f3)) {
@@ -279,51 +282,44 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         assertEquals(Arrays.asList(ROOT_ID, a.id(), b.id(), null), mgr.fileIds(new IgfsPath("/a/b/f6")));
         assertEquals(Arrays.asList(ROOT_ID, null, null, null, null), mgr.fileIds(new IgfsPath("/f7/a/b/f6")));
 
-        // Validate 'rename' operation.
-        final IgniteUuid rndId = IgniteUuid.randomUuid();
-
         // One of participated files does not exist in cache.
-        expectsRenameFail(ROOT_ID, "b", rndId, "b2", rndId, "Failed to lock source directory (not found?)");
-        expectsRenameFail(b.id(), "b", rndId, "b2", rndId, "Failed to lock source directory (not found?)");
-        expectsRenameFail(ROOT_ID, "b", ROOT_ID, "b2", rndId, "Failed to lock destination directory (not found?)");
-        expectsRenameFail(b.id(), "b", ROOT_ID, "b2", rndId, "Failed to lock destination directory (not found?)");
-        expectsRenameFail(rndId, "b", ROOT_ID, "b2", ROOT_ID, "Failed to lock target file (not found?)");
-        expectsRenameFail(rndId, "b", b.id(), "b2", b.id(), "Failed to lock target file (not found?)");
-
-        // Target file ID differ from the file ID resolved from the source directory for source file name.
-        expectsRenameFail(b.id(), "a", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source directory");
-        expectsRenameFail(f1.id(), "a", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source directory");
-        expectsRenameFail(f2.id(), "a", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source directory");
-        expectsRenameFail(f3.id(), "a", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source directory");
-
-        // Invalid source file name (not found).
-        expectsRenameFail(a.id(), "u1", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source");
-        expectsRenameFail(a.id(), "u2", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source");
-        expectsRenameFail(a.id(), "u3", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source");
-
-        // Invalid destination file - already exists.
-        expectsRenameFail(a.id(), "a", ROOT_ID, "f1", ROOT_ID, "Failed to add file name into the destination");
-        expectsRenameFail(f2.id(), "f2", a.id(), "f1", ROOT_ID, "Failed to add file name into the destination");
-        expectsRenameFail(f3.id(), "f3", b.id(), "f1", ROOT_ID, "Failed to add file name into the destination");
-        expectsRenameFail(b.id(), "b", a.id(), "f2", a.id(), "Failed to add file name into the destination");
+        expectsRenameFail("/b8", "/b2", "Failed to perform move because some path component was not found.");
+
+        expectsRenameFail("/a", "/b/b8", "Failed to perform move because some path component was not found.");
+
+        expectsRenameFail("/a/f2", "/a/b/f3", "Failed to perform move because destination points to existing file");
+
+        expectsRenameFail("/a/k", "/a/b/", "Failed to perform move because destination already " +
+            "contains entry with the same name existing file");
+
+        mgr.delete(a.id(), "k", k.id());
+        mgr.delete(b.id(), "k", z.id());
 
         System.out.println("/: " + mgr.directoryListing(ROOT_ID));
         System.out.println("a: " + mgr.directoryListing(a.id()));
         System.out.println("b: " + mgr.directoryListing(b.id()));
         System.out.println("f3: " + mgr.directoryListing(f3.id()));
 
-        mgr.move(a.id(), "a", ROOT_ID, "a2", ROOT_ID);
-        mgr.move(b.id(), "b", a.id(), "b2", a.id());
+        //mgr.move(a.id(), "a", ROOT_ID, "a2", ROOT_ID);
+        mgr.move(path("/a"), path("/a2"));
+        //mgr.move(b.id(), "b", a.id(), "b2", a.id());
+        mgr.move(path("/a2/b"), path("/a2/b2"));
 
         assertNotNull(mgr.info(b.id()));
 
-        mgr.move(f3.id(), "f3", b.id(), "f3-2", a.id());
+        //mgr.move(f3.id(), "f3", b.id(), "f3-2", a.id());
+        mgr.move(path("/a2/b2/f3"), path("/a2/b2/f3-2"));
 
         assertNotNull(mgr.info(b.id()));
 
-        mgr.move(f3.id(), "f3-2", a.id(), "f3", b.id());
-        mgr.move(b.id(), "b2", a.id(), "b", a.id());
-        mgr.move(a.id(), "a2", ROOT_ID, "a", ROOT_ID);
+        //mgr.move(f3.id(), "f3-2", a.id(), "f3", b.id());
+        mgr.move(path("/a2/b2/f3-2"), path("/a2/b2/f3"));
+
+        //mgr.move(b.id(), "b2", a.id(), "b", a.id());
+        mgr.move(path("/a2/b2"), path("/a2/b"));
+
+        //mgr.move(a.id(), "a2", ROOT_ID, "a", ROOT_ID);
+        mgr.move(path("/a2"), path("/a"));
 
         // Validate 'remove' operation.
         for (int i = 0; i < 100; i++) {
@@ -345,7 +341,9 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
             mgr.directoryListing(ROOT_ID));
 
-        assertEquals(F.asMap("b", new IgfsListingEntry(b), "f2", new IgfsListingEntry(f2)),
+        assertEquals(
+            F.asMap("b", new IgfsListingEntry(b),
+                "f2", new IgfsListingEntry(f2)),
             mgr.directoryListing(a.id()));
 
         assertEmpty(mgr.directoryListing(b.id()));
@@ -393,6 +391,16 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
     }
 
     /**
+     * Utility method to make IgfsPath.
+     *
+     * @param p The String path.
+     * @return The IgfsPath object.
+     */
+    private static IgfsPath path(String p) {
+        return new IgfsPath(p);
+    }
+
+    /**
      * Validate passed map is empty.
      *
      * @param map Map to validate it is empty.
@@ -411,8 +419,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
     private void expectsUpdatePropertiesFail(@Nullable final IgniteUuid fileId, @Nullable final Map<String, String> props,
         Class<? extends Throwable> cls, @Nullable String msg) {
         assertThrows(log, new Callable() {
-            @Override
-            public Object call() throws Exception {
+            @Override public Object call() throws Exception {
                 return mgr.updateProperties(null, fileId, "file", props);
             }
         }, cls, msg);
@@ -440,25 +447,18 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
     /**
      * Test expected failures for 'move file' operation.
      *
-     * @param fileId File ID to rename.
-     * @param srcFileName Original file name in the parent's listing.
-     * @param srcParentId Source parent directory ID.
-     * @param destFileName New file name in the parent's listing after renaming.
-     * @param destParentId Destination parent directory ID.
      * @param msg Failure message if expected exception was not thrown.
      */
-    private void expectsRenameFail(final IgniteUuid fileId, final String srcFileName, final IgniteUuid srcParentId,
-        final String destFileName, final IgniteUuid destParentId, @Nullable String msg) {
+    private void expectsRenameFail(final String src, final String dst, @Nullable String msg) {
         Throwable err = assertThrowsInherited(log, new Callable() {
-            @Override
-            public Object call() throws Exception {
-                mgr.move(fileId, srcFileName, srcParentId, destFileName, destParentId);
+            @Override public Object call() throws Exception {
+                mgr.move(new IgfsPath(src), new IgfsPath(dst));
 
                 return null;
             }
-        }, IgniteCheckedException.class, msg);
+        }, IgfsException.class, msg);
 
-        assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgfsException);
+        assertTrue("Unexpected cause: " + err, err instanceof IgfsException);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b3bcf4ae/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 23f85d2..0216f4b 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
@@ -61,7 +61,6 @@ 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.HadoopSortingExternalTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopSortingTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapperSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopTaskExecutionSelfTest;
@@ -73,8 +72,6 @@ import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopCo
 import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopHashMapSelfTest;
 import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipListSelfTest;
 import org.apache.ignite.internal.processors.hadoop.shuffle.streams.HadoopDataStreamSelfTest;
-import org.apache.ignite.internal.processors.hadoop.taskexecutor.external.HadoopExternalTaskExecutionSelfTest;
-import org.apache.ignite.internal.processors.hadoop.taskexecutor.external.communication.HadoopExternalCommunicationSelfTest;
 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;
@@ -97,6 +94,14 @@ public class IgniteHadoopTestSuite extends TestSuite {
 
         TestSuite suite = new TestSuite("Ignite Hadoop MR Test Suite");
 
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfs20FileSystemLoopbackPrimarySelfTest.class.getName())));
+
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfsDualSyncSelfTest.class.getName())));
+        suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfsDualAsyncSelfTest.class.getName())));
+
+        suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsDualSyncTest.class.getName())));
+        suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsDualAsyncTest.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())));
@@ -115,11 +120,6 @@ public class IgniteHadoopTestSuite extends TestSuite {
 
         suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemHandshakeSelfTest.class.getName())));
 
-        suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfs20FileSystemLoopbackPrimarySelfTest.class.getName())));
-
-        suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfsDualSyncSelfTest.class.getName())));
-        suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfsDualAsyncSelfTest.class.getName())));
-
         suite.addTest(IgfsEventsTestSuite.suiteNoarchOnly());
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopFileSystemsTest.class.getName())));
@@ -163,9 +163,6 @@ public class IgniteHadoopTestSuite extends TestSuite {
         suite.addTest(new TestSuite(ldr.loadClass(HadoopCommandLineTest.class.getName())));
 
         suite.addTest(new TestSuite(ldr.loadClass(HadoopSecondaryFileSystemConfigurationTest.class.getName())));
-
-        suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsDualSyncTest.class.getName())));
-        suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsDualAsyncTest.class.getName())));
         return suite;
     }
 


[07/41] ignite git commit: Merge remote-tracking branch 'remotes/origin/ignite-1.4'

Posted by an...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-1.4'


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

Branch: refs/heads/ignite-1168
Commit: b56b15cda7fc94b25400b1334b365053f0017f7f
Parents: b3bcf4a 7db44f1
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 24 09:09:46 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 24 09:09:46 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteAtomicLong.java     |   2 +-
 .../apache/ignite/internal/IgniteKernal.java    |   4 +-
 .../cache/DynamicCacheDescriptor.java           |  10 +-
 .../GridCachePartitionExchangeManager.java      |   6 +
 .../processors/cache/GridCacheProcessor.java    |  18 +-
 .../processors/cache/IgniteCacheProxy.java      |   4 +-
 .../continuous/CacheContinuousQueryManager.java |  66 ++-
 .../continuous/GridContinuousProcessor.java     |   3 +-
 .../org/apache/ignite/mxbean/IgniteMXBean.java  |   8 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   7 +-
 .../discovery/DiscoverySpiCustomMessage.java    |  12 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 398 +++++++++++++------
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |   6 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   2 +-
 .../tcp/internal/TcpDiscoveryNodesRing.java     |  94 ++---
 .../messages/TcpDiscoveryDiscardMessage.java    |  15 +-
 .../TcpDiscoveryNodeAddFinishedMessage.java     |   2 +-
 .../messages/TcpDiscoveryNodeAddedMessage.java  |  19 +-
 .../GridCacheAbstractRemoveFailureTest.java     |   6 +-
 .../distributed/CacheAffEarlySelfTest.java      | 245 ------------
 .../distributed/CacheAffinityEarlyTest.java     | 168 ++++++++
 ...GridCacheValueConsistencyAtomicSelfTest.java |   2 +-
 ...ontinuousQueryReplicatedOneNodeSelfTest.java | 120 ++++++
 ...lientDiscoverySpiFailureTimeoutSelfTest.java |  33 +-
 .../tcp/TcpDiscoveryMultiThreadedTest.java      |  53 ++-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java | 315 ++++++++++++++-
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 .../IgniteCacheQuerySelfTestSuite.java          |   4 +-
 28 files changed, 1099 insertions(+), 525 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b56b15cd/modules/core/src/main/java/org/apache/ignite/IgniteAtomicLong.java
----------------------------------------------------------------------