Abstraction over a running Solr deployment for use in tests and benchmarks. The abstraction normalizes how to shut down and perform other common operations as the methods indicate.
| 40 | * normalizes how to shut down and perform other common operations as the methods indicate. |
| 41 | */ |
| 42 | public interface SolrBackend extends AutoCloseable { |
| 43 | |
| 44 | /** |
| 45 | * Creates a new {@link SolrClient} defaulted to the given collection. The <em>caller</em> owns |
| 46 | * this client and is responsible for closing it. Callers that want a long-lived client should |
| 47 | * cache it themselves. |
| 48 | */ |
| 49 | SolrClient newSolrClient(String collection); |
| 50 | |
| 51 | /** |
| 52 | * Returns the node / admin (collection-less) {@link SolrClient} owned by this backend. The caller |
| 53 | * must NOT close it; it is released when this backend is {@link #close()}d. A {@link |
| 54 | * CloudSolrClient} should be returned if appropriate. While it *can* be used to target specific |
| 55 | * collections, please use {@link #newSolrClient(String)} for that instead. |
| 56 | */ |
| 57 | SolrClient getSolrClient(); |
| 58 | |
| 59 | /** |
| 60 | * Upload a configSet, possibly overwriting (creating files, updating files, NOT deleting files). |
| 61 | * |
| 62 | * @param configDir a path to the config set to upload |
| 63 | * @param name the name to give the configSet |
| 64 | */ |
| 65 | default void uploadConfigSet(Path configDir, String name) |
| 66 | throws SolrServerException, IOException { |
| 67 | getCoreContainer().getConfigSetService().uploadConfig(name, configDir); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Checks if a configSet with the given name exists. |
| 72 | * |
| 73 | * @param name configSet name to check |
| 74 | * @return true if the configSet exists, false otherwise |
| 75 | */ |
| 76 | default boolean hasConfigSet(String name) throws SolrServerException, IOException { |
| 77 | return getCoreContainer().getConfigSetService().checkConfigExists(name); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Creates a collection (or core for single-node backends). Cloud backends honour {@code |
| 82 | * numShards} and {@code replicationFactor}; single-node backends ({@link JettySolrRunner}, {@link |
| 83 | * EmbeddedSolrBackend}) ignore those fields. Callers should use {@link #hasCollection(String)} |
| 84 | * first if they want to avoid errors when the collection already exists. Tests/benchmarks that |
| 85 | * want to test how this works should not use this to do so. |
| 86 | */ |
| 87 | void createCollection(CollectionAdminRequest.Create create) |
| 88 | throws SolrServerException, IOException; |
| 89 | |
| 90 | /** |
| 91 | * Checks if a collection or core with the given name exists. |
| 92 | * |
| 93 | * @param name collection or core name to check |
| 94 | * @return true if the collection/core exists, false otherwise |
| 95 | */ |
| 96 | boolean hasCollection(String name) throws SolrServerException, IOException; |
| 97 | |
| 98 | /** Reloads a collection or core by this name. The purpose is typically to clear caches. */ |
| 99 | default void reloadCollection(String name) throws SolrServerException, IOException { |
no outgoing calls
no test coverage detected
searching dependent graphs…