You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/06/10 21:08:54 UTC

[GitHub] [lucene-solr] murblanc commented on a change in pull request #1565: SOLR-12823: fix test failures

murblanc commented on a change in pull request #1565:
URL: https://github.com/apache/lucene-solr/pull/1565#discussion_r438409534



##########
File path: solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
##########
@@ -476,27 +476,32 @@ public synchronized void createClusterStateWatchersAndUpdate() throws KeeperExce
 
     log.debug("Updating cluster state from ZooKeeper... ");
 
-    // on reconnect of SolrZkClient force refresh and re-add watches.
-    loadClusterProperties();
-    refreshLiveNodes(new LiveNodeWatcher());
-    refreshCollections();
-    refreshCollectionList(new CollectionsChildWatcher());
-    refreshAliases(aliasesManager);
-
-    if (securityNodeListener != null) {
-      addSecurityNodeWatcher(pair -> {
-        ConfigData cd = new ConfigData();
-        cd.data = pair.first() == null || pair.first().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.first()), 4, false);
-        cd.version = pair.second() == null ? -1 : pair.second().getVersion();
-        securityData = cd;
-        securityNodeListener.run();
+    try {
+      // on reconnect of SolrZkClient force refresh and re-add watches.
+      loadClusterProperties();
+      refreshLiveNodes(new LiveNodeWatcher());
+      refreshCollections();
+      refreshCollectionList(new CollectionsChildWatcher());
+      refreshAliases(aliasesManager);
+
+      if (securityNodeListener != null) {
+        addSecurityNodeWatcher(pair -> {
+          ConfigData cd = new ConfigData();
+          cd.data = pair.first() == null || pair.first().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.first()), 4, false);
+          cd.version = pair.second() == null ? -1 : pair.second().getVersion();
+          securityData = cd;
+          securityNodeListener.run();
+        });
+        securityData = getSecurityProps(true);
+      }
+
+      collectionPropsObservers.forEach((k, v) -> {
+        collectionPropsWatchers.computeIfAbsent(k, PropsWatcher::new).refreshAndWatch(true);
       });
-      securityData = getSecurityProps(true);
+    } catch (KeeperException.NoNodeException nne) {
+      throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE,
+          "Cannot connect to cluster at " + zkClient.getZkServerAddress() + ": cluster not found/not ready");

Review comment:
       Could have instead picked another path other than `CLUSTER_STATE` from those created in `ZkController.createClusterZkNodes()` and explicitly tested it like was done before, but this seemed cleaner.
   Open to change.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org