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 00:09:13 UTC

[geode] branch feature/GEODE-6292 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 feature/GEODE-6292
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-6292 by this push:
     new fc574df  GEODE-6292 hot loop in GMSJoinLeave.findCoordinator
fc574df is described below

commit fc574dffefad90848b2c2e6f924241596316a0da
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Thu Jan 17 16:07:11 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.
---
 .../gms/membership/GMSJoinLeaveJUnitTest.java       | 21 +++++++++++++++++++++
 .../membership/gms/membership/GMSJoinLeave.java     |  9 ++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

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..ad999c7 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
@@ -14,7 +14,9 @@
  */
 package org.apache.geode.distributed.internal.membership.gms.membership;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
+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,24 @@ 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");
+  }
+
+  @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 39c03cb..f2066cf 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,14 @@ 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) {
+              throw new SystemConnectException("Interrupted while trying to contact locators");
+            }
+          }
         }
       }
     } while (!anyResponses && System.currentTimeMillis() < giveUpTime);