SOLR-6591: ZkStateReader.updateClusterState should refresh cluster state for watched collections

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1634554 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-10-27 14:51:08 +00:00
parent a42ecace8b
commit b422645bde
1 changed files with 19 additions and 14 deletions

View File

@ -448,20 +448,25 @@ public class ZkStateReader implements Closeable {
// collections in // collections in
// clusterstate.json // clusterstate.json
for (String s : getIndividualColls()) { for (String s : getIndividualColls()) {
DocCollection watched = watchedCollectionStates.get(s); synchronized (this) {
if (watched != null) { if (watchedCollections.contains(s)) {
// if it is a watched collection, add too DocCollection live = getCollectionLive(this, s);
result.put(s, new ClusterState.CollectionRef(watched)); watchedCollectionStates.put(s, live);
} else { // if it is a watched collection, add too
// if it is not collection, then just create a reference which can fetch result.put(s, new ClusterState.CollectionRef(live));
// the collection object just in time from ZK } else {
final String collName = s; // if it is not collection, then just create a reference which can fetch
result.put(s, new ClusterState.CollectionRef(null) { // the collection object just in time from ZK
@Override // this is also cheap (lazy loaded) so we put it inside the synchronized
public DocCollection get() { // block although it is not required
return getCollectionLive(ZkStateReader.this, collName); final String collName = s;
} result.put(s, new ClusterState.CollectionRef(null) {
}); @Override
public DocCollection get() {
return getCollectionLive(ZkStateReader.this, collName);
}
});
}
} }
} }
return new ClusterState(ln, result, stat.getVersion()); return new ClusterState(ln, result, stat.getVersion());