Package org.apache.solr.client.solrj.io
Class SolrClientCache
java.lang.Object
org.apache.solr.client.solrj.io.SolrClientCache
- All Implemented Interfaces:
Closeable,AutoCloseable
The SolrClientCache caches SolrClients, so they can be reused by different TupleStreams.
-
Constructor Summary
ConstructorsConstructorDescriptionSolrClientCache(org.apache.http.client.HttpClient apacheHttpClient) Deprecated.SolrClientCache(org.apache.solr.client.solrj.impl.Http2SolrClient http2SolrClient) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()org.apache.solr.client.solrj.impl.CloudSolrClientgetCloudSolrClient(String zkHost) org.apache.solr.client.solrj.SolrClientgetHttpSolrClient(String baseUrl) Create (and cache) a SolrClient based around the provided URLvoidsetDefaultZKHost(String zkHost) voidsetZkHostValidator(Consumer<String> zkHostValidator) Installs a ZooKeeper host validator thatgetCloudSolrClient(String)consults on every call, before any ZK contact.voidvalidateZkHost(String zkHost) Throws if the installed validator rejects the zkHost.static StringzkHostRejectionMessage(String connectionString) Message for a rejected ZooKeeper connection string.
-
Constructor Details
-
SolrClientCache
public SolrClientCache() -
SolrClientCache
Deprecated. -
SolrClientCache
public SolrClientCache(org.apache.solr.client.solrj.impl.Http2SolrClient http2SolrClient)
-
-
Method Details
-
setZkHostValidator
Installs a ZooKeeper host validator thatgetCloudSolrClient(String)consults on every call, before any ZK contact. The validator rejects a zkHost by throwing, typically a403 ForbiddenSolrException. Anullvalidator disables validation.The validator is invoked while holding the cache monitor, so it must be non-blocking and must not perform I/O.
-
validateZkHost
Throws if the installed validator rejects the zkHost. -
zkHostRejectionMessage
Message for a rejected ZooKeeper connection string. -
setDefaultZKHost
-
getCloudSolrClient
-
getHttpSolrClient
Create (and cache) a SolrClient based around the provided URL- Parameters:
baseUrl- a Solr URL. May either be a "base" URL (i.e. ending in "/solr"), or point to a particular collection or core.- Returns:
- a SolrClient configured to use the provided URL. The cache retains a reference to the
returned client, and will close it when callers invoke
close()
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-