1 package com.griddynamics.jagger.invoker;
3 import com.griddynamics.jagger.util.Pair;
4 import com.griddynamics.jagger.util.Timeout;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
8 import java.util.concurrent.TimeUnit;
24 public class CircularExclusiveAccessLoadBalancer<Q, E>
extends ExclusiveAccessLoadBalancer<Q, E> {
26 private final static Logger log = LoggerFactory.getLogger(CircularExclusiveAccessLoadBalancer.class);
29 super(pairSupplierFactory);
32 private final static String POLL_TIMEOUT_NAME =
"load balancer poll next timeout";
34 private Timeout pollTimeout =
new Timeout(10 * 60 * 1000, POLL_TIMEOUT_NAME);
43 Pair<Q, E> next = null;
44 long startMillis = System.currentTimeMillis();
46 next = getPairQueue().poll(pollTimeout.getValue(), TimeUnit.MILLISECONDS);
47 }
catch (InterruptedException ignored) {
51 throw new IllegalStateException(String.format(
"Didn't manage to poll the next pair. Timeout %s",
55 long endMillis = System.currentTimeMillis();
56 if (endMillis - startMillis > 1000) {
58 "It took {} ms to poll the next pair for the load balancer. Possible reason: not enough test data for selected load",
59 endMillis - startMillis);
66 this.pollTimeout =
new Timeout(pollTimeout, POLL_TIMEOUT_NAME);