geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [08/50] [abbrv] incubator-geode git commit: GEODE-1150 Find Coodinator response was not notifying waiting thread
Date Thu, 28 Apr 2016 23:09:47 GMT
GEODE-1150 Find Coodinator response was not notifying waiting thread

1. Now find Coordinator response notifies waiting thread.
2. joinrequest sees join response if member is no more coordinator
3. Test issue - now we wait for coordinator to change before verifying it


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

Branch: refs/heads/feature/GEODE-1255
Commit: b6be5d473df2c79a8527f688c6ee875337b96409
Parents: 70c5467
Author: Hitesh Khamesra <hkhamesra@pivotal.io>
Authored: Mon Apr 18 09:41:41 2016 -0700
Committer: Hitesh Khamesra <hkhamesra@pivotal.io>
Committed: Fri Apr 22 10:38:08 2016 -0700

----------------------------------------------------------------------
 .../membership/gms/membership/GMSJoinLeave.java | 62 +++++++++++++++++++-
 .../gemfire/distributed/LocatorDUnitTest.java   | 32 ++++++----
 .../gms/membership/GMSJoinLeaveTestHelper.java  |  5 ++
 3 files changed, 85 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6be5d47/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index d91b247..8b54838 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -414,6 +414,29 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         joinResponse.wait(timeout);
       }
       response = joinResponse[0];
+      
+      if (response != null && response.getCurrentView() != null && !isJoined)
{
+        //reset joinResponse[0]
+        joinResponse[0] = null;
+        // we got view here that means either we have to wait for
+        NetView v = response.getCurrentView();
+        InternalDistributedMember coord = v.getCoordinator();
+        if (searchState.alreadyTried.contains(coord)) {
+          // we already sent join request to it..so lets wait some more time here
+          // assuming we got this response immediately, so wait for same timeout here..
+          long timeout = Math.max(services.getConfig().getMemberTimeout(), services.getConfig().getJoinTimeout()
/ 5);
+          joinResponse.wait(timeout);
+          response = joinResponse[0];
+        } else {
+          // try on this coordinator
+          searchState.possibleCoordinator = coord;
+          response = null;
+        }
+        searchState.view = v;
+      }
+      if (isJoined) {
+        return null;
+      }
     }
     return response;
   }
@@ -620,6 +643,9 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
       viewRequests.add(request);
       viewRequests.notifyAll();
     }
+    if (viewCreator != null) {
+      viewCreator.informToPendingJoinRequests();
+    }
   }
 
   // for testing purposes, returns a copy of the view requests for verification
@@ -1174,6 +1200,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   private void processFindCoordinatorResponse(FindCoordinatorResponse resp) {
     synchronized (searchState.responses) {
       searchState.responses.add(resp);
+      searchState.responses.notifyAll();
     }
   }
 
