Class OutlierDetectorConfig.Builder

java.lang.Object
io.servicetalk.loadbalancer.OutlierDetectorConfig.Builder
Enclosing class:
OutlierDetectorConfig

public static final class OutlierDetectorConfig.Builder extends Object
A builder for OutlierDetectorConfig instances.
  • Constructor Details

    • Builder

      public Builder()
      Construct a new builder using the default initial values.
  • Method Details

    • build

      public OutlierDetectorConfig build()
      Build the OutlierDetectorConfig.
      Returns:
      the OutlierDetectorConfig.
    • ewmaHalfLife

      public OutlierDetectorConfig.Builder ewmaHalfLife(Duration 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

      public OutlierDetectorConfig.Builder ewmaCancellationPenalty(long 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

      public OutlierDetectorConfig.Builder ewmaErrorPenalty(long 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. See OutlierDetectorConfig.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-subscribe interval.
      Returns:
      this.
    • consecutive5xx

      public OutlierDetectorConfig.Builder consecutive5xx(int 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

      public OutlierDetectorConfig.Builder failureDetectorInterval(Duration interval)
      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

      public OutlierDetectorConfig.Builder failureDetectorInterval(Duration interval, Duration jitter)
      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

      public OutlierDetectorConfig.Builder baseEjectionTime(Duration baseEjectionTime)
      Set the base ejection time. Defaults to 30 seconds.
      Parameters:
      baseEjectionTime - the base ejection time.
      Returns:
      this.
      See Also:
    • ejectionTimeJitter

      public OutlierDetectorConfig.Builder ejectionTimeJitter(Duration 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

      public OutlierDetectorConfig.Builder maxEjectionPercentage(int 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

      public OutlierDetectorConfig.Builder enforcingConsecutive5xx(int enforcingConsecutive5xx)
      Set the probability in percentage that a host will be marked as unhealthy when a host reaches the OutlierDetectorConfig.consecutive5xx() threshold. Defaults to 100 percent.
      Parameters:
      enforcingConsecutive5xx - the probability the host will be marked as unhealthy.
      Returns:
      this.
    • enforcingSuccessRate

      public OutlierDetectorConfig.Builder 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. Defaults to 100 percent.
      Parameters:
      enforcingSuccessRate - the probability the host will be marked as unhealthy.
      Returns:
      this.
    • successRateMinimumHosts

      public OutlierDetectorConfig.Builder successRateMinimumHosts(int 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

      public OutlierDetectorConfig.Builder 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. 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

      public OutlierDetectorConfig.Builder 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. 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

      public OutlierDetectorConfig.Builder failurePercentageThreshold(int 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

      public OutlierDetectorConfig.Builder 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. 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

      public OutlierDetectorConfig.Builder maxEjectionTime(Duration 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.