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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations