You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/10/06 19:30:40 UTC

[GitHub] [geode] Bill commented on a change in pull request #5598: GEODE-8579: Stop waiting locator-wait-time if all locators are available

Bill commented on a change in pull request #5598:
URL: https://github.com/apache/geode/pull/5598#discussion_r500523949



##########
File path: geode-membership/src/main/java/org/apache/geode/internal/AvailablePort.java
##########
@@ -32,7 +32,7 @@
 import java.util.Random;
 
 import org.apache.geode.annotations.Immutable;
-import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.membership.api.MembershipConfig;

Review comment:
       better (narrower) dependency!

##########
File path: geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/shell/StatusLocatorExitCodeAcceptanceTest.java
##########
@@ -57,7 +56,7 @@
   @BeforeClass
   public static void startLocator() throws IOException {
     rootPath = gfshRule.getTemporaryFolder().getRoot().toPath();
-    locatorPort = getRandomAvailablePort(SOCKET);
+    locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();

Review comment:
       better!

##########
File path: geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/MembershipIntegrationTest.java
##########
@@ -272,6 +276,65 @@ public void secondMembershipPausesForLocatorWaitTime()
     stop(coordinatorLocator, lateJoiningLocator);
   }
 
+  @Test
+  public void locatorsStopWaitingForLocatorWaitTimeIfAllLocatorsContacted()
+      throws IOException, MemberStartupException, InterruptedException, TimeoutException,
+      ExecutionException {
+
+    final Supplier<ExecutorService> executorServiceSupplier =
+        () -> LoggingExecutors.newCachedThreadPool("membership", false);
+
+    int[] locatorPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+
+    int locatorWaitTime = (int) Duration.ofMinutes(5).getSeconds();
+    final MembershipConfig config =
+        createMembershipConfig(true, locatorWaitTime, locatorPorts[0], locatorPorts[1]);
+
+    CompletableFuture<Membership<MemberIdentifier>> createMembership0 =
+        launchLocator(executorServiceSupplier, locatorPorts[0], config);
+
+    // Assert that membership 0 is waiting for the other locator to start
+    Thread.sleep(5000);
+    assertThat(createMembership0.getNow(null)).isNull();
+
+    CompletableFuture<Membership<MemberIdentifier>> createMembership1 =
+        launchLocator(executorServiceSupplier, locatorPorts[1], config);
+
+    // Make sure the members are created in less than the locator-wait-time
+    Membership<MemberIdentifier> membership0 = createMembership0.get(2, TimeUnit.MINUTES);
+    Membership<MemberIdentifier> membership1 = createMembership1.get(2, TimeUnit.MINUTES);
+
+    // Make sure the members see each other in the view
+    assertThat(membership0.getView().getMembers()).hasSize(2);
+    assertThat(membership1.getView().getMembers()).hasSize(2);
+  }

Review comment:
       This is a good test and it's acceptable as-is. I wonder though, if you'd be willing to entertain reducing run-time and increasing determinism by by injecting the (millisecond) time keeper and sleeper into the locator, the way it's done for `PrimaryHandler`?
   
   Here is the PR from August that added that injection: https://github.com/apache/geode/pull/5422
   
   As of that PR (and now on `develop`) there are a couple functional interfaces defined in `PrimaryHander` that could be hoisted a little higher and used in `MembershipLocator` for your purposes, i.e. `Sleeper`, `MillisecondProvider`.
   
   With those injected, this test could control time similar to how `PrimaryHandlerTest` does.

##########
File path: geode-membership/src/main/java/org/apache/geode/internal/AvailablePort.java
##########
@@ -547,12 +548,7 @@ public static void main(String[] args) {
 
     InetAddress addr = null;
     if (addrString != null) {
-      try {
-        addr = InetAddress.getByName(addrString);
-      } catch (Exception e) {
-        e.printStackTrace();
-        ExitCode.FATAL.doSystemExit();
-      }
+      addr = InetAddress.getByName(addrString);

Review comment:
       verified when address cannot be resolved the exception causes exit code 1 (on macos) ✓




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org