jaykay12 commented on code in PR #5047:
URL: https://github.com/apache/solr/pull/5047#discussion_r4218789699


##########
solr/core/src/java/org/apache/solr/cli/ConnectionOptions.java:
##########
@@ -73,4 +76,78 @@ String effectiveSolrUrl() throws IOException {
     }
     return solrUrl;
   }
+
+  static String resolveSolrUrl(ConnectionOptions connectionOptions, String 
credentials)
+      throws Exception {
+    if (connectionOptions != null) {
+      String solrUrl = connectionOptions.effectiveSolrUrl();
+      if (solrUrl != null) {
+        return CLIUtils.normalizeSolrUrl(solrUrl);
+      }
+      String zkHost = connectionOptions.effectiveZkHost();
+      if (zkHost != null) {
+        return CLIUtils.solrUrlFromConnection(
+            CloudSolrClient.CloudSolrClientConnection.parse(zkHost), 
credentials);
+      }
+    }
+
+    String solrConnectionProp = EnvUtils.getProperty("solr.connection");
+    if (solrConnectionProp != null && !solrConnectionProp.isBlank()) {
+      var connection = 
CloudSolrClient.CloudSolrClientConnection.parse(solrConnectionProp);
+      if (connection.isZookeeper()) {
+        return CLIUtils.solrUrlFromConnection(connection, credentials);
+      }
+      return CLIUtils.normalizeSolrUrl(connection.quorumItems().get(0));
+    }
+
+    String zkHostProp = EnvUtils.getProperty("zkHost");
+    if (zkHostProp != null && !zkHostProp.isBlank()) {
+      return CLIUtils.solrUrlFromConnection(
+          CloudSolrClient.CloudSolrClientConnection.parse(zkHostProp), 
credentials);
+    }
+
+    String defaultUrl = CLIUtils.getDefaultSolrUrl();
+    CLIO.err(
+        "Neither --solr-connection, --zk-host or --solr-url parameters, nor 
SOLR_CONNECTION, ZK_HOST env var provided, so assuming solr url is "
+            + defaultUrl
+            + ".");
+    return defaultUrl;
+  }
+
+  static String resolveZkHost(
+      ConnectionOptions connectionOptions, String solrUrl, String credentials) 
throws Exception {
+    if (connectionOptions != null) {
+      String zkHost = connectionOptions.effectiveZkHost();
+      if (zkHost != null) {
+        return zkHost;
+      }
+    }
+
+    String solrConnectionProp = EnvUtils.getProperty("solr.connection");
+    if (solrConnectionProp != null && !solrConnectionProp.isBlank()) {
+      var connection = 
CloudSolrClient.CloudSolrClientConnection.parse(solrConnectionProp);
+      if (connection.isZookeeper()) {
+        return solrConnectionProp;
+      }
+    }
+
+    String zkHostProp = EnvUtils.getProperty("zkHost");
+    if (zkHostProp != null && !zkHostProp.isBlank()) {
+      return zkHostProp;
+    }

Review Comment:
   this is addressed now. 



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