Search in sources :

Example 6 with DistributionLocatorId

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;
}
Also used : DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId)

Example 7 with DistributionLocatorId

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();
}
Also used : StringTokenizer(java.util.StringTokenizer) DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) SortedSet(java.util.SortedSet)

Example 8 with DistributionLocatorId

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);
    }
}
Also used : DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) GemFireIOException(org.apache.geode.GemFireIOException) GemFireIOException(org.apache.geode.GemFireIOException) IOException(java.io.IOException)

Example 9 with DistributionLocatorId

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;
}
Also used : HashSet(java.util.HashSet) CopyOnWriteHashSet(org.apache.geode.internal.CopyOnWriteHashSet) Set(java.util.Set) DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 10 with DistributionLocatorId

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());
}
Also used : DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId)

Aggregations

DistributionLocatorId (org.apache.geode.internal.admin.remote.DistributionLocatorId)16 IOException (java.io.IOException)5 StringTokenizer (java.util.StringTokenizer)5 InetAddress (java.net.InetAddress)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 Set (java.util.Set)3 UnknownHostException (java.net.UnknownHostException)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 ConcurrentSkipListSet (java.util.concurrent.ConcurrentSkipListSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 LocatorMembershipListener (org.apache.geode.cache.client.internal.locator.wan.LocatorMembershipListener)2 Locator (org.apache.geode.distributed.Locator)2 InternalLocator (org.apache.geode.distributed.internal.InternalLocator)2 File (java.io.File)1 Serializable (java.io.Serializable)1 ConnectException (java.net.ConnectException)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1