use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage 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());
}
use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testBecomeCoordinatorThroughViewChange.
@Test
public void testBecomeCoordinatorThroughViewChange() throws Exception {
initMocks();
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
NetView oldView = gmsJoinLeave.getView();
oldView.add(gmsJoinLeaveMemberId);
NetView view = new NetView(oldView, oldView.getViewId() + 1);
InternalDistributedMember creator = view.getCreator();
view.remove(creator);
InstallViewMessage msg = getInstallViewMessage(view, creator, false);
msg.setSender(creator);
gmsJoinLeave.processMessage(msg);
assertTrue("Expected it to become coordinator", gmsJoinLeave.isCoordinator());
}
use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method getInstallViewMessage.
private InstallViewMessage getInstallViewMessage(NetView view, Object credentials, boolean preparing) {
InstallViewMessage installViewMessage = new InstallViewMessage(view, credentials, preparing);
installViewMessage.setSender(gmsJoinLeaveMemberId);
return installViewMessage;
}
use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testConflictingPrepare.
@Test
public void testConflictingPrepare() throws Exception {
initMocks(true);
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
NetView gmsView = gmsJoinLeave.getView();
NetView newView = new NetView(gmsView, gmsView.getViewId() + 6);
InstallViewMessage msg = getInstallViewMessage(newView, null, true);
gmsJoinLeave.processMessage(msg);
NetView alternateView = new NetView(gmsView, gmsView.getViewId() + 1);
msg = getInstallViewMessage(alternateView, null, true);
gmsJoinLeave.processMessage(msg);
assertTrue(gmsJoinLeave.getPreparedView().equals(newView));
}
use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testForceDisconnectedFromNewView.
@Test
public void testForceDisconnectedFromNewView() throws IOException {
// enabledNetworkPartition;
initMocks(true);
Manager mockManager = mock(Manager.class);
when(services.getManager()).thenReturn(mockManager);
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
int viewId = 2;
List<InternalDistributedMember> mbrs = new LinkedList<>();
mbrs.add(mockMembers[1]);
mbrs.add(mockMembers[2]);
mbrs.add(mockMembers[3]);
// install the view
NetView netView = new NetView(mockMembers[0], viewId, mbrs);
InstallViewMessage installViewMessage = getInstallViewMessage(netView, credentials, false);
gmsJoinLeave.processMessage(installViewMessage);
Assert.assertNotEquals(netView, gmsJoinLeave.getView());
verify(mockManager).forceDisconnect(isA(String.class));
}
Aggregations