21 package com.griddynamics.jagger.invoker;
23 import com.griddynamics.jagger.util.Pair;
25 import java.util.Iterator;
40 public class RoundRobinLoadBalancer<Q, E>
extends QueryPoolLoadBalancer<Q, E> {
47 super(queryProvider, endpointProvider);
59 final CircularSupplier<Q> querySupplier = CircularSupplier.create(queryProvider);
60 final CircularSupplier<E> endpointSupplier = CircularSupplier.create(endpointProvider);
62 return new Iterator<Pair<Q, E>>() {
64 public boolean hasNext() {
69 public Pair<Q, E> next() {
70 E endpoint = endpointSupplier.pop();
71 Q query = querySupplier.pop();
72 return Pair.of(query, endpoint);
76 public void remove() {
77 throw new UnsupportedOperationException(
"Read only iterator");
81 public String toString() {
82 return "RoundRobinLoadBalancer iterator";
89 return "RoundRobinLoadBalancer";