Apache Solr open-source search software
SOLR-4448: Allow the solr internal load balancer to be more easily pluggable
Robert Muirca404e3ec069
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 23d58e3133f..8854d0ca88e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -136,6 +136,8 @@ Other Changes* SOLR-4784: Make class LuceneQParser public (janhoy)+* SOLR-4448: Allow the solr internal load balancer to be more easily pluggable.+ (Philip Hoy via Robert Muir)================== 4.3.1 ==================diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.javaindex 21c4dfffadd..d55e01f0701 100644--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java@@ -150,17 +150,23 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory implements org.clientParams.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, connectionTimeout);clientParams.set(HttpClientUtil.PROP_USE_RETRY, false);this.defaultClient = HttpClientUtil.createClient(clientParams);+ this.loadbalancer = createLoadbalancer(defaultClient);+ }++ protected ThreadPoolExecutor getThreadPoolExecutor(){+ return this.commExecutor;+ }+ protected LBHttpSolrServer createLoadbalancer(HttpClient httpClient){try {- loadbalancer = new LBHttpSolrServer(defaultClient);+ return new LBHttpSolrServer(httpClient);} catch (MalformedURLException e) {// should be impossible since we're not passing any URLs herethrow new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);}-}- private <T> T getParameter(NamedList initArgs, String configKey, T defaultValue) {+ protected <T> T getParameter(NamedList initArgs, String configKey, T defaultValue) {T toReturn = defaultValue;if (initArgs != null) {T temp = (T) initArgs.get(configKey);diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.javaindex c4aaafe3333..70c45463364 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java@@ -80,7 +80,7 @@ public class LBHttpSolrServer extends SolrServer {private final Map<String, ServerWrapper> aliveServers = new LinkedHashMap<String, ServerWrapper>();// access to aliveServers should be synchronized on itself- private final Map<String, ServerWrapper> zombieServers = new ConcurrentHashMap<String, ServerWrapper>();+ protected final Map<String, ServerWrapper> zombieServers = new ConcurrentHashMap<String, ServerWrapper>();// changes to aliveServers are reflected in this array, no need to synchronizeprivate volatile ServerWrapper[] aliveServerList = new ServerWrapper[0];@@ -99,7 +99,7 @@ public class LBHttpSolrServer extends SolrServer {solrQuery.setRows(0);}- private static class ServerWrapper {+ protected static class ServerWrapper {final HttpSolrServer solrServer;long lastUsed; // last time used for a real request@@ -335,8 +335,7 @@ public class LBHttpSolrServer extends SolrServer {}- private Exception addZombie(HttpSolrServer server,- Exception e) {+ protected Exception addZombie(HttpSolrServer server, Exception e) {ServerWrapper wrapper;