Search in sources :

Example 1 with LeaveRequestMessage

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]));
}
Also used : LeaveRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage) RemoveMemberMessage(org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 2 with LeaveRequestMessage

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);
}
Also used : LeaveRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage)

Example 3 with LeaveRequestMessage

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());
}
Also used : LeaveRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 4 with LeaveRequestMessage

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());
}
Also used : LeaveRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 5 with LeaveRequestMessage

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]));
}
Also used : LeaveRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage) NetView(org.apache.geode.distributed.internal.membership.NetView) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

LeaveRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage)10 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)5 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)5 Test (org.junit.Test)5 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)4 NetView (org.apache.geode.distributed.internal.membership.NetView)4 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)2 JoinRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)2 RemoveMemberMessage (org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage)2 SerialAckedMessage (org.apache.geode.distributed.internal.SerialAckedMessage)1 GMSMember (org.apache.geode.distributed.internal.membership.gms.GMSMember)1 MessageHandler (org.apache.geode.distributed.internal.membership.gms.interfaces.MessageHandler)1 InstallViewMessage (org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage)1 JoinResponseMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage)1 Event (org.jgroups.Event)1 Message (org.jgroups.Message)1