public class LBHttpSolrServer extends SolrServer
SolrServer lbHttpSolrServer = new LBHttpSolrServer("http://host1:8080/solr/","http://host2:8080/solr","http://host2:8080/solr");
//or if you wish to pass the HttpClient do as follows
httpClient httpClient = new HttpClient();
SolrServer lbHttpSolrServer = new LBHttpSolrServer(httpClient,"http://host1:8080/solr/","http://host2:8080/solr","http://host2:8080/solr");
This detects if a dead server comes alive automatically. The check is done in fixed intervals in a dedicated thread.
This interval can be set using setAliveCheckInterval(int) , the default is set to one minute.
When to use this?| Constructor and Description |
|---|
LBHttpSolrServer(org.apache.commons.httpclient.HttpClient httpClient,
ResponseParser parser,
String... solrServerUrl) |
LBHttpSolrServer(org.apache.commons.httpclient.HttpClient httpClient,
String... solrServerUrl) |
LBHttpSolrServer(String... solrServerUrls) |
| Modifier and Type | Method and Description |
|---|---|
void |
addSolrServer(String server) |
protected void |
finalize() |
org.apache.commons.httpclient.HttpClient |
getHttpClient() |
String |
removeSolrServer(String server) |
NamedList<Object> |
request(SolrRequest request)
Tries to query a live server.
|
void |
setAliveCheckInterval(int interval)
LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive.
|
void |
setConnectionManagerTimeout(int timeout)
set connectionManagerTimeout on the HttpClient
|
void |
setConnectionTimeout(int timeout) |
void |
setSoTimeout(int timeout)
set soTimeout (read timeout) on the underlying HttpConnectionManager.
|
add, add, add, add, addBean, addBean, addBeans, addBeans, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, getBinder, optimize, optimize, optimize, ping, query, query, rollbackpublic LBHttpSolrServer(String... solrServerUrls) throws MalformedURLException
MalformedURLExceptionpublic LBHttpSolrServer(org.apache.commons.httpclient.HttpClient httpClient,
String... solrServerUrl)
throws MalformedURLException
MalformedURLExceptionpublic LBHttpSolrServer(org.apache.commons.httpclient.HttpClient httpClient,
ResponseParser parser,
String... solrServerUrl)
throws MalformedURLException
MalformedURLExceptionpublic void addSolrServer(String server) throws MalformedURLException
MalformedURLExceptionpublic void setConnectionTimeout(int timeout)
public void setConnectionManagerTimeout(int timeout)
public void setSoTimeout(int timeout)
public NamedList<Object> request(SolrRequest request) throws SolrServerException, IOException
request in class SolrServerrequest - the SolrRequest.SolrServerExceptionIOExceptionpublic void setAliveCheckInterval(int interval)
interval - time in millisecondspublic org.apache.commons.httpclient.HttpClient getHttpClient()