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/10 16:39:01 UTC
[geode] branch feature/GEODE-5560 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 feature/GEODE-5560
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/GEODE-5560 by this push:
new 378e693 GEODE-5560 member becomes coordinator but then stops when it receives a view
378e693 is described below
commit 378e69377e2ae3d052ab419dfeb3bb13f9b38573
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Fri Aug 10 09:37:04 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.
---
.../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 2697051..c6301a0 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
@@ -654,6 +654,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 770996a..5f4f560 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 {
@@ -1429,8 +1429,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();