com.netflix.discovery
Interface EurekaClientConfig

All Known Implementing Classes:
DefaultEurekaClientConfig

public interface EurekaClientConfig

Configuration information required by the eureka clients to register an instance with Eureka server.

Most of the required information is provided by the default configuration DefaultEurekaClientConfig. The users just need to provide the eureka server service urls. The Eureka server service urls can be configured by 2 mechanisms 1) By registering the information in the DNS. 2) By specifying it in the configuration.

Once the client is registered, users can look up information from DiscoveryClient based on virtual hostname (also called VIPAddress), the most common way of doing it or by other means to get the information necessary to talk to other instances registered with Eureka.

Note that all configurations are not effective at runtime unless and otherwise specified.


Method Summary
 java.lang.String fetchRegistryForRemoteRegions()
          Comma separated list of regions for which the eureka registry information will be fetched.
 java.lang.String[] getAvailabilityZones(java.lang.String region)
          Gets the list of availability zones (used in AWS data centers) for the region in which this instance resides.
 java.lang.String getBackupRegistryImpl()
          Gets the name of the implementation which implements BackupRegistry to fetch the registry information as a fall back option for only the first time when the eureka client starts.
 int getEurekaConnectionIdleTimeoutSeconds()
          Indicates how much time (in seconds) that the HTTP connections to eureka server can stay idle before it can be closed.
 int getEurekaServerConnectTimeoutSeconds()
          Indicates how long to wait (in seconds) before a connection to eureka server needs to timeout.
 java.lang.String getEurekaServerDNSName()
          Gets the DNS name to be queried to get the list of eureka servers.This information is not required if the contract returns the service urls by implementing getEurekaServerServiceUrls(String).
 java.lang.String getEurekaServerPort()
          Gets the port to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS.This information is not required if the contract returns the service urls by implementing getEurekaServerServiceUrls(String).
 int getEurekaServerReadTimeoutSeconds()
          Indicates how long to wait (in seconds) before a read from eureka server needs to timeout.
 java.util.List<java.lang.String> getEurekaServerServiceUrls(java.lang.String myZone)
          Gets the list of fully qualified URLs to communicate with eureka server.
 int getEurekaServerTotalConnections()
          Gets the total number of connections that is allowed from eureka client to all eureka servers.
 int getEurekaServerTotalConnectionsPerHost()
          Gets the total number of connections that is allowed from eureka client to a eureka server host.
 java.lang.String getEurekaServerURLContext()
          Gets the URL context to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS.This information is not required if the contract returns the service urls by implementing getEurekaServerServiceUrls(String).
 int getEurekaServiceUrlPollIntervalSeconds()
          Indicates how often(in seconds) to poll for changes to eureka server information.
 int getInstanceInfoReplicationIntervalSeconds()
          Indicates how often(in seconds) to replicate instance changes to be replicated to the eureka server.
 java.lang.String getProxyHost()
          Gets the proxy host to eureka server if any.
 java.lang.String getProxyPort()
          Gets the proxy port to eureka server if any.
 java.lang.String getRegion()
          Gets the region (used in AWS datacenters) where this instance resides.
 int getRegistryFetchIntervalSeconds()
          Indicates how often(in seconds) to fetch the registry information from the eureka server.
 boolean shouldDisableDelta()
          Indicates whether the eureka client should disable fetching of delta and should rather resort to getting the full registry information.
 boolean shouldFetchRegistry()
          Indicates whether this client should fetch eureka registry information from eureka server.
 boolean shouldFilterOnlyUpInstances()
          Indicates whether to get the applications after filtering the applications for instances with only InstanceInfo.InstanceStatus.UP states.
 boolean shouldGZipContent()
          Indicates whether the content fetched from eureka server has to be compressed whenever it is supported by the server.
 boolean shouldLogDeltaDiff()
          Indicates whether to log differences between the eureka server and the eureka client in terms of registry information.
 boolean shouldPreferSameZoneEureka()
          Indicates whether or not this instance should try to use the eureka server in the same zone for latency and/or other reason.
 boolean shouldRegisterWithEureka()
          Indicates whether or not this instance should register its information with eureka server for discovery by others.
 boolean shouldUseDnsForFetchingServiceUrls()
          Indicates whether the eureka client should use the DNS mechanism to fetch a list of eureka servers to talk to.
 

Method Detail

getRegistryFetchIntervalSeconds

