21 package com.griddynamics.jagger.invoker;
23 import com.griddynamics.jagger.util.Pair;
25 import java.util.Iterator;
26 import java.util.List;
42 public class OneByOneLoadBalancer<Q, E>
extends QueryPoolLoadBalancer<Q, E> {
49 super(queryProvider, endpointProvider);
61 final CircularSupplier<Q> querySupplier = CircularSupplier.create(queryProvider);
62 final CircularSupplier<E> endpointSupplier = CircularSupplier.create(endpointProvider);
64 return new Iterator<Pair<Q, E>>() {
66 public boolean hasNext() {
71 public Pair<Q, E> next() {
72 boolean exceeded = endpointSupplier.exceeded();
74 E endpoint = endpointSupplier.pop();
75 Q query = exceeded ? querySupplier.pop() : querySupplier.peek();
77 return Pair.of(query, endpoint);
82 public void remove() {
83 throw new UnsupportedOperationException(
"Read only iterator");
87 public String toString() {
88 return "OneByOneLoadBalancer iterator";
96 return "OneByOneLoadBalancer";