use of org.apache.geode.distributed.internal.membership.gms.locator.FindCoordinatorResponse 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.gms.locator.FindCoordinatorResponse in project geode by apache.
the class TcpServerBackwardCompatDUnitTest method testGossipVersionBackwardCompatibility.
/**
* This test starts two locators with current GOSSIPVERSION and then shuts down one of them and
* restart it with new GOSSIPVERSION and verifies that it has recoverd the system View. Then we
* upgrade next locator.
*/
@Test
public void testGossipVersionBackwardCompatibility() {
Host host = Host.getHost(0);
final VM locator0 = host.getVM(0);
final VM locator1 = host.getVM(1);
final VM locatorRestart0 = host.getVM(2);
final VM member = host.getVM(3);
int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
// Create properties for locator0
final int port0 = ports[0];
// new File("");
final File logFile0 = null;
// Create properties for locator1
final int port1 = ports[1];
// new File("");
final File logFile1 = null;
final String locators = host.getHostName() + "[" + port0 + "]," + host.getHostName() + "[" + port1 + "]";
final Properties props = new Properties();
props.setProperty(LOCATORS, locators);
props.setProperty(MCAST_PORT, "0");
props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
// props.setProperty(LOG_LEVEL, "finest");
// Start locator0 with props.
// props.setProperty(DistributionConfig.START_LOCATOR_NAME, host.getHostName() + "["+port0+"]");
locator0.invoke(new CacheSerializableRunnable("Starting first locator on port " + port0) {
@Override
public void run2() throws CacheException {
try {
TcpServer.getGossipVersionMapForTestOnly().put(TcpServer.TESTVERSION - 100, Version.CURRENT_ORDINAL);
Locator.startLocatorAndDS(port0, logFile0, props);
} catch (IOException e) {
org.apache.geode.test.dunit.Assert.fail("Locator1 start failed with Gossip Version: " + TcpServer.GOSSIPVERSION + "!", e);
}
}
});
// Start a new member to add it to discovery set of locator0.
member.invoke(new CacheSerializableRunnable("Start a member") {
@Override
public void run2() throws CacheException {
disconnectFromDS();
TcpServer.getGossipVersionMapForTestOnly().put(TcpServer.TESTVERSION - 100, Version.CURRENT_ORDINAL);
InternalDistributedSystem.connect(props);
}
});
// Start locator1 with props.
// props.setProperty(DistributionConfig.START_LOCATOR_NAME, host.getHostName() + "["+port1+"]");
locator1.invoke(new CacheSerializableRunnable("Starting second locator on port " + port1) {
@Override
public void run2() throws CacheException {
try {
TcpServer.TESTVERSION -= 100;
TcpServer.OLDTESTVERSION -= 100;
TcpServer.getGossipVersionMapForTestOnly().put(TcpServer.TESTVERSION, Version.CURRENT_ORDINAL);
TcpServer.getGossipVersionMapForTestOnly().put(TcpServer.OLDTESTVERSION, Version.GFE_57.ordinal());
// assertIndexDetailsEquals("Gossip Version and Test version are not same",
// TcpServer.GOSSIPVERSION, TcpServer.TESTVERSION);
// assertIndexDetailsEquals("Previous Gossip Version and Test version are not same",
// TcpServer.OLDGOSSIPVERSION, TcpServer.OLDTESTVERSION);
Locator.startLocatorAndDS(port1, logFile1, props);
// Start a gossip client to connect to first locator "locator0".
FindCoordinatorRequest req = new FindCoordinatorRequest(new InternalDistributedMember(SocketCreator.getLocalHost(), 1234));
FindCoordinatorResponse response = null;
response = (FindCoordinatorResponse) new TcpClient().requestToServer(SocketCreator.getLocalHost(), port1, req, 5000);
assertNotNull(response);
} catch (Exception e) {
org.apache.geode.test.dunit.Assert.fail("Locator1 start failed with Gossip Version: " + TcpServer.GOSSIPVERSION + "!", e);
}
}
});
// Stop first locator currently running in locator0 VM.
locator0.invoke(new CacheSerializableRunnable("Stopping first locator") {
@Override
public void run2() throws CacheException {
Locator.getLocator().stop();
disconnectFromDS();
}
});
// Restart first locator in new VM.
// props.setProperty(DistributionConfig.START_LOCATOR_NAME, host.getHostName() + "["+port0+"]");
locatorRestart0.invoke(new CacheSerializableRunnable("Restarting first locator on port " + port0) {
@Override
public void run2() throws CacheException {
try {
TcpServer.TESTVERSION -= 100;
TcpServer.OLDTESTVERSION -= 100;
TcpServer.getGossipVersionMapForTestOnly().put(TcpServer.TESTVERSION, Version.CURRENT_ORDINAL);
TcpServer.getGossipVersionMapForTestOnly().put(TcpServer.OLDTESTVERSION, Version.GFE_57.ordinal());
// assertIndexDetailsEquals("Gossip Version and Test version are not same",
// TcpServer.GOSSIPVERSION, TcpServer.TESTVERSION);
// assertIndexDetailsEquals("Previous Gossip Version and Test version are not same",
// TcpServer.OLDGOSSIPVERSION, TcpServer.OLDTESTVERSION);
Locator.startLocatorAndDS(port0, logFile0, props);
// Start a gossip client to connect to first locator "locator0".
FindCoordinatorRequest req = new FindCoordinatorRequest(new InternalDistributedMember(SocketCreator.getLocalHost(), 1234));
FindCoordinatorResponse response = null;
response = (FindCoordinatorResponse) new TcpClient().requestToServer(SocketCreator.getLocalHost(), port0, req, 5000);
assertNotNull(response);
} catch (Exception e) {
org.apache.geode.test.dunit.Assert.fail("Locator0 start failed with Gossip Version: " + TcpServer.GOSSIPVERSION + "!", e);
}
}
});
}
use of org.apache.geode.distributed.internal.membership.gms.locator.FindCoordinatorResponse 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 {
}
}
Aggregations