Package com.netflix.discovery
Interface EurekaClient
-
- All Superinterfaces:
LookupService
- All Known Implementing Classes:
DiscoveryClient
public interface EurekaClient extends LookupService
Define a simple interface over the current DiscoveryClient implementation. This interface does NOT try to clean up the current client interface for eureka 1.x. Rather it tries to provide an easier transition path from eureka 1.x to eureka 2.x. EurekaClient API contracts are: - provide the ability to get InstanceInfo(s) (in various different ways) - provide the ability to get data about the local Client (known regions, own AZ etc) - provide the ability to register and access the healthcheck handler for the client
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description java.util.Set<java.lang.String>getAllKnownRegions()ApplicationInfoManagergetApplicationInfoManager()ApplicationsgetApplications(java.lang.String serviceUrl)Get all applications registered with a specific eureka service.ApplicationsgetApplicationsForARegion(java.lang.String region)java.util.List<java.lang.String>getDiscoveryServiceUrls(java.lang.String zone)Deprecated.seeEndpointUtilsfor replacement Get the list of all eureka service urls for the eureka client to talk to.EurekaClientConfiggetEurekaClientConfig()HealthCheckHandlergetHealthCheckHandler()InstanceInfo.InstanceStatusgetInstanceRemoteStatus()java.util.List<InstanceInfo>getInstancesByVipAddress(java.lang.String vipAddress, boolean secure)Gets the list of instances matching the given VIP Address.java.util.List<InstanceInfo>getInstancesByVipAddress(java.lang.String vipAddress, boolean secure, java.lang.String region)Gets the list of instances matching the given VIP Address in the passed region.java.util.List<InstanceInfo>getInstancesByVipAddressAndAppName(java.lang.String vipAddress, java.lang.String appName, boolean secure)Gets the list of instances matching the given VIP Address and the given application name if both of them are not null.java.util.List<java.lang.String>getServiceUrlsFromConfig(java.lang.String instanceZone, boolean preferSameZone)Deprecated.seeEndpointUtilsfor replacement Get the list of all eureka service urls from properties file for the eureka client to talk to.java.util.List<java.lang.String>getServiceUrlsFromDNS(java.lang.String instanceZone, boolean preferSameZone)Deprecated.seeEndpointUtilsfor replacement Get the list of all eureka service urls from DNS for the eureka client to talk to.voidregisterEventListener(EurekaEventListener eventListener)RegisterEurekaEventListenerwith the eureka client.voidregisterHealthCheck(HealthCheckHandler healthCheckHandler)RegisterHealthCheckHandlerwith the eureka client.voidregisterHealthCheckCallback(HealthCheckCallback callback)Deprecated.voidshutdown()Shuts down Eureka Client.booleanunregisterEventListener(EurekaEventListener eventListener)Unregister aEurekaEventListenerprevious registered withregisterEventListener(com.netflix.discovery.EurekaEventListener)or injected into the constructor ofDiscoveryClient-
Methods inherited from interface com.netflix.discovery.shared.LookupService
getApplication, getApplications, getInstancesById, getNextServerFromEureka
-
-
-
-
Method Detail
-
getApplicationsForARegion
Applications getApplicationsForARegion(@Nullable java.lang.String region)
- Parameters:
region- the region that the Applications reside in- Returns:
- an
Applicationsfor the matching region. a Null value is treated as the local region.
-
getApplications
Applications getApplications(java.lang.String serviceUrl)
Get all applications registered with a specific eureka service.- Parameters:
serviceUrl- The string representation of the service url.- Returns:
- The registry information containing all applications.
-
getInstancesByVipAddress
java.util.List<InstanceInfo> getInstancesByVipAddress(java.lang.String vipAddress, boolean secure)
Gets the list of instances matching the given VIP Address.- Parameters:
vipAddress- The VIP address to match the instances for.secure- true if it is a secure vip address, false otherwise- Returns:
- - The list of
InstanceInfoobjects matching the criteria
-
getInstancesByVipAddress
java.util.List<InstanceInfo> getInstancesByVipAddress(java.lang.String vipAddress, boolean secure, @Nullable java.lang.String region)
Gets the list of instances matching the given VIP Address in the passed region.- Parameters:
vipAddress- The VIP address to match the instances for.secure- true if it is a secure vip address, false otherwiseregion- region from which the instances are to be fetched. Ifnullthen local region is assumed.- Returns:
- - The list of
InstanceInfoobjects matching the criteria, empty list if not instances found.
-
getInstancesByVipAddressAndAppName
java.util.List<InstanceInfo> getInstancesByVipAddressAndAppName(java.lang.String vipAddress, java.lang.String appName, boolean secure)
Gets the list of instances matching the given VIP Address and the given application name if both of them are not null. If one of them is null, then that criterion is completely ignored for matching instances.- Parameters:
vipAddress- The VIP address to match the instances for.appName- The applicationName to match the instances for.secure- true if it is a secure vip address, false otherwise.- Returns:
- - The list of
InstanceInfoobjects matching the criteria.
-
getAllKnownRegions
java.util.Set<java.lang.String> getAllKnownRegions()
- Returns:
- in String form all regions (local + remote) that can be accessed by this client
-
getInstanceRemoteStatus
InstanceInfo.InstanceStatus getInstanceRemoteStatus()
- Returns:
- the current self instance status as seen on the Eureka server.
-
getDiscoveryServiceUrls
@Deprecated java.util.List<java.lang.String> getDiscoveryServiceUrls(java.lang.String zone)
Deprecated.seeEndpointUtilsfor replacement Get the list of all eureka service urls for the eureka client to talk to.- Parameters:
zone- the zone in which the client resides- Returns:
- The list of all eureka service urls for the eureka client to talk to.
-
getServiceUrlsFromConfig
@Deprecated java.util.List<java.lang.String> getServiceUrlsFromConfig(java.lang.String instanceZone, boolean preferSameZone)Deprecated.seeEndpointUtilsfor replacement Get the list of all eureka service urls from properties file for the eureka client to talk to.- Parameters:
instanceZone- 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
-
getServiceUrlsFromDNS
@Deprecated java.util.List<java.lang.String> getServiceUrlsFromDNS(java.lang.String instanceZone, boolean preferSameZone)Deprecated.seeEndpointUtilsfor replacement 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:
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.
-
registerHealthCheckCallback
@Deprecated void registerHealthCheckCallback(HealthCheckCallback callback)
Deprecated.UseregisterHealthCheck(com.netflix.appinfo.HealthCheckHandler)instead. RegisterHealthCheckCallbackwith the eureka client. Once registered, the eureka client will invoke theHealthCheckCallbackin intervals specified byEurekaClientConfig.getInstanceInfoReplicationIntervalSeconds().- Parameters:
callback- app specific healthcheck.
-
registerHealthCheck
void registerHealthCheck(HealthCheckHandler healthCheckHandler)
RegisterHealthCheckHandlerwith the eureka client. Once registered, the eureka client will first make an onDemand update of the registering instanceInfo by calling the newly registered healthcheck handler, and subsequently invoke theHealthCheckHandlerin intervals specified byEurekaClientConfig.getInstanceInfoReplicationIntervalSeconds().- Parameters:
healthCheckHandler- app specific healthcheck handler.
-
registerEventListener
void registerEventListener(EurekaEventListener eventListener)
RegisterEurekaEventListenerwith the eureka client. Once registered, the eureka client will invokeEurekaEventListener.onEvent(com.netflix.discovery.EurekaEvent)whenever there is a change in eureka client's internal state. Use this instead of polling the client for changes.EurekaEventListener.onEvent(com.netflix.discovery.EurekaEvent)is called from the context of an internal thread and must therefore return as quickly as possible without blocking.- Parameters:
eventListener-
-
unregisterEventListener
boolean unregisterEventListener(EurekaEventListener eventListener)
Unregister aEurekaEventListenerprevious registered withregisterEventListener(com.netflix.discovery.EurekaEventListener)or injected into the constructor ofDiscoveryClient- Parameters:
eventListener-- Returns:
- True if removed otherwise false if the listener was never registered.
-
getHealthCheckHandler
HealthCheckHandler getHealthCheckHandler()
- Returns:
- the current registered healthcheck handler
-
shutdown
void shutdown()
Shuts down Eureka Client. Also sends a deregistration request to the eureka server.
-
getEurekaClientConfig
EurekaClientConfig getEurekaClientConfig()
- Returns:
- the configuration of this eureka client
-
getApplicationInfoManager
ApplicationInfoManager getApplicationInfoManager()
- Returns:
- the application info manager of this eureka client
-
-