Search in sources :

Example 1 with ClusterResolverException

use of com.netflix.discovery.shared.resolver.ClusterResolverException in project eureka by Netflix.

the class DnsTxtRecordClusterResolver method resolve.

private static List<AwsEndpoint> resolve(String region, String rootClusterDNS, boolean extractZone, int port, boolean isSecure, String relativeUri) {
    try {
        Set<String> zoneDomainNames = resolve(rootClusterDNS);
        if (zoneDomainNames.isEmpty()) {
            throw new ClusterResolverException("Cannot resolve Eureka cluster addresses; there are no data in TXT record for DN " + rootClusterDNS);
        }
        List<AwsEndpoint> endpoints = new ArrayList<>();
        for (String zoneDomain : zoneDomainNames) {
            String zone = extractZone ? ResolverUtils.extractZoneFromHostName(zoneDomain) : null;
            Set<String> zoneAddresses = resolve(zoneDomain);
            for (String address : zoneAddresses) {
                endpoints.add(new AwsEndpoint(address, port, isSecure, relativeUri, region, zone));
            }
        }
        return endpoints;
    } catch (NamingException e) {
        throw new ClusterResolverException("Cannot resolve Eureka cluster addresses for root: " + rootClusterDNS, e);
    }
}
Also used : ClusterResolverException(com.netflix.discovery.shared.resolver.ClusterResolverException) ArrayList(java.util.ArrayList) NamingException(javax.naming.NamingException)

Aggregations

ClusterResolverException (com.netflix.discovery.shared.resolver.ClusterResolverException)1 ArrayList (java.util.ArrayList)1 NamingException (javax.naming.NamingException)1