madrob commented on a change in pull request #1297: SOLR-14253 Replace various
sleep calls with ZK waits
URL: https://github.com/apache/lucene-solr/pull/1297#discussion_r385779735
##########
File path:
solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java
##########
@@ -672,35 +636,35 @@ void cleanupCollection(String collectionName, NamedList
results) throws Exceptio
commandMap.get(DELETE).call(zkStateReader.getClusterState(), new
ZkNodeProps(props), results);
}
- Map<String, Replica> waitToSeeReplicasInState(String collectionName,
Collection<String> coreNames) throws InterruptedException {
- assert coreNames.size() > 0;
- Map<String, Replica> result = new HashMap<>();
- TimeOut timeout = new
TimeOut(Integer.getInteger("solr.waitToSeeReplicasInStateTimeoutSeconds", 120),
TimeUnit.SECONDS, timeSource); // could be a big cluster
- while (true) {
- DocCollection coll =
zkStateReader.getClusterState().getCollection(collectionName);
- for (String coreName : coreNames) {
- if (result.containsKey(coreName)) continue;
- for (Slice slice : coll.getSlices()) {
- for (Replica replica : slice.getReplicas()) {
- if (coreName.equals(replica.getStr(ZkStateReader.CORE_NAME_PROP)))
{
- result.put(coreName, replica);
- break;
+ Map<String, Replica> waitToSeeReplicasInState(String collectionName,
Collection<String> coreNames) {
+ final Map<String, Replica> result = new HashMap<>();
+ int timeout =
Integer.getInteger("solr.waitToSeeReplicasInStateTimeoutSeconds", 120); //
could be a big cluster
+ try {
+ zkStateReader.waitForState(collectionName, timeout, TimeUnit.SECONDS, c
-> {
+ // todo this is ugly, but I'm not sure there is a better way to fix it?
Review comment:
I think I found something that makes sense.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]