Class HttpSolrClientBase
- java.lang.Object
-
- org.apache.solr.client.solrj.SolrClient
-
- org.apache.solr.client.solrj.impl.HttpSolrClientBase
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
- Direct Known Subclasses:
Http2SolrClient
,HttpJdkSolrClient
public abstract class HttpSolrClientBase extends SolrClient
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
basicAuthAuthorizationStr
protected static String
DEFAULT_PATH
protected Set<String>
defaultParserMimeTypes
protected static Charset
FALLBACK_CHARSET
protected long
idleTimeoutMillis
protected ResponseParser
parser
protected long
requestTimeoutMillis
protected RequestWriter
requestWriter
protected String
serverBaseUrl
The URL of the Solr server.protected Set<String>
urlParamNames
-
Fields inherited from class org.apache.solr.client.solrj.SolrClient
defaultCollection
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HttpSolrClientBase(String serverBaseUrl, HttpSolrClientBuilderBase<?,?> builder)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract String
allProcessorSupportedContentTypesCommaDelimited(Collection<String> processorSupportedContentTypes)
abstract Cancellable
asyncRequest(SolrRequest<?> solrRequest, String collection, AsyncListener<NamedList<Object>> asyncListener)
Deprecated.protected static String
basicAuthCredentialsToAuthorizationString(String user, String pass)
protected ModifiableSolrParams
calculateQueryParams(Set<String> queryParamNames, ModifiableSolrParams wparams)
String
getBaseURL()
long
getIdleTimeout()
ResponseParser
getParser()
protected String
getRequestUrl(SolrRequest<?> solrRequest, String collection)
Set<String>
getUrlParamNames()
protected ModifiableSolrParams
initalizeSolrParams(SolrRequest<?> solrRequest, ResponseParser parserToUse)
Deprecated, for removal: This API element is subject to removal in a future version.protected ModifiableSolrParams
initializeSolrParams(SolrRequest<?> solrRequest, ResponseParser parserToUse)
protected abstract boolean
isFollowRedirects()
protected boolean
isMultipart(Collection<ContentStream> streams)
boolean
isV2ApiRequest(SolrRequest<?> request)
protected NamedList<Object>
processErrorsAndResponse(int httpStatus, String responseReason, String responseMethod, ResponseParser processor, InputStream is, String mimeType, String encoding, boolean isV2Api, String urlExceptionMessage)
protected abstract boolean
processorAcceptsMimeType(Collection<String> processorSupportedContentTypes, String mimeType)
CompletableFuture<NamedList<Object>>
requestAsync(SolrRequest<?> request)
Execute an asynchronous request against a Solr server using the default collection.abstract CompletableFuture<NamedList<Object>>
requestAsync(SolrRequest<?> request, String collection)
Execute an asynchronous request against a Solr server for a given collection.protected ResponseParser
responseParser(SolrRequest<?> solrRequest)
protected void
setParser(ResponseParser parser)
protected abstract void
updateDefaultMimeTypeForParser()
protected void
validateGetRequest(SolrRequest<?> solrRequest)
protected boolean
wantStream(ResponseParser processor)
-
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, getDefaultCollection, optimize, optimize, optimize, optimize, optimize, optimize, ping, ping, query, query, query, query, queryAndStreamResponse, queryAndStreamResponse, queryAndStreamResponse, request, request, rollback, rollback
-
-
-
-
Field Detail
-
DEFAULT_PATH
protected static final String DEFAULT_PATH
- See Also:
- Constant Field Values
-
FALLBACK_CHARSET
protected static final Charset FALLBACK_CHARSET
-
serverBaseUrl
protected final String serverBaseUrl
The URL of the Solr server.
-
idleTimeoutMillis
protected final long idleTimeoutMillis
-
requestTimeoutMillis
protected final long requestTimeoutMillis
-
requestWriter
protected RequestWriter requestWriter
-
parser
protected ResponseParser parser
-
basicAuthAuthorizationStr
protected final String basicAuthAuthorizationStr
-
-
Constructor Detail
-
HttpSolrClientBase
protected HttpSolrClientBase(String serverBaseUrl, HttpSolrClientBuilderBase<?,?> builder)
-
-
Method Detail
-
getRequestUrl
protected String getRequestUrl(SolrRequest<?> solrRequest, String collection) throws MalformedURLException
- Throws:
MalformedURLException
-
responseParser
protected ResponseParser responseParser(SolrRequest<?> solrRequest)
-
initalizeSolrParams
@Deprecated(since="9.8", forRemoval=true) protected ModifiableSolrParams initalizeSolrParams(SolrRequest<?> solrRequest, ResponseParser parserToUse)
Deprecated, for removal: This API element is subject to removal in a future version.
-
initializeSolrParams
protected ModifiableSolrParams initializeSolrParams(SolrRequest<?> solrRequest, ResponseParser parserToUse)
-
isMultipart
protected boolean isMultipart(Collection<ContentStream> streams)
-
calculateQueryParams
protected ModifiableSolrParams calculateQueryParams(Set<String> queryParamNames, ModifiableSolrParams wparams)
-
validateGetRequest
protected void validateGetRequest(SolrRequest<?> solrRequest) throws IOException
- Throws:
IOException
-
isFollowRedirects
protected abstract boolean isFollowRedirects()
-
processErrorsAndResponse
protected NamedList<Object> processErrorsAndResponse(int httpStatus, String responseReason, String responseMethod, ResponseParser processor, InputStream is, String mimeType, String encoding, boolean isV2Api, String urlExceptionMessage) throws SolrServerException
- Throws:
SolrServerException
-
wantStream
protected boolean wantStream(ResponseParser processor)
-
processorAcceptsMimeType
protected abstract boolean processorAcceptsMimeType(Collection<String> processorSupportedContentTypes, String mimeType)
-
allProcessorSupportedContentTypesCommaDelimited
protected abstract String allProcessorSupportedContentTypesCommaDelimited(Collection<String> processorSupportedContentTypes)
-
basicAuthCredentialsToAuthorizationString
protected static String basicAuthCredentialsToAuthorizationString(String user, String pass)
-
setParser
protected void setParser(ResponseParser parser)
-
updateDefaultMimeTypeForParser
protected abstract void updateDefaultMimeTypeForParser()
-
asyncRequest
@Deprecated public abstract Cancellable asyncRequest(SolrRequest<?> solrRequest, String collection, AsyncListener<NamedList<Object>> asyncListener)
Deprecated.- Parameters:
solrRequest
- the request to performcollection
- if null the default collection is usedasyncListener
- callers should provide an implementation to handle events: start, success, exception- Returns:
- Cancellable allowing the caller to attempt cancellation
-
requestAsync
public abstract CompletableFuture<NamedList<Object>> requestAsync(SolrRequest<?> request, String collection)
Execute an asynchronous request against a Solr server for a given collection.- Parameters:
request
- the request to executecollection
- the collection to execute the request against- Returns:
- a
CompletableFuture
that tracks the progress of the async request. Supports cancelling requests viaCompletableFuture.cancel(boolean)
, adding callbacks/error handling usingCompletableFuture.whenComplete(BiConsumer)
andCompletableFuture.exceptionally(Function)
methods, and other CompletableFuture functionality. Will complete exceptionally in case of either anIOException
orSolrServerException
during the request. Once completed, the CompletableFuture will contain aNamedList
with the response from the server.
-
requestAsync
public CompletableFuture<NamedList<Object>> requestAsync(SolrRequest<?> request)
Execute an asynchronous request against a Solr server using the default collection.- Parameters:
request
- the request to execute- Returns:
- a
CompletableFuture
seerequestAsync(SolrRequest, String)
.
-
isV2ApiRequest
public boolean isV2ApiRequest(SolrRequest<?> request)
-
getBaseURL
public String getBaseURL()
-
getParser
public ResponseParser getParser()
-
getIdleTimeout
public long getIdleTimeout()
-
-