ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: Ignite-929
Date Thu, 28 May 2015 12:05:38 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-929 50b219849 -> 46c852825


Ignite-929


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

Branch: refs/heads/ignite-929
Commit: 46c852825b6740e497676adf6c585877a68e75e9
Parents: 50b2198
Author: avinogradov <avinogradov@gridgain.com>
Authored: Thu May 28 15:05:29 2015 +0300
Committer: avinogradov <avinogradov@gridgain.com>
Committed: Thu May 28 15:05:29 2015 +0300

----------------------------------------------------------------------
 .../cache/CacheStopAndDestroySelfTest.java      | 49 ++++++++++++++++++++
 1 file changed, 49 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/46c85282/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
index e86bd99..0a4bb55 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
@@ -18,9 +18,20 @@
 package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.managers.communication.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.plugin.extensions.communication.*;
+import org.apache.ignite.spi.*;
+import org.apache.ignite.spi.communication.tcp.*;
+import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 
+import java.util.*;
+import java.util.concurrent.atomic.*;
+
 /**
  * Checks stop and destroy methods behavior.
  */
@@ -68,10 +79,39 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
 
         iCfg.setCacheConfiguration();
 
+        TcpCommunicationSpi commSpi = new CountingTxRequestsToClientNodeTcpCommunicationSpi();
+
+        commSpi.setLocalPort(GridTestUtils.getNextCommPort(getClass()));
+        commSpi.setTcpNoDelay(true);
+
+        iCfg.setCommunicationSpi(commSpi);
+
         return iCfg;
     }
 
     /**
+     * Helps to count messages.
+     */
+    public static class CountingTxRequestsToClientNodeTcpCommunicationSpi extends TcpCommunicationSpi
{
+        /** Counter. */
+        public static AtomicInteger cnt = new AtomicInteger();
+
+        /** Node filter. */
+        public static UUID nodeFilter;
+
+        /** {@inheritDoc} */
+        @Override public void sendMessage(ClusterNode node, Message msg) throws IgniteSpiException
{
+            super.sendMessage(node, msg);
+
+            if (nodeFilter != null &&
+                node.id().equals(nodeFilter) &&
+                msg instanceof GridIoMessage &&
+                ((GridIoMessage)msg).message() instanceof GridDhtTxPrepareRequest)
+                cnt.incrementAndGet();
+        }
+    }
+
+    /**
      * Test.
      *
      * @throws Exception If failed.
@@ -79,6 +119,9 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
     public void testCacheStopAndDestroy() throws Exception {
         startGridsMultiThreaded(gridCount());
 
+        //GridDhtTxPrepareRequest requests to Client node will be counted.
+        CountingTxRequestsToClientNodeTcpCommunicationSpi.nodeFilter = grid(2).context().localNodeId();
+
         CacheConfiguration cCfgD = defaultCacheConfiguration();
         cCfgD.setName(CACHE_NAME_DESTROY_DHT);
         cCfgD.setCacheMode(CacheMode.PARTITIONED);
@@ -302,9 +345,15 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
 
         grid(2).cache(CACHE_NAME_CLOSE_NEAR).close();
 
+        CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.set(0);
+
         //Should not produce messages to client node.
         grid(0).cache(CACHE_NAME_CLOSE_NEAR).put(KEY_VAL, KEY_VAL + 0);
 
+        U.sleep(1000);
+
+        assert CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.get() == 0;
+
         assert grid(0).cache(CACHE_NAME_CLOSE_NEAR).get(KEY_VAL).equals(KEY_VAL + 0);// Not
affected.
         assert grid(1).cache(CACHE_NAME_CLOSE_NEAR).get(KEY_VAL).equals(KEY_VAL + 0);// Not
affected.
 


Mime
View raw message