mlbiscoc commented on code in PR #2935:
URL: https://github.com/apache/solr/pull/2935#discussion_r1925986935
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java:
##########
@@ -216,38 +236,42 @@ private SimpleOrderedMap<?> submitClusterStateRequest(
@Override
public Set<String> getLiveNodes() {
- if (liveNodes == null) {
- throw new RuntimeException(
- "We don't know of any live_nodes to fetch the"
- + " latest live_nodes information from. "
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using
working"
- + " solrUrl(s) or zkHost(s).");
- }
if (TimeUnit.SECONDS.convert((System.nanoTime() - liveNodesTimestamp),
TimeUnit.NANOSECONDS)
> getCacheTimeout()) {
- for (String nodeName : liveNodes) {
- String baseUrl = Utils.getBaseUrlForNodeName(nodeName, urlScheme);
- try (SolrClient client = getSolrClient(baseUrl)) {
- Set<String> liveNodes = fetchLiveNodes(client);
- this.liveNodes = (liveNodes);
- liveNodesTimestamp = System.nanoTime();
- return liveNodes;
- } catch (Exception e) {
- log.warn("Attempt to fetch cluster state from {} failed.", baseUrl,
e);
- }
- }
+
+ if (liveNodes.stream()
+ .anyMatch((node) ->
updateLiveNodes(URLUtil.getBaseUrlForNodeName(node, urlScheme))))
+ return this.liveNodes;
+
+ log.warn(
+ "Attempt to fetch cluster state from all known live nodes {} failed.
Trying backup nodes",
+ liveNodes);
+
+ if (configuredNodes.stream().anyMatch((node) ->
updateLiveNodes(node.toString())))
Review Comment:
We could but to me it makes sense to try live nodes first unless this class
was explicitly created as your JIRA proposal pointed, in that it only uses the
passed URLs and nothing else.
I think it should be used as backup and go for fetching from live nodes
first and assume by its name it is "live". If we do the opt in as a feature
flag for dynamic node discovery then that gives them control. I'm fine with
flipping it with configured first though if you feel strongly 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]