@@ -1771,7 +1798,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   }
 
   class ViewCreator extends Thread {
-    boolean shutdown = false;
+    volatile boolean shutdown = false;
     volatile boolean waiting = false;
     volatile boolean testFlagForRemovalRequest = false;
 
@@ -1960,6 +1987,39 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         }
       } finally {
         shutdown = true;
+        informToPendingJoinRequests();
+      }
+    }
+    
+    synchronized void informToPendingJoinRequests() {
+      if (!shutdown) {
+        return;
+      }
+
+      ArrayList<DistributionMessage> requests = new ArrayList<>();
+      synchronized (viewRequests) {
+        if (viewRequests.size() > 0) {
+          requests.addAll(viewRequests);
+        } else {
+          return;
+        }
+        viewRequests.clear();
+      }
+
+      for (DistributionMessage msg : requests) {
+        switch (msg.getDSFID()) {
+        case JOIN_REQUEST:
+          logger.info("Informing to pending join requests {}", msg);
+
+          NetView v = currentView;
+          if (!v.getCoordinator().equals(localAddress)) {
+            //lets inform that coordinator has been changed
+            JoinResponseMessage jrm = new JoinResponseMessage(((JoinRequestMessage) msg).getMemberID(),
v);
+            services.getMessenger().send(jrm);
+          }
+        default:
+          break;
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6be5d47/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
index 71eb68e..702a859 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
@@ -1412,7 +1412,6 @@ public class LocatorDUnitTest extends DistributedTestCase {
       }
     };
   }
-
   /**
    * Tests starting multiple locators at the same time and ensuring that the locators
    * end up only have 1 master.
@@ -1516,9 +1515,11 @@ public class LocatorDUnitTest extends DistributedTestCase {
             host0 + "[" + port3 + "]";
         dsProps.setProperty("locators", newLocators);
 
-        assertTrue(vm3.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
+        assertTrue(vm3.invoke("Checking ViewCreator thread on Lead Server", () -> GMSJoinLeaveTestHelper.isViewCreator()));
         //Given the start up order of servers, this server is the elder server
-        assertTrue(vm3.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
+        assertTrue(vm3.invoke("Checking ViewCreator thread on Lead Server", () -> GMSJoinLeaveTestHelper.isViewCreator()));
+        
+        final InternalDistributedMember currentCoordinator = GMSJoinLeaveTestHelper.getCurrentCoordinator();
 
         startLocatorAsync(vm1, new Object[] { port2, dsProps });
         startLocatorAsync(vm2, new Object[] { port3, dsProps });
@@ -1526,6 +1527,11 @@ public class LocatorDUnitTest extends DistributedTestCase {
         waitCriterion = new WaitCriterion() {
           public boolean done() {
             try {
+              InternalDistributedMember c = GMSJoinLeaveTestHelper.getCurrentCoordinator();
+              if (c.equals(currentCoordinator)) {
+                //now locator should be new coordinator
+                return false;
+              }
               return system.getDM().getAllHostedLocators().size() == 2;
             } catch (Exception e) {
               e.printStackTrace();
@@ -1540,17 +1546,17 @@ public class LocatorDUnitTest extends DistributedTestCase {
         };
         Wait.waitForCriterion(waitCriterion, 15 * 1000, 200, true);
 
-        int netviewId = vm1.invoke(() -> GMSJoinLeaveTestHelper.getViewId());
-        assertEquals(netviewId, (int) vm2.invoke(() -> GMSJoinLeaveTestHelper.getViewId()));
-        assertEquals(netviewId, (int) vm3.invoke(() -> GMSJoinLeaveTestHelper.getViewId()));
-        assertEquals(netviewId, (int) vm4.invoke(() -> GMSJoinLeaveTestHelper.getViewId()));
-        assertFalse(vm4.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
+        int netviewId = vm1.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.getViewId());
+        assertEquals(netviewId, (int) vm2.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
+        assertEquals(netviewId, (int) vm3.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
+        assertEquals(netviewId, (int) vm4.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
+        assertFalse(vm4.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
         //Given the start up order of servers, this server is the elder server
-        assertFalse(vm3.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
+        assertFalse(vm3.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
         if (vm1.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator())) {
-          assertFalse(vm2.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
+          assertFalse(vm2.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
         } else {
-          assertTrue(vm2.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
+          assertTrue(vm2.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
         }
 
       } finally {
@@ -1565,7 +1571,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
   }
 
   private void startLocatorSync(VM vm, Object[] args) {
-    vm.invoke(new SerializableRunnable("Starting process on " + args[0], args) {
+    vm.invoke(new SerializableRunnable("Starting locator process on " + args[0], args) {
       public void run() {
         File logFile = new File("");
         try {
@@ -1578,7 +1584,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
   }
 
   private void startLocatorAsync(VM vm, Object[] args) {
-    vm.invokeAsync(new SerializableRunnable("Starting process on " + args[0], args) {
+    vm.invokeAsync(new SerializableRunnable("Starting Locator process async on " + args[0],
args) {
       public void run() {
         File logFile = new File("");
         try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6be5d47/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
index 17409a4..bf13420 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
@@ -19,6 +19,7 @@ package com.gemstone.gemfire.distributed.internal.membership.gms.membership;
 import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.distributed.internal.DM;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
 import com.gemstone.gemfire.distributed.internal.membership.gms.mgr.GMSMembershipManager;
 import com.gemstone.gemfire.test.dunit.Wait;
@@ -70,6 +71,10 @@ public class GMSJoinLeaveTestHelper {
     Services services = membershipManager.getServices();
     return (GMSJoinLeave) services.getJoinLeave();
   }
+  
+  public static InternalDistributedMember getCurrentCoordinator() {
+    return getGmsJoinLeave().getView().getCoordinator();
+  }
 
   public static Integer getViewId() {
     return getGmsJoinLeave().getView().getViewId();


Mime
View raw message