Search in sources :

Example 1 with SuspectMembersMessage

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

the class GMSHealthMonitorJUnitTest method testBeSickAndPlayDead.

@Test
public void testBeSickAndPlayDead() throws Exception {
    NetView v = new NetView(mockMembers.get(0), 2, mockMembers);
    gmsHealthMonitor.installView(v);
    gmsHealthMonitor.beSick();
    // a sick member will not respond to a heartbeat request
    HeartbeatRequestMessage req = new HeartbeatRequestMessage(mockMembers.get(0), 10);
    req.setSender(mockMembers.get(0));
    gmsHealthMonitor.processMessage(req);
    verify(messenger, never()).send(isA(HeartbeatMessage.class));
    // a sick member will not record a heartbeat from another member
    HeartbeatMessage hb = new HeartbeatMessage(-1);
    hb.setSender(mockMembers.get(0));
    gmsHealthMonitor.processMessage(hb);
    assertTrue(gmsHealthMonitor.memberTimeStamps.get(hb.getSender()) == null);
    // a sick member will not take action on a Suspect message from another member
    SuspectMembersMessage smm = mock(SuspectMembersMessage.class);
    Error err = new AssertionError("expected suspect message to be ignored");
    when(smm.getMembers()).thenThrow(err);
    when(smm.getSender()).thenThrow(err);
    when(smm.getDSFID()).thenCallRealMethod();
    gmsHealthMonitor.processMessage(smm);
}
Also used : HeartbeatMessage(org.apache.geode.distributed.internal.membership.gms.messages.HeartbeatMessage) NetView(org.apache.geode.distributed.internal.membership.NetView) HeartbeatRequestMessage(org.apache.geode.distributed.internal.membership.gms.messages.HeartbeatRequestMessage) SuspectMembersMessage(org.apache.geode.distributed.internal.membership.gms.messages.SuspectMembersMessage) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 2 with SuspectMembersMessage

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

the class GMSHealthMonitorJUnitTest method testRemoveMemberCalledAfterDoingFinalCheckOnCoordinator.

/***
   * Send remove member message after doing final check for coordinator, ping timeout This test
   * trying to remove coordinator
   */
