You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/09/09 02:44:13 UTC

[lucene-solr] branch reference_impl_dev updated: @815 Bring it back in, take that out, nice, nice.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/reference_impl_dev by this push:
     new 4b4cdc9  @815 Bring it back in, take that out, nice, nice.
4b4cdc9 is described below

commit 4b4cdc919ad406c060e1e2e2bc976e35732ec537
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Sep 8 21:43:57 2020 -0500

    @815 Bring it back in, take that out, nice, nice.
---
 .../apache/solr/common/cloud/ZkStateReader.java    | 51 ++++++++++------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index f00a058..5999225 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -879,14 +879,9 @@ public class ZkStateReader implements SolrCloseable {
     //closeTracker.close();
     this.closed = true;
     try {
-      waitLatches.forEach((w) -> w.countDown());
-
       if (closeClient) {
         IOUtils.closeQuietly(zkClient);
       }
-
-      waitLatches.forEach((w) -> w.countDown());
-
     } finally {
       assert ObjectReleaseTracker.release(this);
     }
@@ -1847,8 +1842,8 @@ public class ZkStateReader implements SolrCloseable {
     final DocCollectionAndLiveNodesWatcherWrapper wrapper
         = new DocCollectionAndLiveNodesWatcherWrapper(collection, watcher);
 
-//    removeDocCollectionWatcher(collection, wrapper);
-//    removeLiveNodesListener(wrapper);
+    removeDocCollectionWatcher(collection, wrapper);
+    removeLiveNodesListener(wrapper);
   }
 
   /**
@@ -1866,25 +1861,24 @@ public class ZkStateReader implements SolrCloseable {
     if (log.isDebugEnabled()) log.debug("remove watcher for collection {}", collection);
     AtomicBoolean reconstructState = new AtomicBoolean(false);
     synchronized (collectionWatches) {
-//      collectionWatches.compute(collection, (k, v) -> {
-//        if (v == null) return null;
-//        v.stateWatchers.remove(watcher);
-//        if (v.canBeRemoved()) {
-//          // nocommit
-////          log.info("no longer watch collection {}", collection);
-////          watchedCollectionStates.remove(collection);
-////          lazyCollectionStates.put(collection, new LazyCollectionRef(collection));
-////          reconstructState.set(true);
-//          return null;
-//        }
-//        return v;
-//      });
+      collectionWatches.compute(collection, (k, v) -> {
+        if (v == null) return null;
+        v.stateWatchers.remove(watcher);
+        if (v.canBeRemoved()) {
+          log.info("no longer watch collection {}", collection);
+          watchedCollectionStates.remove(collection);
+          lazyCollectionStates.put(collection, new LazyCollectionRef(collection));
+          reconstructState.set(true);
+          return null;
+        }
+        return v;
+      });
+    }
+    if (reconstructState.get()) {
+      synchronized (getUpdateLock()) {
+        constructState(Collections.emptySet());
+      }
     }
-//    if (reconstructState.get()) {
-//      synchronized (getUpdateLock()) {
-//        constructState(Collections.emptySet());
-//      }
-//    }
   }
 
   /* package-private for testing */
@@ -1990,7 +1984,7 @@ public class ZkStateReader implements SolrCloseable {
 
   private void notifyStateWatchers(String collection, DocCollection collectionState) {
     try {
-      notifications.submit(new Notification(collection, collectionState));
+      notifications.submit(new Notification(collection, collectionState, collectionWatches));
     } catch (RejectedExecutionException e) {
       if (closed == false) {
         log.error("Couldn't run collection notifications for {}", collection, e);
@@ -2003,9 +1997,12 @@ public class ZkStateReader implements SolrCloseable {
     final String collection;
     final DocCollection collectionState;
 
-    private Notification(String collection, DocCollection collectionState) {
+    private final ConcurrentHashMap<String,CollectionWatch<DocCollectionWatcher>> collectionWatches;
+
+    public Notification(String collection, DocCollection collectionState, ConcurrentHashMap<String, CollectionWatch<DocCollectionWatcher>> collectionWatches) {
       this.collection = collection;
       this.collectionState = collectionState;
+      this.collectionWatches = collectionWatches;
     }
 
     @Override