janhoy commented on code in PR #2391:
URL: https://github.com/apache/solr/pull/2391#discussion_r2435548204
##########
solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java:
##########
@@ -342,6 +344,185 @@ public MiniSolrCloudCluster(
}
}
+ /**
+ * Create a MiniSolrCloudCluster with embedded ZooKeeper quorum mode. Each
Solr node runs its own
+ * embedded ZooKeeper server, and together they form a quorum.
+ *
+ * @param numServers number of Solr servers (must be at least 3 for quorum)
+ * @param baseDir base directory that the mini cluster should be run from
+ * @param solrXml solr.xml file content
+ * @param jettyConfig Jetty configuration
+ * @param securityJson Optional security.json configuration
+ * @param trackJettyMetrics whether to track Jetty metrics
+ * @throws Exception if there was an error starting the cluster
+ */
+ MiniSolrCloudCluster(
+ int numServers,
+ Path baseDir,
+ String solrXml,
+ JettyConfig jettyConfig,
+ Optional<String> securityJson,
+ boolean trackJettyMetrics,
+ boolean useEmbeddedZkQuorum)
+ throws Exception {
+
+ if (!useEmbeddedZkQuorum) {
+ throw new IllegalArgumentException("This constructor is only for
embedded ZK quorum mode");
+ }
+ if (numServers < 3) {
+ throw new IllegalArgumentException(
+ "ZooKeeper quorum requires at least 3 nodes, got: " + numServers);
+ }
+
+ Objects.requireNonNull(securityJson);
+ this.baseDir = Objects.requireNonNull(baseDir);
+ this.jettyConfig = Objects.requireNonNull(jettyConfig);
+ this.solrXml = solrXml == null ? DEFAULT_CLOUD_SOLR_XML : solrXml;
+ this.trackJettyMetrics = trackJettyMetrics;
+ this.externalZkServer = true; // No ZkTestServer in quorum mode
+ this.zkServer = null; // No single ZK server
+
+ log.info("Starting cluster of {} servers with embedded ZK quorum in {}",
numServers, baseDir);
+ Files.createDirectories(baseDir);
+
+ // Phase 1: Reserve random ports for all nodes
+ int[] ports = new int[numServers];
+ for (int i = 0; i < numServers; i++) {
+ try (java.net.ServerSocket socket = new java.net.ServerSocket(0)) {
+ ports[i] = socket.getLocalPort();
+ }
+ }
+
+ // Build the zkHost string with all ZK ports (Solr port + 1000)
+ StringBuilder zkHostBuilder = new StringBuilder();
+ for (int i = 0; i < numServers; i++) {
+ if (i > 0) {
+ zkHostBuilder.append(",");
+ }
+ int zkPort = ports[i] + 1000;
+ zkHostBuilder.append("127.0.0.1:").append(zkPort);
+ }
+ this.zkHost = zkHostBuilder.toString(); // Save for later use
+
+ if (log.isInfoEnabled()) {
+ log.info("Reserved ports for {} nodes: {}", numServers,
java.util.Arrays.toString(ports));
+ log.info("ZK connection string: {}", this.zkHost);
+ }
+
+ // Set system properties for embedded ZK quorum mode
+ System.setProperty("solr.zookeeper.server.enabled", "true");
Review Comment:
Sounds like node role should be enough, it should turn things on, perhaps
set that property automagically?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]