@Test
public void testRemoveMemberCalledAfterDoingFinalCheckOnCoordinator() throws Exception {
    NetView v = new NetView(mockMembers.get(0), 2, mockMembers);
    // preferred coordinators are 0 and 1
    // next preferred coordinator
    when(messenger.getMemberID()).thenReturn(mockMembers.get(1));
    gmsHealthMonitor.started();
    gmsHealthMonitor.installView(v);
    Thread.sleep(memberTimeout / GMSHealthMonitor.LOGICAL_INTERVAL);
    ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
    recipient.add(mockMembers.get(0));
    recipient.add(mockMembers.get(1));
    ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
    // removing
    SuspectRequest sr = new SuspectRequest(mockMembers.get(0), "Not Responding");
    // coordinator
    as.add(sr);
    SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
    // member 4 sends suspect message
    sm.setSender(mockMembers.get(myAddressIndex + 1));
    gmsHealthMonitor.processMessage(sm);
    // this happens after final check, ping timeout = 1000 ms
    Thread.sleep(memberTimeout + 200);
    verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class), any(String.class));
    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsReceived() > 0);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) ArrayList(java.util.ArrayList) SuspectMembersMessage(org.apache.geode.distributed.internal.membership.gms.messages.SuspectMembersMessage) SuspectRequest(org.apache.geode.distributed.internal.membership.gms.messages.SuspectRequest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 3 with SuspectMembersMessage

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

the class GMSHealthMonitor method sendSuspectRequest.

private void sendSuspectRequest(final List<SuspectRequest> requests) {
    // the background suspect-collector thread is currently disabled
    // synchronized (suspectRequests) {
    // if (suspectRequests.size() > 0) {
    // for (SuspectRequest sr: suspectRequests) {
    // if (!requests.contains(sr)) {
    // requests.add(sr);
    // }
    // }
    // suspectRequests.clear();
    // }
    // }
    logger.debug("Sending suspect request for members {}", requests);
    List<InternalDistributedMember> recipients;
    if (currentView.size() > 4) {
        HashSet<InternalDistributedMember> filter = new HashSet<>();
        for (Enumeration<InternalDistributedMember> e = suspectedMemberInView.keys(); e.hasMoreElements(); ) {
            filter.add(e.nextElement());
        }
        filter.addAll(requests.stream().map(SuspectRequest::getSuspectMember).collect(Collectors.toList()));
        recipients = currentView.getPreferredCoordinators(filter, services.getJoinLeave().getMemberID(), 5);
    } else {
        recipients = currentView.getMembers();
    }
    SuspectMembersMessage smm = new SuspectMembersMessage(recipients, requests);
    Set<InternalDistributedMember> failedRecipients;
    try {
        failedRecipients = services.getMessenger().send(smm);
        this.stats.incSuspectsSent();
    } catch (CancelException e) {
        return;
    }
    if (failedRecipients != null && failedRecipients.size() > 0) {
        logger.info("Unable to send suspect message to {}", recipients);
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) CancelException(org.apache.geode.CancelException) SuspectMembersMessage(org.apache.geode.distributed.internal.membership.gms.messages.SuspectMembersMessage) SuspectRequest(org.apache.geode.distributed.internal.membership.gms.messages.SuspectRequest) HashSet(java.util.HashSet)

Example 4 with SuspectMembersMessage

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

the class GMSHealthMonitorJUnitTest method testRemoveMemberCalled.

/***
   * Send remove member message after doing final check, ping Timeout
   */
@Test
public void testRemoveMemberCalled() throws Exception {
    System.out.println("testRemoveMemberCalled starting");
    NetView v = new NetView(mockMembers.get(0), 2, mockMembers);
    // 3rd is current member
    // coordinator and local member
    when(messenger.getMemberID()).thenReturn(mockMembers.get(0));
    gmsHealthMonitor.started();
    gmsHealthMonitor.installView(v);
    Thread.sleep(memberTimeout / GMSHealthMonitor.LOGICAL_INTERVAL);
    ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
    recipient.add(mockMembers.get(0));
    ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
    // removing member
    SuspectRequest sr = new SuspectRequest(mockMembers.get(1), "Not Responding");
    // 1
    as.add(sr);
    SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
    sm.setSender(mockMembers.get(0));
    gmsHealthMonitor.processMessage(sm);
    Awaitility.await("waiting for remove(member) to be invoked").atMost(3 * memberTimeout, TimeUnit.SECONDS).until(() -> {
        verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class), any(String.class));
    });
    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsReceived() > 0);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) ArrayList(java.util.ArrayList) SuspectMembersMessage(org.apache.geode.distributed.internal.membership.gms.messages.SuspectMembersMessage) SuspectRequest(org.apache.geode.distributed.internal.membership.gms.messages.SuspectRequest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 5 with SuspectMembersMessage

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

the class GMSHealthMonitorJUnitTest method testRemoveMemberNotCalledBeforeTimeout.

/***
   * Shouldn't send remove member message before doing final check, or before ping Timeout
   */
@Test
public void testRemoveMemberNotCalledBeforeTimeout() {
    System.out.println("testRemoveMemberNotCalledBeforeTimeout starting");
    NetView v = new NetView(mockMembers.get(0), 2, mockMembers);
    // 3rd is current member
    // coordinator and local member
    when(messenger.getMemberID()).thenReturn(mockMembers.get(0));
    // coordinator and local member
    when(joinLeave.getMemberID()).thenReturn(mockMembers.get(0));
    gmsHealthMonitor.started();
    gmsHealthMonitor.installView(v);
    ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
    recipient.add(mockMembers.get(0));
    ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
    // removing member
    SuspectRequest sr = new SuspectRequest(mockMembers.get(1), "Not Responding");
    // 1
    as.add(sr);
    SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
    sm.setSender(mockMembers.get(0));
    gmsHealthMonitor.processMessage(sm);
    try {
        // this happens after final check, ping timeout
        Thread.sleep(memberTimeout - 100);
    } catch (InterruptedException e) {
    }
    System.out.println("testRemoveMemberNotCalledBeforeTimeout ending");
    verify(joinLeave, never()).remove(any(InternalDistributedMember.class), any(String.class));
    Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsReceived() > 0);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) ArrayList(java.util.ArrayList) SuspectMembersMessage(org.apache.geode.distributed.internal.membership.gms.messages.SuspectMembersMessage) SuspectRequest(org.apache.geode.distributed.internal.membership.gms.messages.SuspectRequest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

SuspectMembersMessage (org.apache.geode.distributed.internal.membership.gms.messages.SuspectMembersMessage)5 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)4 NetView (org.apache.geode.distributed.internal.membership.NetView)4 SuspectRequest (org.apache.geode.distributed.internal.membership.gms.messages.SuspectRequest)4 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)4 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)4 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)1 CancelException (org.apache.geode.CancelException)1 HeartbeatMessage (org.apache.geode.distributed.internal.membership.gms.messages.HeartbeatMessage)1 HeartbeatRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.HeartbeatRequestMessage)1