Package io.servicetalk.loadbalancer
Class OutlierDetectorConfig.Builder
java.lang.Object
io.servicetalk.loadbalancer.OutlierDetectorConfig.Builder
- Enclosing class:
- OutlierDetectorConfig
A builder for
OutlierDetectorConfig
instances.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbaseEjectionTime
(Duration baseEjectionTime) Set the base ejection time.build()
Build the OutlierDetectorConfig.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
(long ewmaCancellationPenalty) Set the penalty factor for local cancellation of requests.ewmaErrorPenalty
(long 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.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 5L.- 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 10L. SeeOutlierDetectorConfig.ewmaErrorPenalty()
.- Parameters:
ewmaErrorPenalty
- the penalty factor for requests that were classified as an error.- 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
.
-
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
.
-