@Singleton public class DefaultEurekaClientConfig extends java.lang.Object implements EurekaClientConfig
EurekaClientConfig
.
The information required for configuring eureka client is provided in a configuration file.The configuration file is searched for in the classpath with the name specified by the property eureka.client.props and with the suffix .properties. If the property is not specified, eureka-client.properties is assumed as the default.The properties that are looked up uses the namespace passed on to this class.
If the eureka.environment property is specified, additionally
eureka-client-
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_NAMESPACE
Deprecated.
2016-08-29 use
CommonConstants.DEFAULT_CONFIG_NAMESPACE |
static java.lang.String |
DEFAULT_ZONE |
static java.lang.String |
URL_SEPARATOR |
Constructor and Description |
---|
DefaultEurekaClientConfig() |
DefaultEurekaClientConfig(java.lang.String namespace) |
Modifier and Type | Method and Description |
---|---|
boolean |
allowRedirects()
Indicates whether server can redirect a client request to a backup server/cluster.
|
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 |
getCacheRefreshExecutorExponentialBackOffBound()
Cache refresh executor exponential back off related property.
|
int |
getCacheRefreshExecutorThreadPoolSize()
(non-Javadoc)
|
java.lang.String |
getClientDataAccept() |
java.lang.String |
getDecoderName()
This is a transient config and once the latest codecs are stable, can be removed (as there will only be one)
|
java.lang.String |
getDollarReplacement()
Get a replacement string for Dollar sign
$ during serializing/deserializing information in eureka server. |
java.lang.String |
getEncoderName()
This is a transient config and once the latest codecs are stable, can be removed (as there will only be one)
|
java.lang.String |
getEscapeCharReplacement()
Get a replacement string for underscore sign
_ during serializing/deserializing information in eureka server. |
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
EurekaClientConfig.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
EurekaClientConfig.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
URL s 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
EurekaClientConfig.getEurekaServerServiceUrls(String) . |
int |
getEurekaServiceUrlPollIntervalSeconds()
Indicates how often(in seconds) to poll for changes to eureka server
information.
|
java.lang.String |
getExperimental(java.lang.String name)
To avoid configuration API pollution when trying new/experimental or features or for the migration process,
the corresponding configuration can be put into experimental configuration section.
|
int |
getHeartbeatExecutorExponentialBackOffBound()
Heartbeat executor exponential back off related property.
|
int |
getHeartbeatExecutorThreadPoolSize()
(non-Javadoc)
|
int |
getInitialInstanceInfoReplicationIntervalSeconds()
Indicates how long initially (in seconds) to replicate instance info
to the eureka server
|
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 |
getProxyPassword()
Gets the proxy password if any.
|
java.lang.String |
getProxyPort()
Gets the proxy port to eureka server if any.
|
java.lang.String |
getProxyUserName()
Gets the proxy user name 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.
|
java.lang.String |
getRegistryRefreshSingleVipAddress()
Indicates whether the client is only interested in the registry information for a single VIP.
|
EurekaTransportConfig |
getTransportConfig()
For compatibility, return the transport layer config class
|
boolean |
shouldDisableDelta()
Indicates whether the eureka client should disable fetching of delta and
should rather resort to getting the full registry information.
|
boolean |
shouldEnforceFetchRegistryAtInit()
If set to true, the
EurekaClient initialization should throw an exception at constructor time
if the initial fetch of eureka registry information from the remote servers is unsuccessful. |
boolean |
shouldEnforceRegistrationAtInit()
If set to true, the
EurekaClient initialization should throw an exception at constructor time
if an initial registration to the remote servers is unsuccessful. |
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 |
shouldOnDemandUpdateStatusChange()
If set to true, local status updates via
ApplicationInfoManager.setInstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus)
will trigger on-demand (but rate limited) register/updates to remote eureka servers |
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 |
shouldUnregisterOnShutdown()
Indicates whether the client should explicitly unregister itself from the remote server
on client shutdown.
|
boolean |
shouldUseDnsForFetchingServiceUrls()
Indicates whether the eureka client should use the DNS mechanism to fetch
a list of eureka servers to talk to.
|
@Deprecated public static final java.lang.String DEFAULT_NAMESPACE
CommonConstants.DEFAULT_CONFIG_NAMESPACE
public static final java.lang.String DEFAULT_ZONE
public static final java.lang.String URL_SEPARATOR
public DefaultEurekaClientConfig()
public DefaultEurekaClientConfig(java.lang.String namespace)
public int getRegistryFetchIntervalSeconds()
EurekaClientConfig
getRegistryFetchIntervalSeconds
in interface EurekaClientConfig
public int getInstanceInfoReplicationIntervalSeconds()
EurekaClientConfig
getInstanceInfoReplicationIntervalSeconds
in interface EurekaClientConfig
public int getInitialInstanceInfoReplicationIntervalSeconds()
EurekaClientConfig
getInitialInstanceInfoReplicationIntervalSeconds
in interface EurekaClientConfig
public int getEurekaServiceUrlPollIntervalSeconds()
EurekaClientConfig
Eureka servers could be added or removed and this setting controls how soon the eureka clients should know about it.
getEurekaServiceUrlPollIntervalSeconds
in interface EurekaClientConfig
public java.lang.String getProxyHost()
EurekaClientConfig
getProxyHost
in interface EurekaClientConfig
public java.lang.String getProxyPort()
EurekaClientConfig
getProxyPort
in interface EurekaClientConfig
public java.lang.String getProxyUserName()
EurekaClientConfig
getProxyUserName
in interface EurekaClientConfig
public java.lang.String getProxyPassword()
EurekaClientConfig
getProxyPassword
in interface EurekaClientConfig
public boolean shouldGZipContent()
EurekaClientConfig
shouldGZipContent
in interface EurekaClientConfig
public int getEurekaServerReadTimeoutSeconds()
EurekaClientConfig
getEurekaServerReadTimeoutSeconds
in interface EurekaClientConfig
public int getEurekaServerConnectTimeoutSeconds()
EurekaClientConfig
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.
getEurekaServerConnectTimeoutSeconds
in interface EurekaClientConfig
public java.lang.String getBackupRegistryImpl()
EurekaClientConfig
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.
getBackupRegistryImpl
in interface EurekaClientConfig
BackupRegistry
.public int getEurekaServerTotalConnections()
EurekaClientConfig
getEurekaServerTotalConnections
in interface EurekaClientConfig
public int getEurekaServerTotalConnectionsPerHost()
EurekaClientConfig
getEurekaServerTotalConnectionsPerHost
in interface EurekaClientConfig
public java.lang.String getEurekaServerURLContext()
EurekaClientConfig
EurekaClientConfig.getEurekaServerServiceUrls(String)
.
The DNS mechanism is used when
EurekaClientConfig.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.
getEurekaServerURLContext
in interface EurekaClientConfig
URI
of the eureka
server.public java.lang.String getEurekaServerPort()
EurekaClientConfig
EurekaClientConfig.getEurekaServerServiceUrls(String)
.
The DNS mechanism is used when
EurekaClientConfig.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.
getEurekaServerPort
in interface EurekaClientConfig
public java.lang.String getEurekaServerDNSName()
EurekaClientConfig
EurekaClientConfig.getEurekaServerServiceUrls(String)
.
The DNS mechanism is used when
EurekaClientConfig.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.
getEurekaServerDNSName
in interface EurekaClientConfig
public boolean shouldUseDnsForFetchingServiceUrls()
EurekaClientConfig
EurekaClientConfig.getEurekaServiceUrlPollIntervalSeconds()
.
Alternatively, the service urls can be returned
EurekaClientConfig.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.
shouldUseDnsForFetchingServiceUrls
in interface EurekaClientConfig
public boolean shouldRegisterWithEureka()
EurekaClientConfig
In some cases, you do not want your instances to be discovered whereas you just want do discover other instances.
shouldRegisterWithEureka
in interface EurekaClientConfig
public boolean shouldUnregisterOnShutdown()
EurekaClientConfig
shouldUnregisterOnShutdown
in interface EurekaClientConfig
public boolean shouldPreferSameZoneEureka()
EurekaClientConfig
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
EurekaClientConfig.getRegistryFetchIntervalSeconds()
shouldPreferSameZoneEureka
in interface EurekaClientConfig
public boolean allowRedirects()
EurekaClientConfig
allowRedirects
in interface EurekaClientConfig
public boolean shouldLogDeltaDiff()
EurekaClientConfig
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
EurekaClientConfig.getRegistryFetchIntervalSeconds()
shouldLogDeltaDiff
in interface EurekaClientConfig
public boolean shouldDisableDelta()
EurekaClientConfig
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
EurekaClientConfig.getRegistryFetchIntervalSeconds()
shouldDisableDelta
in interface EurekaClientConfig
@Nullable public java.lang.String fetchRegistryForRemoteRegions()
EurekaClientConfig
EurekaClientConfig.getAvailabilityZones(String)
.
Failing to do so, will result in failure of discovery client startup.fetchRegistryForRemoteRegions
in interface EurekaClientConfig
null
if no remote region has to be fetched.public java.lang.String getRegion()
EurekaClientConfig
getRegion
in interface EurekaClientConfig
public java.lang.String[] getAvailabilityZones(java.lang.String region)
EurekaClientConfig
The changes are effective at runtime at the next registry fetch cycle as specified by
EurekaClientConfig.getRegistryFetchIntervalSeconds()
getAvailabilityZones
in interface EurekaClientConfig
region
- the region where this instance is deployed.public java.util.List<java.lang.String> getEurekaServerServiceUrls(java.lang.String myZone)
EurekaClientConfig
URL
s to communicate with eureka
server.
Typically the eureka server URL
s 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
EurekaClientConfig.getEurekaServiceUrlPollIntervalSeconds()
getEurekaServerServiceUrls
in interface EurekaClientConfig
myZone
- the zone in which the instance is deployed.public boolean shouldFilterOnlyUpInstances()
EurekaClientConfig
InstanceInfo.InstanceStatus.UP
states.
The changes are effective at runtime at the next registry fetch cycle as specified by
EurekaClientConfig.getRegistryFetchIntervalSeconds()
shouldFilterOnlyUpInstances
in interface EurekaClientConfig
public int getEurekaConnectionIdleTimeoutSeconds()
EurekaClientConfig
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
getEurekaConnectionIdleTimeoutSeconds
in interface EurekaClientConfig
public boolean shouldFetchRegistry()
EurekaClientConfig
shouldFetchRegistry
in interface EurekaClientConfig
true
if registry information has to be fetched, false
otherwise.public boolean shouldEnforceFetchRegistryAtInit()
EurekaClientConfig
EurekaClient
initialization should throw an exception at constructor time
if the initial fetch of eureka registry information from the remote servers is unsuccessful.
Note that if EurekaClientConfig.shouldFetchRegistry()
is set to false, then this config is a no-op.shouldEnforceFetchRegistryAtInit
in interface EurekaClientConfig
public java.lang.String getRegistryRefreshSingleVipAddress()
EurekaClientConfig
getRegistryRefreshSingleVipAddress
in interface EurekaClientConfig
null
if single VIP interest is not present.public int getHeartbeatExecutorThreadPoolSize()
getHeartbeatExecutorThreadPoolSize
in interface EurekaClientConfig
EurekaClientConfig.getHeartbeatExecutorThreadPoolSize()
public int getHeartbeatExecutorExponentialBackOffBound()
EurekaClientConfig
getHeartbeatExecutorExponentialBackOffBound
in interface EurekaClientConfig
public int getCacheRefreshExecutorThreadPoolSize()
getCacheRefreshExecutorThreadPoolSize
in interface EurekaClientConfig
EurekaClientConfig.getCacheRefreshExecutorThreadPoolSize()
public int getCacheRefreshExecutorExponentialBackOffBound()
EurekaClientConfig
getCacheRefreshExecutorExponentialBackOffBound
in interface EurekaClientConfig
public java.lang.String getDollarReplacement()
EurekaClientConfig
$
during serializing/deserializing information in eureka server.getDollarReplacement
in interface EurekaClientConfig
$
.public java.lang.String getEscapeCharReplacement()
EurekaClientConfig
_
during serializing/deserializing information in eureka server.getEscapeCharReplacement
in interface EurekaClientConfig
_
.public boolean shouldOnDemandUpdateStatusChange()
EurekaClientConfig
ApplicationInfoManager.setInstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus)
will trigger on-demand (but rate limited) register/updates to remote eureka serversshouldOnDemandUpdateStatusChange
in interface EurekaClientConfig
public boolean shouldEnforceRegistrationAtInit()
EurekaClientConfig
EurekaClient
initialization should throw an exception at constructor time
if an initial registration to the remote servers is unsuccessful.
Note that if EurekaClientConfig.shouldRegisterWithEureka()
is set to false, then this config is a no-opshouldEnforceRegistrationAtInit
in interface EurekaClientConfig
public java.lang.String getEncoderName()
EurekaClientConfig
getEncoderName
in interface EurekaClientConfig
public java.lang.String getDecoderName()
EurekaClientConfig
getDecoderName
in interface EurekaClientConfig
public java.lang.String getClientDataAccept()
getClientDataAccept
in interface EurekaClientConfig
Enum.name()
for client data acceptpublic java.lang.String getExperimental(java.lang.String name)
EurekaClientConfig
getExperimental
in interface EurekaClientConfig
public EurekaTransportConfig getTransportConfig()
EurekaClientConfig
getTransportConfig
in interface EurekaClientConfig
EurekaTransportConfig