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 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 LocatorHelper method addExchangedLocators.
/**
* This method adds the map of locatorsinfo sent by other locator to this locator's allLocatorInfo
*
* @param locators
* @param locatorListener
*/
public static boolean addExchangedLocators(Map<Integer, Set<DistributionLocatorId>> locators, LocatorMembershipListener locatorListener) {
ConcurrentHashMap<Integer, Set<DistributionLocatorId>> allLocators = (ConcurrentHashMap<Integer, Set<DistributionLocatorId>>) locatorListener.getAllLocatorsInfo();
if (!allLocators.equals(locators)) {
for (Map.Entry<Integer, Set<DistributionLocatorId>> entry : locators.entrySet()) {
Set<DistributionLocatorId> existingValue = allLocators.putIfAbsent(entry.getKey(), new CopyOnWriteHashSet<DistributionLocatorId>(entry.getValue()));
if (existingValue != null) {
Set<DistributionLocatorId> localLocators = allLocators.get(entry.getKey());
if (!localLocators.equals(entry.getValue())) {
entry.getValue().removeAll(localLocators);
for (DistributionLocatorId locator : entry.getValue()) {
localLocators.add(locator);
addServerLocator(entry.getKey(), locatorListener, locator);
locatorListener.locatorJoined(entry.getKey(), locator, null);
}
}
} else {
for (DistributionLocatorId locator : entry.getValue()) {
addServerLocator(entry.getKey(), locatorListener, locator);
locatorListener.locatorJoined(entry.getKey(), locator, null);
}
}
}
return true;
}
return false;
}
use of org.apache.geode.internal.admin.remote.DistributionLocatorId in project geode by apache.
the class LocatorMembershipListenerImpl method updateAllLocatorInfo.
/**
* A locator from the request is checked against the existing remote locator metadata. If it is
* not available then added to existing remote locator metadata and LocatorMembershipListener is
* invoked to inform about the this newly added locator to all other locators available in remote
* locator metadata. As a response, remote locator metadata is sent.
*
* @param request
*/
private synchronized Object updateAllLocatorInfo(RemoteLocatorJoinRequest request) {
int distributedSystemId = request.getDistributedSystemId();
DistributionLocatorId locator = request.getLocator();
LocatorHelper.addLocator(distributedSystemId, locator, this, null);
return new RemoteLocatorJoinResponse(this.getAllLocatorsInfo());
}
Aggregations