Class OutlierDetectorConfig.Builder
- Enclosing class:
- OutlierDetectorConfig
OutlierDetectorConfig
instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbaseEjectionTime
(Duration baseEjectionTime) Set the base ejection time.build()
Build the OutlierDetectorConfig.cancellationIsError
(boolean cancellationIsError) Set whether a cancellation is considered to be an error by the outlier detector.consecutive5xx
(int consecutive5xx) Set the threshold for consecutive failures before a host is ejected.ejectionTimeJitter
(Duration ejectionTimeJitter) Set the ejection time jitter.enforcingConsecutive5xx
(int enforcingConsecutive5xx) Set the probability in percentage that a host will be marked as unhealthy when a host reaches theOutlierDetectorConfig.consecutive5xx()
threshold.enforcingFailurePercentage
(int enforcingFailurePercentage) Set the probability in percentage that a host will be marked as unhealthy when a host exceeds the failure percentage outlier detectors threshold.enforcingSuccessRate
(int enforcingSuccessRate) Set the probability in percentage that a host will be marked as unhealthy when a host exceeds the success rate outlier detectors threshold.ewmaCancellationPenalty
(int ewmaCancellationPenalty) Set the penalty factor for local cancellation of requests.ewmaConcurrentRequestPenalty
(int ewmaConcurrentRequestPenalty) Set the penalty factory to apply to concurrent requests.ewmaErrorPenalty
(int ewmaErrorPenalty) Set the penalty factor for requests that were classified as an error.ewmaHalfLife
(Duration ewmaHalfLife) Set the Exponentially Weighted Moving Average (EWMA) half-life.failedConnectionsThreshold
(int failedConnectionsThreshold) Configure a threshold for consecutive connection failures to a host.failureDetectorInterval
(Duration interval) Set the failure detector interval on which the outlier detector will perform periodic tasks.failureDetectorInterval
(Duration interval, Duration jitter) Set the interval on which to run failure percentage and success rate failure detectors.failurePercentageMinimumHosts
(int failurePercentageMinimumHosts) Set the minimum number of hosts required to perform the failure percentage outlier detector analysis.failurePercentageRequestVolume
(int failurePercentageRequestVolume) Set the minimum number of requests in an outlier detector interval required to include it in the failure percentage outlier detector analysis.failurePercentageThreshold
(int failurePercentageThreshold) Set the failure threshold in percentage for ejecting a host.maxEjectionPercentage
(int maxEjectionPercentage) Set the maximum percentage of hosts that can be ejected due to outlier detection.maxEjectionTime
(Duration maxEjectionTime) Set the maximum amount of time a host can be ejected regardless of the number of consecutive ejections.serviceDiscoveryResubscribeInterval
(Duration interval, Duration jitter) Configure an interval for re-subscribing to the original events stream in case all existing hosts become unhealthy.successRateMinimumHosts
(int successRateMinimumHosts) Set the minimum number of hosts required to perform the success rate outlier detector analysis.successRateRequestVolume
(int successRateRequestVolume) Set the minimum number of requests in an outlier detector interval required to include it in the success rate outlier detector analysis.successRateStdevFactor
(int successRateStdevFactor) Set the value divided by 1000 and then multiplied against the success rate standard deviation which sets the threshold for ejection in the success rate outlier detector.
-
Constructor Details
-
Builder
public Builder()Construct a new builder using the default initial values.
-
-
Method Details
-
build
Build the OutlierDetectorConfig.- Returns:
- the OutlierDetectorConfig.
-
ewmaHalfLife
Set the Exponentially Weighted Moving Average (EWMA) half-life.In the context of an exponentially weighted moving average, the half-life means the time during which historical data has the same weight as a new sample.
Defaults to 10 seconds.
- Parameters:
ewmaHalfLife
- the half-life for latency data.- Returns:
this
-
ewmaCancellationPenalty
Set the penalty factor for local cancellation of requests.The latency of the cancelled request is multiplied by the provided penalty before incorporating it into the EWMA.
Defaults to 5.
- Parameters:
ewmaCancellationPenalty
- the penalty factor for local cancellation of requests.- Returns:
this
-
ewmaErrorPenalty
Set the penalty factor for requests that were classified as an error.The latency of the failed request is multiplied by the provided penalty before incorporating it into the EWMA.
Defaults to 10.
- Parameters:
ewmaErrorPenalty
- the penalty factor for requests that were classified as an error.- Returns:
this
- See Also:
-
cancellationIsError
Set whether a cancellation is considered to be an error by the outlier detector.- Parameters:
cancellationIsError
- whether a cancellation is considered to be an error by the outlier detector.- Returns:
this
-
ewmaConcurrentRequestPenalty
Set the penalty factory to apply to concurrent requests.The EWMA penalty to apply to endpoints when there are concurrent requests. By penalizing endpoints with concurrent load the traffic distribution will be more fair for algorithms that consider load metrics. Larger penalties will favor a more even request distribution while lower penalties will bias traffic toward endpoints with better performance. A value of 0 disables the penalty, 1 is an intermediate value, and larger values such as 10 or more will strongly favor fairness over performance.
Defaults to 1.
- Parameters:
ewmaConcurrentRequestPenalty
- the penalty factory to apply for concurrent load.- Returns:
this
-
serviceDiscoveryResubscribeInterval
public OutlierDetectorConfig.Builder serviceDiscoveryResubscribeInterval(Duration interval, Duration jitter) Configure an interval for re-subscribing to the original events stream in case all existing hosts become unhealthy.In situations when there is a latency between
ServiceDiscoverer
propagating the updated state and all known hosts become unhealthy, which could happen due to intermediate caching layers, re-subscribing to the events stream can help to exit from a dead state.Note: setting the interval to
Duration.ofNanos(Long.MAX_VALUE)
will effectively disable health check resubscribes.- Parameters:
interval
- interval at which re-subscribes will be scheduled.jitter
- the amount of jitter to apply to each re-subscribeinterval
.- Returns:
this
.
-
failedConnectionsThreshold
Configure a threshold for consecutive connection failures to a host.When the
LoadBalancer
consecutively fails to open connections in the amount greater or equal to the specified value, the host will be marked as unhealthy and connection establishment will take place in the background repeatedly on theOutlierDetectorConfig.failureDetectorInterval()
(with jitterOutlierDetectorConfig.failureDetectorIntervalJitter()
) until a connection is established. During that time, the host will not take part in load balancing selection.Use a negative value of the argument to disable health checking.
- Parameters:
failedConnectionsThreshold
- number of consecutive connection failures to consider a host unhealthy and eligible for background health checking. Use negative value to disable the health checking mechanism.- Returns:
this
.
-
consecutive5xx
Set the threshold for consecutive failures before a host is ejected.Defaults to 5.
- Parameters:
consecutive5xx
- the threshold for consecutive failures before a host is ejected.- Returns:
this
-
failureDetectorInterval
Set the failure detector interval on which the outlier detector will perform periodic tasks.These tasks can include detection of outlier or the active revival checks.
This method will also use either the default jitter or the provided interval, whichever is smaller.
Defaults to 10 second interval with 3 second jitter.
- Parameters:
interval
- the interval on which to run failure percentage and success rate failure detectors.- Returns:
this
-
failureDetectorInterval
Set the interval on which to run failure percentage and success rate failure detectors.These tasks can include detection of outlier or the active revival checks.
Defaults to 10 second interval with 3 second jitter.
- Parameters:
interval
- the interval on which to run failure percentage and success rate failure detectors.jitter
- the jitter of the time interval. The next interval will have a duration of [interval - jitter, interval + jitter].- Returns:
this
-
baseEjectionTime
Set the base ejection time.Defaults to 30 seconds.
- Parameters:
baseEjectionTime
- the base ejection time.- Returns:
this
.- See Also:
-
ejectionTimeJitter
Set the ejection time jitter.Defaults to 3 seconds.
- Parameters:
ejectionTimeJitter
- the jitter to add to the calculated ejection time.- Returns:
this
.- See Also:
-
maxEjectionPercentage
Set the maximum percentage of hosts that can be ejected due to outlier detection.Defaults to 10 percent but at least one host will be allowed to be ejected regardless of value.
- Parameters:
maxEjectionPercentage
- the maximum percentage of hosts that can be ejected due to outlier detection.- Returns:
this
.
-
enforcingConsecutive5xx
Set the probability in percentage that a host will be marked as unhealthy when a host reaches theOutlierDetectorConfig.consecutive5xx()
threshold.Defaults to 100 percent.
- Parameters:
enforcingConsecutive5xx
- the probability the host will be marked as unhealthy.- Returns:
this
.
-
enforcingSuccessRate
Set the probability in percentage that a host will be marked as unhealthy when a host exceeds the success rate outlier detectors threshold.Defaults to 100 percent.
- Parameters:
enforcingSuccessRate
- the probability the host will be marked as unhealthy.- Returns:
this
.
-
successRateMinimumHosts
Set the minimum number of hosts required to perform the success rate outlier detector analysis. Defaults to 5.- Parameters:
successRateMinimumHosts
- the minimum number of hosts required to perform the success rate outlier detector analysis.- Returns:
this
.
-
successRateRequestVolume
Set the minimum number of requests in an outlier detector interval required to include it in the success rate outlier detector analysis.Defaults to 100.
- Parameters:
successRateRequestVolume
- the minimum number of requests in an outlier detector interval required to include it in the success rate outlier detector analysis.- Returns:
this
.
-
successRateStdevFactor
Set the value divided by 1000 and then multiplied against the success rate standard deviation which sets the threshold for ejection in the success rate outlier detector.Defaults to 1900.
- Parameters:
successRateStdevFactor
- the value divided by 1000 and then multiplied against the success rate standard deviation which sets the threshold for ejection in the success rate outlier detector.- Returns:
this
.
-
failurePercentageThreshold
Set the failure threshold in percentage for ejecting a host.Defaults to 85 percent.
- Parameters:
failurePercentageThreshold
- the failure threshold in percentage for ejecting a host.- Returns:
this
.
-
enforcingFailurePercentage
Set the probability in percentage that a host will be marked as unhealthy when a host exceeds the failure percentage outlier detectors threshold.Defaults to 0 percent.
- Parameters:
enforcingFailurePercentage
- the probability in percentage that a host will be marked as unhealthy when percentage outlier detectors threshold.- Returns:
this
.
-
failurePercentageMinimumHosts
public OutlierDetectorConfig.Builder failurePercentageMinimumHosts(int failurePercentageMinimumHosts) Set the minimum number of hosts required to perform the failure percentage outlier detector analysis.Defaults to 5.
- Parameters:
failurePercentageMinimumHosts
- the minimum number of hosts required to perform the failure percentage outlier detector analysis.- Returns:
this
.
-
failurePercentageRequestVolume
public OutlierDetectorConfig.Builder failurePercentageRequestVolume(int failurePercentageRequestVolume) Set the minimum number of requests in an outlier detector interval required to include it in the failure percentage outlier detector analysis.Defaults to 50.
- Parameters:
failurePercentageRequestVolume
- the minimum number of requests in an outlier detector interval required to include it in the failure percentage outlier detector analysis.- Returns:
this
.
-
maxEjectionTime
Set the maximum amount of time a host can be ejected regardless of the number of consecutive ejections.Defaults to a max ejection time of 300 seconds and 0 seconds jitter.
- Parameters:
maxEjectionTime
- the maximum amount of time a host can be ejected regardless of the number of consecutive ejections.- Returns:
this
.
-