ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-1758
Date Mon, 26 Oct 2015 08:28:12 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1758 40c6d35eb -> f2dec6d86


ignite-1758


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

Branch: refs/heads/ignite-1758
Commit: f2dec6d861a23aeebe690c1ee8c5e4f741aa0256
Parents: 40c6d35
Author: sboikov <sboikov@gridgain.com>
Authored: Mon Oct 26 11:27:57 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Mon Oct 26 11:27:57 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    | 77 ++++++++++++--------
 .../IgniteClientReconnectCacheTest.java         | 33 +++++++++
 ...gniteClientReconnectMassiveShutdownTest.java |  3 +
 3 files changed, 84 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f2dec6d8/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 722e570..f63b149 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
@@ -1829,61 +1829,80 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
     /** {@inheritDoc} */
     @Nullable @Override public Serializable collectDiscoveryData(UUID nodeId) {
+        boolean reconnect = ctx.localNodeId().equals(nodeId) && cachesOnDisconnect
!= null;
+
         // Collect dynamically started caches to a single object.
-        Collection<DynamicCacheChangeRequest> reqs =
-            new ArrayList<>(registeredCaches.size() + registeredTemplates.size());
+        Collection<DynamicCacheChangeRequest> reqs;
 
-        boolean reconnect = ctx.localNodeId().equals(nodeId) && cachesOnDisconnect
!= null;
+        Map<String, Map<UUID, Boolean>> clientNodesMap;
 
-        Map<String, DynamicCacheDescriptor> descs = reconnect ? cachesOnDisconnect
: registeredCaches;
+        if (reconnect) {
+            reqs = new ArrayList<>(caches.size());
 
-        for (DynamicCacheDescriptor desc : descs.values()) {
-            DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(),
null);
+            clientNodesMap = U.newHashMap(caches.size());
 
-            req.startCacheConfiguration(desc.cacheConfiguration());
+            for (GridCacheAdapter<?, ?> cache : caches.values()) {
+                DynamicCacheDescriptor desc = cachesOnDisconnect.get(maskNull(cache.name()));
 
-            req.cacheType(desc.cacheType());
+                if (desc == null)
+                    continue;
 
-            req.deploymentId(desc.deploymentId());
+                DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(cache.name(),
null);
 
-            reqs.add(req);
-        }
+                req.startCacheConfiguration(desc.cacheConfiguration());
 
-        for (DynamicCacheDescriptor desc : registeredTemplates.values()) {
-            DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(),
null);
+                req.cacheType(desc.cacheType());
 
-            req.startCacheConfiguration(desc.cacheConfiguration());
+                req.deploymentId(desc.deploymentId());
 
-            req.template(true);
+                reqs.add(req);
 
-            req.deploymentId(desc.deploymentId());
+                Boolean nearEnabled = cache.isNear();
+
+                Map<UUID, Boolean> map = U.newHashMap(1);
+
+                map.put(nodeId, nearEnabled);
 
-            reqs.add(req);
+                clientNodesMap.put(cache.name(), map);
+            }
         }
+        else {
+            reqs = new ArrayList<>(registeredCaches.size() + registeredTemplates.size());
 
-        DynamicCacheChangeBatch req = new DynamicCacheChangeBatch(reqs);
+            for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+                DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(),
null);
 
-        Map<String, Map<UUID, Boolean>> clientNodesMap = ctx.discovery().clientNodesMap();
+                req.startCacheConfiguration(desc.cacheConfiguration());
 
-        if (reconnect) {
-            clientNodesMap = U.newHashMap(caches.size());
+                req.cacheType(desc.cacheType());
 
-            for (GridCacheAdapter<?, ?> cache : caches.values()) {
-                Boolean nearEnabled = cache.isNear();
+                req.deploymentId(desc.deploymentId());
 
-                Map<UUID, Boolean> map = U.newHashMap(1);
+                reqs.add(req);
+            }
 
-                map.put(nodeId, nearEnabled);
+            for (DynamicCacheDescriptor desc : registeredTemplates.values()) {
+                DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(),
null);
 
-                clientNodesMap.put(cache.name(), map);
+                req.startCacheConfiguration(desc.cacheConfiguration());
+
+                req.template(true);
+
+                req.deploymentId(desc.deploymentId());
+
+                reqs.add(req);
             }
+
+            clientNodesMap = ctx.discovery().clientNodesMap();
         }
 
-        req.clientNodes(clientNodesMap);
+        DynamicCacheChangeBatch batch = new DynamicCacheChangeBatch(reqs);
+
+        batch.clientNodes(clientNodesMap);
 
-        req.clientReconnect(reconnect);
+        batch.clientReconnect(reconnect);
 
-        return req;
+        return batch;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2dec6d8/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
index edd95e9..6131f54 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
@@ -1128,6 +1128,39 @@ public class IgniteClientReconnectCacheTest extends IgniteClientReconnectAbstrac
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testReconnectDestroyCache() throws Exception {
+        clientMode = true;
+
+        Ignite client = startGrid(SRV_CNT);
+
+        CacheConfiguration<Integer, Integer> ccfg1 = new CacheConfiguration<>();
+        ccfg1.setName("cache1");
+
+        CacheConfiguration<Integer, Integer> ccfg2 = new CacheConfiguration<>();
+        ccfg2.setName("cache2");
+
+        final Ignite srv = grid(0);
+
+        srv.createCache(ccfg1);
+        srv.createCache(ccfg2).put(1, 1);
+
+        IgniteCache<Integer, Integer> cache = client.cache("cache2");
+
+        reconnectClientNode(client, srv, new Runnable() {
+            @Override public void run() {
+                srv.destroyCache("cache1");
+            }
+        });
+
+        cache.put(2, 2);
+
+        assertEquals(1, (Object)cache.get(1));
+        assertEquals(2, (Object)cache.get(2));
+    }
+
+    /**
      * @param client Client.
      * @param disconnectLatch Disconnect event latch.
      * @param reconnectLatch Reconnect event latch.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2dec6d8/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectMassiveShutdownTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectMassiveShutdownTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectMassiveShutdownTest.java
index 5ae5a48..ccb1114 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectMassiveShutdownTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectMassiveShutdownTest.java
@@ -34,6 +34,7 @@ import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.util.typedef.X;
+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;
@@ -77,6 +78,8 @@ public class IgniteClientReconnectMassiveShutdownTest extends GridCommonAbstract
 
         cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
 
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
         return cfg;
     }
 


Mime
View raw message