use of org.apache.geode.internal.admin.remote.DistributionLocatorId in project geode by apache.
the class InternalDistributedSystem method canonicalizeLocators.
/**
* Canonicalizes a locators string so that they may be compared.
*
* @since GemFire 4.0
*/
private static String canonicalizeLocators(String locators) {
SortedSet sorted = new TreeSet();
StringTokenizer st = new StringTokenizer(locators, ",");
while (st.hasMoreTokens()) {
String l = st.nextToken();
StringBuilder canonical = new StringBuilder();
DistributionLocatorId locId = new DistributionLocatorId(l);
String addr = locId.getBindAddress();
if (addr != null && addr.trim().length() > 0) {
canonical.append(addr);
} else {
canonical.append(locId.getHost().getHostAddress());
}
canonical.append("[");
canonical.append(String.valueOf(locId.getPort()));
canonical.append("]");
sorted.add(canonical.toString());
}
StringBuilder sb = new StringBuilder();
for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
sb.append((String) iter.next());
if (iter.hasNext()) {
sb.append(",");
}
}
return sb.toString();
}
use of org.apache.geode.internal.admin.remote.DistributionLocatorId in project geode by apache.
the class InternalDistributedSystem method startInitLocator.
/**
* @since GemFire 5.7
*/
private void startInitLocator() throws InterruptedException {
String locatorString = this.originalConfig.getStartLocator();
if (locatorString.length() == 0) {
return;
}
// there is a quorum of the old members available
if (attemptingToReconnect && !this.isConnected) {
if (this.quorumChecker != null) {
logger.info("performing a quorum check to see if location services can be started early");
if (!quorumChecker.checkForQuorum(3 * this.config.getMemberTimeout())) {
logger.info("quorum check failed - not allowing location services to start early");
return;
}
logger.info("Quorum check passed - allowing location services to start early");
}
}
DistributionLocatorId locId = new DistributionLocatorId(locatorString);
try {
this.startedLocator = // LOG: this is
InternalLocator.createLocator(// LOG: this is
locId.getPort(), // LOG: this is
null, // LOG: this is
null, // LOG: this is
this.logWriter, // LOG: this is after IDS has created LogWriterLoggers and
this.securityLogWriter, // Appenders
locId.getHost(), locId.getHostnameForClients(), this.originalConfig.toProperties(), false);
// if locator is started this way, cluster config is not enabled, set the flag correctly
this.startedLocator.getConfig().setEnableClusterConfiguration(false);
boolean startedPeerLocation = false;
try {
this.startedLocator.startPeerLocation(true);
startedPeerLocation = true;
} finally {
if (!startedPeerLocation) {
this.startedLocator.stop();
}
}
} catch (IOException e) {
throw new GemFireIOException(LocalizedStrings.InternalDistributedSystem_PROBLEM_STARTING_A_LOCATOR_SERVICE.toLocalizedString(), e);
}
}
use of org.apache.geode.internal.admin.remote.DistributionLocatorId in project geode by apache.
the class StartupMessageDataJUnitTest method createManyLocatorStrings.
private String[] createManyLocatorStrings(int n) throws Exception {
String[] locatorStrings = new String[3];
for (int i = 0; i < 3; i++) {
int j = i + 1;
int k = j + 1;
int l = k + 1;
DistributionLocatorId locatorId = new DistributionLocatorId(SocketCreator.getLocalHost(), 445566, "" + i + "" + i + "" + i + "." + j + "" + j + "" + j + "." + k + "" + k + "" + k + "." + l + "" + l + "" + l, null);
locatorStrings[i] = locatorId.marshal();
}
return locatorStrings;
}
use of org.apache.geode.internal.admin.remote.DistributionLocatorId in project geode by apache.
the class StartupMessageDataJUnitTest method createOneLocatorString.
private String createOneLocatorString() throws Exception {
DistributionLocatorId locatorId = new DistributionLocatorId(SocketCreator.getLocalHost(), 445566, "111.222.333.444", null);
String locatorString = locatorId.marshal();
assertEquals("" + locatorId.getHost().getHostAddress() + ":111.222.333.444[445566]", locatorString);
return locatorString;
}
use of org.apache.geode.internal.admin.remote.DistributionLocatorId in project geode by apache.
the class WanLocatorDiscovererImpl method buildRemoteDSJoinRequest.
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;
}
Aggregations