use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage in project geode by apache.
the class GMSJoinLeave method sendView.
private boolean sendView(NetView view, boolean preparing, ViewReplyProcessor viewReplyProcessor) throws InterruptedException {
int id = view.getViewId();
InstallViewMessage msg = new InstallViewMessage(view, services.getAuthenticator().getCredentials(this.localAddress), preparing);
Set<InternalDistributedMember> recips = new HashSet<>(view.getMembers());
// a recent member was seen not to receive a new view - I think this is why
// recips.removeAll(newMembers); // new members get the view in a JoinResponseMessage
// no need to send it to ourselves
recips.remove(this.localAddress);
Set<InternalDistributedMember> responders = recips;
if (!view.getCrashedMembers().isEmpty()) {
recips = new HashSet<>(recips);
recips.addAll(view.getCrashedMembers());
}
if (preparing) {
this.preparedView = view;
} else {
// if another server is the coordinator - GEODE-870
if (isCoordinator && !localAddress.equals(view.getCoordinator()) && getViewCreator() != null) {
markViewCreatorForShutdown = true;
this.isCoordinator = false;
}
installView(view);
}
if (recips.isEmpty()) {
if (!preparing) {
logger.info("no recipients for new view aside from myself");
}
return true;
}
logger.info((preparing ? "preparing" : "sending") + " new view " + view);
msg.setRecipients(recips);
Set<InternalDistributedMember> pendingLeaves = getPendingRequestIDs(LEAVE_REQUEST_MESSAGE);
Set<InternalDistributedMember> pendingRemovals = getPendingRequestIDs(REMOVE_MEMBER_REQUEST);
pendingRemovals.removeAll(view.getCrashedMembers());
viewReplyProcessor.initialize(id, responders);
viewReplyProcessor.processPendingRequests(pendingLeaves, pendingRemovals);
addPublicKeysToView(view);
services.getMessenger().send(msg);
// only wait for responses during preparation
if (preparing) {
logger.debug("waiting for view responses");
Set<InternalDistributedMember> failedToRespond = viewReplyProcessor.waitForResponses();
logger.info("finished waiting for responses to view preparation");
InternalDistributedMember conflictingViewSender = viewReplyProcessor.getConflictingViewSender();
NetView conflictingView = viewReplyProcessor.getConflictingView();
if (conflictingView != null) {
logger.warn("received a conflicting membership view from " + conflictingViewSender + " during preparation: " + conflictingView);
return false;
}
if (!failedToRespond.isEmpty() && (!services.getCancelCriterion().isCancelInProgress())) {
logger.warn("these members failed to respond to the view change: " + failedToRespond);
return false;
}
}
return true;
}
use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testBecomeParticipantThroughViewChange.
@Test
public void testBecomeParticipantThroughViewChange() throws Exception {
initMocks();
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
NetView oldView = gmsJoinLeave.getView();
oldView.add(gmsJoinLeaveMemberId);
InternalDistributedMember creator = oldView.getCreator();
GMSJoinLeaveTestHelper.becomeCoordinatorForTest(gmsJoinLeave);
NetView view = new NetView(2, gmsJoinLeave.getView().getViewId() + 1);
view.setCreator(creator);
view.add(creator);
view.add(gmsJoinLeaveMemberId);
InstallViewMessage msg = getInstallViewMessage(view, creator, false);
msg.setSender(creator);
gmsJoinLeave.processMessage(msg);
assertTrue("Expected it to stop being coordinator", !gmsJoinLeave.isCoordinator());
}
use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage 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.messages.InstallViewMessage 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));
}
use of org.apache.geode.distributed.internal.membership.gms.messages.InstallViewMessage in project geode by apache.
the class GMSJoinLeaveJUnitTest method testNoViewAckCausesRemovalMessage.
@Test
public void testNoViewAckCausesRemovalMessage() throws Exception {
initMocks(true);
when(healthMonitor.checkIfAvailable(isA(InternalDistributedMember.class), isA(String.class), isA(Boolean.class))).thenReturn(false);
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
NetView oldView = gmsJoinLeave.getView();
NetView newView = new NetView(oldView, oldView.getViewId() + 1);
// the new view will remove the old coordinator (normal shutdown) and add a new member
// who will not ack the view. This should cause it to be removed from the system
// with a RemoveMemberMessage
newView.add(mockMembers[2]);
newView.remove(mockMembers[0]);
InstallViewMessage installViewMessage = getInstallViewMessage(newView, credentials, false);
gmsJoinLeave.processMessage(installViewMessage);
// this test's member-timeout * 3
Awaitility.await().atMost(6, SECONDS).until(() -> gmsJoinLeave.getView().getViewId() != oldView.getViewId());
assertTrue(gmsJoinLeave.isCoordinator());
// wait for suspect processing
verify(healthMonitor, timeout(10000).atLeast(1)).checkIfAvailable(isA(DistributedMember.class), isA(String.class), isA(Boolean.class));
// verify(messenger, atLeast(1)).send(isA(RemoveMemberMessage.class));
}
Aggregations