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


##########
solr/core/src/java/org/apache/solr/core/ZkContainer.java:
##########
@@ -75,42 +85,119 @@ public class ZkContainer {
   public ZkContainer() {}
 
   public void initZooKeeper(final CoreContainer cc, CloudConfig config) {
-    boolean zkRun = 
EnvUtils.getPropertyAsBool("solr.zookeeper.server.enabled", false);
+    // zkServerEnabled is set whenever in solrCloud mode ('-c') but no 
explicit zkHost/ZK_HOST is
+    // provided.
+    final boolean zkServerEnabled =
+        EnvUtils.getPropertyAsBool("solr.zookeeper.server.enabled", false);
+    boolean zkQuorumNode = false;
+    if 
(NodeRoles.MODE_ON.equals(cc.nodeRoles.getRoleMode(NodeRoles.Role.ZOOKEEPER_QUORUM)))
 {
+      zkQuorumNode = true;
+      log.info("Starting node in ZooKeeper Quorum role.");
+    }
 
-    if (zkRun && config == null)
+    if (zkServerEnabled && config == null) {
       throw new SolrException(
           SolrException.ErrorCode.SERVER_ERROR,
           "Cannot start Solr in cloud mode - no cloud config provided");
+    }
+
+    if (config == null) {
+      log.info("Solr is running in standalone mode");
+      return;
+    }
 
-    if (config == null) return; // not in zk mode
+    final boolean runAsQuorum = config.getZkHost() != null && zkQuorumNode;
 
     String zookeeperHost = config.getZkHost();
+    final var solrHome = cc.getSolrHome();
+    if (zkServerEnabled) {
+      if (!runAsQuorum) {
+        // Old school ZooKeeperServerMain being used under the covers.
+        String zkDataHome =
+            EnvUtils.getProperty(
+                "solr.zookeeper.server.datadir", 
solrHome.resolve("zoo_data").toString());
+        String zkConfHome =
+            EnvUtils.getProperty("solr.zookeeper.server.confdir", 
solrHome.toString());
+        zkServer =
+            new SolrZkServer(
+                stripChroot(config.getZkHost()),
+                Path.of(zkDataHome),
+                zkConfHome,
+                config.getSolrHostPort());
+        zkServer.parseConfig();
+        zkServer.start();
+
+        // set client from server config if not already set
+        if (zookeeperHost == null) {
+          zookeeperHost = zkServer.getClientString();
+        }
+        // TODO - should this code go in SolrZkServer to augment or replace 
its current
+        // capabilities?  Doing so
+        //  would definitely keep ZkContainer cleaner...

Review Comment:
   @gerlowskija I removed NOCOMMIT in this comment to unblock other precommit 
tests. Making this review comment to make sure we don't forget about it :) 



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