You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2019/01/18 22:50:05 UTC

[geode] branch develop updated: GEODE-6292 hot loop in GMSJoinLeave.findCoordinator

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

bschuchardt 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 e52f6f6  GEODE-6292 hot loop in GMSJoinLeave.findCoordinator
e52f6f6 is described below

commit e52f6f66fb64ec40553b14e6f312fff2fcc7bbe8
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Fri Jan 18 14:49:17 2019 -0800

    GEODE-6292 hot loop in GMSJoinLeave.findCoordinator
    
    Added a 1 second pause before retrying if no locators could
    be contacted and locator-wait-time has been set.
---
 .../apache/geode/distributed/LocatorDUnitTest.java |  1 -
 .../gms/membership/GMSJoinLeaveJUnitTest.java      | 26 ++++++++++++++++++++++
 .../membership/gms/membership/GMSJoinLeave.java    | 11 ++++++++-
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java
index 4be3d8b..8ea0ad4 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java
@@ -1678,7 +1678,6 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
     final Properties properties =
         getBasicProperties(Host.getHost(0).getHostName() + "[" + port1 + "]");
     properties.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
-    properties.setProperty(LOG_LEVEL, "finest");
     addDSProps(properties);
     if (stateFile.exists()) {
       assertThat(stateFile.delete()).isTrue();
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
index a35cc6d..e57b34d 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -15,6 +15,8 @@
 package org.apache.geode.distributed.internal.membership.gms.membership;
 
 import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -49,6 +51,7 @@ import org.junit.experimental.categories.Category;
 import org.mockito.internal.verification.Times;
 import org.mockito.verification.Timeout;
 
+import org.apache.geode.SystemConnectException;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.ClusterDistributionManager;
 import org.apache.geode.distributed.internal.DistributionConfig;
@@ -189,6 +192,29 @@ public class GMSJoinLeaveJUnitTest {
   }
 
   @Test
+  public void testFindCoordinatorPausesWhenLocatorWaitTimeIsSet() throws Exception {
+    initMocks(false);
+    when(mockConfig.getLocatorWaitTime()).thenReturn(15000);
+
+    TcpClientWrapper tcpClientWrapper = mock(TcpClientWrapper.class);
+    gmsJoinLeave.setTcpClientWrapper(tcpClientWrapper);
+
+    when(tcpClientWrapper.sendCoordinatorFindRequest(isA(InetSocketAddress.class),
+        isA(FindCoordinatorRequest.class), isA(Integer.class)))
+            .thenThrow(new IOException("Connection refused"));
+
+    // interrupt this thread so that findCoordinator() won't keep looping
+    // and will throw an exception when going to pause
+    Thread.currentThread().interrupt();
+    assertThatThrownBy(() -> gmsJoinLeave.findCoordinator())
+        .isInstanceOf(SystemConnectException.class)
+        .hasMessageContaining("Interrupted while trying to contact locators");
+    assertThat(Thread.currentThread().interrupted()).isTrue();
+    verify(tcpClientWrapper, times(1)).sendCoordinatorFindRequest(any(InetSocketAddress.class),
+        any(FindCoordinatorRequest.class), any(Integer.class));
+  }
+
+  @Test
   public void testFindCoordinatorInView() throws Exception {
     initMocks();
 
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index afc1d28..f088efb 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -1152,7 +1152,16 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
             }
           }
         } catch (IOException | ClassNotFoundException problem) {
-          logger.debug("EOFException IOException ", problem);
+          logger.debug("Exception thrown when contacting a locator", problem);
+          if (state.locatorsContacted == 0 && System.currentTimeMillis() < giveUpTime) {
+            try {
+              Thread.sleep(1000);
+            } catch (InterruptedException e) {
+              Thread.currentThread().interrupt();
+              services.getCancelCriterion().checkCancelInProgress(e);
+              throw new SystemConnectException("Interrupted while trying to contact locators");
+            }
+          }
         }
       }
     } while (!anyResponses && System.currentTimeMillis() < giveUpTime);