Search in sources :

Example 16 with NetView

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

the class JGroupsMessengerJUnitTest method testSendToMultipleMembers.

@Test
public void testSendToMultipleMembers() throws Exception {
    initMocks(false);
    InternalDistributedMember sender = messenger.getMemberID();
    InternalDistributedMember other = createAddress(8888);
    NetView v = new NetView(sender);
    v.add(other);
    when(joinLeave.getView()).thenReturn(v);
    messenger.installView(v);
    List<InternalDistributedMember> recipients = v.getMembers();
    SerialAckedMessage msg = new SerialAckedMessage();
    msg.setRecipients(recipients);
    messenger.send(msg);
    int sentMessages = interceptor.unicastSentDataMessages;
    assertTrue("expected 2 message to be sent but found " + sentMessages, sentMessages == 2);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) SerialAckedMessage(org.apache.geode.distributed.internal.SerialAckedMessage) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 17 with NetView

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

the class JGroupsMessengerJUnitTest method testJGroupsIOExceptionHandler.

@Test
public void testJGroupsIOExceptionHandler() throws Exception {
    initMocks(false);
    InternalDistributedMember mbr = createAddress(8888);
    NetView v = new NetView(mbr);
    v.add(messenger.getMemberID());
    messenger.installView(v);
    IOException ioe = new IOException("test exception");
    messenger.handleJGroupsIOException(ioe, new JGAddress(mbr));
    // should be ignored
    messenger.handleJGroupsIOException(ioe, new JGAddress(mbr));
    verify(healthMonitor).suspect(mbr, "Unable to send messages to this member via JGroups");
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) GemFireIOException(org.apache.geode.GemFireIOException) IOException(java.io.IOException) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 18 with NetView

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

the class JGroupsMessengerJUnitTest method testMessageFiltering.

@Test
public void testMessageFiltering() throws Exception {
    initMocks(true);
    InternalDistributedMember mbr = createAddress(8888);
    NetView view = new NetView(mbr);
    // the digest should be set in an outgoing join response
    JoinResponseMessage joinResponse = new JoinResponseMessage(mbr, view, 0);
    messenger.filterOutgoingMessage(joinResponse);
    assertNotNull(joinResponse.getMessengerData());
    // save the view digest for later
    byte[] data = joinResponse.getMessengerData();
    // the digest should be used and the message bytes nulled out in an incoming join response
    messenger.filterIncomingMessage(joinResponse);
    assertNull(joinResponse.getMessengerData());
    // the digest shouldn't be set in an outgoing rejection message
    joinResponse = new JoinResponseMessage("you can't join my distributed system.  nyah nyah nyah!", 0);
    messenger.filterOutgoingMessage(joinResponse);
    assertNull(joinResponse.getMessengerData());
    // the digest shouldn't be installed from an incoming rejection message
    joinResponse.setMessengerData(data);
    messenger.filterIncomingMessage(joinResponse);
    assertNotNull(joinResponse.getMessengerData());
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) JoinResponseMessage(org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 19 with NetView

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

the class GMSQuorumCheckerJUnitTest method testQuorumCheckerNoQuorumNoResponders.

@Test
public void testQuorumCheckerNoQuorumNoResponders() throws Exception {
    NetView view = prepareView();
    Set<Integer> pongResponders = new HashSet<Integer>();
    PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
    Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
    GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
    qc.initialize();
    boolean quorum = qc.checkForQuorum(500);
    assertFalse(quorum);
    assertSame(view.getMembers().size(), answerer.getPingCount());
}
Also used : Message(org.jgroups.Message) NetView(org.apache.geode.distributed.internal.membership.NetView) HashSet(java.util.HashSet) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 20 with NetView

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

the class GMSQuorumCheckerJUnitTest method testQuorumChecker10Servers2Locators5ServersAnd2LocatorsButNotLeadMemberLost.

@Test
public void testQuorumChecker10Servers2Locators5ServersAnd2LocatorsButNotLeadMemberLost() throws Exception {
    NetView view = prepareView();
    mockMembers[0].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
    mockMembers[1].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
    Set<Integer> pongResponders = new HashSet<Integer>();
    for (int i = 0; i < mockMembers.length; i++) {
        pongResponders.add(mockMembers[i].getPort());
    }
    // remove 5 servers
    pongResponders.remove(mockMembers[7].getPort());
    pongResponders.remove(mockMembers[8].getPort());
    pongResponders.remove(mockMembers[9].getPort());
    pongResponders.remove(mockMembers[10].getPort());
    pongResponders.remove(mockMembers[11].getPort());
    // remove locators
    pongResponders.remove(mockMembers[0].getPort());
    pongResponders.remove(mockMembers[1].getPort());
    PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
    Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
    GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
    qc.initialize();
    boolean quorum = qc.checkForQuorum(500);
    assertFalse(quorum);
    assertSame(view.getMembers().size(), answerer.getPingCount());
}
Also used : Message(org.jgroups.Message) NetView(org.apache.geode.distributed.internal.membership.NetView) HashSet(java.util.HashSet) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

NetView (org.apache.geode.distributed.internal.membership.NetView)101 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)65 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)59 Test (org.junit.Test)59 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)57 HashSet (java.util.HashSet)25 InstallViewMessage (org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage)18 Message (org.jgroups.Message)14 ArrayList (java.util.ArrayList)12 JoinResponseMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage)10 UnitTest (org.apache.geode.test.junit.categories.UnitTest)10 LinkedList (java.util.LinkedList)9 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)9 IOException (java.io.IOException)8 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)8 Properties (java.util.Properties)7 FindCoordinatorResponse (org.apache.geode.distributed.internal.membership.gms.locator.FindCoordinatorResponse)7 CancelException (org.apache.geode.CancelException)6 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)6 JoinRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)6