cpoerschke commented on code in PR #959:
URL: https://github.com/apache/solr/pull/959#discussion_r953997265


##########
solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java:
##########
@@ -66,18 +71,71 @@
 public class TestContainerPlugin extends SolrCloudTestCase {
   private Phaser phaser;
 
+  private CountingListener listener;
+
   private boolean forceV2;
 
+  /**
+   * A package listener that will count how many times it has been triggered. 
Useful to wait for
+   * changes accross multiple cores.
+   *
+   * <p>Use by calling {@link #reset()} before the API calls, and then {@link 
#waitFor(int)} to
+   * block until <code>num</code> cores have been notified.
+   */
+  class CountingListener implements PackageListeners.Listener {
+    private Semaphore changeCalled = new Semaphore(0);

Review Comment:
   minor: could be `final`



##########
solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java:
##########
@@ -66,18 +71,71 @@
 public class TestContainerPlugin extends SolrCloudTestCase {
   private Phaser phaser;
 
+  private CountingListener listener;
+
   private boolean forceV2;
 
+  /**
+   * A package listener that will count how many times it has been triggered. 
Useful to wait for
+   * changes accross multiple cores.
+   *
+   * <p>Use by calling {@link #reset()} before the API calls, and then {@link 
#waitFor(int)} to
+   * block until <code>num</code> cores have been notified.
+   */
+  class CountingListener implements PackageListeners.Listener {

Review Comment:
   minor: could be `private static final`



##########
solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java:
##########
@@ -66,18 +71,71 @@
 public class TestContainerPlugin extends SolrCloudTestCase {
   private Phaser phaser;
 
+  private CountingListener listener;
+
   private boolean forceV2;
 
+  /**
+   * A package listener that will count how many times it has been triggered. 
Useful to wait for
+   * changes accross multiple cores.
+   *
+   * <p>Use by calling {@link #reset()} before the API calls, and then {@link 
#waitFor(int)} to
+   * block until <code>num</code> cores have been notified.
+   */
+  class CountingListener implements PackageListeners.Listener {
+    private Semaphore changeCalled = new Semaphore(0);
+
+    @Override
+    public String packageName() {
+      return null; // will fire on all package changes
+    }
+
+    @Override
+    public Map<String, PackageAPI.PkgVersion> packageDetails() {
+      return null; // only used to print meta information
+    }
+
+    @Override
+    public void changed(PackageLoader.Package pkg, Ctx ctx) {
+      changeCalled.release();
+    }
+
+    public void reset() {
+      changeCalled.drainPermits();
+    }
+
+    public boolean waitFor(int num) throws InterruptedException {
+      return changeCalled.tryAcquire(num, 10, TimeUnit.SECONDS);

Review Comment:
   could potentially `&& changeCalled.availablePermits() == 0` i.e. there 
should be no additional excess permits available after `num` have been acquired.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to