Class P2CLoadBalancingPolicyBuilder

java.lang.Object
io.servicetalk.loadbalancer.P2CLoadBalancingPolicyBuilder

public final class P2CLoadBalancingPolicyBuilder extends Object
A builder for P2CLoadBalancingPolicy instances.
See Also:
  • Method Details

    • maxEffort

      public P2CLoadBalancingPolicyBuilder maxEffort(int maxEffort)
      Set the maximum number of attempts that P2C will attempt to select a pair with at least one healthy host.

      Defaults to 5.

      Parameters:
      maxEffort - the maximum number of attempts.
      Returns:
      this
    • failOpen

      public P2CLoadBalancingPolicyBuilder failOpen(boolean failOpen)
      Set whether the selector should fail-open in the event no healthy hosts are found.

      When a load balancing policy is configured to fail-open and is unable to find a healthy host, it will attempt to select or establish a connection from an arbitrary host even if it is unlikely to return a healthy session.

      Defaults to false.

      Parameters:
      failOpen - if true, will attempt to select or establish a connection from an arbitrary host even if it is unlikely to return a healthy session.
      Returns:
      this
    • ignoreWeights

      public P2CLoadBalancingPolicyBuilder ignoreWeights(boolean ignoreWeights)
      Set whether the host selector should ignore Hosts weight.

      Host weight influences the probability it will be selected to serve a request. The host weight can come from many sources including known host capacity, priority groups, and others, so ignoring weight information can lead to other features not working properly and should be used with care.

      Defaults to false.

      Parameters:
      ignoreWeights - whether the host selector should ignore host weight information.
      Returns:
      this
    • build

      public <ResolvedAddress, C extends LoadBalancedConnection> LoadBalancingPolicy<ResolvedAddress,C> build()
      Construct the P2CLoadBalancingPolicy.
      Type Parameters:
      ResolvedAddress - the type of the resolved address.
      C - the refined type of the LoadBalancedConnection.
      Returns:
      the concrete P2CLoadBalancingPolicy.