SOLR-4448: Allow the solr internal load balancer to be more easily pluggable

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1482600 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-05-14 21:29:52 +00:00
parent a1e29c7415
commit ca404e3ec0
3 changed files with 14 additions and 7 deletions

View File

@ -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 ==================

View File

@ -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 here
throw 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);

View File

@ -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 synchronize
private 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;