21 package com.griddynamics.jagger.invoker;
23 import com.griddynamics.jagger.util.Pair;
25 import java.util.Iterator;
41 public class RoundRobinLoadBalancer<Q, E>
extends QueryPoolLoadBalancer<Q, E> {
48 super(queryProvider, endpointProvider);
60 final CircularSupplier<Q> querySupplier = CircularSupplier.create(queryProvider);
61 final CircularSupplier<E> endpointSupplier = CircularSupplier.create(endpointProvider);
63 return new Iterator<Pair<Q, E>>() {
65 public boolean hasNext() {
70 public Pair<Q, E> next() {
71 E endpoint = endpointSupplier.pop();
72 Q query = querySupplier.pop();
73 return Pair.of(query, endpoint);
77 public void remove() {
78 throw new UnsupportedOperationException(
"Read only iterator");
82 public String toString() {
83 return "RoundRobinLoadBalancer iterator";
90 return "RoundRobinLoadBalancer";