congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
com.netflix.discovery.endpoint
Code IndexAdd Tabnine to your IDE (free)

How to use com.netflix.discovery.endpoint

Best Java code snippets using com.netflix.discovery.endpoint (Showing top 20 results out of 315)

origin: Netflix/eureka

@Override
public String resolveIp(String hostName) {
  return DnsResolver.resolve(hostName);
}
origin: Netflix/eureka

private Collection<String> getIPsForZoneFromDNS(String myZone) {
  return EndpointUtils.getServiceUrlsFromDNS(
      clientConfig,
      myZone,
      true,
      new EndpointUtils.InstanceInfoBasedUrlRandomizer(applicationInfoManager.getInfo())
  );
}
origin: Netflix/eureka

/**
 * @deprecated see replacement in {@link com.netflix.discovery.endpoint.EndpointUtils}
 */
@Deprecated
@Override
public List<String> getDiscoveryServiceUrls(String zone) {
  return EndpointUtils.getDiscoveryServiceUrls(clientConfig, zone, urlRandomizer);
}
origin: Netflix/eureka

/**
 * Resolve peer URLs.
 *
 * @return peer URLs with node's own URL filtered out
 */
protected List<String> resolvePeerUrls() {
  InstanceInfo myInfo = applicationInfoManager.getInfo();
  String zone = InstanceInfo.getZone(clientConfig.getAvailabilityZones(clientConfig.getRegion()), myInfo);
  List<String> replicaUrls = EndpointUtils
      .getDiscoveryServiceUrls(clientConfig, zone, new EndpointUtils.InstanceInfoBasedUrlRandomizer(myInfo));
  int idx = 0;
  while (idx < replicaUrls.size()) {
    if (isThisMyUrl(replicaUrls.get(idx))) {
      replicaUrls.remove(idx);
    } else {
      idx++;
    }
  }
  return replicaUrls;
}
origin: Netflix/eureka

/**
 * Get the list of all eureka service urls for the eureka client to talk to.
 *
 * @param clientConfig the clientConfig to use
 * @param zone the zone in which the client resides
 * @param randomizer a randomizer to randomized returned urls, if loading from dns
 *
 * @return The list of all eureka service urls for the eureka client to talk to.
 */
public static List<String> getDiscoveryServiceUrls(EurekaClientConfig clientConfig, String zone, ServiceUrlRandomizer randomizer) {
  boolean shouldUseDns = clientConfig.shouldUseDnsForFetchingServiceUrls();
  if (shouldUseDns) {
    return getServiceUrlsFromDNS(clientConfig, zone, clientConfig.shouldPreferSameZoneEureka(), randomizer);
  }
  return getServiceUrlsFromConfig(clientConfig, zone, clientConfig.shouldPreferSameZoneEureka());
}
origin: Netflix/eureka

/**
 * @deprecated see replacement in {@link com.netflix.discovery.endpoint.EndpointUtils}
 *
 * Get the list of all eureka service urls from DNS for the eureka client to
 * talk to. The client picks up the service url from its zone and then fails over to
 * other zones randomly. If there are multiple servers in the same zone, the client once
 * again picks one randomly. This way the traffic will be distributed in the case of failures.
 *
 * @param instanceZone The zone in which the client resides.
 * @param preferSameZone true if we have to prefer the same zone as the client, false otherwise.
 * @return The list of all eureka service urls for the eureka client to talk to.
 */
@Deprecated
@Override
public List<String> getServiceUrlsFromDNS(String instanceZone, boolean preferSameZone) {
  return EndpointUtils.getServiceUrlsFromDNS(clientConfig, instanceZone, preferSameZone, urlRandomizer);
}
origin: Netflix/eureka

