com.netflix.discovery

Class DefaultEurekaClientConfig

  • java.lang.Object
    • com.netflix.discovery.DefaultEurekaClientConfig
  • All Implemented Interfaces:
    EurekaClientConfig


    public class DefaultEurekaClientConfigextends java.lang.Objectimplements EurekaClientConfig
    A default implementation of eureka client configuration as required by 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-.properties is loaded in addition to eureka-client.properties.

    • Constructor Detail

      • DefaultEurekaClientConfig

        public DefaultEurekaClientConfig()
      • DefaultEurekaClientConfig

        public DefaultEurekaClientConfig(java.lang.String namespace)
    • Method Detail

      • getRegistryFetchIntervalSeconds

        public int getRegistryFetchIntervalSeconds()
        Description copied from interface: EurekaClientConfig
        Indicates how often(in seconds) to fetch the registry information from the eureka server.
        Specified by:
        getRegistryFetchIntervalSeconds in interface EurekaClientConfig
        Returns:
        the fetch interval in seconds.
      • getInstanceInfoReplicationIntervalSeconds

        public int getInstanceInfoReplicationIntervalSeconds()
        Description copied from interface: EurekaClientConfig
        Indicates how often(in seconds) to replicate instance changes to be replicated to the eureka server.
        Specified by:
        getInstanceInfoReplicationIntervalSeconds in interface EurekaClientConfig
        Returns:
        the instance replication interval in seconds.
      • getEurekaServiceUrlPollIntervalSeconds

        public int getEurekaServiceUrlPollIntervalSeconds()
        Description copied from interface: EurekaClientConfig
        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.

        Specified by:
        getEurekaServiceUrlPollIntervalSeconds in interface EurekaClientConfig
        Returns:
        the interval to poll for eureka service url changes.
      • shouldGZipContent

        public boolean shouldGZipContent()
        Description copied from interface: EurekaClientConfig
        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.
        Specified by:
        shouldGZipContent in interface EurekaClientConfig
        Returns:
        true, if the content need to be compressed, false otherwise.
      • getEurekaServerReadTimeoutSeconds

        public int getEurekaServerReadTimeoutSeconds()
        Description copied from interface: EurekaClientConfig
        Indicates how long to wait (in seconds) before a read from eureka server needs to timeout.
        Specified by:
        getEurekaServerReadTimeoutSeconds in interface EurekaClientConfig
        Returns:
        time in seconds before the read should timeout.
      • getEurekaServerConnectTimeoutSeconds

        public int getEurekaServerConnectTimeoutSeconds()
        Description copied from interface: EurekaClientConfig
        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 org.apache.http.client.HttpClient and this setting affects the actual connection creation and also the wait time to get the connection from the pool.

        Specified by:
        getEurekaServerConnectTimeoutSeconds in interface EurekaClientConfig
        Returns:
        time in seconds before the connections should timeout.
      • getBackupRegistryImpl

        public java.lang.String getBackupRegistryImpl()
        Description copied from interface: EurekaClientConfig
        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.

        Specified by:
        getBackupRegistryImpl in interface EurekaClientConfig
        Returns:
        the class name which implements BackupRegistry.
      • getEurekaServerTotalConnections

        public int getEurekaServerTotalConnections()
        Description copied from interface: EurekaClientConfig
        Gets the total number of connections that is allowed from eureka client to all eureka servers.
        Specified by:
        getEurekaServerTotalConnections in interface EurekaClientConfig
        Returns:
        total number of allowed connections from eureka client to all eureka servers.
      • getEurekaServerTotalConnectionsPerHost

        public int getEurekaServerTotalConnectionsPerHost()
        Description copied from interface: EurekaClientConfig
        Gets the total number of connections that is allowed from eureka client to a eureka server host.
        Specified by:
        getEurekaServerTotalConnectionsPerHost in interface EurekaClientConfig
        Returns:
        total number of allowed connections from eureka client to a eureka server.
      • shouldRegisterWithEureka

        public boolean shouldRegisterWithEureka()
        Description copied from interface: EurekaClientConfig
        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.

        Specified by:
        shouldRegisterWithEureka in interface EurekaClientConfig
        Returns:
        true if this instance should register with eureka, false otherwise
      • shouldPreferSameZoneEureka

        public boolean shouldPreferSameZoneEureka()
        Description copied from interface: EurekaClientConfig
        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 EurekaClientConfig.getRegistryFetchIntervalSeconds()

        Specified by:
        shouldPreferSameZoneEureka in interface EurekaClientConfig
        Returns:
        true if the eureka client should prefer the server in the same zone, false otherwise.
      • shouldLogDeltaDiff

        public boolean shouldLogDeltaDiff()
        Description copied from interface: EurekaClientConfig
        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 EurekaClientConfig.getRegistryFetchIntervalSeconds()

        Specified by:
        shouldLogDeltaDiff in interface EurekaClientConfig
        Returns:
        true if the eureka client should log delta differences in the case of reconciliation failure.
      • shouldDisableDelta

        public boolean shouldDisableDelta()
        Description copied from interface: EurekaClientConfig
        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 EurekaClientConfig.getRegistryFetchIntervalSeconds()

        Specified by:
        shouldDisableDelta in interface EurekaClientConfig
        Returns:
        true to enable fetching delta information for registry, false to get the full registry.
      • fetchRegistryForRemoteRegions

        @Nullablepublic java.lang.String fetchRegistryForRemoteRegions()
        Description copied from interface: EurekaClientConfig
        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 EurekaClientConfig.getAvailabilityZones(String). Failing to do so, will result in failure of discovery client startup.
        Specified by:
        fetchRegistryForRemoteRegions in interface EurekaClientConfig
        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

        public java.lang.String getRegion()
        Description copied from interface: EurekaClientConfig
        Gets the region (used in AWS datacenters) where this instance resides.
        Specified by:
        getRegion in interface EurekaClientConfig
        Returns:
        AWS region where this instance resides.
      • getAvailabilityZones

        public java.lang.String[] getAvailabilityZones(java.lang.String region)
        Description copied from interface: EurekaClientConfig
        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 EurekaClientConfig.getRegistryFetchIntervalSeconds()

        Specified by:
        getAvailabilityZones in interface EurekaClientConfig
        Parameters:
        region - the region where this instance is deployed.
        Returns:
        the list of available zones accessible by this instance.
      • getEurekaServerServiceUrls

        public java.util.List<java.lang.String> getEurekaServerServiceUrls(java.lang.String myZone)
        Description copied from interface: EurekaClientConfig
        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 EurekaClientConfig.getEurekaServiceUrlPollIntervalSeconds()

        Specified by:
        getEurekaServerServiceUrls in interface EurekaClientConfig
        Parameters:
        myZone - the zone in which the instance is deployed.
        Returns:
        the list of eureka server service urls for eureka clients to talk to.
      • getEurekaConnectionIdleTimeoutSeconds

        public int getEurekaConnectionIdleTimeoutSeconds()
        Description copied from interface: EurekaClientConfig
        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

        Specified by:
        getEurekaConnectionIdleTimeoutSeconds in interface EurekaClientConfig
        Returns:
        time in seconds the connections to eureka can stay idle before it can be closed.
      • shouldFetchRegistry

        public boolean shouldFetchRegistry()
        Description copied from interface: EurekaClientConfig
        Indicates whether this client should fetch eureka registry information from eureka server.
        Specified by:
        shouldFetchRegistry in interface EurekaClientConfig
        Returns:
        true if registry information has to be fetched, false otherwise.
      • getRegistryRefreshSingleVipAddress

        public java.lang.String getRegistryRefreshSingleVipAddress()
        Description copied from interface: EurekaClientConfig
        Indicates whether the client is only interested in the registry information for a single VIP.
        Specified by:
        getRegistryRefreshSingleVipAddress in interface EurekaClientConfig
        Returns:
        the address of the VIP (name:port). null if single VIP interest is not present.


NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14