use of org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testIsMemberLeaving.
@Test
public void testIsMemberLeaving() throws Exception {
initMocks();
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], mockMembers[1], gmsJoinLeaveMemberId));
assertFalse(gmsJoinLeave.isMemberLeaving(mockMembers[0]));
assertFalse(gmsJoinLeave.isMemberLeaving(mockMembers[1]));
gmsJoinLeave.remove(mockMembers[0], "removing for test");
verify(messenger, timeout(2000).atLeastOnce()).send(isA(RemoveMemberMessage.class));
assertTrue(gmsJoinLeave.isMemberLeaving(mockMembers[0]));
LeaveRequestMessage msg = new LeaveRequestMessage(gmsJoinLeave.getMemberID(), mockMembers[1], "leaving for test");
msg.setSender(mockMembers[1]);
gmsJoinLeave.processMessage(msg);
assertTrue(gmsJoinLeave.isMemberLeaving(mockMembers[1]));
}
use of org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method processLeaveMessage.
private void processLeaveMessage(InternalDistributedMember rMember) {
LeaveRequestMessage msg = new LeaveRequestMessage(gmsJoinLeave.getMemberID(), rMember, "testing");
msg.setSender(rMember);
gmsJoinLeave.processMessage(msg);
}
use of org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testBecomeCoordinator.
@Test
public void testBecomeCoordinator() throws Exception {
String reason = "testing";
initMocks();
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
NetView view = gmsJoinLeave.getView();
view.add(gmsJoinLeaveMemberId);
InternalDistributedMember creator = view.getCreator();
LeaveRequestMessage msg = new LeaveRequestMessage(creator, creator, reason);
msg.setSender(creator);
gmsJoinLeave.processMessage(msg);
assertTrue("Expected becomeCoordinator to be invoked", gmsJoinLeave.isCoordinator());
}
use of org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testLeaveOfNonMemberIsNoOp.
@Test
public void testLeaveOfNonMemberIsNoOp() throws Exception {
String reason = "testing";
initMocks();
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
mockMembers[1].setVmViewId(gmsJoinLeave.getView().getViewId() - 1);
LeaveRequestMessage msg = new LeaveRequestMessage(gmsJoinLeave.getMemberID(), mockMembers[1], reason);
msg.setSender(mockMembers[1]);
gmsJoinLeave.processMessage(msg);
assertTrue("Expected leave request from non-member to be ignored", gmsJoinLeave.getViewRequests().isEmpty());
}
use of org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testDuplicateLeaveRequestDoesNotCauseNewView.
@Test
public void testDuplicateLeaveRequestDoesNotCauseNewView() throws Exception {
String reason = "testing";
initMocks();
gmsJoinLeave.unitTesting.add("noRandomViewChange");
prepareAndInstallView(gmsJoinLeaveMemberId, createMemberList(gmsJoinLeaveMemberId, mockMembers[0]));
GMSJoinLeaveTestHelper.becomeCoordinatorForTest(gmsJoinLeave);
LeaveRequestMessage msg = new LeaveRequestMessage(gmsJoinLeave.getMemberID(), mockMembers[0], reason);
msg.setSender(mockMembers[0]);
gmsJoinLeave.processMessage(msg);
msg = new LeaveRequestMessage(gmsJoinLeave.getMemberID(), mockMembers[0], reason);
msg.setSender(mockMembers[0]);
gmsJoinLeave.processMessage(msg);
waitForViewAndNoRequestsInProgress(7);
NetView view = gmsJoinLeave.getView();
assertTrue("expected member to be removed: " + mockMembers[0] + "; view: " + view, !view.contains(mockMembers[0]));
assertTrue("expected member to be in shutdownMembers collection: " + mockMembers[0] + "; view: " + view, view.getShutdownMembers().contains(mockMembers[0]));
}
Aggregations