dsmiley commented on code in PR #3510:
URL: https://github.com/apache/solr/pull/3510#discussion_r2323518552
##########
solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java:
##########
@@ -872,38 +873,40 @@ public void removeLiveNodesListener(LiveNodesListener
listener) {
}
/**
- * Returns the lowest Solr version among all live nodes in the cluster. It's
not greater than
- * {@link SolrVersion#LATEST_STRING}. Will not return null. If older Solr
nodes have joined that
- * don't declare their version, the result won't be accurate, but it's at
least an upper bound on
- * the possible version it might be.
+ * Returns the lowest Solr version among all live nodes in the cluster. If
older Solr nodes have
+ * joined that don't declare their version, the result won't be accurate,
but it's at least an
+ * upper bound on the possible version it might be.
*
- * @return the lowest Solr version of the cluster; not null
+ * @return an Optional containing the lowest Solr version of nodes in the
cluster, or empty if no
+ * live nodes exist or all nodes return 9.9.0 for unspecified versions
*/
- public SolrVersion fetchLowestSolrVersion() throws KeeperException,
InterruptedException {
+ public Optional<SolrVersion> fetchLowestSolrVersion()
+ throws KeeperException, InterruptedException {
List<String> liveNodeNames = zkClient.getChildren(LIVE_NODES_ZKNODE, null,
true);
- SolrVersion lowest = SolrVersion.LATEST; // current software
+ SolrVersion lowest = null;
// the last version to not specify its version in live nodes
final SolrVersion UNSPECIFIED_VERSION = SolrVersion.valueOf("9.9.0");
+
for (String nodeName : liveNodeNames) {
String path = LIVE_NODES_ZKNODE + "/" + nodeName;
byte[] data = zkClient.getData(path, null, null, true);
if (data == null || data.length == 0) {
- return UNSPECIFIED_VERSION;
+ return Optional.of(UNSPECIFIED_VERSION);
Review Comment:
I was very deliberate about what to do here, and the javadocs should spell
this out. If there's no data for a particular node, then we know an older
version of Solr is a member of this cluster. An empty return from the method
here conveys something different -- that there are no members of the cluster
yet.
--
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]