21 package com.griddynamics.jagger.invoker;
23 import com.google.common.collect.AbstractIterator;
24 import com.griddynamics.jagger.util.Pair;
25 import java.util.Iterator;
26 import java.util.Random;
38 public class RandomLoadBalancer<Q, E>
extends PairSupplierFactoryLoadBalancer<Q, E> {
40 private long randomSeed;
43 this.randomSeed = randomSeed;
58 return new AbstractIterator<Pair<Q,E>>() {
60 private PairSupplier<Q, E> pairs = getPairSupplier();
61 private int size = pairs.size();
62 private Random random =
new Random(randomSeed++);
65 protected Pair<Q, E> computeNext() {
66 return pairs.get(random.nextInt(size));
70 public String toString() {
71 return "RandomLoadBalancer iterator";