[
https://issues.apache.org/jira/browse/SOLR-8323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15263665#comment-15263665
]
ASF GitHub Bot commented on SOLR-8323:
--------------------------------------
Github user romseygeek commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/32#discussion_r61541687
--- Diff:
solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java ---
@@ -572,6 +574,40 @@ public void downloadConfig(String configName, Path
downloadPath) throws IOExcept
zkStateReader.getConfigManager().downloadConfigDir(configName,
downloadPath);
}
+ /**
+ * Block until a collection state matches a predicate, or a timeout
+ *
+ * Note that the predicate may be called again even after it has
returned true, so
+ * implementors should avoid changing state within the predicate call
itself.
+ *
+ * @param collection the collection to watch
+ * @param wait how long to wait
+ * @param unit the units of the wait parameter
+ * @param predicate a {@link CollectionStatePredicate} to check the
collection state
+ * @throws InterruptedException on interrupt
+ * @throws TimeoutException on timeout
+ */
+ public void waitForState(String collection, long wait, TimeUnit unit,
CollectionStatePredicate predicate)
+ throws InterruptedException, TimeoutException {
+ connect();
+ zkStateReader.waitForState(collection, wait, unit, predicate);
+ }
+
+ /**
+ * Register a CollectionStateWatcher to be called when the cluster state
for a collection changes
+ *
+ * Note that the watcher is unregistered after it has been called once.
To make a watcher persistent,
+ * it should re-register itself in its {@link
CollectionStateWatcher#onStateChanged(Set, DocCollection)}
+ * call
+ *
+ * @param collection the collection to watch
+ * @param watcher a watcher that will be called when the state changes
+ */
+ public void registerCollectionStateWatcher(String collection,
CollectionStateWatcher watcher) {
+ connect();
+ zkStateReader.registerCollectionStateWatcher(collection, watcher);
+ }
+
--- End diff --
TBH, I don't think getZkStateReader() *should* be a public method - client
code that's using CloudSolrClient shouldn't need to interact with low-level
stuff like the state reader. Maybe we only need to expose waitForState() here
though.
> Add CollectionWatcher API to ZkStateReader
> ------------------------------------------
>
> Key: SOLR-8323
> URL: https://issues.apache.org/jira/browse/SOLR-8323
> Project: Solr
> Issue Type: Improvement
> Affects Versions: master
> Reporter: Alan Woodward
> Assignee: Alan Woodward
> Attachments: SOLR-8323.patch, SOLR-8323.patch, SOLR-8323.patch,
> SOLR-8323.patch
>
>
> An API to watch for changes to collection state would be a generally useful
> thing, both internally and for client use.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]