|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.solr.client.solrj.SolrServer
org.apache.solr.client.solrj.impl.LBHttpSolrServer
public class LBHttpSolrServer
LBHttpSolrServer or "LoadBalanced HttpSolrServer" is just a wrapper to CommonsHttpSolrServer. This is useful when you have multiple SolrServers and the requests need to be Load Balanced among them. This should NOT be used for indexing. Also see the wiki page.
It offers automatic failover when a server goes down and it detects when the server comes back up. Load balancing is done using a simple roundrobin on the list of servers. If a request to a server fails by an IOException due to a connection timeout or read timeout then the host is taken off the list of live servers and moved to a 'dead server list' and the request is resent to the next live server. This process is continued till it tries all the live servers. If atleast one server is alive, the request succeeds, andif not it fails.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 Summary | |
---|---|
LBHttpSolrServer(org.apache.commons.httpclient.HttpClient httpClient,
ResponseParser parser,
String... solrServerUrl)
|
|
LBHttpSolrServer(org.apache.commons.httpclient.HttpClient httpClient,
String... solrServerUrl)
|
|
LBHttpSolrServer(String... solrServerUrls)
|
Method Summary | |
---|---|
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. |
Methods inherited from class org.apache.solr.client.solrj.SolrServer |
---|
add, add, add, add, addBean, addBean, addBeans, addBeans, commit, commit, deleteById, deleteById, deleteByQuery, getBinder, optimize, optimize, optimize, ping, query, query, rollback |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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
Method Detail |
---|
public void addSolrServer(String server) throws MalformedURLException
MalformedURLException
public String removeSolrServer(String server)
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()
protected void finalize() throws Throwable
finalize
in class Object
Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |