Search in sources :

Example 1 with RemoveMemberMessage

use of org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage in project geode by apache.

the class GMSJoinLeave method sendRemoveMessages.

private void sendRemoveMessages(List<InternalDistributedMember> removals, List<String> reasons, Set<InternalDistributedMember> oldIds) {
    Iterator<String> reason = reasons.iterator();
    for (InternalDistributedMember mbr : removals) {
        // if olds not contains mbr then send remove request
        if (!oldIds.contains(mbr)) {
            RemoveMemberMessage response = new RemoveMemberMessage(mbr, mbr, reason.next());
            services.getMessenger().send(response);
        } else {
            reason.next();
        }
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) RemoveMemberMessage(org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage)

Example 2 with RemoveMemberMessage

use of org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage in project geode by apache.

the class GMSJoinLeave method remove.

@Override
public void remove(InternalDistributedMember m, String reason) {
    NetView v = this.currentView;
    services.getCancelCriterion().checkCancelInProgress(null);
    if (v != null && v.contains(m)) {
        Set<InternalDistributedMember> filter = new HashSet<>();
        filter.add(m);
        RemoveMemberMessage msg = new RemoveMemberMessage(v.getPreferredCoordinators(filter, getMemberID(), 5), m, reason);
        msg.setSender(this.localAddress);
        processRemoveRequest(msg);
        if (!this.isCoordinator) {
            msg.resetRecipients();
            msg.setRecipients(v.getPreferredCoordinators(Collections.emptySet(), localAddress, 10));
            services.getMessenger().send(msg);
        }
    } else {
        RemoveMemberMessage msg = new RemoveMemberMessage(m, m, reason);
        services.getMessenger().send(msg);
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) RemoveMemberMessage(org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage) NetView(org.apache.geode.distributed.internal.membership.NetView) HashSet(java.util.HashSet)

Example 3 with RemoveMemberMessage

use of org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage in project geode by apache.

the class GMSJoinLeaveJUnitTest method testRemoveCausesForcedDisconnect.

@Test
public void testRemoveCausesForcedDisconnect() throws Exception {
    String reason = "testing";
    initMocks();
    prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
    gmsJoinLeave.getView().add(mockMembers[1]);
    RemoveMemberMessage msg = new RemoveMemberMessage(mockMembers[0], gmsJoinLeave.getMemberID(), reason);
    msg.setSender(mockMembers[1]);
    gmsJoinLeave.processMessage(msg);
    verify(manager).forceDisconnect(reason);
}
Also used : 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 4 with RemoveMemberMessage

use of org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage in project geode by apache.

the class GMSJoinLeaveJUnitTest method processRemoveMessage.

private void processRemoveMessage(InternalDistributedMember rMember) {
    RemoveMemberMessage msg = new RemoveMemberMessage(gmsJoinLeave.getMemberID(), rMember, "testing");
    msg.setSender(gmsJoinLeave.getMemberID());
    gmsJoinLeave.processMessage(msg);
}
Also used : RemoveMemberMessage(org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage)

Example 5 with RemoveMemberMessage

use of org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage in project geode by apache.

the class GMSJoinLeaveJUnitTest method testViewNotSentWhenShuttingDown.

@Test
public void testViewNotSentWhenShuttingDown() throws Exception {
    try {
        initMocks(false);
        System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
        gmsJoinLeave.join();
        installView(1, gmsJoinLeaveMemberId, createMemberList(mockMembers[0], mockMembers[1], mockMembers[2], gmsJoinLeaveMemberId, mockMembers[3]));
        assertTrue(gmsJoinLeave.getViewCreator().isAlive());
        when(manager.shutdownInProgress()).thenReturn(Boolean.TRUE);
        for (int i = 1; i < 4; i++) {
            RemoveMemberMessage msg = new RemoveMemberMessage(gmsJoinLeaveMemberId, mockMembers[i], "crashed");
            msg.setSender(gmsJoinLeaveMemberId);
            gmsJoinLeave.processMessage(msg);
        }
        Awaitility.await("waiting for view creator to stop").atMost(5000, MILLISECONDS).until(() -> !gmsJoinLeave.getViewCreator().isAlive());
        assertEquals(1, gmsJoinLeave.getView().getViewId());
    } finally {
        System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
    }
}
Also used : 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)

Aggregations

RemoveMemberMessage (org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage)11 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)7 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)7 Test (org.junit.Test)7 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)5 NetView (org.apache.geode.distributed.internal.membership.NetView)3 NetworkPartitionMessage (org.apache.geode.distributed.internal.membership.gms.messages.NetworkPartitionMessage)2 Timeout (org.mockito.verification.Timeout)2 HashSet (java.util.HashSet)1 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)1 GMSMember (org.apache.geode.distributed.internal.membership.gms.GMSMember)1 JoinRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)1 LeaveRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.LeaveRequestMessage)1 Times (org.mockito.internal.verification.Times)1