Add support to also reload HashFunctions when Solr boots (otherwise codecs using new hash functions may fail to load).

We may need a better "automatic" reloading with one method call, that reloads all NamedSPILoaders. I will think about it and open issue. Solr could then only call NamedSPILoader.reloadAll(), so all instantiated ones get reloaded automatically. Currently its to risky to add new SPIs without Solr support (because it cannot be tested).

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1371150 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-08-09 10:34:30 +00:00
parent b2ab339643
commit 2c38158032
2 changed files with 18 additions and 1 deletions

View File

@ -62,7 +62,21 @@ public abstract class HashFunction implements NamedSPILoader.NamedSPI {
return loader.availableServices();
}
/**
* Reloads the hash function list from the given {@link ClassLoader}.
* Changes to the function list are visible after the method ends, all
* iterators ({@link #availableHashFunctionNames()},...) stay consistent.
*
* <p><b>NOTE:</b> Only new functions are added, existing ones are
* never removed or replaced.
*
* <p><em>This method is expensive and should only be called for discovery
* of new functions on the given classpath/classloader!</em>
*/
public static void reloadHashFunctions(ClassLoader classloader) {
loader.reload(classloader);
}
@Override
public String toString() {
return name;

View File

@ -36,6 +36,7 @@ import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.util.hash.HashFunction;
import org.apache.lucene.analysis.util.WordlistLoader;
import org.apache.solr.common.ResourceLoader;
import org.apache.solr.handler.admin.CoreAdminHandler;
@ -175,6 +176,8 @@ public class SolrResourceLoader implements ResourceLoader
* this ResourceLoader.
*/
void reloadLuceneSPI() {
// Hash functions:
HashFunction.reloadHashFunctions(this.classLoader);
// Codecs:
PostingsFormat.reloadPostingsFormats(this.classLoader);
Codec.reloadCodecs(this.classLoader);