@Override public String getLocators() { if (startLocator != null && startLocator.length() > 0) { String locs = locators; String startL = getStartLocator(); int comma = startL.indexOf(','); if (comma >= 0) { startL = startL.substring(0, comma); } if (locs.length() > 0) { if (locs.contains(startL)) { return locs; // fix for bug 43929 } return locs + "," + startL; } else { return startL; } } return locators; }
private RemoteLocatorJoinRequest buildRemoteDSJoinRequest(int port, DistributionConfigImpl config, final String hostnameForClients) { String localLocator = config.getStartLocator(); DistributionLocatorId locatorId = null; if (localLocator.equals(DistributionConfig.DEFAULT_START_LOCATOR)) { locatorId = new DistributionLocatorId(port, config.getBindAddress(), hostnameForClients); } else { locatorId = new DistributionLocatorId(localLocator); } RemoteLocatorJoinRequest request = new RemoteLocatorJoinRequest(config.getDistributedSystemId(), locatorId, ""); return request; }
/** * For WAN 70 Exchange the locator information within the distributed system * */ private void exchangeLocalLocators(int port, DistributionConfigImpl config, LocatorMembershipListener locatorListener, final String hostnameForClients) { String localLocator = config.getStartLocator(); DistributionLocatorId locatorId = null; if (localLocator.equals(DistributionConfig.DEFAULT_START_LOCATOR)) { locatorId = new DistributionLocatorId(port, config.getBindAddress(), hostnameForClients); } else { locatorId = new DistributionLocatorId(localLocator); } LocatorHelper.addLocator(config.getDistributedSystemId(), locatorId, locatorListener, null); RemoteLocatorJoinRequest request = buildRemoteDSJoinRequest(port, config, hostnameForClients); StringTokenizer locatorsOnThisVM = new StringTokenizer(config.getLocators(), ","); while (locatorsOnThisVM.hasMoreTokens()) { DistributionLocatorId localLocatorId = new DistributionLocatorId(locatorsOnThisVM.nextToken()); if (!locatorId.equals(localLocatorId)) { LocatorDiscovery localDiscovery = new LocatorDiscovery(this, localLocatorId, request, locatorListener); LocatorDiscovery.LocalLocatorDiscovery localLocatorDiscovery = localDiscovery.new LocalLocatorDiscovery(); this._executor.execute(localLocatorDiscovery); } } }
@Test public void testValidLocatorAddress() { String address = "81.240.0.1[7056]"; config.modifiable = true; config.setAttributeObject(START_LOCATOR, address, ConfigSource.api()); assertEquals(config.getStartLocator(), address); }