Skip to content

Commit

Permalink
SOLR-14749: Make sure the plugin config is reloaded on Overseer.
Browse files Browse the repository at this point in the history
  • Loading branch information
sigram committed Mar 9, 2021
1 parent 578b2ae commit 7ada403
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import java.lang.reflect.Type;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Phaser;
import java.util.function.Supplier;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting;
import org.apache.lucene.util.ResourceLoaderAware;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.request.beans.PluginMeta;
Expand Down Expand Up @@ -79,12 +81,30 @@ public class ContainerPluginsRegistry implements ClusterPropertiesListener, MapW

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

private Phaser phaser;

@Override
public boolean onChange(Map<String, Object> properties) {
refresh();
Phaser localPhaser = phaser; // volatile read
if (localPhaser != null) {
assert localPhaser.getRegisteredParties() == 1;
localPhaser.arrive(); // we should be the only ones registered, so this will advance phase each time
}
return false;
}

/**
* A phaser that will advance phases every time {@link #onChange(Map)} is called.
* Useful for allowing tests to know when a new configuration is finished getting set.
*/

@VisibleForTesting
public void setPhaser(Phaser phaser) {
phaser.register();
this.phaser = phaser;
}

public void registerListener(PluginRegistryListener listener) {
listeners.add(listener);
}
Expand Down
Loading

0 comments on commit 7ada403

Please sign in to comment.