dnsName = "txt." + dnsName;
logger.debug("The zone url to be looked up is {} :", dnsName);
Set<String> ec2UrlsForZone = DnsResolver.getCNamesFromTxtRecord(dnsName);
for (String ec2Url : ec2UrlsForZone) {
  logger.debug("The eureka url for the dns name {} is {}", dnsName, ec2Url);
  ec2UrlsForZone.add(ec2Url);
if (DiscoveryUrlType.CNAME.equals(type)) {
  return ec2UrlsForZone;
origin: Netflix/eureka

if (isLocalOrIp(currentHost)) {
  return originalHost;
  String targetHost = null;
  do {
    Attributes attrs = getDirContext().getAttributes(currentHost, new String[]{A_RECORD_TYPE, CNAME_RECORD_TYPE});
    Attribute attr = attrs.get(A_RECORD_TYPE);
    if (attr != null) {
origin: Netflix/eureka

Set<String> zoneCnamesForRegion = new TreeSet<String>(DnsResolver.getCNamesFromTxtRecord(discoveryDnsName));
Map<String, List<String>> zoneCnameMapForRegion = new TreeMap<String, List<String>>();
for (String zoneCname : zoneCnamesForRegion) {
  String zone = null;
  if (isEC2Url(zoneCname)) {
    throw new RuntimeException(
        "Cannot find the right DNS entry for "
origin: Netflix/eureka

String region = getRegion(clientConfig);
String[] availZones = clientConfig.getAvailabilityZones(clientConfig.getRegion());
if (availZones == null || availZones.length == 0) {
int myZoneOffset = getZoneOffset(instanceZone, preferSameZone, availZones);
origin: Netflix/eureka

/**
 * @deprecated use {@link #getServiceUrlsFromConfig(String, boolean)} instead.
 */
@Deprecated
public static List<String> getEurekaServiceUrlsFromConfig(String instanceZone, boolean preferSameZone) {
  return EndpointUtils.getServiceUrlsFromConfig(staticClientConfig, instanceZone, preferSameZone);
}
origin: Netflix/eureka

  @Nullable
  @Override
  public List<String> resolveARecord(String rootDomainName) {
    return DnsResolver.resolveARecord(rootDomainName);
  }
}
origin: Netflix/eureka

/**
 * @deprecated see replacement in {@link com.netflix.discovery.endpoint.EndpointUtils}
 *
 * Get the list of EC2 URLs given the zone name.
 *
 * @param dnsName The dns name of the zone-specific CNAME
 * @param type CNAME or EIP that needs to be retrieved
 * @return The list of EC2 URLs associated with the dns name
 */
@Deprecated
public static Set<String> getEC2DiscoveryUrlsFromZone(String dnsName,
                           EndpointUtils.DiscoveryUrlType type) {
  return EndpointUtils.getEC2DiscoveryUrlsFromZone(dnsName, type);
}
origin: Netflix/eureka

  private static Set<String> resolve(String rootClusterDNS) throws NamingException {
    Set<String> result;
    try {
      result = DnsResolver.getCNamesFromTxtRecord(rootClusterDNS);
      if (!rootClusterDNS.startsWith("txt.")) {
        result = DnsResolver.getCNamesFromTxtRecord("txt." + rootClusterDNS);
      }
    } catch (NamingException e) {
      if (!rootClusterDNS.startsWith("txt.")) {
        result = DnsResolver.getCNamesFromTxtRecord("txt." + rootClusterDNS);
      } else {
        throw e;
      }
    }
    return result;
  }
}
origin: Netflix/eureka

  @Override
  protected Set<String> getZonesForARegion(String region) {
    Map<String, List<String>> zoneBasedDiscoveryUrlsFromRegion = EndpointUtils
        .getZoneBasedDiscoveryUrlsFromRegion(clientConfig, region);
    if (null != zoneBasedDiscoveryUrlsFromRegion) {
      return zoneBasedDiscoveryUrlsFromRegion.keySet();
    }

    return Collections.emptySet();
  }
}
origin: Netflix/eureka

  /**
   * Looks up the DNS name provided in the JNDI context.
   */
  public static Set<String> getCNamesFromTxtRecord(String discoveryDnsName) throws NamingException {
    Attributes attrs = getDirContext().getAttributes(discoveryDnsName, new String[]{TXT_RECORD_TYPE});
    Attribute attr = attrs.get(TXT_RECORD_TYPE);
    String txtRecord = null;
    if (attr != null) {
      txtRecord = attr.get().toString();

      /**
       * compatible splited txt record of "host1 host2 host3" but not "host1" "host2" "host3".
       * some dns service provider support txt value only format "host1 host2 host3"
       */
      if (txtRecord.startsWith("\"") && txtRecord.endsWith("\"")) {
        txtRecord = txtRecord.substring(1, txtRecord.length() - 1);
      }
    }

    Set<String> cnamesSet = new TreeSet<String>();
    if (txtRecord == null || txtRecord.trim().isEmpty()) {
      return cnamesSet;
    }
    String[] cnames = txtRecord.split(" ");
    Collections.addAll(cnamesSet, cnames);
    return cnamesSet;
  }
}
origin: Netflix/eureka

private List<AwsEndpoint> getClusterEndpointsFromConfig() {
  String[] availZones = clientConfig.getAvailabilityZones(clientConfig.getRegion());
  String myZone = InstanceInfo.getZone(availZones, myInstanceInfo);
  Map<String, List<String>> serviceUrls = EndpointUtils
      .getServiceUrlsMapFromConfig(clientConfig, myZone, clientConfig.shouldPreferSameZoneEureka());
  List<AwsEndpoint> endpoints = new ArrayList<>();
  for (String zone : serviceUrls.keySet()) {
    for (String url : serviceUrls.get(zone)) {
      try {
        endpoints.add(new AwsEndpoint(url, getRegion(), zone));
      } catch (Exception ignore) {
        logger.warn("Invalid eureka server URI: {}; removing from the server pool", url);
      }
    }
  }
  logger.debug("Config resolved to {}", endpoints);
  if (endpoints.isEmpty()) {
    logger.error("Cannot resolve to any endpoints from provided configuration: {}", serviceUrls);
  }
  return endpoints;
}
origin: Netflix/eureka

/**
 * Get the list of EIPS from the DNS.
 *
 * <p>
 * This mechanism looks for the EIP pool in the zone the instance is in by
 * looking up the DNS name <code>{zone}.{region}.{domainName}</code>. The
 * zone is fetched from the {@link InstanceInfo} object;the region is picked
 * up from the specified configuration
 * {@link com.netflix.discovery.EurekaClientConfig#getRegion()};the domain name is picked up from
 * the specified configuration {@link com.netflix.discovery.EurekaClientConfig#getEurekaServerDNSName()}
 * with a "txt." prefix (see {@link com.netflix.discovery.endpoint.EndpointUtils
 * #getZoneBasedDiscoveryUrlsFromRegion(com.netflix.discovery.EurekaClientConfig, String)}.
 * </p>
 *
 * @param myZone
 *            the zone where this instance exist in.
 * @return the collection of EIPs that exist in the zone this instance is
 *         in.
 */
private Collection<String> getEIPsForZoneFromDNS(String myZone) {
  List<String> ec2Urls = EndpointUtils.getServiceUrlsFromDNS(
      clientConfig,
      myZone,
      true,
      new EndpointUtils.InstanceInfoBasedUrlRandomizer(applicationInfoManager.getInfo())
  );
  return getEIPsFromServiceUrls(ec2Urls);
}
origin: Netflix/eureka

/**
 * @deprecated see replacement in {@link com.netflix.discovery.endpoint.EndpointUtils}
 *
 * Get the list of all eureka service urls from properties file for the eureka client to talk to.
 *
 * @param instanceZone The zone in which the client resides
 * @param preferSameZone true if we have to prefer the same zone as the client, false otherwise
 * @return The list of all eureka service urls for the eureka client to talk to
 */
@Deprecated
@Override
public List<String> getServiceUrlsFromConfig(String instanceZone, boolean preferSameZone) {
  return EndpointUtils.getServiceUrlsFromConfig(clientConfig, instanceZone, preferSameZone);
}
origin: Netflix/eureka

  private List<AwsEndpoint> createEurekaEndpointsFromConfig() {
    List<String> serviceUrls = EndpointUtils.getServiceUrlsFromConfig(clientConfig, myZone, clientConfig.shouldPreferSameZoneEureka());
    List<AwsEndpoint> endpoints = new ArrayList<>(serviceUrls.size());
    for (String serviceUrl : serviceUrls) {
      try {
        URI serviceURI = new URI(serviceUrl);
        endpoints.add(new AwsEndpoint(
            serviceURI.getHost(),
            serviceURI.getPort(),
            "https".equalsIgnoreCase(serviceURI.getSchemeSpecificPart()),
            serviceURI.getPath(),
            myRegion,
            myZone
        ));
      } catch (URISyntaxException ignore) {
        logger.warn("Invalid eureka server URI: {}; removing from the server pool", serviceUrl);
      }
    }
    return endpoints;
  }
}
com.netflix.discovery.endpoint

Most used classes

  • EndpointUtils$InstanceInfoBasedUrlRandomizer
  • EndpointUtils
    This class contains some of the utility functions previously found in DiscoveryClient, but should be
  • DnsResolver
  • EndpointUtils$DiscoveryUrlType
  • EndpointUtils$ServiceUrlRandomizer
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now