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 2018/08/15 16:25:46 UTC
[geode] branch develop updated: GEODE-5560 member becomes
coordinator but then stops when it receives a view
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 7299dd8 GEODE-5560 member becomes coordinator but then stops when it receives a view
7299dd8 is described below
commit 7299dd84fcda8e2b7e475c63b094c22948112bd4
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Wed Aug 15 09:24:58 2018 -0700
GEODE-5560 member becomes coordinator but then stops when it receives a view
Upgraded the check to see if the receiver of a new membership view should
become the coordinator. If we've received a Leave message from the coordinator
or the coordinator is scheduled to be kicked out of the system we take over
the role of coordinator if necessary.
This closes #2299
---
.../gms/membership/GMSJoinLeaveJUnitTest.java | 19 +++++++++++++++++++
.../membership/gms/membership/GMSJoinLeave.java | 18 ++++++++++++++----
2 files changed, 33 insertions(+), 4 deletions(-)
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 0ff678c..d87f7e4 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
@@ -717,6 +717,25 @@ public class GMSJoinLeaveJUnitTest {
}
@Test
+ public void testBecomeCoordinatorThroughViewChangeWhenCoordinatorIsShuttingDown()
+ throws Exception {
+ initMocks();
+ prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
+ NetView oldView = gmsJoinLeave.getView();
+ oldView.add(gmsJoinLeaveMemberId);
+ NetView view = new NetView(oldView, oldView.getViewId() + 1);
+ InternalDistributedMember creator = view.getCreator();
+ LeaveRequestMessage leaveRequestMessage =
+ new LeaveRequestMessage(gmsJoinLeaveMemberId, mockMembers[0], "leaving for test");
+ gmsJoinLeave.processMessage(leaveRequestMessage);
+ assertTrue(gmsJoinLeave.isCoordinator());
+ InstallViewMessage msg = getInstallViewMessage(view, creator, false);
+ msg.setSender(creator);
+ gmsJoinLeave.processMessage(msg);
+ assertTrue("Expected it to remain coordinator", gmsJoinLeave.isCoordinator());
+ }
+
+ @Test
public void testBecomeParticipantThroughViewChange() throws Exception {
initMocks();
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
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 45b17bf..d364f2c 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
@@ -600,7 +600,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
if (!isCoordinator && !isStopping && !services.getCancelCriterion().isCancelInProgress()) {
logger.debug("Checking to see if I should become coordinator");
NetView check = new NetView(v, v.getViewId() + 1);
- check.remove(incomingRequest.getMemberID());
+ check.remove(mbr);
synchronized (removedMembers) {
check.removeAll(removedMembers);
check.addCrashedMembers(removedMembers);
@@ -611,7 +611,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
}
if (check.getCoordinator().equals(localAddress)) {
synchronized (viewInstallationLock) {
- becomeCoordinator(incomingRequest.getMemberID());
+ becomeCoordinator(mbr);
}
}
} else {
@@ -1438,8 +1438,18 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
}
if (!newView.getCreator().equals(this.localAddress)) {
- if (newView.shouldBeCoordinator(this.localAddress)) {
- becomeCoordinator();
+ NetView check = new NetView(newView, newView.getViewId() + 1);
+ synchronized (leftMembers) {
+ check.removeAll(leftMembers);
+ }
+ synchronized (removedMembers) {
+ check.removeAll(removedMembers);
+ check.addCrashedMembers(removedMembers);
+ }
+ if (check.shouldBeCoordinator(this.localAddress)) {
+ if (!isCoordinator) {
+ becomeCoordinator();
+ }
} else if (this.isCoordinator) {
// stop being coordinator
stopCoordinatorServices();