You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ja...@apache.org on 2018/03/05 23:04:07 UTC

[geode] branch develop updated: GEODE-2667: Added logging and additional tests for GatewayReceiver destroy (#1528)

This is an automated email from the ASF dual-hosted git repository.

jasonhuynh pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9108bac  GEODE-2667: Added logging and additional tests for GatewayReceiver destroy (#1528)
9108bac is described below

commit 9108bac5bed60772c7a278ae52268f211583afa7
Author: Jason Huynh <hu...@gmail.com>
AuthorDate: Mon Mar 5 15:04:03 2018 -0800

    GEODE-2667: Added logging and additional tests for GatewayReceiver destroy (#1528)
---
 .../geode/internal/cache/GemFireCacheImpl.java     |  2 +-
 .../internal/cache/wan/GatewayReceiverImpl.java    |  1 +
 .../cache/wan/serial/GatewayReceiverDUnitTest.java | 79 ++++++++++++++++++++--
 3 files changed, 77 insertions(+), 5 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 6efb94c..491cff9 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -4590,7 +4590,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
 
     if (!otherMembers.isEmpty()) {
       if (logger.isDebugEnabled()) {
-        logger.debug("Sending add cache server profile message to other members.");
+        logger.debug("Sending remove cache server profile message to other members.");
       }
       ReplyProcessor21 replyProcessor = new ReplyProcessor21(this.dm, otherMembers);
       message.setRecipients(otherMembers);
diff --git a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverImpl.java b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverImpl.java
index caa4453..3e3c725 100644
--- a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverImpl.java
+++ b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverImpl.java
@@ -216,6 +216,7 @@ public class GatewayReceiverImpl implements GatewayReceiver {
   }
 
   public void destroy() {
+    logger.info("Destroying Gateway Receiver: " + this);
     if (receiver.isRunning()) {
       throw new GatewayReceiverException(
           "Gateway Receiver is running and needs to be stopped first");
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/serial/GatewayReceiverDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/serial/GatewayReceiverDUnitTest.java
index 006a2df..db97754 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/serial/GatewayReceiverDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/serial/GatewayReceiverDUnitTest.java
@@ -47,7 +47,7 @@ public class GatewayReceiverDUnitTest extends WANTestBase {
   @Test
   public void removingGatewayReceiverUsingReplicatedRegionShouldRemoveCacheServerFlagFromProfile()
       throws Exception {
-    testPrimarySecondaryQueueDrainInOrder_RR(
+    testRemoveGatewayReceiver(
         () -> WANTestBase.createReplicatedRegion(getTestMethodName(), null, isOffHeap()),
         () -> ((DistributedRegion) WANTestBase.cache.getRegion(getTestMethodName()))
             .getDistributionAdvisor());
@@ -56,14 +56,29 @@ public class GatewayReceiverDUnitTest extends WANTestBase {
   @Test
   public void removingGatewayReceiverUsingPartitionedRegionShouldRemoveCacheServerFlagFromProfile()
       throws Exception {
-    testPrimarySecondaryQueueDrainInOrder_RR(
+    testRemoveGatewayReceiver(
         () -> WANTestBase.createPartitionedRegion(getTestMethodName(), null, 1, 10, isOffHeap()),
         () -> ((PartitionedRegion) WANTestBase.cache.getRegion(getTestMethodName()))
             .getDistributionAdvisor());
   }
 
-  public <T> void testPrimarySecondaryQueueDrainInOrder_RR(
-      SerializableRunnableIF createRegionLambda,
+  @Test
+  public void canAddReceiverAfterRemovingFromReplicatedRegion() throws Exception {
+    testCanAddGatewayReceiverAfterOneHasBeenRemoved(
+        () -> WANTestBase.createReplicatedRegion(getTestMethodName(), null, isOffHeap()),
+        () -> ((DistributedRegion) WANTestBase.cache.getRegion(getTestMethodName()))
+            .getDistributionAdvisor());
+  }
+
+  @Test
+  public void canAddReceiverAfterRemovingFromPartitionedRegion() throws Exception {
+    testCanAddGatewayReceiverAfterOneHasBeenRemoved(
+        () -> WANTestBase.createPartitionedRegion(getTestMethodName(), null, 1, 10, isOffHeap()),
+        () -> ((PartitionedRegion) WANTestBase.cache.getRegion(getTestMethodName()))
+            .getDistributionAdvisor());
+  }
+
+  public <T> void testRemoveGatewayReceiver(SerializableRunnableIF createRegionLambda,
       SerializableCallableIF<DistributionAdvisor> extractAdvisorLambda) throws Exception {
     InternalDistributedMember[] memberIds = new InternalDistributedMember[8];
 
@@ -114,6 +129,62 @@ public class GatewayReceiverDUnitTest extends WANTestBase {
     vm3.invoke(() -> assertProfileCacheServerFlagEquals(memberIds[2], false, extractAdvisorLambda));
   }
 
+  public <T> void testCanAddGatewayReceiverAfterOneHasBeenRemoved(
+      SerializableRunnableIF createRegionLambda,
+      SerializableCallableIF<DistributionAdvisor> extractAdvisorLambda) throws Exception {
+    InternalDistributedMember[] memberIds = new InternalDistributedMember[8];
+
+    Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
+    Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
+
+    vm2.invoke(() -> WANTestBase.createCache(nyPort));
+    vm3.invoke(() -> WANTestBase.createCache(nyPort));
+
+    memberIds[2] = (InternalDistributedMember) vm2
+        .invoke(() -> WANTestBase.cache.getDistributedSystem().getDistributedMember());
+
+    memberIds[3] = (InternalDistributedMember) vm3
+        .invoke(() -> WANTestBase.cache.getDistributedSystem().getDistributedMember());
+
+    vm2.invoke(createRegionLambda);
+    vm3.invoke(createRegionLambda);
+
+    vm2.invoke(() -> WANTestBase.doPuts(getTestMethodName(), 100));
+
+    vm2.invoke(() -> {
+      GatewayReceiverDUnitTest.receiver = GatewayReceiverDUnitTest.createAndReturnReceiver();
+      return;
+    });
+    vm3.invoke(() -> {
+      GatewayReceiverDUnitTest.receiver = GatewayReceiverDUnitTest.createAndReturnReceiver();
+      return;
+    });
+
+    vm2.invoke(() -> {
+      GatewayReceiverDUnitTest.receiver.stop();
+      GatewayReceiverDUnitTest.receiver.destroy();
+    });
+
+    vm3.invoke(() -> {
+      GatewayReceiverDUnitTest.receiver.stop();
+      GatewayReceiverDUnitTest.receiver.destroy();
+    });
+
+    vm2.invoke(() -> {
+      GatewayReceiverDUnitTest.receiver = GatewayReceiverDUnitTest.createAndReturnReceiver();
+      return;
+    });
+    vm3.invoke(() -> {
+      GatewayReceiverDUnitTest.receiver = GatewayReceiverDUnitTest.createAndReturnReceiver();
+      return;
+    });
+
+    vm2.invoke(() -> assertProfileCacheServerFlagEquals(memberIds[3], true, extractAdvisorLambda));
+    vm3.invoke(() -> assertProfileCacheServerFlagEquals(memberIds[2], true, extractAdvisorLambda));
+
+  }
+
+
 
   private void assertProfileCacheServerFlagEquals(InternalDistributedMember member,
       boolean expectedFlag, SerializableCallableIF<DistributionAdvisor> extractAdvisor)

-- 
To stop receiving notification emails like this one, please contact
jasonhuynh@apache.org.