epugh commented on code in PR #2391:
URL: https://github.com/apache/solr/pull/2391#discussion_r2737524063


##########
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:
   Can I point you to https://github.com/apache/solr/pull/2783 where I added a 
page to the Ref Guide on "Deployment Topologies".  I would LOVE your input, 
becasue I sort of guess how people would do things in a Kubernetes environment 
with solr-operator.  I assumed that you would have one big pool, with some less 
resources nodes for `zookeeper_quorum:on,data:off,overseer:preferred ` and 
others with more resources for `zookeeper_quorum:off,data:on`.   I think you 
are suggesting that isn't actually likely, they would be seperate. 
   
   Here is a diagram of some nodes doing both data and zookeeper: 
   <img width="1113" height="247" alt="image" 
src="https://github.com/user-attachments/assets/f7585f0c-a5b9-43d7-b8bc-53a9a302419f";
 />
   
   and then what I have for Kubernetes ( but based on my very vague knowledge)
   
   <img width="1134" height="647" alt="image" 
src="https://github.com/user-attachments/assets/a90c55a8-d6ef-4003-b9a8-a330520fd34f";
 />.
   
   I'd love some PR updates on how from your expereince people actually would 
scale up!
    



-- 
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]

Reply via email to