Package org.apache.solr.cloud
Class RemoteSolrBackend
java.lang.Object
org.apache.solr.cloud.RemoteSolrBackend
- All Implemented Interfaces:
AutoCloseable,SolrBackend
SolrBackend that connects to a pre-existing remote SolrCloud cluster. The caller supplies
the HTTP connection string at construction time (e.g. http://localhost:8983/solr).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Shuts down this backend, releases the admin client, and all other resources.voidcreateCollection(org.apache.solr.client.solrj.request.CollectionAdminRequest.Create create) Creates a collection (or core for single-node backends).org.apache.solr.core.CoreContainerProvides access to an embedded/in-processCoreContainer-- if available (else null).org.apache.solr.client.solrj.SolrClientReturns the node / admin (collection-less)SolrClientowned by this backend.booleanhasCollection(String name) Checks if a collection or core with the given name exists.booleanhasConfigSet(String name) Checks if a configSet with the given name exists.org.apache.solr.client.solrj.SolrClientnewSolrClient(String collection) Creates a newSolrClientdefaulted to the given collection.voiduploadConfigSet(Path configDir, String name) Upload a configSet, possibly overwriting (creating files, updating files, NOT deleting files).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.solr.SolrBackend
dumpCoreInfo, dumpMetrics, getBaseUrl, reloadCollection
-
Constructor Details
-
RemoteSolrBackend
-
-
Method Details
-
getCoreContainer
public org.apache.solr.core.CoreContainer getCoreContainer()Description copied from interface:SolrBackendProvides access to an embedded/in-processCoreContainer-- if available (else null). If there is more than one node, then one is returned.- Specified by:
getCoreContainerin interfaceSolrBackend- Returns:
- can be null.
-
newSolrClient
Description copied from interface:SolrBackendCreates a newSolrClientdefaulted to the given collection. The caller owns this client and is responsible for closing it. Callers that want a long-lived client should cache it themselves.- Specified by:
newSolrClientin interfaceSolrBackend
-
getSolrClient
public org.apache.solr.client.solrj.SolrClient getSolrClient()Description copied from interface:SolrBackendReturns the node / admin (collection-less)SolrClientowned by this backend. The caller must NOT close it; it is released when this backend isSolrBackend.close()d. ACloudSolrClientshould be returned if appropriate. While it *can* be used to target specific collections, please useSolrBackend.newSolrClient(String)for that instead.- Specified by:
getSolrClientin interfaceSolrBackend
-
uploadConfigSet
public void uploadConfigSet(Path configDir, String name) throws org.apache.solr.client.solrj.SolrServerException, IOException Description copied from interface:SolrBackendUpload a configSet, possibly overwriting (creating files, updating files, NOT deleting files).- Specified by:
uploadConfigSetin interfaceSolrBackend- Parameters:
configDir- a path to the config set to uploadname- the name to give the configSet- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
hasConfigSet
public boolean hasConfigSet(String name) throws org.apache.solr.client.solrj.SolrServerException, IOException Description copied from interface:SolrBackendChecks if a configSet with the given name exists.- Specified by:
hasConfigSetin interfaceSolrBackend- Parameters:
name- configSet name to check- Returns:
- true if the configSet exists, false otherwise
- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
createCollection
public void createCollection(org.apache.solr.client.solrj.request.CollectionAdminRequest.Create create) throws org.apache.solr.client.solrj.SolrServerException, IOException Description copied from interface:SolrBackendCreates a collection (or core for single-node backends). Cloud backends honournumShardsandreplicationFactor; single-node backends (JettySolrRunner,EmbeddedSolrBackend) ignore those fields. Callers should useSolrBackend.hasCollection(String)first if they want to avoid errors when the collection already exists. Tests/benchmarks that want to test how this works should not use this to do so.- Specified by:
createCollectionin interfaceSolrBackend- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
hasCollection
public boolean hasCollection(String name) throws org.apache.solr.client.solrj.SolrServerException, IOException Description copied from interface:SolrBackendChecks if a collection or core with the given name exists.- Specified by:
hasCollectionin interfaceSolrBackend- Parameters:
name- collection or core name to check- Returns:
- true if the collection/core exists, false otherwise
- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
close
public void close()Description copied from interface:SolrBackendShuts down this backend, releases the admin client, and all other resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSolrBackend
-