Search in sources :

Example 1 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 2 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 3 with DistributionLocatorId

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

Example 4 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 5 with DistributionLocatorId

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;
}
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