Class EndpointUtils


  • public class EndpointUtils
    extends java.lang.Object
    This class contains some of the utility functions previously found in DiscoveryClient, but should be elsewhere. It *does not yet* clean up the moved code.
    • Constructor Detail

      • EndpointUtils

        public EndpointUtils()
    • Method Detail

      • getDiscoveryServiceUrls

        public static java.util.List<java.lang.String> getDiscoveryServiceUrls​(EurekaClientConfig clientConfig,
                                                                               java.lang.String zone,
                                                                               EndpointUtils.ServiceUrlRandomizer randomizer)
        Get the list of all eureka service urls for the eureka client to talk to.
        Parameters:
        clientConfig - the clientConfig to use
        zone - the zone in which the client resides
        randomizer - a randomizer to randomized returned urls, if loading from dns
        Returns:
        The list of all eureka service urls for the eureka client to talk to.
      • getServiceUrlsFromDNS

        public static java.util.List<java.lang.String> getServiceUrlsFromDNS​(EurekaClientConfig clientConfig,
                                                                             java.lang.String instanceZone,
                                                                             boolean preferSameZone,
                                                                             EndpointUtils.ServiceUrlRandomizer randomizer)
        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.
        Parameters:
        clientConfig - the clientConfig to use
        instanceZone - The zone in which the client resides.
        preferSameZone - true if we have to prefer the same zone as the client, false otherwise.
        randomizer - a randomizer to randomized returned urls
        Returns:
        The list of all eureka service urls for the eureka client to talk to.
      • getServiceUrlsFromConfig

        public static java.util.List<java.lang.String> getServiceUrlsFromConfig​(EurekaClientConfig clientConfig,
                                                                                java.lang.String instanceZone,
                                                                                boolean preferSameZone)
        Get the list of all eureka service urls from properties file for the eureka client to talk to.
        Parameters:
        clientConfig - the clientConfig to use
        instanceZone - The zone in which the client resides
        preferSameZone - true if we have to prefer the same zone as the client, false otherwise
        Returns:
        The list of all eureka service urls for the eureka client to talk to
      • getServiceUrlsMapFromConfig

        public static java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getServiceUrlsMapFromConfig​(EurekaClientConfig clientConfig,
                                                                                                                         java.lang.String instanceZone,
                                                                                                                         boolean preferSameZone)
        Get the list of all eureka service urls from properties file for the eureka client to talk to.
        Parameters:
        clientConfig - the clientConfig to use
        instanceZone - The zone in which the client resides
        preferSameZone - true if we have to prefer the same zone as the client, false otherwise
        Returns:
        an (ordered) map of zone -> list of urls mappings, with the preferred zone first in iteration order
      • getEC2DiscoveryUrlsFromZone

        public static java.util.Set<java.lang.String> getEC2DiscoveryUrlsFromZone​(java.lang.String dnsName,
                                                                                  EndpointUtils.DiscoveryUrlType type)
        Get the list of EC2 URLs given the zone name.
        Parameters:
        dnsName - The dns name of the zone-specific CNAME
        type - CNAME or EIP that needs to be retrieved
        Returns:
        The list of EC2 URLs associated with the dns name
      • getZoneBasedDiscoveryUrlsFromRegion

        public static java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getZoneBasedDiscoveryUrlsFromRegion​(EurekaClientConfig clientConfig,
                                                                                                                                 java.lang.String region)
        Get the zone based CNAMES that are bound to a region.
        Parameters:
        region - - The region for which the zone names need to be retrieved
        Returns:
        - The list of CNAMES from which the zone-related information can be retrieved
      • getRegion

        public static java.lang.String getRegion​(EurekaClientConfig clientConfig)
        Get the region that this particular instance is in.
        Returns:
        - The region in which the particular instance belongs to.