use of org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave.ViewCreator in project geode by apache.
the class GMSJoinLeaveJUnitTest method testPreparedViewFoundDuringBecomeCoordinator.
@Test
public void testPreparedViewFoundDuringBecomeCoordinator() throws Exception {
initMocks(false);
prepareAndInstallView(gmsJoinLeaveMemberId, createMemberList(gmsJoinLeaveMemberId, mockMembers[0]));
// a new member is joining
NetView preparedView = new NetView(gmsJoinLeave.getView(), gmsJoinLeave.getView().getViewId() + 5);
mockMembers[1].setVmViewId(preparedView.getViewId());
preparedView.add(mockMembers[1]);
InstallViewMessage msg = getInstallViewMessage(preparedView, null, true);
gmsJoinLeave.processMessage(msg);
GMSJoinLeaveTestHelper.becomeCoordinatorForTest(gmsJoinLeave);
Thread.sleep(2000);
ViewCreator vc = gmsJoinLeave.getViewCreator();
int viewId = 0;
if (gmsJoinLeave.getPreparedView() == null) {
viewId = gmsJoinLeave.getView().getViewId();
} else {
viewId = gmsJoinLeave.getPreparedView().getViewId();
}
ViewAckMessage vack = new ViewAckMessage(gmsJoinLeaveMemberId, viewId, true);
vack.setSender(mockMembers[0]);
gmsJoinLeave.processMessage(vack);
vack = new ViewAckMessage(gmsJoinLeaveMemberId, viewId, true);
vack.setSender(mockMembers[1]);
gmsJoinLeave.processMessage(vack);
vack = new ViewAckMessage(gmsJoinLeaveMemberId, viewId, true);
vack.setSender(gmsJoinLeaveMemberId);
gmsJoinLeave.processMessage(vack);
Awaitility.await("view creator finishes").atMost(30, SECONDS).until(() -> vc.waiting);
NetView newView = gmsJoinLeave.getView();
System.out.println("new view is " + newView);
assertTrue(newView.contains(mockMembers[1]));
assertTrue(newView.getViewId() > preparedView.getViewId());
}
Aggregations