Skip to content

Commit 7ada403

Browse files
committed
SOLR-14749: Make sure the plugin config is reloaded on Overseer.
1 parent 578b2ae commit 7ada403

File tree

2 files changed

+193
-140
lines changed

2 files changed

+193
-140
lines changed

solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
import java.lang.reflect.Type;
2727
import java.util.*;
2828
import java.util.concurrent.CopyOnWriteArrayList;
29+
import java.util.concurrent.Phaser;
2930
import java.util.function.Supplier;
3031

3132
import com.fasterxml.jackson.databind.DeserializationFeature;
3233
import com.fasterxml.jackson.databind.MapperFeature;
3334
import com.fasterxml.jackson.databind.ObjectMapper;
35+
import com.google.common.annotations.VisibleForTesting;
3436
import org.apache.lucene.util.ResourceLoaderAware;
3537
import org.apache.solr.client.solrj.SolrRequest;
3638
import org.apache.solr.client.solrj.request.beans.PluginMeta;
@@ -79,12 +81,30 @@ public class ContainerPluginsRegistry implements ClusterPropertiesListener, MapW
7981

8082
private final Map<String, ApiInfo> currentPlugins = new HashMap<>();
8183

84+
private Phaser phaser;
85+
8286
@Override
8387
public boolean onChange(Map<String, Object> properties) {
8488
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+
}
8594
return false;
8695
}
8796

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+
88108
public void registerListener(PluginRegistryListener listener) {
89109
listeners.add(listener);
90110
}

0 commit comments

Comments
 (0)