Package com.netflix.discovery.endpoint
Class EndpointUtils
- java.lang.Object
-
- com.netflix.discovery.endpoint.EndpointUtils
-
public class EndpointUtils extends java.lang.ObjectThis class contains some of the utility functions previously found in DiscoveryClient, but should be elsewhere. It *does not yet* clean up the moved code.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEndpointUtils.DiscoveryUrlTypestatic classEndpointUtils.InstanceInfoBasedUrlRandomizerstatic interfaceEndpointUtils.ServiceUrlRandomizer
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_REGIONstatic java.lang.StringDEFAULT_ZONE
-
Constructor Summary
Constructors Constructor Description EndpointUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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.static java.lang.StringgetRegion(EurekaClientConfig clientConfig)Get the region that this particular instance is in.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.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.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.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.
-
-
-
Field Detail
-
DEFAULT_REGION
public static final java.lang.String DEFAULT_REGION
- See Also:
- Constant Field Values
-
DEFAULT_ZONE
public static final java.lang.String DEFAULT_ZONE
- See Also:
- Constant Field Values
-
-
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 usezone- the zone in which the client residesrandomizer- 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 useinstanceZone- 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 useinstanceZone- The zone in which the client residespreferSameZone- 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 useinstanceZone- The zone in which the client residespreferSameZone- 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 CNAMEtype- 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.
-
-