Search in sources :

Example 16 with GMSMember

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

the class GMSJoinLeaveJUnitTest method testNetworkPartitionDetected.

@Test
public void testNetworkPartitionDetected() throws IOException {
    initMocks(true);
    prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
    // set up a view with sufficient members, then create a new view
    // where enough weight is lost to cause a network partition
    List<InternalDistributedMember> mbrs = new LinkedList<>();
    mbrs.add(mockMembers[0]);
    mbrs.add(mockMembers[1]);
    mbrs.add(mockMembers[2]);
    mbrs.add(gmsJoinLeaveMemberId);
    ((GMSMember) mockMembers[1].getNetMember()).setMemberWeight((byte) 20);
    NetView newView = new NetView(mockMembers[0], gmsJoinLeave.getView().getViewId() + 1, mbrs);
    InstallViewMessage installViewMessage = getInstallViewMessage(newView, credentials, false);
    gmsJoinLeave.processMessage(installViewMessage);
    Set<InternalDistributedMember> crashes = new HashSet<>();
    crashes.add(mockMembers[1]);
    crashes.add(mockMembers[2]);
    mbrs = new LinkedList<>(mbrs);
    mbrs.remove(mockMembers[1]);
    mbrs.remove(mockMembers[2]);
    NetView partitionView = new NetView(mockMembers[0], newView.getViewId() + 1, mbrs, Collections.emptySet(), crashes);
    installViewMessage = getInstallViewMessage(partitionView, credentials, false);
    gmsJoinLeave.processMessage(installViewMessage);
    verify(manager).forceDisconnect(isA(String.class));
    verify(manager).quorumLost(crashes, newView);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) GMSMember(org.apache.geode.distributed.internal.membership.gms.GMSMember) NetView(org.apache.geode.distributed.internal.membership.NetView) InstallViewMessage(org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage) LinkedList(java.util.LinkedList) 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 17 with GMSMember

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

the class GMSHealthMonitorJUnitTest method testClientSocketHandler.

@Test
public void testClientSocketHandler() throws Exception {
    int viewId = 2;
    long msb = 3;
    long lsb = 4;
    GMSMember otherMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
    GMSMember gmsMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
    executeTestClientSocketHandler(gmsMember, otherMember, GMSHealthMonitor.OK);
}
Also used : GMSMember(org.apache.geode.distributed.internal.membership.gms.GMSMember) 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 18 with GMSMember

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

the class GMSHealthMonitorJUnitTest method executeTestDoTCPCheck.

private void executeTestDoTCPCheck(int receivedStatus, boolean expectedResult) throws Exception {
    InternalDistributedMember otherMember = createInternalDistributedMember(Version.CURRENT_ORDINAL, 0, 1, 1);
    InternalDistributedMember gmsMember = createInternalDistributedMember(Version.CURRENT_ORDINAL, 0, 1, 1);
    // Set up the incoming/received bytes. We just wrap output streams and write out the gms member
    // information
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(receivedStatus);
    byte[] receivedBytes = baos.toByteArray();
    InputStream mockInputStream = new ByteArrayInputStream(receivedBytes);
    Socket fakeSocket = mock(Socket.class);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    when(fakeSocket.getInputStream()).thenReturn(mockInputStream);
    when(fakeSocket.getOutputStream()).thenReturn(outputStream);
    when(fakeSocket.isConnected()).thenReturn(true);
    Assert.assertEquals(expectedResult, gmsHealthMonitor.doTCPCheckMember(otherMember, fakeSocket));
    Assert.assertTrue(gmsHealthMonitor.getStats().getFinalCheckRequestsSent() > 0);
    Assert.assertTrue(gmsHealthMonitor.getStats().getTcpFinalCheckRequestsSent() > 0);
    Assert.assertTrue(gmsHealthMonitor.getStats().getFinalCheckResponsesReceived() > 0);
    Assert.assertTrue(gmsHealthMonitor.getStats().getTcpFinalCheckResponsesReceived() > 0);
    // we can check to see if the gms member information was written out by the tcp check
    byte[] bytesWritten = outputStream.toByteArray();
    Assert.assertArrayEquals(writeMemberToBytes((GMSMember) gmsMember.getNetMember()), bytesWritten);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) GMSMember(org.apache.geode.distributed.internal.membership.gms.GMSMember) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket)

Example 19 with GMSMember

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

the class GMSHealthMonitorJUnitTest method testClientSocketHandlerWhenViewIdDoNotMatch.

@Test
public void testClientSocketHandlerWhenViewIdDoNotMatch() throws Exception {
    int viewId = 2;
    long msb = 3;
    long lsb = 4;
    GMSMember otherMember = createGMSMember(Version.CURRENT_ORDINAL, viewId + 1, msb, lsb);
    GMSMember gmsMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
    executeTestClientSocketHandler(gmsMember, otherMember, GMSHealthMonitor.ERROR);
}
Also used : GMSMember(org.apache.geode.distributed.internal.membership.gms.GMSMember) 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 20 with GMSMember

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

the class GMSHealthMonitorJUnitTest method testClientSocketHandlerWhenMsbDoNotMatch.

@Test
public void testClientSocketHandlerWhenMsbDoNotMatch() throws Exception {
    int viewId = 2;
    long msb = 3;
    long lsb = 4;
    GMSMember otherMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb + 1, lsb);
    GMSMember gmsMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
    executeTestClientSocketHandler(gmsMember, otherMember, GMSHealthMonitor.ERROR);
}
Also used : GMSMember(org.apache.geode.distributed.internal.membership.gms.GMSMember) 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

GMSMember (org.apache.geode.distributed.internal.membership.gms.GMSMember)21 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)12 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)8 Test (org.junit.Test)8 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)7 NetView (org.apache.geode.distributed.internal.membership.NetView)4 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)4 UUID (org.jgroups.util.UUID)4 DataInputStream (java.io.DataInputStream)3 HashSet (java.util.HashSet)3 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 LinkedList (java.util.LinkedList)2 HighPriorityDistributionMessage (org.apache.geode.distributed.internal.HighPriorityDistributionMessage)2 InstallViewMessage (org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage)2 JoinRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)2 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)2 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1