Class ModifiedLBSolrClient
- java.lang.Object
-
- org.apache.solr.client.solrj.SolrClient
-
- org.apache.manifoldcf.agents.output.solr.ModifiedLBSolrClient
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Serializable,java.lang.AutoCloseable
- Direct Known Subclasses:
ModifiedLBHttp2SolrClient
public abstract class ModifiedLBSolrClient extends org.apache.solr.client.solrj.SolrClient- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classModifiedLBSolrClient.Reqstatic classModifiedLBSolrClient.Rspprotected static classModifiedLBSolrClient.ServerIteratorprotected static classModifiedLBSolrClient.ServerWrapper
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.solr.client.solrj.ResponseParserparserprotected java.util.Set<java.lang.String>queryParamsprotected org.apache.solr.client.solrj.request.RequestWriterrequestWriterprotected static java.util.Set<java.lang.Integer>RETRY_CODESprotected java.util.Map<java.lang.String,ModifiedLBSolrClient.ServerWrapper>zombieServers
-
Constructor Summary
Constructors Constructor Description ModifiedLBSolrClient(java.util.List<java.lang.String> baseSolrUrls)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddQueryParams(java.lang.String queryOnlyParam)voidaddSolrServer(java.lang.String server)protected java.lang.ExceptionaddZombie(java.lang.String serverStr, java.lang.Exception e)voidclose()protected ModifiedLBSolrClient.ServerWrappercreateServerWrapper(java.lang.String baseUrl)protected java.lang.ExceptiondoRequest(java.lang.String baseUrl, ModifiedLBSolrClient.Req req, ModifiedLBSolrClient.Rsp rsp, boolean isNonRetryable, boolean isZombie)protected abstract org.apache.solr.client.solrj.SolrClientgetClient(java.lang.String baseUrl)org.apache.solr.client.solrj.ResponseParsergetParser()java.util.Set<java.lang.String>getQueryParams()org.apache.solr.client.solrj.request.RequestWritergetRequestWriter()static java.lang.Stringnormalize(java.lang.String server)protected ModifiedLBSolrClient.ServerWrapperpickServer(ModifiedLBSolrClient.ServerWrapper[] aliveServerList, org.apache.solr.client.solrj.SolrRequest<?> request)Pick a server from list to execute request.java.lang.StringremoveSolrServer(java.lang.String server)ModifiedLBSolrClient.Rsprequest(ModifiedLBSolrClient.Req req)Tries to query a live server from the list provided in Req.org.apache.solr.common.util.NamedList<java.lang.Object>request(org.apache.solr.client.solrj.SolrRequest<?> request, java.lang.String collection)Tries to query a live server.org.apache.solr.common.util.NamedList<java.lang.Object>request(org.apache.solr.client.solrj.SolrRequest<?> request, java.lang.String collection, java.lang.Integer numServersToTry)voidsetAliveCheckInterval(int interval)LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive.voidsetParser(org.apache.solr.client.solrj.ResponseParser parser)Changes theResponseParserthat will be used for the internal SolrServer objects.voidsetQueryParams(java.util.Set<java.lang.String> queryParams)Expert Method.voidsetRequestWriter(org.apache.solr.client.solrj.request.RequestWriter requestWriter)Changes theRequestWriterthat will be used for the internal SolrServer objects.protected voidupdateAliveList()-
Methods inherited from class org.apache.solr.client.solrj.SolrClient
add, add, add, add, add, add, add, add, add, add, addBean, addBean, addBean, addBean, addBeans, addBeans, addBeans, addBeans, addBeans, addBeans, commit, commit, commit, commit, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, deleteByQuery, deleteByQuery, getBinder, getById, getById, getById, getById, getById, getById, getById, getById, getContext, optimize, optimize, optimize, optimize, optimize, optimize, ping, ping, query, query, query, query, queryAndStreamResponse, queryAndStreamResponse, queryAndStreamResponse, request, rollback, rollback
-
-
-
-
Field Detail
-
RETRY_CODES
protected static final java.util.Set<java.lang.Integer> RETRY_CODES
-
zombieServers
protected final java.util.Map<java.lang.String,ModifiedLBSolrClient.ServerWrapper> zombieServers
-
parser
protected volatile org.apache.solr.client.solrj.ResponseParser parser
-
requestWriter
protected volatile org.apache.solr.client.solrj.request.RequestWriter requestWriter
-
queryParams
protected java.util.Set<java.lang.String> queryParams
-
-
Method Detail
-
updateAliveList
protected void updateAliveList()
-
createServerWrapper
protected ModifiedLBSolrClient.ServerWrapper createServerWrapper(java.lang.String baseUrl)
-
getQueryParams
public java.util.Set<java.lang.String> getQueryParams()
-
setQueryParams
public void setQueryParams(java.util.Set<java.lang.String> queryParams)
Expert Method.- Parameters:
queryParams- set of param keys to only send via the query string
-
addQueryParams
public void addQueryParams(java.lang.String queryOnlyParam)
-
normalize
public static java.lang.String normalize(java.lang.String server)
-
request
public ModifiedLBSolrClient.Rsp request(ModifiedLBSolrClient.Req req) throws org.apache.solr.client.solrj.SolrServerException, java.io.IOException
Tries to query a live server from the list provided in Req. Servers in the dead pool are skipped. If a request fails due to an IOException, the server is moved to the dead pool for a certain period of time, or until a test request on that server succeeds.Servers are queried in the exact order given (except servers currently in the dead pool are skipped). If no live servers from the provided list remain to be tried, a number of previously skipped dead servers will be tried. Req.getNumDeadServersToTry() controls how many dead servers will be tried.
If no live servers are found a SolrServerException is thrown.
- Parameters:
req- contains both the request as well as the list of servers to query- Returns:
- the result of the request
- Throws:
java.io.IOException- If there is a low-level I/O error.org.apache.solr.client.solrj.SolrServerException
-
doRequest
protected java.lang.Exception doRequest(java.lang.String baseUrl, ModifiedLBSolrClient.Req req, ModifiedLBSolrClient.Rsp rsp, boolean isNonRetryable, boolean isZombie) throws org.apache.solr.client.solrj.SolrServerException, java.io.IOException- Throws:
org.apache.solr.client.solrj.SolrServerExceptionjava.io.IOException
-
getClient
protected abstract org.apache.solr.client.solrj.SolrClient getClient(java.lang.String baseUrl)
-
addZombie
protected java.lang.Exception addZombie(java.lang.String serverStr, java.lang.Exception e)
-
setAliveCheckInterval
public void setAliveCheckInterval(int interval)
LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive. Use this to set that interval- Parameters:
interval- time in milliseconds
-
getParser
public org.apache.solr.client.solrj.ResponseParser getParser()
-
setParser
public void setParser(org.apache.solr.client.solrj.ResponseParser parser)
Changes theResponseParserthat will be used for the internal SolrServer objects.- Parameters:
parser- Default Response Parser chosen to parse the response if the parser were not specified as part of the request.- See Also:
SolrRequest.getResponseParser()
-
setRequestWriter
public void setRequestWriter(org.apache.solr.client.solrj.request.RequestWriter requestWriter)
Changes theRequestWriterthat will be used for the internal SolrServer objects.- Parameters:
requestWriter- Default RequestWriter, used to encode requests sent to the server.
-
getRequestWriter
public org.apache.solr.client.solrj.request.RequestWriter getRequestWriter()
-
addSolrServer
public void addSolrServer(java.lang.String server) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
removeSolrServer
public java.lang.String removeSolrServer(java.lang.String server)
-
request
public org.apache.solr.common.util.NamedList<java.lang.Object> request(org.apache.solr.client.solrj.SolrRequest<?> request, java.lang.String collection) throws org.apache.solr.client.solrj.SolrServerException, java.io.IOExceptionTries to query a live server. A SolrServerException is thrown if all servers are dead. If the request failed due to IOException then the live server is moved to dead pool and the request is retried on another live server. After live servers are exhausted, any servers previously marked as dead will be tried before failing the request.- Specified by:
requestin classorg.apache.solr.client.solrj.SolrClient- Parameters:
request- the SolrRequest.- Returns:
- response
- Throws:
java.io.IOException- If there is a low-level I/O error.org.apache.solr.client.solrj.SolrServerException
-
request
public org.apache.solr.common.util.NamedList<java.lang.Object> request(org.apache.solr.client.solrj.SolrRequest<?> request, java.lang.String collection, java.lang.Integer numServersToTry) throws org.apache.solr.client.solrj.SolrServerException, java.io.IOException- Throws:
org.apache.solr.client.solrj.SolrServerExceptionjava.io.IOException
-
pickServer
protected ModifiedLBSolrClient.ServerWrapper pickServer(ModifiedLBSolrClient.ServerWrapper[] aliveServerList, org.apache.solr.client.solrj.SolrRequest<?> request)
Pick a server from list to execute request. By default servers are picked in round-robin manner, custom classes can override this method for more advance logic- Parameters:
aliveServerList- list of currently alive serversrequest- the request will be sent to the picked server- Returns:
- the picked server
-
close
public void close()
-
-