use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testDuplicateRemoveRequestDoesNotCauseNewView.
@Test
public void testDuplicateRemoveRequestDoesNotCauseNewView() throws Exception {
String reason = "testing";
initMocks();
prepareAndInstallView(gmsJoinLeaveMemberId, createMemberList(gmsJoinLeaveMemberId, mockMembers[0]));
gmsJoinLeave.getView().add(mockMembers[1]);
gmsJoinLeave.unitTesting.add("noRandomViewChange");
GMSJoinLeaveTestHelper.becomeCoordinatorForTest(gmsJoinLeave);
RemoveMemberMessage msg = new RemoveMemberMessage(gmsJoinLeave.getMemberID(), mockMembers[0], reason);
msg.setSender(mockMembers[0]);
gmsJoinLeave.processMessage(msg);
msg = new RemoveMemberMessage(gmsJoinLeave.getMemberID(), mockMembers[0], reason);
msg.setSender(mockMembers[0]);
gmsJoinLeave.processMessage(msg);
waitForViewAndNoRequestsInProgress(7);
NetView view = gmsJoinLeave.getView();
assertTrue("expected member to be removed: " + mockMembers[0] + "; view: " + view, !view.contains(mockMembers[0]));
assertTrue("expected member to be in crashedMembers collection: " + mockMembers[0] + "; view: " + view, view.getCrashedMembers().contains(mockMembers[0]));
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method createView.
private NetView createView() {
List<InternalDistributedMember> mbrs = new LinkedList<>();
Set<InternalDistributedMember> shutdowns = new HashSet<>();
Set<InternalDistributedMember> crashes = new HashSet<>();
mbrs.add(mockMembers[0]);
mbrs.add(mockMembers[1]);
mbrs.add(mockMembers[2]);
mbrs.add(gmsJoinLeaveMemberId);
// prepare the view
NetView netView = new NetView(mockMembers[0], 1, mbrs, shutdowns, crashes);
return netView;
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testCoordinatorAndOthersShutdownAndWeBecomeCoordinatorProcessQueuedUpLeaveMessages.
/**
* This tests a member shutdown using the memberShutdown call (simulating the call from
* DistributionManager) The gmsJoinLeaveMemberId is not the coordinator but should now become the
* coordinator and remove all members that have sent us leave requests prior to us becoming
* coordinator
*/
@Test
public void testCoordinatorAndOthersShutdownAndWeBecomeCoordinatorProcessQueuedUpLeaveMessages() throws Exception {
initMocks(false);
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], mockMembers[1], mockMembers[2], gmsJoinLeaveMemberId, mockMembers[3]));
Assert.assertFalse(gmsJoinLeave.isCoordinator());
// The coordinator and other members shutdown
gmsJoinLeave.memberShutdown(mockMembers[1], "Shutdown");
gmsJoinLeave.memberShutdown(mockMembers[2], "Shutdown");
gmsJoinLeave.memberShutdown(mockMembers[0], "Shutdown");
NetView nextView = gmsJoinLeave.getViewCreator().initialView;
assertTrue(gmsJoinLeave.isCoordinator());
assertTrue(nextView.getCoordinator().equals(gmsJoinLeaveMemberId));
Assert.assertFalse(nextView.getMembers().contains(mockMembers[1]));
Assert.assertFalse(nextView.getMembers().contains(mockMembers[2]));
assertTrue(nextView.getMembers().contains(mockMembers[3]));
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testCoordinatorFindRequestSuccess.
@Test
public void testCoordinatorFindRequestSuccess() throws Exception {
try {
initMocks(false);
HashSet<InternalDistributedMember> registrants = new HashSet<>();
registrants.add(mockMembers[0]);
FindCoordinatorResponse fcr = new FindCoordinatorResponse(mockMembers[0], mockMembers[0], false, null, registrants, false, true, null);
NetView view = createView();
JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], view, 0);
TcpClientWrapper tcpClientWrapper = mock(TcpClientWrapper.class);
gmsJoinLeave.setTcpClientWrapper(tcpClientWrapper);
FindCoordinatorRequest fcreq = new FindCoordinatorRequest(gmsJoinLeaveMemberId, new HashSet<>(), -1, null, 0, "");
int connectTimeout = (int) services.getConfig().getMemberTimeout() * 2;
when(tcpClientWrapper.sendCoordinatorFindRequest(new InetSocketAddress("localhost", 12345), fcreq, connectTimeout)).thenReturn(fcr);
callAsnyc(() -> {
gmsJoinLeave.installView(view);
});
assertTrue("Should be able to join ", gmsJoinLeave.join());
} finally {
}
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testViewWithoutMemberInitiatesForcedDisconnect.
@Test
public void testViewWithoutMemberInitiatesForcedDisconnect() throws Exception {
initMocks();
GMSJoinLeaveTestHelper.becomeCoordinatorForTest(gmsJoinLeave);
List<InternalDistributedMember> members = Arrays.asList(mockMembers);
NetView v = new NetView(mockMembers[0], 2, members);
InstallViewMessage message = getInstallViewMessage(v, null, false);
gmsJoinLeave.processMessage(message);
verify(manager).forceDisconnect(isA(String.class));
}
Aggregations