SOLR-18150: Add SolrBackend abstraction for test/benchmark deployments#4214
SOLR-18150: Add SolrBackend abstraction for test/benchmark deployments#4214dsmiley wants to merge 1 commit intoapache:mainfrom
Conversation
- 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 { |
There was a problem hiding this comment.
it's a pretty natural fit to implement directly here
| } | ||
|
|
||
| @Override | ||
| public SolrClient getAdminClient() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
hmm; or we just log?
| public void dumpMetrics(PrintStream out) { | ||
| try { | ||
| for (JettySolrRunner jetty : jettys) { | ||
| jetty.outputMetrics(out); |
There was a problem hiding this comment.
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}). |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
put into cloud package as it assumes SolrCloud
| * | ||
| * <p>Data is persisted in the given {@code solrHome} directory. | ||
| */ | ||
| public class EmbeddedSolrBackend implements SolrBackend { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
again; should probably log & not throw
Key features:
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.