use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeave method processFindCoordinatorRequest.
private void processFindCoordinatorRequest(FindCoordinatorRequest req) {
FindCoordinatorResponse resp;
if (this.isJoined) {
NetView v = currentView;
resp = new FindCoordinatorResponse(v.getCoordinator(), localAddress, services.getMessenger().getPublicKey(v.getCoordinator()), req.getRequestId());
} else {
resp = new FindCoordinatorResponse(localAddress, localAddress, services.getMessenger().getPublicKey(localAddress), req.getRequestId());
}
resp.setRecipient(req.getMemberID());
services.getMessenger().send(resp);
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSJoinLeave method addMemberToNetView.
private NetView addMemberToNetView(InternalDistributedMember oldCoordinator) {
boolean testing = unitTesting.contains("noRandomViewChange");
NetView newView;
Set<InternalDistributedMember> leaving = new HashSet<>();
Set<InternalDistributedMember> removals;
synchronized (viewInstallationLock) {
int rand = testing ? 0 : NetView.RANDOM.nextInt(10);
int viewNumber = currentView.getViewId() + 5 + rand;
if (this.localAddress.getVmViewId() < 0) {
this.localAddress.setVmViewId(viewNumber);
}
List<InternalDistributedMember> mbrs = new ArrayList<>(currentView.getMembers());
if (!mbrs.contains(localAddress)) {
mbrs.add(localAddress);
}
synchronized (this.removedMembers) {
removals = new HashSet<>(this.removedMembers);
}
synchronized (this.leftMembers) {
leaving.addAll(leftMembers);
}
if (oldCoordinator != null && !removals.contains(oldCoordinator)) {
leaving.add(oldCoordinator);
}
mbrs.removeAll(removals);
mbrs.removeAll(leaving);
newView = new NetView(this.localAddress, viewNumber, mbrs, leaving, removals);
newView.setFailureDetectionPorts(currentView);
newView.setFailureDetectionPort(this.localAddress, services.getHealthMonitor().getFailureDetectionPort());
}
return newView;
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSLocatorRecoveryJUnitTest method testRecoverFromFileWithNormalFile.
@Test
public void testRecoverFromFileWithNormalFile() throws Exception {
NetView view = new NetView();
populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL, view);
assertTrue(locator.recoverFromFile(tempStateFile));
}
use of org.apache.geode.distributed.internal.membership.NetView 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.NetView in project geode by apache.
the class GMSJoinLeaveJUnitTest method testBecomeCoordinatorThroughRemove.
@Test
public void testBecomeCoordinatorThroughRemove() throws Exception {
String reason = "testing";
initMocks();
prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));
NetView view = gmsJoinLeave.getView();
view.add(gmsJoinLeaveMemberId);
InternalDistributedMember creator = view.getCreator();
RemoveMemberMessage msg = new RemoveMemberMessage(creator, creator, reason);
msg.setSender(creator);
gmsJoinLeave.processMessage(msg);
assertTrue("Expected becomeCoordinator to be invoked", gmsJoinLeave.isCoordinator());
}
Aggregations