SOLR-1532 -- Allow StreamingUpdateSolrServer to use a provided HttpClient

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@890769 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2009-12-15 11:32:27 +00:00
parent 326e5201ce
commit 0e8eb2a2d8
2 changed files with 23 additions and 4 deletions

View File

@ -67,6 +67,8 @@ New Features
* SOLR-1621: Allow current single core deployments to be specified by solr.xml (Mark Miller , noble)
* SOLR-1532: Allow StreamingUpdateSolrServer to use a provided HttpClient (Gabriele Renzi via shalin)
Optimizations
----------------------

View File

@ -27,6 +27,7 @@ import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
@ -61,10 +62,26 @@ public class StreamingUpdateSolrServer extends CommonsHttpSolrServer
final Queue<Runner> runners;
volatile CountDownLatch lock = null; // used to block everything
final int threadCount;
public StreamingUpdateSolrServer(String solrServerUrl, int queueSize, int threadCount ) throws MalformedURLException {
super( solrServerUrl );
queue = new LinkedBlockingQueue<UpdateRequest>( queueSize );
/**
* Uses an internal MultiThreadedHttpConnectionManager to manage http connections
*
* @param solrServerUrl The solr server url
* @param queueSize The buffer size before the documents are sent o the server
* @param threadCount The number of backgtound threads used to empty the queue
* @throws MalformedURLException
*/
public StreamingUpdateSolrServer(String solrServerUrl, int queueSize, int threadCount) throws MalformedURLException {
this(solrServerUrl, null, queueSize, threadCount);
}
/**
* Uses the supplied HttpClient to send documents to the solr server, the HttpClient should be instantiated using a
* MultiThreadedHttpConnectionManager.
*/
public StreamingUpdateSolrServer(String solrServerUrl, HttpClient client, int queueSize, int threadCount) throws MalformedURLException {
super(solrServerUrl, client);
queue = new LinkedBlockingQueue<UpdateRequest>(queueSize);
this.threadCount = threadCount;
runners = new LinkedList<Runner>();
}