|
26 | 26 | import java.lang.reflect.Type;
|
27 | 27 | import java.util.*;
|
28 | 28 | import java.util.concurrent.CopyOnWriteArrayList;
|
| 29 | +import java.util.concurrent.Phaser; |
29 | 30 | import java.util.function.Supplier;
|
30 | 31 |
|
31 | 32 | import com.fasterxml.jackson.databind.DeserializationFeature;
|
32 | 33 | import com.fasterxml.jackson.databind.MapperFeature;
|
33 | 34 | import com.fasterxml.jackson.databind.ObjectMapper;
|
| 35 | +import com.google.common.annotations.VisibleForTesting; |
34 | 36 | import org.apache.lucene.util.ResourceLoaderAware;
|
35 | 37 | import org.apache.solr.client.solrj.SolrRequest;
|
36 | 38 | import org.apache.solr.client.solrj.request.beans.PluginMeta;
|
@@ -79,12 +81,30 @@ public class ContainerPluginsRegistry implements ClusterPropertiesListener, MapW
|
79 | 81 |
|
80 | 82 | private final Map<String, ApiInfo> currentPlugins = new HashMap<>();
|
81 | 83 |
|
| 84 | + private Phaser phaser; |
| 85 | + |
82 | 86 | @Override
|
83 | 87 | public boolean onChange(Map<String, Object> properties) {
|
84 | 88 | refresh();
|
| 89 | + Phaser localPhaser = phaser; // volatile read |
| 90 | + if (localPhaser != null) { |
| 91 | + assert localPhaser.getRegisteredParties() == 1; |
| 92 | + localPhaser.arrive(); // we should be the only ones registered, so this will advance phase each time |
| 93 | + } |
85 | 94 | return false;
|
86 | 95 | }
|
87 | 96 |
|
| 97 | + /** |
| 98 | + * A phaser that will advance phases every time {@link #onChange(Map)} is called. |
| 99 | + * Useful for allowing tests to know when a new configuration is finished getting set. |
| 100 | + */ |
| 101 | + |
| 102 | + @VisibleForTesting |
| 103 | + public void setPhaser(Phaser phaser) { |
| 104 | + phaser.register(); |
| 105 | + this.phaser = phaser; |
| 106 | + } |
| 107 | + |
88 | 108 | public void registerListener(PluginRegistryListener listener) {
|
89 | 109 | listeners.add(listener);
|
90 | 110 | }
|
|
0 commit comments