21 package com.griddynamics.jagger.invoker;
23 import com.griddynamics.jagger.util.Pair;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 import java.util.Iterator;
37 public abstract class QueryPoolLoadBalancer<Q, E>
implements LoadBalancer<Q, E> {
39 private final static Logger log = LoggerFactory.getLogger(QueryPoolLoadBalancer.class);
45 protected volatile boolean initialized =
false;
46 protected final Object lock =
new Object();
52 this.queryProvider = queryProvider;
53 this.endpointProvider = endpointProvider;
57 this.queryProvider = queryProvider;
61 this.endpointProvider = endpointProvider;
65 this.kernelInfo = kernelInfo;
75 return getIterableSize(endpointProvider);
84 log.debug(
"already initialized. returning...");
88 if (endpointProvider == null) {
89 throw new IllegalStateException(
"Endpoint provider is null");
91 log.info(
"total endpoints number - {}", endpointSize());
94 if (queryProvider == null) {
95 log.info(
"Query provider is null.");
97 log.info(
"total queries number - {}", querySize());
100 log.info(
"kernel info: {}", kernelInfo);
108 return getIterableSize(queryProvider);
112 if (iterable == null)
115 Iterator<Q> iterator = iterable.iterator();
117 while (iterator.hasNext()){