geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hiteshkhame...@apache.org
Subject geode git commit: GEODE-3052 Need to reset isCoordinator flag in GMSLocator.
Date Fri, 14 Jul 2017 21:27:44 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 9905794eb -> 15a3b5a6e


GEODE-3052 Need to reset isCoordinator flag in GMSLocator.

isCoordinator flag ensures that this process is becoming the
coordinator thus other process should join this process. But
when network parttion happens, we were not resetting this flag.

Now we reset isCoordinator flag when viewCreator thread shutdowns.

added unit test for it.


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

Branch: refs/heads/develop
Commit: 15a3b5a6eb789b01639a03c4318f5d3c10bd2158
Parents: 9905794
Author: Hitesh Khamesra <hkhamesra@pivotal.io>
Authored: Thu Jul 13 11:47:20 2017 -0700
Committer: Hitesh Khamesra <hkhamesra@pivotal.io>
Committed: Fri Jul 14 14:27:40 2017 -0700

----------------------------------------------------------------------
 .../membership/gms/locator/GMSLocator.java      |  1 +
 .../membership/gms/membership/GMSJoinLeave.java | 10 ++++----
 .../gms/membership/GMSJoinLeaveJUnitTest.java   | 26 ++++++++++++++++++++
 3 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/15a3b5a6/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
index 2c56f5b..e627452 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
@@ -295,6 +295,7 @@ public class GMSLocator implements Locator, NetLocator {
               logger.info("This member is becoming coordinator");
               v = null;
             }
+            logger.debug("this member is becoming coordinator from view {} ", fromView);
           }
           byte[] coordPk = null;
           if (v != null) {

http://git-wip-us.apache.org/repos/asf/geode/blob/15a3b5a6/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
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 9591673..40a4254 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
@@ -1541,11 +1541,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     if (viewCreator != null && !viewCreator.isShutdown()) {
       logger.debug("Shutting down ViewCreator");
       viewCreator.shutdown();
-      org.apache.geode.distributed.internal.membership.gms.interfaces.Locator locator =
-          services.getLocator();
-      if (locator != null) {
-        locator.setIsCoordinator(false);
-      }
       try {
         viewCreator.join(1000);
       } catch (InterruptedException e) {
@@ -2209,6 +2204,11 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
       } finally {
         shutdown = true;
         informToPendingJoinRequests();
+        org.apache.geode.distributed.internal.membership.gms.interfaces.Locator locator =
+            services.getLocator();
+        if (locator != null) {
+          locator.setIsCoordinator(false);
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/15a3b5a6/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
index d8c12e2..2807be3 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -42,6 +42,7 @@ import org.apache.geode.distributed.internal.membership.gms.Services;
 import org.apache.geode.distributed.internal.membership.gms.Services.Stopper;
 import org.apache.geode.distributed.internal.membership.gms.interfaces.Authenticator;
 import org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor;
+import org.apache.geode.distributed.internal.membership.gms.interfaces.Locator;
 import org.apache.geode.distributed.internal.membership.gms.interfaces.Manager;
 import org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger;
 import org.apache.geode.distributed.internal.membership.gms.locator.FindCoordinatorRequest;
@@ -99,6 +100,7 @@ public class GMSJoinLeaveJUnitTest {
   private GMSJoinLeave gmsJoinLeave;
   private Manager manager;
   private Stopper stopper;
+  private TestLocator testLocator;
   private InternalDistributedMember removeMember = null;
   private InternalDistributedMember leaveMember = null;
 
@@ -145,6 +147,9 @@ public class GMSJoinLeaveJUnitTest {
     when(services.getManager()).thenReturn(manager);
     when(services.getHealthMonitor()).thenReturn(healthMonitor);
 
+    testLocator = new TestLocator();
+    when(services.getLocator()).thenReturn(testLocator);
+
     Timer t = new Timer(true);
     when(services.getTimer()).thenReturn(t);
 
@@ -172,6 +177,24 @@ public class GMSJoinLeaveJUnitTest {
     }
   }
 
+  static class TestLocator implements Locator {
+
+    boolean isCoordinator;
+
+    @Override
+    public void installView(NetView v) {}
+
+    @Override
+    public void setIsCoordinator(boolean isCoordinator) {
+      this.isCoordinator = isCoordinator;
+    }
+
+    public boolean isCoordinator() {
+      return isCoordinator;
+    }
+
+  }
+
   @Test
   public void testFindCoordinatorInView() throws Exception {
     initMocks();
@@ -1131,9 +1154,12 @@ public class GMSJoinLeaveJUnitTest {
         gmsJoinLeave.processMessage(msg);
       }
 
+      assertTrue(testLocator.isCoordinator);
+
       Awaitility.await("waiting for view creator to stop").atMost(5000, MILLISECONDS)
           .until(() -> !gmsJoinLeave.getViewCreator().isAlive());
       assertEquals(1, gmsJoinLeave.getView().getViewId());
+      assertFalse(testLocator.isCoordinator);
 
     } finally {
       System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);


Mime
View raw message