int getRegistryFetchIntervalSeconds()
Indicates how often(in seconds) to fetch the registry information from the eureka server.

Returns:
the fetch interval in seconds.

getInstanceInfoReplicationIntervalSeconds

int getInstanceInfoReplicationIntervalSeconds()
Indicates how often(in seconds) to replicate instance changes to be replicated to the eureka server.

Returns:
the instance replication interval in seconds.

getEurekaServiceUrlPollIntervalSeconds

int getEurekaServiceUrlPollIntervalSeconds()
Indicates how often(in seconds) to poll for changes to eureka server information.

Eureka servers could be added or removed and this setting controls how soon the eureka clients should know about it.

Returns:
the interval to poll for eureka service url changes.

getProxyHost

java.lang.String getProxyHost()
Gets the proxy host to eureka server if any.

Returns:
the proxy host.

getProxyPort

java.lang.String getProxyPort()
Gets the proxy port to eureka server if any.

Returns:
the proxy port.

shouldGZipContent

boolean shouldGZipContent()
Indicates whether the content fetched from eureka server has to be compressed whenever it is supported by the server. The registry information from the eureka server is compressed for optimum network traffic.

Returns:
true, if the content need to be compressed, false otherwise.

getEurekaServerReadTimeoutSeconds

int getEurekaServerReadTimeoutSeconds()
Indicates how long to wait (in seconds) before a read from eureka server needs to timeout.

Returns:
time in seconds before the read should timeout.

getEurekaServerConnectTimeoutSeconds

int getEurekaServerConnectTimeoutSeconds()
Indicates how long to wait (in seconds) before a connection to eureka server needs to timeout.

Note that the connections in the client are pooled by HttpClient and this setting affects the actual connection creation and also the wait time to get the connection from the pool.

Returns:
time in seconds before the connections should timeout.

getBackupRegistryImpl

java.lang.String getBackupRegistryImpl()
Gets the name of the implementation which implements BackupRegistry to fetch the registry information as a fall back option for only the first time when the eureka client starts.

This may be needed for applications which needs additional resiliency for registry information without which it cannot operate.

Returns:
the class name which implements BackupRegistry.

getEurekaServerTotalConnections

int getEurekaServerTotalConnections()
Gets the total number of connections that is allowed from eureka client to all eureka servers.

Returns:
total number of allowed connections from eureka client to all eureka servers.

getEurekaServerTotalConnectionsPerHost

int getEurekaServerTotalConnectionsPerHost()
Gets the total number of connections that is allowed from eureka client to a eureka server host.

Returns:
total number of allowed connections from eureka client to a eureka server.

getEurekaServerURLContext

java.lang.String getEurekaServerURLContext()
Gets the URL context to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS.This information is not required if the contract returns the service urls by implementing getEurekaServerServiceUrls(String).

The DNS mechanism is used when shouldUseDnsForFetchingServiceUrls() is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically.

The changes are effective at runtime.

Returns:
the string indicating the context URI of the eureka server.

getEurekaServerPort

java.lang.String getEurekaServerPort()
Gets the port to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS.This information is not required if the contract returns the service urls by implementing getEurekaServerServiceUrls(String).

The DNS mechanism is used when shouldUseDnsForFetchingServiceUrls() is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically.

The changes are effective at runtime.

Returns:
the string indicating the port where the eureka server is listening.

getEurekaServerDNSName

java.lang.String getEurekaServerDNSName()
Gets the DNS name to be queried to get the list of eureka servers.This information is not required if the contract returns the service urls by implementing getEurekaServerServiceUrls(String).

The DNS mechanism is used when shouldUseDnsForFetchingServiceUrls() is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically.

The changes are effective at runtime.

Returns:
the string indicating the DNS name to be queried for eureka servers.

shouldUseDnsForFetchingServiceUrls

boolean shouldUseDnsForFetchingServiceUrls()
Indicates whether the eureka client should use the DNS mechanism to fetch a list of eureka servers to talk to. When the DNS name is updated to have additional servers, that information is used immediately after the eureka client polls for that information as specified in getEurekaServiceUrlPollIntervalSeconds().

Alternatively, the service urls can be returned getEurekaServerServiceUrls(String), but the users should implement their own mechanism to return the updated list in case of changes.

The changes are effective at runtime.

Returns:
true if the DNS mechanism should be used for fetching urls, false otherwise.

