Class DefaultEurekaServerConfig

  • All Implemented Interfaces:
    EurekaServerConfig

    @Singleton
    public class DefaultEurekaServerConfig
    extends java.lang.Object
    implements EurekaServerConfig
    A default implementation of eureka server configuration as required by EurekaServerConfig.

    The information required for configuring eureka server is provided in a configuration file.The configuration file is searched for in the classpath with the name specified by the property eureka.server.props and with the suffix .properties. If the property is not specified, eureka-server.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-server-.properties is loaded in addition to eureka-server.properties.

    • Constructor Detail

      • DefaultEurekaServerConfig

        public DefaultEurekaServerConfig()
      • DefaultEurekaServerConfig

        public DefaultEurekaServerConfig​(java.lang.String namespace)
    • Method Detail

      • getAWSAccessId

        public java.lang.String getAWSAccessId()
        Description copied from interface: EurekaServerConfig
        Gets the AWS Access Id. This is primarily used for Elastic IP Biding. The access id should be provided with appropriate AWS permissions to bind the EIP.
        Specified by:
        getAWSAccessId in interface EurekaServerConfig
        Returns:
      • getAWSSecretKey

        public java.lang.String getAWSSecretKey()
        Description copied from interface: EurekaServerConfig
        Gets the AWS Secret Key. This is primarily used for Elastic IP Biding. The access id should be provided with appropriate AWS permissions to bind the EIP.
        Specified by:
        getAWSSecretKey in interface EurekaServerConfig
        Returns:
      • getEIPBindRebindRetries

        public int getEIPBindRebindRetries()
        Description copied from interface: EurekaServerConfig
        Gets the number of times the server should try to bind to the candidate EIP.

        The changes are effective at runtime.

        Specified by:
        getEIPBindRebindRetries in interface EurekaServerConfig
        Returns:
        the number of times the server should try to bind to the candidate EIP.
      • getEIPBindingRetryIntervalMsWhenUnbound

        public int getEIPBindingRetryIntervalMsWhenUnbound()
        Description copied from interface: EurekaServerConfig
        Get the interval with which the server should check if the EIP is bound and should try to bind in the case if it is already not bound, iff the EIP is not currently bound.

        The changes are effective at runtime.

        Specified by:
        getEIPBindingRetryIntervalMsWhenUnbound in interface EurekaServerConfig
        Returns:
        the time in milliseconds.
      • getEIPBindingRetryIntervalMs

        public int getEIPBindingRetryIntervalMs()
        Description copied from interface: EurekaServerConfig
        Gets the interval with which the server should check if the EIP is bound and should try to bind in the case if it is already not bound, iff the EIP is already bound. (so this refresh is just for steady state checks)

        The changes are effective at runtime.

        Specified by:
        getEIPBindingRetryIntervalMs in interface EurekaServerConfig
        Returns:
        the time in milliseconds.
      • shouldEnableSelfPreservation

        public boolean shouldEnableSelfPreservation()
        Description copied from interface: EurekaServerConfig
        Checks to see if the eureka server is enabled for self preservation.

        When enabled, the server keeps track of the number of renewals it should receive from the server. Any time, the number of renewals drops below the threshold percentage as defined by EurekaServerConfig.getRenewalPercentThreshold(), the server turns off expirations to avert danger.This will help the server in maintaining the registry information in case of network problems between client and the server.

        The changes are effective at runtime.

        Specified by:
        shouldEnableSelfPreservation in interface EurekaServerConfig
        Returns:
        true to enable self preservation, false otherwise.
      • getPeerEurekaNodesUpdateIntervalMs

        public int getPeerEurekaNodesUpdateIntervalMs()
        Description copied from interface: EurekaServerConfig
        The interval with which the information about the changes in peer eureka nodes is updated. The user can use the DNS mechanism or dynamic configuration provided by Archaius to change the information dynamically.

        The changes are effective at runtime.

        Specified by:
        getPeerEurekaNodesUpdateIntervalMs in interface EurekaServerConfig
        Returns:
        timer in milliseconds indicating the interval.
      • getExpectedClientRenewalIntervalSeconds

        public int getExpectedClientRenewalIntervalSeconds()
        Description copied from interface: EurekaServerConfig
        The interval with which clients are expected to send their heartbeats. Defaults to 30 seconds. If clients send heartbeats with different frequency, say, every 15 seconds, then this parameter should be tuned accordingly, otherwise, self-preservation won't work as expected.
        Specified by:
        getExpectedClientRenewalIntervalSeconds in interface EurekaServerConfig
        Returns:
        time in seconds indicating the expected interval
      • shouldEnableReplicatedRequestCompression

        public boolean shouldEnableReplicatedRequestCompression()
        Description copied from interface: EurekaServerConfig
        If set to true, the replicated data send in the request will be always compressed. This does not define response path, which is driven by "Accept-Encoding" header.
        Specified by:
        shouldEnableReplicatedRequestCompression in interface EurekaServerConfig
      • getNumberOfReplicationRetries

        public int getNumberOfReplicationRetries()
        Description copied from interface: EurekaServerConfig
        Get the number of times the replication events should be retried with peers.

        The changes are effective at runtime.

        Specified by:
        getNumberOfReplicationRetries in interface EurekaServerConfig
        Returns:
        the number of retries.
      • getPeerEurekaStatusRefreshTimeIntervalMs

        public int getPeerEurekaStatusRefreshTimeIntervalMs()
        Description copied from interface: EurekaServerConfig
        Gets the interval with which the status information about peer nodes is updated.

        The changes are effective at runtime.

        Specified by:
        getPeerEurekaStatusRefreshTimeIntervalMs in interface EurekaServerConfig
        Returns:
        time in milliseconds indicating the interval.
      • getWaitTimeInMsWhenSyncEmpty

        public int getWaitTimeInMsWhenSyncEmpty()
        Description copied from interface: EurekaServerConfig
        Gets the time to wait when the eureka server starts up unable to get instances from peer nodes. It is better not to start serving rightaway during these scenarios as the information that is stored in the registry may not be complete. When the instance registry starts up empty, it builds over time when the clients start to send heartbeats and the server requests the clients for registration information.
        Specified by:
        getWaitTimeInMsWhenSyncEmpty in interface EurekaServerConfig
        Returns:
        time in milliseconds.
      • getPeerNodeConnectTimeoutMs

        public int getPeerNodeConnectTimeoutMs()
        Description copied from interface: EurekaServerConfig
        Gets the timeout value for connecting to peer eureka nodes for replication.
        Specified by:
        getPeerNodeConnectTimeoutMs in interface EurekaServerConfig
        Returns:
        timeout value in milliseconds.
      • getPeerNodeReadTimeoutMs

        public int getPeerNodeReadTimeoutMs()
        Description copied from interface: EurekaServerConfig
        Gets the timeout value for reading information from peer eureka nodes for replication.
        Specified by:
        getPeerNodeReadTimeoutMs in interface EurekaServerConfig
        Returns:
        timeout value in milliseconds.
      • getPeerNodeTotalConnections

        public int getPeerNodeTotalConnections()
        Description copied from interface: EurekaServerConfig
        Gets the total number of HTTP connections allowed to peer eureka nodes for replication.
        Specified by:
        getPeerNodeTotalConnections in interface EurekaServerConfig
        Returns:
        total number of allowed HTTP connections.
      • getPeerNodeTotalConnectionsPerHost

        public int getPeerNodeTotalConnectionsPerHost()
        Description copied from interface: EurekaServerConfig
        Gets the total number of HTTP connections allowed to a particular peer eureka node for replication.
        Specified by:
        getPeerNodeTotalConnectionsPerHost in interface EurekaServerConfig
        Returns:
        total number of allowed HTTP connections for a peer node.
      • getRetentionTimeInMSInDeltaQueue

        public long getRetentionTimeInMSInDeltaQueue()
        Description copied from interface: EurekaServerConfig
        Get the time for which the delta information should be cached for the clients to retrieve the value without missing it.
        Specified by:
        getRetentionTimeInMSInDeltaQueue in interface EurekaServerConfig
        Returns:
        time in milliseconds
      • getDeltaRetentionTimerIntervalInMs

        public long getDeltaRetentionTimerIntervalInMs()
        Description copied from interface: EurekaServerConfig
        Get the time interval with which the clean up task should wake up and check for expired delta information.
        Specified by:
        getDeltaRetentionTimerIntervalInMs in interface EurekaServerConfig
        Returns:
        time in milliseconds.
      • getEvictionIntervalTimerInMs

        public long getEvictionIntervalTimerInMs()
        Description copied from interface: EurekaServerConfig
        Get the time interval with which the task that expires instances should wake up and run.
        Specified by:
        getEvictionIntervalTimerInMs in interface EurekaServerConfig
        Returns:
        time in milliseconds.
      • shouldUseAwsAsgApi

        public boolean shouldUseAwsAsgApi()
        Description copied from interface: EurekaServerConfig
        Whether to use AWS API to query ASG statuses.
        Specified by:
        shouldUseAwsAsgApi in interface EurekaServerConfig
        Returns:
        true if AWS API is used, false otherwise.
      • getASGQueryTimeoutMs

        public int getASGQueryTimeoutMs()
        Description copied from interface: EurekaServerConfig
        Get the timeout value for querying the AWS for ASG information.
        Specified by:
        getASGQueryTimeoutMs in interface EurekaServerConfig
        Returns:
        timeout value in milliseconds.
      • getASGUpdateIntervalMs

        public long getASGUpdateIntervalMs()
        Description copied from interface: EurekaServerConfig
        Get the time interval with which the ASG information must be queried from AWS.
        Specified by:
        getASGUpdateIntervalMs in interface EurekaServerConfig
        Returns:
        time in milliseconds.
      • getResponseCacheAutoExpirationInSeconds

        public long getResponseCacheAutoExpirationInSeconds()
        Description copied from interface: EurekaServerConfig
        Gets the time for which the registry payload should be kept in the cache if it is not invalidated by change events.
        Specified by:
        getResponseCacheAutoExpirationInSeconds in interface EurekaServerConfig
        Returns:
        time in seconds.
      • shouldUseReadOnlyResponseCache

        public boolean shouldUseReadOnlyResponseCache()
        Description copied from interface: EurekaServerConfig
        The ResponseCache currently uses a two level caching strategy to responses. A readWrite cache with an expiration policy, and a readonly cache that caches without expiry.
        Specified by:
        shouldUseReadOnlyResponseCache in interface EurekaServerConfig
        Returns:
        true if the read only cache is to be used
      • shouldDisableDelta

        public boolean shouldDisableDelta()
        Description copied from interface: EurekaServerConfig
        Checks to see if the delta information can be served to client or not.

        The changes are effective at runtime.

        Specified by:
        shouldDisableDelta in interface EurekaServerConfig
        Returns:
        true if the delta information is allowed to be served, false otherwise.
      • getMinThreadsForStatusReplication

        public int getMinThreadsForStatusReplication()
        Description copied from interface: EurekaServerConfig
        Get the minimum number of threads to be used for status replication.
        Specified by:
        getMinThreadsForStatusReplication in interface EurekaServerConfig
        Returns:
        minimum number of threads to be used for status replication.
      • getMaxThreadsForStatusReplication

        public int getMaxThreadsForStatusReplication()
        Description copied from interface: EurekaServerConfig
        Get the maximum number of threads to be used for status replication.
        Specified by:
        getMaxThreadsForStatusReplication in interface EurekaServerConfig
        Returns:
        maximum number of threads to be used for status replication.
      • getMaxElementsInStatusReplicationPool

        public int getMaxElementsInStatusReplicationPool()
        Description copied from interface: EurekaServerConfig
        Get the maximum number of replication events that can be allowed to back up in the status replication pool.

        Depending on the memory allowed, timeout and the replication traffic, this value can vary.

        Specified by:
        getMaxElementsInStatusReplicationPool in interface EurekaServerConfig
        Returns:
        the maximum number of replication events that can be allowed to back up.
      • shouldSyncWhenTimestampDiffers

        public boolean shouldSyncWhenTimestampDiffers()
        Description copied from interface: EurekaServerConfig
        Checks whether to synchronize instances when timestamp differs.

        The changes are effective at runtime.

        Specified by:
        shouldSyncWhenTimestampDiffers in interface EurekaServerConfig
        Returns:
        true, to synchronize, false otherwise.
      • getRegistrySyncRetries

        public int getRegistrySyncRetries()
        Description copied from interface: EurekaServerConfig
        Get the number of times that a eureka node would try to get the registry information from the peers during startup.
        Specified by:
        getRegistrySyncRetries in interface EurekaServerConfig
        Returns:
        the number of retries
      • getRegistrySyncRetryWaitMs

        public long getRegistrySyncRetryWaitMs()
        Description copied from interface: EurekaServerConfig
        Get the wait/sleep time between each retry sync attempts, if the prev retry failed and there are more retries to attempt.
        Specified by:
        getRegistrySyncRetryWaitMs in interface EurekaServerConfig
        Returns:
        the wait time in ms between each sync retries
      • getMaxElementsInPeerReplicationPool

        public int getMaxElementsInPeerReplicationPool()
        Description copied from interface: EurekaServerConfig
        Get the maximum number of replication events that can be allowed to back up in the replication pool. This replication pool is responsible for all events except status updates.

        Depending on the memory allowed, timeout and the replication traffic, this value can vary.

        Specified by:
        getMaxElementsInPeerReplicationPool in interface EurekaServerConfig
        Returns:
        the maximum number of replication events that can be allowed to back up.
      • getMinThreadsForPeerReplication

        public int getMinThreadsForPeerReplication()
        Description copied from interface: EurekaServerConfig
        Get the minimum number of threads to be used for replication.
        Specified by:
        getMinThreadsForPeerReplication in interface EurekaServerConfig
        Returns:
        minimum number of threads to be used for replication.
      • getMaxThreadsForPeerReplication

        public int getMaxThreadsForPeerReplication()
        Description copied from interface: EurekaServerConfig
        Get the maximum number of threads to be used for replication.
        Specified by:
        getMaxThreadsForPeerReplication in interface EurekaServerConfig
        Returns:
        maximum number of threads to be used for replication.
      • getMaxTimeForReplication

        public int getMaxTimeForReplication()
        Description copied from interface: EurekaServerConfig
        Get the time in milliseconds to try to replicate before dropping replication events.
        Specified by:
        getMaxTimeForReplication in interface EurekaServerConfig
        Returns:
        time in milliseconds
      • shouldPrimeAwsReplicaConnections

        public boolean shouldPrimeAwsReplicaConnections()
        Description copied from interface: EurekaServerConfig
        Checks whether the connections to replicas should be primed. In AWS, the firewall requires sometime to establish network connection for new nodes.
        Specified by:
        shouldPrimeAwsReplicaConnections in interface EurekaServerConfig
        Returns:
        true, if connections should be primed, false otherwise.
      • shouldDisableDeltaForRemoteRegions

        public boolean shouldDisableDeltaForRemoteRegions()
        Description copied from interface: EurekaServerConfig
        Checks to see if the delta information can be served to client or not for remote regions.

        The changes are effective at runtime.

        Specified by:
        shouldDisableDeltaForRemoteRegions in interface EurekaServerConfig
        Returns:
        true if the delta information is allowed to be served, false otherwise.
      • getRemoteRegionReadTimeoutMs

        public int getRemoteRegionReadTimeoutMs()
        Description copied from interface: EurekaServerConfig
        Gets the timeout value for reading information from peer eureka nodes for remote regions.
        Specified by:
        getRemoteRegionReadTimeoutMs in interface EurekaServerConfig
        Returns:
        timeout value in milliseconds.
      • getRemoteRegionTotalConnections

        public int getRemoteRegionTotalConnections()
        Description copied from interface: EurekaServerConfig
        Gets the total number of HTTP connections allowed to peer eureka nodes for remote regions.
        Specified by:
        getRemoteRegionTotalConnections in interface EurekaServerConfig
        Returns:
        total number of allowed HTTP connections.
      • getRemoteRegionTotalConnectionsPerHost

        public int getRemoteRegionTotalConnectionsPerHost()
        Description copied from interface: EurekaServerConfig
        Gets the total number of HTTP connections allowed to a particular peer eureka node for remote regions.
        Specified by:
        getRemoteRegionTotalConnectionsPerHost in interface EurekaServerConfig
        Returns:
        total number of allowed HTTP connections for a peer node.
      • shouldGZipContentFromRemoteRegion

        public boolean shouldGZipContentFromRemoteRegion()
        Description copied from interface: EurekaServerConfig
        Indicates whether the content fetched from eureka server has to be compressed for remote regions whenever it is supported by the server. The registry information from the eureka server is compressed for optimum network traffic.
        Specified by:
        shouldGZipContentFromRemoteRegion in interface EurekaServerConfig
        Returns:
        true, if the content need to be compressed, false otherwise.
      • getRemoteRegionUrlsWithName

        public java.util.Map<java.lang.String,​java.lang.String> getRemoteRegionUrlsWithName()
        Expects a property with name: [eureka-namespace].remoteRegionUrlsWithName and a value being a comma separated list of region name & remote url pairs, separated with a ";".
        So, if you wish to specify two regions with name region1 & region2, the property value will be:
             eureka.remoteRegionUrlsWithName=region1;http://region1host/eureka/v2,region2;http://region2host/eureka/v2
             
        The above property will result in the following map:
             region1->"http://region1host/eureka/v2"
             region2->"http://region2host/eureka/v2"
             
        Specified by:
        getRemoteRegionUrlsWithName in interface EurekaServerConfig
        Returns:
        A map of region name to remote region URL parsed from the property specified above. If there is no property available, then an empty map is returned.
      • getRemoteRegionUrls

        public java.lang.String[] getRemoteRegionUrls()
        Description copied from interface: EurekaServerConfig
        Get the list of remote region urls.
        Specified by:
        getRemoteRegionUrls in interface EurekaServerConfig
        Returns:
        - array of string representing URLs.
      • getRemoteRegionAppWhitelist

        @Nullable
        public java.util.Set<java.lang.String> getRemoteRegionAppWhitelist​(@Nullable
                                                                           java.lang.String regionName)
        Description copied from interface: EurekaServerConfig
        Returns a list of applications that must be retrieved from the passed remote region.
        This list can be null which means that no filtering should be applied on the applications for this region i.e. all applications must be returned.
        A global whitelist can also be configured which can be used when no setting is available for a region, such a whitelist can be obtained by passing null to this method.
        Specified by:
        getRemoteRegionAppWhitelist in interface EurekaServerConfig
        Parameters:
        regionName - Name of the region for which the application whitelist is to be retrieved. If null a global setting is returned.
        Returns:
        A set of application names which must be retrieved from the passed region. If null all applications must be retrieved.
      • getRemoteRegionFetchThreadPoolSize

        public int getRemoteRegionFetchThreadPoolSize()
        Description copied from interface: EurekaServerConfig
        Size of a thread pool used to execute remote region registry fetch requests. Delegating these requests to internal threads is necessary workaround to https://bugs.openjdk.java.net/browse/JDK-8049846 bug.
        Specified by:
        getRemoteRegionFetchThreadPoolSize in interface EurekaServerConfig
      • getRemoteRegionTrustStore

        public java.lang.String getRemoteRegionTrustStore()
        Description copied from interface: EurekaServerConfig
        Gets the fully qualified trust store file that will be used for remote region registry fetches.
        Specified by:
        getRemoteRegionTrustStore in interface EurekaServerConfig
        Returns:
      • disableTransparentFallbackToOtherRegion

        public boolean disableTransparentFallbackToOtherRegion()
        Description copied from interface: EurekaServerConfig
        Old behavior of fallback to applications in the remote region (if configured) if there are no instances of that application in the local region, will be disabled.
        Specified by:
        disableTransparentFallbackToOtherRegion in interface EurekaServerConfig
        Returns:
        true if the old behavior is to be disabled.
      • shouldBatchReplication

        public boolean shouldBatchReplication()
        Description copied from interface: EurekaServerConfig
        Indicates whether the replication between cluster nodes should be batched for network efficiency.
        Specified by:
        shouldBatchReplication in interface EurekaServerConfig
        Returns:
        true if the replication needs to be batched.
      • getMyUrl

        public java.lang.String getMyUrl()
        Description copied from interface: EurekaServerConfig
        Allows to configure URL which Eureka should treat as its own during replication. In some cases Eureka URLs don't match IP address or hostname (for example, when nodes are behind load balancers). Setting this parameter on each node to URLs of associated load balancers helps to avoid replication to the same node where event originally came to. Important: you need to configure the whole URL including scheme and path, like http://eureka-node1.mydomain.com:8010/eureka/v2/
        Specified by:
        getMyUrl in interface EurekaServerConfig
        Returns:
        URL Eureka will treat as its own
      • shouldLogIdentityHeaders

        public boolean shouldLogIdentityHeaders()
        Description copied from interface: EurekaServerConfig
        Indicates whether the eureka server should log/metric clientAuthHeaders
        Specified by:
        shouldLogIdentityHeaders in interface EurekaServerConfig
        Returns:
        true if the clientAuthHeaders should be logged and/or emitted as metrics
      • getJsonCodecName

        public java.lang.String getJsonCodecName()
        Specified by:
        getJsonCodecName in interface EurekaServerConfig
        Returns:
        the class name of the full json codec to use for the server. If none set a default codec will be used
      • getXmlCodecName

        public java.lang.String getXmlCodecName()
        Specified by:
        getXmlCodecName in interface EurekaServerConfig
        Returns:
        the class name of the full xml codec to use for the server. If none set a default codec will be used
      • getRoute53BindRebindRetries

        public int getRoute53BindRebindRetries()
        Description copied from interface: EurekaServerConfig
        Gets the number of times the server should try to bind to the candidate Route53 domain.

        The changes are effective at runtime.

        Specified by:
        getRoute53BindRebindRetries in interface EurekaServerConfig
        Returns:
        the number of times the server should try to bind to the candidate Route53 domain.
      • getRoute53BindingRetryIntervalMs

        public int getRoute53BindingRetryIntervalMs()
        Description copied from interface: EurekaServerConfig
        Gets the interval with which the server should check if the Route53 domain is bound and should try to bind in the case if it is already not bound.

        The changes are effective at runtime.

        Specified by:
        getRoute53BindingRetryIntervalMs in interface EurekaServerConfig
        Returns:
        the time in milliseconds.
      • getExperimental

        public java.lang.String getExperimental​(java.lang.String name)
        Description copied from interface: EurekaServerConfig
        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.
        Specified by:
        getExperimental in interface EurekaServerConfig
        Returns:
        a property of experimental feature
      • getHealthStatusMinNumberOfAvailablePeers

        public int getHealthStatusMinNumberOfAvailablePeers()
        Description copied from interface: EurekaServerConfig
        Get the minimum number of available peer replication instances for this instance to be considered healthy. The design of eureka allows for an instance to continue operating with zero peers, but that would not be ideal.

        The default value of -1 is interpreted as a marker to not compare the number of replicas. This would be done to either disable this check or to run eureka in a single node configuration.

        Specified by:
        getHealthStatusMinNumberOfAvailablePeers in interface EurekaServerConfig
        Returns:
        minimum number of available peer replication instances for this instance to be considered healthy.