geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [11/16] geode git commit: GEODE-2179 - Checking for disconnected connection in GatewaySenderMBean
Date Thu, 08 Dec 2016 17:12:24 GMT
GEODE-2179 - Checking for disconnected connection in GatewaySenderMBean

Making sure that the mbean returns false for isConnected if the gateway
is not actually connected to the remote side.


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

Branch: refs/heads/feature/GEODE-1027
Commit: 0494b31caf6f43cec85660fd8d939f2b1c6739c2
Parents: 1d34eeb
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Fri Dec 2 15:47:13 2016 -0800
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed Dec 7 15:14:28 2016 -0800

----------------------------------------------------------------------
 .../wan/GatewaySenderEventRemoteDispatcher.java |  2 +-
 .../management/WANManagementDUnitTest.java      | 40 +++++++++++---------
 2 files changed, 24 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0494b31c/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
index 16b1965..8da5613 100644
--- a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
+++ b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
@@ -802,7 +802,7 @@ public class GatewaySenderEventRemoteDispatcher implements GatewaySenderEventDis
 
   @Override
   public boolean isConnectedToRemote() {
-    return connection != null;
+    return connection != null && !connection.isDestroyed();
   }
 
   public void stop() {

http://git-wip-us.apache.org/repos/asf/geode/blob/0494b31c/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
index 9a6cc10..3cc37eb 100644
--- a/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/management/WANManagementDUnitTest.java
@@ -19,12 +19,14 @@ import org.junit.Test;
 
 import static org.junit.Assert.*;
 
+import com.jayway.awaitility.Awaitility;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
@@ -60,7 +62,17 @@ public class WANManagementDUnitTest extends ManagementTestBase {
   }
 
   @Test
-  public void testMBeanCallback() throws Exception {
+  public void testMBeanCallbackSerial() throws Exception {
+    testMBeanCallback(false);
+  }
+
+  @Test
+  public void testMBeanCallbackParallel() throws Exception {
+    testMBeanCallback(true);
+
+  }
+
+  public void testMBeanCallback(boolean parallel) throws Exception {
 
     VM nyLocator = getManagedNodeList().get(0);
     VM nyReceiver = getManagedNodeList().get(1);
@@ -103,10 +115,8 @@ public class WANManagementDUnitTest extends ManagementTestBase {
     puneSender.invoke(() -> WANTestBase.waitForSenderRunningState("pn"));
     managing.invoke(() -> WANTestBase.waitForSenderRunningState("pn"));
 
-
-
-    checkSenderMBean(puneSender, getTestMethodName() + "_PR");
-    checkSenderMBean(managing, getTestMethodName() + "_PR");
+    checkSenderMBean(puneSender, getTestMethodName() + "_PR", true);
+    checkSenderMBean(managing, getTestMethodName() + "_PR", true);
 
     checkReceiverMBean(nyReceiver);
 
@@ -119,6 +129,10 @@ public class WANManagementDUnitTest extends ManagementTestBase {
     checkProxySender(managing, puneMember);
     checkSenderNavigationAPIS(managing, puneMember);
 
+    nyReceiver.invoke(() -> WANTestBase.stopReceivers());
+
+    checkSenderMBean(puneSender, getTestMethodName() + "_PR", false);
+    checkSenderMBean(managing, getTestMethodName() + "_PR", false);
   }
 
   @Category(FlakyTest.class) // GEODE-1603
@@ -159,8 +173,7 @@ public class WANManagementDUnitTest extends ManagementTestBase {
     managing.invoke(() -> WANTestBase.createManagementCache(nyPort));
     startManagingNode(managing);
 
-
-    checkSenderMBean(puneSender, getTestMethodName() + "_PR");
+    checkSenderMBean(puneSender, getTestMethodName() + "_PR", true);
     checkReceiverMBean(nyReceiver);
 
     DistributedMember nyMember =
@@ -168,8 +181,6 @@ public class WANManagementDUnitTest extends ManagementTestBase {
 
     checkProxyReceiver(managing, nyMember);
     checkReceiverNavigationAPIS(managing, nyMember);
-
-
   }
 
 
@@ -187,19 +198,15 @@ public class WANManagementDUnitTest extends ManagementTestBase {
     Integer nyPort =
         (Integer) nyLocator.invoke(() -> WANTestBase.createFirstRemoteLocator(12, punePort));
 
-
-
     puneSender.invoke(() -> WANTestBase.createCache(punePort));
     managing.invoke(() -> WANTestBase.createManagementCache(punePort));
     startManagingNode(managing);
 
-
     puneSender.invoke(() -> WANTestBase.createAsyncEventQueue("pn", false, 100, 100, false,
false,
         "puneSender", false));
     managing.invoke(() -> WANTestBase.createAsyncEventQueue("pn", false, 100, 100, false,
false,
         "managing", false));
 
-
     puneSender.invoke(() -> WANTestBase
         .createReplicatedRegionWithAsyncEventQueue(getTestMethodName() + "_RR", "pn", false));
     managing.invoke(() -> WANTestBase
@@ -213,7 +220,6 @@ public class WANManagementDUnitTest extends ManagementTestBase {
     checkAsyncQueueMBean(puneSender);
     checkAsyncQueueMBean(managing);
 
-
     DistributedMember puneMember =
         (DistributedMember) puneSender.invoke(() -> WANManagementDUnitTest.getMember());
 
@@ -392,7 +398,6 @@ public class WANManagementDUnitTest extends ManagementTestBase {
   }
 
 
-
   /**
    * Checks whether a GatewayReceiverMBean is created or not
    * 
@@ -417,7 +422,7 @@ public class WANManagementDUnitTest extends ManagementTestBase {
    * @param vm reference to VM
    */
   @SuppressWarnings("serial")
-  protected void checkSenderMBean(final VM vm, final String regionPath) {
+  protected void checkSenderMBean(final VM vm, final String regionPath, boolean connected)
{
     SerializableRunnable checkMBean = new SerializableRunnable("Check Sender MBean") {
       public void run() {
         Cache cache = GemFireCacheImpl.getInstance();
@@ -425,7 +430,8 @@ public class WANManagementDUnitTest extends ManagementTestBase {
 
         GatewaySenderMXBean bean = service.getLocalGatewaySenderMXBean("pn");
         assertNotNull(bean);
-        assertTrue(bean.isConnected());
+        Awaitility.await().atMost(1, TimeUnit.MINUTES)
+            .until(() -> assertEquals(connected, bean.isConnected()));
 
         ObjectName regionBeanName = service.getRegionMBeanName(
             cache.getDistributedSystem().getDistributedMember(), "/" + regionPath);


Mime
View raw message