public class LBHttpSolrServer extends SolrServer
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 usingSolrServer 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");
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, rollback
public LBHttpSolrServer(String... solrServerUrls) throws MalformedURLException
MalformedURLException
public LBHttpSolrServer(org.apache.commons.httpclient.HttpClient httpClient, String... solrServerUrl) throws MalformedURLException
MalformedURLException
public LBHttpSolrServer(org.apache.commons.httpclient.HttpClient httpClient, ResponseParser parser, String... solrServerUrl) throws MalformedURLException
MalformedURLException
public void addSolrServer(String server) throws MalformedURLException
MalformedURLException
public 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 SolrServer
request
- the SolrRequest.SolrServerException
IOException
public void setAliveCheckInterval(int interval)
interval
- time in millisecondspublic org.apache.commons.httpclient.HttpClient getHttpClient()