Search in sources :

Example 1 with NetView

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

the class GMSQuorumCheckerJUnitTest method testQuorumChecker10Servers2Locators5ServerAnd1LocatorWithLeadMemberLost.

@Test
public void testQuorumChecker10Servers2Locators5ServerAnd1LocatorWithLeadMemberLost() 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
    // lead member
    pongResponders.remove(mockMembers[2].getPort());
    pongResponders.remove(mockMembers[8].getPort());
    pongResponders.remove(mockMembers[9].getPort());
    pongResponders.remove(mockMembers[10].getPort());
    pongResponders.remove(mockMembers[11].getPort());
    // remove locator
    pongResponders.remove(mockMembers[0].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)

Example 2 with NetView

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

the class JGroupsMessengerJUnitTest method testEncryptedFindCoordinatorResponse.

@Test
public void testEncryptedFindCoordinatorResponse() throws Exception {
    InternalDistributedMember otherMbr = new InternalDistributedMember("localhost", 8888);
    Properties p = new Properties();
    p.put(ConfigurationProperties.SECURITY_UDP_DHALGO, "AES:128");
    initMocks(false, p);
    NetView v = createView(otherMbr);
    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
    otherMbrEncrptor.setPublicKey(messenger.getPublicKey(messenger.getMemberID()), messenger.getMemberID());
    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
    messenger.initClusterKey();
    FindCoordinatorResponse gfmsg = new FindCoordinatorResponse(messenger.getMemberID(), messenger.getMemberID(), messenger.getClusterSecretKey(), 1);
    Set<InternalDistributedMember> recipients = new HashSet<>();
    recipients.add(otherMbr);
    gfmsg.setRecipients(recipients);
    short version = Version.CURRENT_ORDINAL;
    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
    messenger.writeEncryptedMessage(gfmsg, version, out);
    byte[] requestBytes = out.toByteArray();
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(requestBytes));
    messenger.addRequestId(1, messenger.getMemberID());
    DistributionMessage distributionMessage = messenger.readEncryptedMessage(dis, version, otherMbrEncrptor);
    assertEquals(gfmsg, distributionMessage);
}
Also used : FindCoordinatorResponse(org.apache.geode.distributed.internal.membership.gms.locator.FindCoordinatorResponse) NetView(org.apache.geode.distributed.internal.membership.NetView) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DataInputStream(java.io.DataInputStream) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ByteArrayInputStream(java.io.ByteArrayInputStream) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) HashSet(java.util.HashSet) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 3 with NetView

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

the class GMSQuorumCheckerJUnitTest method prepareView.

private NetView prepareView(int numMembers) throws IOException {
    int viewId = 1;
    List<InternalDistributedMember> mbrs = new LinkedList<InternalDistributedMember>();
    for (int i = 0; i < numMembers; i++) {
        mbrs.add(mockMembers[i]);
    }
    // prepare the view
    NetView netView = new NetView(mockMembers[0], viewId, mbrs);
    return netView;
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) LinkedList(java.util.LinkedList)

Example 4 with NetView

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

the class JGroupsMessengerJUnitTest method ioExceptionDuringShutdownAvoidsSuspectProcessing.

@Test
public void ioExceptionDuringShutdownAvoidsSuspectProcessing() throws Exception {
    // see GEODE-634
    initMocks(false);
    NetView v = createView();
    when(joinLeave.getView()).thenReturn(v);
    when(manager.shutdownInProgress()).thenReturn(true);
    messenger.installView(v);
    messenger.handleJGroupsIOException(new IOException("fichez-moi le camp"), new JGAddress(v.getMembers().get(1)));
    verify(healthMonitor, never()).checkIfAvailable(isA(InternalDistributedMember.class), isA(String.class), isA(Boolean.class));
}
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 5 with NetView

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

the class JGroupsMessengerJUnitTest method createView.

private NetView createView(InternalDistributedMember otherMbr) {
    InternalDistributedMember sender = messenger.getMemberID();
    List<InternalDistributedMember> mbrs = new ArrayList<>();
    mbrs.add(sender);
    mbrs.add(otherMbr);
    NetView v = new NetView(sender, 1, mbrs);
    return v;
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ArrayList(java.util.ArrayList) NetView(org.apache.geode.distributed.internal.membership.NetView)

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