Class Http2SolrClient
- java.lang.Object
-
- org.apache.solr.client.solrj.SolrClient
-
- org.apache.solr.client.solrj.impl.HttpSolrClientBase
-
- org.apache.solr.client.solrj.impl.Http2SolrClient
-
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable
public class Http2SolrClient extends HttpSolrClientBase
Difference between thisHttp2SolrClientandHttpSolrClient:Http2SolrClientsends requests in HTTP/2Http2SolrClientcan point to multiple urlsHttp2SolrClientdoes not expose its internal httpClient likeHttpSolrClient.getHttpClient(), sharing connection pools should be done byHttp2SolrClient.Builder.withHttpClient(Http2SolrClient)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttp2SolrClient.Builderstatic classHttp2SolrClient.OutStream
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.solr.client.solrj.impl.Http2SolrClient.AsyncTrackerasyncTrackerstatic StringREQ_PRINCIPAL_KEY-
Fields inherited from class org.apache.solr.client.solrj.impl.HttpSolrClientBase
basicAuthAuthorizationStr, DEFAULT_PATH, defaultParserMimeTypes, FALLBACK_CHARSET, idleTimeoutMillis, parser, requestTimeoutMillis, requestWriter, serverBaseUrl, urlParamNames
-
Fields inherited from class org.apache.solr.client.solrj.SolrClient
defaultCollection
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttp2SolrClient(String serverBaseUrl, Http2SolrClient.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListenerFactory(HttpListenerFactory factory)Deprecated.protected StringallProcessorSupportedContentTypesCommaDelimited(Collection<String> processorSupportedContentTypes)CancellableasyncRequest(SolrRequest<?> solrReq, String collection, AsyncListener<NamedList<Object>> asyncListener)voidclose()StringgetBaseURL()Set<String>getQueryParams()Deprecated.protected RequestWritergetRequestWriter()Http2SolrClient.OutStreaminitOutStream(String baseUrl, UpdateRequest updateRequest, String collection)protected booleanisFollowRedirects()protected booleanprocessorAcceptsMimeType(Collection<String> processorSupportedContentTypes, String mimeType)NamedList<Object>request(SolrRequest<?> solrRequest, String collection)Execute a request against a Solr server for a given collectionCompletableFuture<NamedList<Object>>requestAsync(SolrRequest<?> solrRequest, String collection)Execute an asynchronous request against a Solr server for a given collection.<R extends SolrResponse>
RrequestWithBaseUrl(String baseUrl, String collection, SolrRequest<R> req)Executes a SolrRequest using the provided URL to temporarily override any "base URL" currently used by this client<R> RrequestWithBaseUrl(String baseUrl, SolrClientFunction<Http2SolrClient,R> clientFunction)Temporarily modifies the client to use a different base URL and runs the provided lambdastatic voidresetSslContextFactory()voidsend(Http2SolrClient.OutStream outStream, SolrRequest<?> req, String collection)voidsetAuthenticationStore(org.eclipse.jetty.client.api.AuthenticationStore authenticationStore)static voidsetDefaultSSLConfig(SSLConfig sslConfig)voidsetFollowRedirects(boolean follow)Deprecated.useHttpSolrClientBuilderBase.withFollowRedirects(boolean)Redirects(boolean)} insteadvoidsetRequestWriter(RequestWriter requestWriter)Deprecated.voidsetUrlParamNames(Set<String> urlParamNames)Deprecated.protected voidupdateDefaultMimeTypeForParser()-
Methods inherited from class org.apache.solr.client.solrj.impl.HttpSolrClientBase
basicAuthCredentialsToAuthorizationString, calculateQueryParams, getIdleTimeout, getParser, getRequestUrl, getUrlParamNames, initalizeSolrParams, initializeSolrParams, isMultipart, isV2ApiRequest, processErrorsAndResponse, requestAsync, responseParser, setParser, validateGetRequest, wantStream
-
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, rollback, rollback
-
-
-
-
Field Detail
-
REQ_PRINCIPAL_KEY
public static final String REQ_PRINCIPAL_KEY
- See Also:
- Constant Field Values
-
asyncTracker
protected org.apache.solr.client.solrj.impl.Http2SolrClient.AsyncTracker asyncTracker
-
-
Constructor Detail
-
Http2SolrClient
protected Http2SolrClient(String serverBaseUrl, Http2SolrClient.Builder builder)
-
-
Method Detail
-
addListenerFactory
@Deprecated(since="9.7") public void addListenerFactory(HttpListenerFactory factory)
Deprecated.
-
close
public void close()
-
setAuthenticationStore
public void setAuthenticationStore(org.eclipse.jetty.client.api.AuthenticationStore authenticationStore)
-
initOutStream
public Http2SolrClient.OutStream initOutStream(String baseUrl, UpdateRequest updateRequest, String collection) throws IOException
- Throws:
IOException
-
send
public void send(Http2SolrClient.OutStream outStream, SolrRequest<?> req, String collection) throws IOException
- Throws:
IOException
-
asyncRequest
public Cancellable asyncRequest(SolrRequest<?> solrReq, String collection, AsyncListener<NamedList<Object>> asyncListener)
- Specified by:
asyncRequestin classHttpSolrClientBase- Parameters:
solrReq- 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 CompletableFuture<NamedList<Object>> requestAsync(SolrRequest<?> solrRequest, String collection)
Description copied from class:HttpSolrClientBaseExecute an asynchronous request against a Solr server for a given collection.- Specified by:
requestAsyncin classHttpSolrClientBase- Parameters:
solrRequest- the request to executecollection- the collection to execute the request against- Returns:
- a
CompletableFuturethat 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 anIOExceptionorSolrServerExceptionduring the request. Once completed, the CompletableFuture will contain aNamedListwith the response from the server.
-
request
public NamedList<Object> request(SolrRequest<?> solrRequest, String collection) throws SolrServerException, IOException
Description copied from class:SolrClientExecute a request against a Solr server for a given collection- Specified by:
requestin classSolrClient- Parameters:
solrRequest- the request to executecollection- the collection to execute the request against- Returns:
- a
NamedListcontaining the response from the server - Throws:
SolrServerException- if there is an error on the serverIOException- If there is a low-level I/O error.
-
requestWithBaseUrl
public final <R extends SolrResponse> R requestWithBaseUrl(String baseUrl, String collection, SolrRequest<R> req) throws SolrServerException, IOException
Executes a SolrRequest using the provided URL to temporarily override any "base URL" currently used by this client- Parameters:
baseUrl- a URL to a root Solr path (i.e. "/solr") that should be used for this requestcollection- an optional collection or core name used to override the client's "default collection". May be 'null' for any requests that don't require a collection or wish to rely on the client's defaultreq- the SolrRequest to send- Throws:
SolrServerExceptionIOException
-
requestWithBaseUrl
public <R> R requestWithBaseUrl(String baseUrl, SolrClientFunction<Http2SolrClient,R> clientFunction) throws SolrServerException, IOException
Temporarily modifies the client to use a different base URL and runs the provided lambda- Type Parameters:
R- the type returned by the provided function (and by this method)- Parameters:
baseUrl- the base URL to use on any requests made within the 'clientFunction' lambdaclientFunction- a Function that consumes a Http2SolrClient and returns an arbitrary value- Returns:
- the value returned after invoking 'clientFunction'
- Throws:
SolrServerExceptionIOException
-
isFollowRedirects
protected boolean isFollowRedirects()
- Specified by:
isFollowRedirectsin classHttpSolrClientBase
-
processorAcceptsMimeType
protected boolean processorAcceptsMimeType(Collection<String> processorSupportedContentTypes, String mimeType)
- Specified by:
processorAcceptsMimeTypein classHttpSolrClientBase
-
allProcessorSupportedContentTypesCommaDelimited
protected String allProcessorSupportedContentTypesCommaDelimited(Collection<String> processorSupportedContentTypes)
- Specified by:
allProcessorSupportedContentTypesCommaDelimitedin classHttpSolrClientBase
-
setRequestWriter
@Deprecated public void setRequestWriter(RequestWriter requestWriter)
Deprecated.Choose theRequestWriterto use.By default,
BinaryRequestWriteris used.Note: This setter method is not thread-safe.
-
getRequestWriter
protected RequestWriter getRequestWriter()
-
setFollowRedirects
@Deprecated public void setFollowRedirects(boolean follow)
Deprecated.useHttpSolrClientBuilderBase.withFollowRedirects(boolean)Redirects(boolean)} insteadConfigure whether the client should follow redirects or not.This defaults to false under the assumption that if you are following a redirect to get to a Solr installation, something is configured wrong somewhere.
-
getBaseURL
public String getBaseURL()
- Overrides:
getBaseURLin classHttpSolrClientBase
-
getQueryParams
@Deprecated public Set<String> getQueryParams()
Deprecated.
-
setUrlParamNames
@Deprecated public void setUrlParamNames(Set<String> urlParamNames)
Deprecated.Expert Method- Parameters:
urlParamNames- set of param keys that are only sent via the query string. Note that the param will be sent as a query string if the key is part of this Set or the SolrRequest's query params.- See Also:
SolrRequest.getQueryParams()
-
updateDefaultMimeTypeForParser
protected void updateDefaultMimeTypeForParser()
- Specified by:
updateDefaultMimeTypeForParserin classHttpSolrClientBase
-
setDefaultSSLConfig
public static void setDefaultSSLConfig(SSLConfig sslConfig)
-
resetSslContextFactory
public static void resetSslContextFactory()
-
-