shouldRegisterWithEureka

boolean shouldRegisterWithEureka()
Indicates whether or not this instance should register its information with eureka server for discovery by others.

In some cases, you do not want your instances to be discovered whereas you just want do discover other instances.

Returns:
true if this instance should register with eureka, false otherwise

shouldPreferSameZoneEureka

boolean shouldPreferSameZoneEureka()
Indicates whether or not this instance should try to use the eureka server in the same zone for latency and/or other reason.

Ideally eureka clients are configured to talk to servers in the same zone

The changes are effective at runtime at the next registry fetch cycle as specified by getRegistryFetchIntervalSeconds()

Returns:
true if the eureka client should prefer the server in the same zone, false otherwise.

shouldLogDeltaDiff

boolean shouldLogDeltaDiff()
Indicates whether to log differences between the eureka server and the eureka client in terms of registry information.

Eureka client tries to retrieve only delta changes from eureka server to minimize network traffic. After receiving the deltas, eureka client reconciles the information from the server to verify it has not missed out some information. Reconciliation failures could happen when the client has had network issues communicating to server.If the reconciliation fails, eureka client gets the full registry information.

While getting the full registry information, the eureka client can log the differences between the client and the server and this setting controls that.

The changes are effective at runtime at the next registry fetch cycle as specified by getRegistryFetchIntervalSeconds()

Returns:
true if the eureka client should log delta differences in the case of reconciliation failure.

shouldDisableDelta

boolean shouldDisableDelta()
Indicates whether the eureka client should disable fetching of delta and should rather resort to getting the full registry information.

Note that the delta fetches can reduce the traffic tremendously, because the rate of change with the eureka server is normally much lower than the rate of fetches.

The changes are effective at runtime at the next registry fetch cycle as specified by getRegistryFetchIntervalSeconds()

Returns:
true to enable fetching delta information for registry, false to get the full registry.

fetchRegistryForRemoteRegions

@Nullable
java.lang.String fetchRegistryForRemoteRegions()
Comma separated list of regions for which the eureka registry information will be fetched. It is mandatory to define the availability zones for each of these regions as returned by getAvailabilityZones(String). Failing to do so, will result in failure of discovery client startup.

Returns:
Comma separated list of regions for which the eureka registry information will be fetched. null if no remote region has to be fetched.

getRegion

java.lang.String getRegion()
Gets the region (used in AWS datacenters) where this instance resides.

Returns:
AWS region where this instance resides.

getAvailabilityZones

java.lang.String[] getAvailabilityZones(java.lang.String region)
Gets the list of availability zones (used in AWS data centers) for the region in which this instance resides.

The changes are effective at runtime at the next registry fetch cycle as specified by getRegistryFetchIntervalSeconds()

Parameters:
region - the region where this instance is deployed.
Returns:
the list of available zones accessible by this instance.

getEurekaServerServiceUrls

java.util.List<java.lang.String> getEurekaServerServiceUrls(java.lang.String myZone)
Gets the list of fully qualified URLs to communicate with eureka server.

Typically the eureka server URLs carry protocol,host,port,context and version information if any. Example: http://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/v2/

The changes are effective at runtime at the next service url refresh cycle as specified by getEurekaServiceUrlPollIntervalSeconds()

Parameters:
myZone - the zone in which the instance is deployed.
Returns:
the list of eureka server service urls for eureka clients to talk to.

shouldFilterOnlyUpInstances

boolean shouldFilterOnlyUpInstances()
Indicates whether to get the applications after filtering the applications for instances with only InstanceInfo.InstanceStatus.UP states.

The changes are effective at runtime at the next registry fetch cycle as specified by getRegistryFetchIntervalSeconds()

Returns:
true to filter, false otherwise.

getEurekaConnectionIdleTimeoutSeconds

int getEurekaConnectionIdleTimeoutSeconds()
Indicates how much time (in seconds) that the HTTP connections to eureka server can stay idle before it can be closed.

In the AWS environment, it is recommended that the values is 30 seconds or less, since the firewall cleans up the connection information after a few mins leaving the connection hanging in limbo

Returns:
time in seconds the connections to eureka can stay idle before it can be closed.

shouldFetchRegistry

boolean shouldFetchRegistry()
Indicates whether this client should fetch eureka registry information from eureka server.

Returns:
true if registry information has to be fetched, false otherwise.