Interface Weighted

All Known Subinterfaces:
HttpServiceInstance, WeightedServiceInstance

public interface Weighted

A weighted element defining a weight

Since:
1.12
Author:
Jeremy Kuhn
  • Method Summary

    Modifier and Type
    Method
    Description
    static <A extends Weighted>
    Collection<A>
    expandToLoadBalanced(Collection<A> weightedElements)
    Returns a weighted collection of weighted elements for load balancing.
    int
    Returns the weight of the weighted element in a collection of weighted elements.
  • Method Details

    • getWeight

      int getWeight()

      Returns the weight of the weighted element in a collection of weighted elements.

      Returns:
      a strictly positive integer
    • expandToLoadBalanced

      static <A extends Weighted> Collection<A> expandToLoadBalanced(Collection<A> weightedElements)

      Returns a weighted collection of weighted elements for load balancing.

      The returned collection reflects the weight of the specified weighted elements. For instance, if we have 3 elements A, B, C as input with weights 2, 4, 6 respectively the returned collection contains exactly 1 A instance, 2 B instances and 3 C instances.

      Type Parameters:
      A - the type of the weighted elements
      Parameters:
      weightedElements - a list of weighted elements
      Returns:
      a weighted collection of elements.