You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/05/15 00:06:41 UTC

svn commit: r1482614 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/handler/component/ solr/solrj/ solr/solrj/src/java/org/apache/solr/client/solrj/impl/

Author: rmuir
Date: Tue May 14 22:06:40 2013
New Revision: 1482614

URL: http://svn.apache.org/r1482614
Log:
SOLR-4448: Allow the solr internal load balancer to be more easily pluggable

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1482614&r1=1482613&r2=1482614&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Tue May 14 22:06:40 2013
@@ -112,6 +112,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 ==================
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java?rev=1482614&r1=1482613&r2=1482614&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java Tue May 14 22:06:40 2013
@@ -150,17 +150,23 @@ public class HttpShardHandlerFactory ext
     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);

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=1482614&r1=1482613&r2=1482614&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java Tue May 14 22:06:40 2013
@@ -80,7 +80,7 @@ public class LBHttpSolrServer extends So
   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 So
     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 So
 
   }
 
-  private Exception addZombie(HttpSolrServer server,
-      Exception e) {
+  protected Exception addZombie(HttpSolrServer server, Exception e) {
 
     ServerWrapper wrapper;