|
|||||||||
| 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 a load balancing wrapper around
HttpSolrServer. This is useful when you
have multiple SolrServers and the requests need to be Load Balanced among them.
Do NOT use this class for indexing in master/slave scenarios since documents must be sent to the
correct master; no inter-node routing is done.
In SolrCloud (leader/replica) scenarios, this class may be used for updates since updates will be forwarded
to the appropriate leader.
Also see the wiki page.
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?
| Nested Class Summary | |
|---|---|
static class |
LBHttpSolrServer.Req
|
static class |
LBHttpSolrServer.Rsp
|
protected static class |
LBHttpSolrServer.ServerWrapper
|
| Field Summary | |
|---|---|
protected Map<String,LBHttpSolrServer.ServerWrapper> |
zombieServers
|
| Constructor Summary | |
|---|---|
LBHttpSolrServer(org.apache.http.client.HttpClient httpClient,
ResponseParser parser,
String... solrServerUrl)
The provided httpClient should use a multi-threaded connection manager |
|
LBHttpSolrServer(org.apache.http.client.HttpClient httpClient,
String... solrServerUrl)
The provided httpClient should use a multi-threaded connection manager |
|
LBHttpSolrServer(String... solrServerUrls)
|
|
| Method Summary | |
|---|---|
void |
addSolrServer(String server)
|
protected Exception |
addZombie(HttpSolrServer server,
Exception e)
|
protected void |
finalize()
|
org.apache.http.client.HttpClient |
getHttpClient()
|
ResponseParser |
getParser()
|
protected HttpSolrServer |
makeServer(String server)
|
static String |
normalize(String server)
|
String |
removeSolrServer(String server)
|
LBHttpSolrServer.Rsp |
request(LBHttpSolrServer.Req req)
Tries to query a live server from the list provided in Req. |
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 |
setConnectionTimeout(int timeout)
|
void |
setParser(ResponseParser parser)
|
void |
setRequestWriter(RequestWriter requestWriter)
|
void |
setSoTimeout(int timeout)
set soTimeout (read timeout) on the underlying HttpConnectionManager. |
void |
shutdown()
Release allocated resources. |
| Methods inherited from class org.apache.solr.client.solrj.SolrServer |
|---|
add, add, add, add, addBean, addBean, addBeans, addBeans, commit, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, getBinder, optimize, optimize, optimize, ping, query, query, queryAndStreamResponse, rollback |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Map<String,LBHttpSolrServer.ServerWrapper> zombieServers
| Constructor Detail |
|---|
public LBHttpSolrServer(String... solrServerUrls)
throws MalformedURLException
MalformedURLException
public LBHttpSolrServer(org.apache.http.client.HttpClient httpClient,
String... solrServerUrl)
throws MalformedURLException
MalformedURLException
public LBHttpSolrServer(org.apache.http.client.HttpClient httpClient,
ResponseParser parser,
String... solrServerUrl)
throws MalformedURLException
MalformedURLException| Method Detail |
|---|
public static String normalize(String server)
protected HttpSolrServer makeServer(String server)
throws MalformedURLException
MalformedURLException
public LBHttpSolrServer.Rsp request(LBHttpSolrServer.Req req)
throws SolrServerException,
IOException
req - contains both the request as well as the list of servers to query
IOException - If there is a low-level I/O error.
SolrServerException
protected Exception addZombie(HttpSolrServer server,
Exception e)
public void addSolrServer(String server)
throws MalformedURLException
MalformedURLExceptionpublic String removeSolrServer(String server)
public void setConnectionTimeout(int timeout)
public void setSoTimeout(int timeout)
public void shutdown()
SolrServer
shutdown in class SolrServer
public NamedList<Object> request(SolrRequest request)
throws SolrServerException,
IOException
request in class SolrServerrequest - the SolrRequest.
IOException - If there is a low-level I/O error.
SolrServerExceptionpublic void setAliveCheckInterval(int interval)
interval - time in millisecondspublic org.apache.http.client.HttpClient getHttpClient()
public ResponseParser getParser()
public void setParser(ResponseParser parser)
public void setRequestWriter(RequestWriter requestWriter)
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||