Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
Pair<Q, E> com.griddynamics.jagger.invoker.CircularExclusiveAccessLoadBalancer< Q, E >.pollNext ( )
protectedvirtual

Implements com.griddynamics.jagger.invoker.ExclusiveAccessLoadBalancer< Q, E >.

Definition at line 41 of file CircularExclusiveAccessLoadBalancer.java.

41  {
42 
43  Pair<Q, E> next = null;
44  long startMillis = System.currentTimeMillis();
45  try {
46  next = getPairQueue().poll(pollTimeout.getValue(), TimeUnit.MILLISECONDS);
47  } catch (InterruptedException ignored) {
48  }
49 
50  if (next == null) {
51  throw new IllegalStateException(String.format("Didn't manage to poll the next pair. Timeout %s",
52  pollTimeout));
53  }
54 
55  long endMillis = System.currentTimeMillis();
56  if (endMillis - startMillis > 1000) {
57  log.warn(
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);
60  }
61 
62  return next;
63  }