Search in sources :

Example 1 with SuspectMember

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

the class GMSMembershipManagerJUnitTest method testStartupEvents.

@Test
public void testStartupEvents() throws Exception {
    manager.start();
    manager.started();
    manager.isJoining = true;
    List<InternalDistributedMember> viewmembers = Arrays.asList(new InternalDistributedMember[] { mockMembers[0], myMemberId });
    manager.installView(new NetView(myMemberId, 2, viewmembers));
    // add a surprise member that will be shunned due to it's having
    // an old view ID
    InternalDistributedMember surpriseMember = mockMembers[2];
    surpriseMember.setVmViewId(1);
    manager.handleOrDeferSurpriseConnect(surpriseMember);
    assertEquals(1, manager.getStartupEvents().size());
    // add a surprise member that will be accepted
    InternalDistributedMember surpriseMember2 = mockMembers[3];
    surpriseMember2.setVmViewId(3);
    manager.handleOrDeferSurpriseConnect(surpriseMember2);
    assertEquals(2, manager.getStartupEvents().size());
    // suspect a member
    InternalDistributedMember suspectMember = mockMembers[1];
    manager.handleOrDeferSuspect(new SuspectMember(mockMembers[0], suspectMember, "testing"));
    // suspect messages aren't queued - they're ignored before joining the system
    assertEquals(2, manager.getStartupEvents().size());
    verify(listener, never()).memberSuspect(suspectMember, mockMembers[0], "testing");
    HighPriorityAckedMessage m = new HighPriorityAckedMessage();
    mockMembers[0].setVmViewId(1);
    m.setRecipient(mockMembers[0]);
    m.setSender(mockMembers[1]);
    manager.handleOrDeferMessage(m);
    assertEquals(3, manager.getStartupEvents().size());
    // this view officially adds surpriseMember2
    viewmembers = Arrays.asList(new InternalDistributedMember[] { mockMembers[0], myMemberId, surpriseMember2 });
    manager.handleOrDeferViewEvent(new NetView(myMemberId, 3, viewmembers));
    assertEquals(4, manager.getStartupEvents().size());
    // add a surprise member that will be shunned due to it's having
    // an old view ID
    InternalDistributedMember surpriseMember3 = mockMembers[4];
    surpriseMember.setVmViewId(1);
    manager.handleOrDeferSurpriseConnect(surpriseMember);
    assertEquals(5, manager.getStartupEvents().size());
    // process a new view after we finish joining but before event processing has started
    manager.isJoining = false;
    mockMembers[4].setVmViewId(4);
    viewmembers = Arrays.asList(new InternalDistributedMember[] { mockMembers[0], myMemberId, surpriseMember2, mockMembers[4] });
    manager.handleOrDeferViewEvent(new NetView(myMemberId, 4, viewmembers));
    assertEquals(6, manager.getStartupEvents().size());
    // exercise the toString methods for code coverage
    for (StartupEvent ev : manager.getStartupEvents()) {
        ev.toString();
    }
    manager.startEventProcessing();
    // all startup events should have been processed
    assertEquals(0, manager.getStartupEvents().size());
    // the new view should have been installed
    assertEquals(4, manager.getView().getViewId());
    // supriseMember2 should have been announced
    verify(listener).newMemberConnected(surpriseMember2);
    // supriseMember should have been rejected (old view ID)
    verify(listener, never()).newMemberConnected(surpriseMember);
    // for code coverage also install a view after we finish joining but before
    // event processing has started. This should notify the distribution manager
    // with a LocalViewMessage to process the view
    reset(listener);
    manager.handleOrDeferViewEvent(new NetView(myMemberId, 5, viewmembers));
    assertEquals(0, manager.getStartupEvents().size());
    verify(listener).messageReceived(isA(LocalViewMessage.class));
    // process a suspect now - it will be passed to the listener
    reset(listener);
    suspectMember = mockMembers[1];
    manager.handleOrDeferSuspect(new SuspectMember(mockMembers[0], suspectMember, "testing"));
    verify(listener).memberSuspect(suspectMember, mockMembers[0], "testing");
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) HighPriorityAckedMessage(org.apache.geode.distributed.internal.HighPriorityAckedMessage) SuspectMember(org.apache.geode.distributed.internal.membership.gms.SuspectMember) StartupEvent(org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager.StartupEvent) 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 2 with SuspectMember

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

the class GMSMembershipManager method memberSuspected.

@Override
public void memberSuspected(InternalDistributedMember initiator, InternalDistributedMember suspect, String reason) {
    SuspectMember s = new SuspectMember(initiator, suspect, reason);
    handleOrDeferSuspect(s);
}
Also used : SuspectMember(org.apache.geode.distributed.internal.membership.gms.SuspectMember)

Aggregations

SuspectMember (org.apache.geode.distributed.internal.membership.gms.SuspectMember)2 HighPriorityAckedMessage (org.apache.geode.distributed.internal.HighPriorityAckedMessage)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 NetView (org.apache.geode.distributed.internal.membership.NetView)1 StartupEvent (org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager.StartupEvent)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)1 Test (org.junit.Test)1