Skip to content

SOLR-18150: Add SolrBackend abstraction for test/benchmark deployments#4214

Open
dsmiley wants to merge 1 commit intoapache:mainfrom
dsmiley:SOLR-18150-SolrBackend
Open

SOLR-18150: Add SolrBackend abstraction for test/benchmark deployments#4214
dsmiley wants to merge 1 commit intoapache:mainfrom
dsmiley:SOLR-18150-SolrBackend

Conversation

@dsmiley
Copy link
Contributor

@dsmiley dsmiley commented Mar 13, 2026

  • Created SolrBackend interface to abstract over different Solr deployment types
  • Added implementations:
    • EmbeddedSolrBackend: in-process CoreContainer/EmbeddedSolrServer
    • RemoteSolrBackend: CloudSolrClient connecting to remote SolrCloud cluster
    • JettySolrRunner: HTTP/Jetty + EmbeddedSolrServer
    • MiniSolrCloudCluster: embedded multi-node SolrCloud

Key features:

  • Unified API for collection/configSet management across deployment types
  • Methods throw SolrServerException & IOException
  • hasConfigSet/hasCollection methods for existence checking
  • createCollection/uploadConfigSet for resource creation
  • getBaseUrl(Random) returns URL of a node (random for cloud deployments)
  • dumpMetrics/dumpCoreInfo for diagnostics

https://issues.apache.org/jira/browse/SOLR-18150

This PR only introduces the abstraction but no callers. Follow-on is to do so with benchmarks & tests separately. I have WIP for the benchmark side already.

- Created SolrBackend interface to abstract over different Solr deployment types
- Added implementations:
  - EmbeddedSolrBackend: in-process CoreContainer/EmbeddedSolrServer
  - RemoteSolrBackend: CloudSolrClient connecting to remote SolrCloud cluster
  - JettySolrRunner: HTTP/Jetty + EmbeddedSolrServer
  - MiniSolrCloudCluster: embedded multi-node SolrCloud

Key features:
- Unified API for collection/configSet management across deployment types
- Methods throw SolrServerException & IOException
- hasConfigSet/hasCollection methods for existence checking
- createCollection/uploadConfigSet for resource creation
- getBaseUrl(Random) returns URL of a node (random for cloud deployments)
- dumpMetrics/dumpCoreInfo for diagnostics

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

/** "Mini" SolrCloud cluster to be used for testing */
public class MiniSolrCloudCluster {
public class MiniSolrCloudCluster implements SolrBackend {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a pretty natural fit to implement directly here

}

@Override
public SolrClient getAdminClient() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my "nocommit" on SolrBackend.getAdminClient naming is partially motivated by seeing this here. It'd be nice to simply call it getSolrClient.

try {
shutdown();
} catch (Exception e) {
throw new RuntimeException(e);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm; or we just log?

public void dumpMetrics(PrintStream out) {
try {
for (JettySolrRunner jetty : jettys) {
jetty.outputMetrics(out);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps should add a banner comment (it's prometheus). The change to dumpMetrics is that there is ultimately one stream/file whereas previously it was multiple files in this directory where each file name was a combination of the passed in fileName and also a netty node identifier


/**
* {@link SolrBackend} that connects to a pre-existing remote SolrCloud cluster. The caller supplies
* the ZooKeeper connection string at construction time (e.g. {@code localhost:9983/solr}).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops; false; it's an HTTP URL

* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.cloud;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put into cloud package as it assumes SolrCloud

*
* <p>Data is persisted in the given {@code solrHome} directory.
*/
public class EmbeddedSolrBackend implements SolrBackend {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EmbeddedSolrServer cannot implement SolrBackend directly because the latter is in solr-core and SolrBackend is in test-framework

* @since solr 1.3
*/
public class JettySolrRunner {
public class JettySolrRunner implements SolrBackend {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ended up being slightly awkward to implement directly. An alternative could be a new method asSolrBackend

: Files.newOutputStream(outputDirectory.resolve(registryName + "_" + fileName))) {
new PrometheusTextFormatWriter(false).write(os, prometheusReader.collect());
}
out.println("Registry: " + registryName);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should improve to use a # comment style as it's prometheus. And add some surrounding lines to make it easier to spot.

try {
stop();
} catch (Exception e) {
throw new RuntimeException(e);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again; should probably log & not throw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant