You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ry...@apache.org on 2007/09/08 21:03:58 UTC
svn commit: r573893 [2/3] - in /lucene/solr/trunk: ./
client/java/solrj/src/org/apache/solr/client/solrj/embedded/
client/java/solrj/test/org/apache/solr/client/solrj/embedded/
src/java/org/apache/solr/analysis/ src/java/org/apache/solr/core/
src/java/...
Modified: lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/schema/IndexSchema.java Sat Sep 8 12:03:54 2007
@@ -25,6 +25,7 @@
import org.apache.lucene.queryParser.QueryParser;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.DOMUtil;
+import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.Config;
import org.apache.solr.analysis.TokenFilterFactory;
@@ -55,7 +56,7 @@
public final class IndexSchema {
final static Logger log = Logger.getLogger(IndexSchema.class.getName());
-
+ private final SolrConfig solrConfig;
private final String schemaFile;
private String name;
private float version;
@@ -66,20 +67,28 @@
*
* @see Config#openResource
*/
- public IndexSchema(String schemaFile) {
+ public IndexSchema(SolrConfig solrConfig, String schemaFile) {
+ this.solrConfig = solrConfig;
this.schemaFile=schemaFile;
- readConfig();
+ readSchema(solrConfig);
}
+ public SolrConfig getSolrConfig() {
+ return solrConfig;
+ }
/**
* Direct acess to the InputStream for the schemaFile used by this instance.
*
* @see Config#openResource
*/
public InputStream getInputStream() {
- return Config.openResource(schemaFile);
+ return solrConfig.openResource(schemaFile);
}
+ /** Gets the name of the schema file. */
+ public String getSchemaFile() {
+ return schemaFile;
+ }
float getVersion() {
return version;
@@ -284,7 +293,7 @@
}
- private void readConfig() {
+ private void readSchema(SolrConfig solrConfig) {
log.info("Reading Solr Schema");
try {
@@ -293,9 +302,9 @@
Document document = builder.parse(getInputStream());
***/
- Config config = new Config("schema", getInputStream(), "/schema/");
- Document document = config.getDocument();
- final XPath xpath = config.getXPath();
+ Config schemaConf = new Config("schema", getInputStream(), "/schema/");
+ Document document = schemaConf.getDocument();
+ final XPath xpath = schemaConf.getXPath();
Node nd = (Node) xpath.evaluate("/schema/@name", document, XPathConstants.NODE);
if (nd==null) {
@@ -305,13 +314,13 @@
log.info("Schema name=" + name);
}
- version = config.getFloat("/schema/@version", 1.0f);
+ version = schemaConf.getFloat("/schema/@version", 1.0f);
final IndexSchema schema = this;
AbstractPluginLoader<FieldType> loader = new AbstractPluginLoader<FieldType>( "[schema.xml] fieldType" ) {
@Override
- protected FieldType create( String name, String className, Node node ) throws Exception
+ protected FieldType create( SolrCore core, String name, String className, Node node ) throws Exception
{
FieldType ft = (FieldType)Config.newInstance(className);
ft.setTypeName(name);
@@ -448,7 +457,7 @@
similarity = new DefaultSimilarity();
log.fine("using default similarity");
} else {
- similarity = (Similarity)Config.newInstance(node.getNodeValue().trim());
+ similarity = (Similarity)solrConfig.newInstance(node.getNodeValue().trim());
log.fine("using similarity " + similarity.getClass().getName());
}
@@ -583,7 +592,7 @@
NamedNodeMap attrs = node.getAttributes();
String analyzerName = DOMUtil.getAttr(attrs,"class");
if (analyzerName != null) {
- return (Analyzer)Config.newInstance(analyzerName);
+ return (Analyzer)solrConfig.newInstance(analyzerName);
}
XPath xpath = XPathFactory.newInstance().newXPath();
@@ -593,7 +602,7 @@
if (tokNode==null){
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"analyzer without class or tokenizer & filter list");
}
- TokenizerFactory tfac = readTokenizerFactory(tokNode);
+ TokenizerFactory tfac = readTokenizerFactory(solrConfig, tokNode);
/******
// oops, getChildNodes() includes text (newlines, etc) in addition
@@ -607,7 +616,7 @@
ArrayList<TokenFilterFactory> filters = new ArrayList<TokenFilterFactory>();
for (int i=0; i<nList.getLength(); i++) {
- TokenFilterFactory filt = readTokenFilterFactory(nList.item(i));
+ TokenFilterFactory filt = readTokenFilterFactory(solrConfig, nList.item(i));
if (filt != null) filters.add(filt);
}
@@ -615,21 +624,27 @@
};
// <tokenizer class="solr.StandardFilterFactory"/>
- private TokenizerFactory readTokenizerFactory(Node node) {
+ private TokenizerFactory readTokenizerFactory(SolrConfig solrConfig, Node node) {
// if (node.getNodeName() != "tokenizer") return null;
NamedNodeMap attrs = node.getAttributes();
String className = DOMUtil.getAttr(attrs,"class","tokenizer");
- TokenizerFactory tfac = (TokenizerFactory)Config.newInstance(className);
+ TokenizerFactory tfac = (TokenizerFactory)solrConfig.newInstance(className);
+ if (tfac instanceof SolrConfig.Initializable)
+ ((SolrConfig.Initializable)tfac).init(solrConfig, DOMUtil.toMapExcept(attrs,"class"));
+ else
tfac.init(DOMUtil.toMapExcept(attrs,"class"));
return tfac;
}
// <tokenizer class="solr.StandardFilterFactory"/>
- private TokenFilterFactory readTokenFilterFactory(Node node) {
+ private TokenFilterFactory readTokenFilterFactory(SolrConfig solrConfig, Node node) {
// if (node.getNodeName() != "filter") return null;
NamedNodeMap attrs = node.getAttributes();
String className = DOMUtil.getAttr(attrs,"class","token filter");
- TokenFilterFactory tfac = (TokenFilterFactory)Config.newInstance(className);
+ TokenFilterFactory tfac = (TokenFilterFactory)solrConfig.newInstance(className);
+ if (tfac instanceof SolrConfig.Initializable)
+ ((SolrConfig.Initializable)tfac).init(solrConfig, DOMUtil.toMapExcept(attrs,"class"));
+ else
tfac.init(DOMUtil.toMapExcept(attrs,"class"));
return tfac;
}
Modified: lucene/solr/trunk/src/java/org/apache/solr/search/CacheConfig.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/CacheConfig.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/CacheConfig.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/CacheConfig.java Sat Sep 8 12:03:54 2007
@@ -36,7 +36,7 @@
*
* @version $Id$
*/
-class CacheConfig {
+public class CacheConfig {
private String nodeName;
private Map args;
@@ -56,8 +56,8 @@
this.regenerator = regenerator;
}
- public static CacheConfig[] getMultipleConfigs(String configPath) {
- NodeList nodes = (NodeList)SolrConfig.config.evaluate(configPath, XPathConstants.NODESET);
+ public static CacheConfig[] getMultipleConfigs(SolrConfig solrConfig, String configPath) {
+ NodeList nodes = (NodeList)solrConfig.evaluate(configPath, XPathConstants.NODESET);
if (nodes==null || nodes.getLength()==0) return null;
CacheConfig[] configs = new CacheConfig[nodes.getLength()];
for (int i=0; i<nodes.getLength(); i++) {
@@ -67,8 +67,8 @@
}
- public static CacheConfig getConfig(String xpath) {
- Node node = (Node)SolrConfig.config.getNode(xpath, false);
+ public static CacheConfig getConfig(SolrConfig solrConfig, String xpath) {
+ Node node = (Node)solrConfig.getNode(xpath, false);
return getConfig(node);
}
Modified: lucene/solr/trunk/src/java/org/apache/solr/search/DocSetHitCollector.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/DocSetHitCollector.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/DocSetHitCollector.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/DocSetHitCollector.java Sat Sep 8 12:03:54 2007
@@ -27,8 +27,8 @@
final class DocSetHitCollector extends HitCollector {
- static float HASHSET_INVERSE_LOAD_FACTOR = 1.0f / SolrConfig.config.getFloat("//HashDocSet/@loadFactor",0.75f);
- static int HASHDOCSET_MAXSIZE= SolrConfig.config.getInt("//HashDocSet/@maxSize",-1);
+ final float HASHSET_INVERSE_LOAD_FACTOR;
+ final int HASHDOCSET_MAXSIZE;
int pos=0;
OpenBitSet bits;
@@ -37,11 +37,14 @@
// in case there aren't that many hits, we may not want a very sparse
// bit array. Optimistically collect the first few docs in an array
// in case there are only a few.
- final int[] scratch = new int[HASHDOCSET_MAXSIZE];
+ final int[] scratch;
// todo - could pass in bitset and an operation also...
- DocSetHitCollector(int maxDoc) {
+ DocSetHitCollector(float inverseLoadFactor, int maxSize, int maxDoc) {
this.maxDoc = maxDoc;
+ HASHSET_INVERSE_LOAD_FACTOR = inverseLoadFactor;
+ HASHDOCSET_MAXSIZE = maxSize;
+ scratch = new int[HASHDOCSET_MAXSIZE];
}
public void collect(int doc, float score) {
Modified: lucene/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/SolrIndexSearcher.java Sat Sep 8 12:03:54 2007
@@ -56,7 +56,7 @@
public class SolrIndexSearcher extends Searcher implements SolrInfoMBean {
private static Logger log = Logger.getLogger(SolrIndexSearcher.class.getName());
-
+ private final SolrCore core;
private final IndexSchema schema;
private final String name;
@@ -66,11 +66,21 @@
private final IndexReader reader;
private final boolean closeReader;
+ private final int queryResultWindowSize;
+ private final int queryResultMaxDocsCached;
+ private final boolean useFilterForSortedQuery;
+ public final boolean enableLazyFieldLoading;
+
private final boolean cachingEnabled;
private final SolrCache filterCache;
private final SolrCache queryResultCache;
private final SolrCache documentCache;
+ private final LuceneQueryOptimizer optimizer;
+
+ private final float HASHSET_INVERSE_LOAD_FACTOR;
+ private final int HASHDOCSET_MAXSIZE;
+
// map of generic caches - not synchronized since it's read-only after the constructor.
private final HashMap<String, SolrCache> cacheMap;
private static final HashMap<String, SolrCache> noGenericCaches=new HashMap<String,SolrCache>(0);
@@ -80,21 +90,22 @@
private static final SolrCache[] noCaches = new SolrCache[0];
/** Creates a searcher searching the index in the named directory. */
- public SolrIndexSearcher(IndexSchema schema, String name, String path, boolean enableCache) throws IOException {
- this(schema,name,IndexReader.open(path), true, enableCache);
+ public SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, String path, boolean enableCache) throws IOException {
+ this(core, schema,name,IndexReader.open(path), true, enableCache);
}
/** Creates a searcher searching the index in the provided directory. */
- public SolrIndexSearcher(IndexSchema schema, String name, Directory directory, boolean enableCache) throws IOException {
- this(schema,name,IndexReader.open(directory), true, enableCache);
+ public SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, Directory directory, boolean enableCache) throws IOException {
+ this(core, schema,name,IndexReader.open(directory), true, enableCache);
}
/** Creates a searcher searching the provided index. */
- public SolrIndexSearcher(IndexSchema schema, String name, IndexReader r, boolean enableCache) {
- this(schema,name,r, false, enableCache);
+ public SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, IndexReader r, boolean enableCache) {
+ this(core, schema,name,r, false, enableCache);
}
- private SolrIndexSearcher(IndexSchema schema, String name, IndexReader r, boolean closeReader, boolean enableCache) {
+ private SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, IndexReader r, boolean closeReader, boolean enableCache) {
+ this.core = core;
this.schema = schema;
this.name = "Searcher@" + Integer.toHexString(hashCode()) + (name!=null ? " "+name : "");
@@ -105,21 +116,27 @@
this.closeReader = closeReader;
searcher.setSimilarity(schema.getSimilarity());
+ SolrConfig solrConfig = schema.getSolrConfig();
+ queryResultWindowSize = solrConfig.queryResultWindowSize;
+ queryResultMaxDocsCached = solrConfig.queryResultMaxDocsCached;
+ useFilterForSortedQuery = solrConfig.useFilterForSortedQuery;
+ enableLazyFieldLoading = solrConfig.enableLazyFieldLoading;
+
cachingEnabled=enableCache;
if (cachingEnabled) {
ArrayList<SolrCache> clist = new ArrayList<SolrCache>();
- filterCache= filterCacheConfig==null ? null : filterCacheConfig.newInstance();
+ filterCache= solrConfig.filterCacheConfig==null ? null : solrConfig.filterCacheConfig.newInstance();
if (filterCache!=null) clist.add(filterCache);
- queryResultCache = queryResultCacheConfig==null ? null : queryResultCacheConfig.newInstance();
+ queryResultCache = solrConfig.queryResultCacheConfig==null ? null : solrConfig.queryResultCacheConfig.newInstance();
if (queryResultCache!=null) clist.add(queryResultCache);
- documentCache = documentCacheConfig==null ? null : documentCacheConfig.newInstance();
+ documentCache = solrConfig.documentCacheConfig==null ? null : solrConfig.documentCacheConfig.newInstance();
if (documentCache!=null) clist.add(documentCache);
- if (userCacheConfigs == null) {
+ if (solrConfig.userCacheConfigs == null) {
cacheMap = noGenericCaches;
} else {
- cacheMap = new HashMap<String,SolrCache>(userCacheConfigs.length);
- for (CacheConfig userCacheConfig : userCacheConfigs) {
+ cacheMap = new HashMap<String,SolrCache>(solrConfig.userCacheConfigs.length);
+ for (CacheConfig userCacheConfig : solrConfig.userCacheConfigs) {
SolrCache cache = null;
if (userCacheConfig != null) cache = userCacheConfig.newInstance();
if (cache != null) {
@@ -137,9 +154,13 @@
cacheMap = noGenericCaches;
cacheList= noCaches;
}
+ optimizer = solrConfig.filtOptEnabled ? new LuceneQueryOptimizer(solrConfig.filtOptCacheSize,solrConfig.filtOptThreshold) : null;
+ // for DocSets
+ HASHSET_INVERSE_LOAD_FACTOR = solrConfig.hashSetInverseLoadFactor;
+ HASHDOCSET_MAXSIZE = solrConfig.hashDocSetMaxSize;
// register self
- SolrInfoRegistry.getRegistry().put(this.name, this);
+ core.getInfoRegistry().put(this.name, this);
}
@@ -153,7 +174,7 @@
public void register() {
for (SolrCache cache : cacheList) {
cache.setState(SolrCache.State.LIVE);
- SolrInfoRegistry.getRegistry().put(cache.name(), cache);
+ core.getInfoRegistry().put(cache.name(), cache);
}
registerTime=System.currentTimeMillis();
}
@@ -165,7 +186,7 @@
*/
public void close() throws IOException {
// unregister first, so no management actions are tried on a closing searcher.
- SolrInfoRegistry.getRegistry().remove(name);
+ core.getInfoRegistry().remove(name);
if (cachingEnabled) {
StringBuilder sb = new StringBuilder();
@@ -193,27 +214,12 @@
public IndexReader getReader() { return reader; }
/** Direct access to the IndexSchema for use with this searcher */
public IndexSchema getSchema() { return schema; }
-
-
- // params for the "nutch" query optimizer
- private static boolean filtOptEnabled=SolrConfig.config.getBool("query/boolTofilterOptimizer/@enabled",false);
- private static int filtOptCacheSize=SolrConfig.config.getInt("query/boolTofilterOptimizer/@cacheSize",32);
- private static float filtOptThreshold= SolrConfig.config.getFloat("query/boolTofilterOptimizer/@threshold",.05f);
- private LuceneQueryOptimizer optimizer = filtOptEnabled ? new LuceneQueryOptimizer(filtOptCacheSize,filtOptThreshold) : null;
-
-
- private static final CacheConfig filterCacheConfig = CacheConfig.getConfig("query/filterCache");
- private static final CacheConfig queryResultCacheConfig = CacheConfig.getConfig("query/queryResultCache");
- private static final CacheConfig documentCacheConfig = CacheConfig.getConfig("query/documentCache");
- private static final CacheConfig[] userCacheConfigs = CacheConfig.getMultipleConfigs("query/cache");
-
-
//
// Set default regenerators on filter and query caches if they don't have any
//
- static {
- if (filterCacheConfig != null && filterCacheConfig.getRegenerator() == null) {
- filterCacheConfig.setRegenerator(
+ public static void initRegenerators(SolrConfig solrConfig) {
+ if (solrConfig.filterCacheConfig != null && solrConfig.filterCacheConfig.getRegenerator() == null) {
+ solrConfig.filterCacheConfig.setRegenerator(
new CacheRegenerator() {
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache, SolrCache oldCache, Object oldKey, Object oldVal) throws IOException {
newSearcher.cacheDocSet((Query)oldKey, null, false);
@@ -223,8 +229,9 @@
);
}
- if (queryResultCacheConfig != null && queryResultCacheConfig.getRegenerator() == null) {
- queryResultCacheConfig.setRegenerator(
+ if (solrConfig.queryResultCacheConfig != null && solrConfig.queryResultCacheConfig.getRegenerator() == null) {
+ final int queryResultWindowSize = solrConfig.queryResultWindowSize;
+ solrConfig.queryResultCacheConfig.setRegenerator(
new CacheRegenerator() {
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache, SolrCache oldCache, Object oldKey, Object oldVal) throws IOException {
QueryResultKey key = (QueryResultKey)oldKey;
@@ -253,12 +260,6 @@
}
}
-
- private static boolean useFilterForSortedQuery=SolrConfig.config.getBool("query/useFilterForSortedQuery", false);
- private static int queryResultWindowSize=SolrConfig.config.getInt("query/queryResultWindowSize", 1);
- private static int queryResultMaxDocsCached=SolrConfig.config.getInt("query/queryResultMaxDocsCached", Integer.MAX_VALUE);
-
-
public Hits search(Query query, Filter filter, Sort sort) throws IOException {
// todo - when Solr starts accepting filters, need to
// change this conditional check (filter!=null) and create a new filter
@@ -326,9 +327,6 @@
}
}
- /* solrconfig lazyfields setting */
- public static final boolean enableLazyFieldLoading = SolrConfig.config.getBool("query/enableLazyFieldLoading", false);
-
/**
* Retrieve the {@link Document} instance corresponding to the document id.
*/
@@ -579,7 +577,7 @@
// query must be positive
protected DocSet getDocSetNC(Query query, DocSet filter) throws IOException {
if (filter==null) {
- DocSetHitCollector hc = new DocSetHitCollector(maxDoc());
+ DocSetHitCollector hc = new DocSetHitCollector(HASHSET_INVERSE_LOAD_FACTOR, HASHDOCSET_MAXSIZE, maxDoc());
if (query instanceof TermQuery) {
Term t = ((TermQuery)query).getTerm();
TermDocs tdocs = null;
@@ -596,7 +594,7 @@
} else {
// FUTURE: if the filter is sorted by docid, could use skipTo (SkipQueryFilter)
- final DocSetHitCollector hc = new DocSetHitCollector(maxDoc());
+ final DocSetHitCollector hc = new DocSetHitCollector(HASHSET_INVERSE_LOAD_FACTOR, HASHDOCSET_MAXSIZE, maxDoc());
final DocSet filt = filter;
searcher.search(query, null, new HitCollector() {
public void collect(int doc, float score) {
@@ -987,7 +985,7 @@
float maxScore;
int[] ids;
float[] scores;
- final DocSetHitCollector setHC = new DocSetHitCollector(maxDoc());
+ final DocSetHitCollector setHC = new DocSetHitCollector(HASHSET_INVERSE_LOAD_FACTOR, HASHDOCSET_MAXSIZE, maxDoc());
query = QueryUtils.makeQueryable(query);
Modified: lucene/solr/trunk/src/java/org/apache/solr/tst/OldRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/tst/OldRequestHandler.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/tst/OldRequestHandler.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/tst/OldRequestHandler.java Sat Sep 8 12:03:54 2007
@@ -40,10 +40,14 @@
public class OldRequestHandler implements SolrRequestHandler {
-
+ SolrCore core;
long numRequests;
long numErrors;
+ public OldRequestHandler(SolrCore core) {
+ this.core = core;
+ }
+
public void init(NamedList args) {
SolrCore.log.log(Level.INFO, "Unused request handler arguments:" + args);
}
Modified: lucene/solr/trunk/src/java/org/apache/solr/tst/TestRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/tst/TestRequestHandler.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/tst/TestRequestHandler.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/tst/TestRequestHandler.java Sat Sep 8 12:03:54 2007
@@ -45,6 +45,11 @@
public class TestRequestHandler implements SolrRequestHandler {
private static Logger log = Logger.getLogger(SolrIndexSearcher.class.getName());
+ SolrCore core;
+
+ public TestRequestHandler(SolrCore core) {
+ this.core = core;
+ }
public void init(NamedList args) {
SolrCore.log.log(Level.INFO, "Unused request handler arguments:" + args);
}
Modified: lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java Sat Sep 8 12:03:54 2007
@@ -143,8 +143,8 @@
// The key is the id, the value (Integer) is the number
// of docs to save (delete all except the last "n" added)
protected final Map<String,Integer> pset;
- protected int maxPendingDeletes = SolrConfig.config.getInt("updateHandler/maxPendingDeletes", -1);
-
+ protected int maxPendingDeletes = -1;
+
// commonly used constants for the count in the pset
protected final static Integer ZERO = 0;
protected final static Integer ONE = 1;
@@ -164,6 +164,7 @@
which makes commits more efficient
*/
pset = new TreeMap<String,Integer>();
+ maxPendingDeletes = core.getSolrConfig().getInt("updateHandler/maxPendingDeletes", -1);
ReadWriteLock rwl = new ReentrantReadWriteLock();
iwAccess = rwl.readLock();
@@ -616,8 +617,8 @@
docsSinceCommit = 0;
pending = null;
- docsUpperBound = SolrConfig.config.getInt("updateHandler/autoCommit/maxDocs", -1);
- timeUpperBound = SolrConfig.config.getInt("updateHandler/autoCommit/maxTime", -1);
+ docsUpperBound = core.getSolrConfig().getInt("updateHandler/autoCommit/maxDocs", -1);
+ timeUpperBound = core.getSolrConfig().getInt("updateHandler/autoCommit/maxTime", -1);
SolrCore.log.info("AutoCommit: " + this);
}
Modified: lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexConfig.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexConfig.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexConfig.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexConfig.java Sat Sep 8 12:03:54 2007
@@ -29,24 +29,18 @@
*/
public class SolrIndexConfig {
public static final String defaultsName ="indexDefaults";
+ static final SolrIndexConfig defaultDefaults = new SolrIndexConfig();
- //default values
- public static final boolean defUseCompoundFile=SolrConfig.config.getBool(defaultsName +"/useCompoundFile", true);
- public static final int defMaxBufferedDocs=SolrConfig.config.getInt(defaultsName +"/maxBufferedDocs", -1);
- public static final int defMaxMergeDocs=SolrConfig.config.getInt(defaultsName +"/maxMergeDocs", -1);
- public static final int defMergeFactor=SolrConfig.config.getInt(defaultsName +"/mergeFactor", -1);
- public static final int defMaxFieldLength=SolrConfig.config.getInt(defaultsName +"/maxFieldLength", -1);
- public static final int defWriteLockTimeout=SolrConfig.config.getInt(defaultsName +"/writeLockTimeout", -1);
- public static final int defCommitLockTimeout=SolrConfig.config.getInt(defaultsName +"/commitLockTimeout", -1);
- public static final String defLockType=SolrConfig.config.get(defaultsName +"/lockType", null);
-
-
- /*** These are "final" in lucene 1.9
- static {
- if (writeLockTimeout != -1) IndexWriter.WRITE_LOCK_TIMEOUT=writeLockTimeout;
- if (commitLockTimeout != -1) IndexWriter.COMMIT_LOCK_TIMEOUT=commitLockTimeout;
+ private SolrIndexConfig() {
+ useCompoundFile = true;
+ maxBufferedDocs = -1;
+ maxMergeDocs = -1;
+ mergeFactor = -1;
+ maxFieldLength = -1;
+ writeLockTimeout = -1;
+ commitLockTimeout = -1;
+ lockType = null;
}
- ***/
public final boolean useCompoundFile;
public final int maxBufferedDocs;
@@ -57,14 +51,18 @@
public final int commitLockTimeout;
public final String lockType;
- public SolrIndexConfig(String prefix) {
- useCompoundFile=SolrConfig.config.getBool(prefix+"/useCompoundFile", defUseCompoundFile);
- maxBufferedDocs=SolrConfig.config.getInt(prefix+"/maxBufferedDocs",defMaxBufferedDocs);
- maxMergeDocs=SolrConfig.config.getInt(prefix+"/maxMergeDocs",defMaxMergeDocs);
- mergeFactor=SolrConfig.config.getInt(prefix+"/mergeFactor",defMergeFactor);
- maxFieldLength= SolrConfig.config.getInt(prefix+"/maxFieldLength",defMaxFieldLength);
- writeLockTimeout= SolrConfig.config.getInt(prefix+"/writeLockTimeout", defWriteLockTimeout);
- commitLockTimeout= SolrConfig.config.getInt(prefix+"/commitLockTimeout", defCommitLockTimeout);
- lockType=SolrConfig.config.get(prefix+"/lockType", defLockType);
+ public SolrIndexConfig(SolrConfig solrConfig, String prefix, SolrIndexConfig def) {
+ if (prefix == null)
+ prefix = defaultsName;
+ if (def == null)
+ def = defaultDefaults;
+ useCompoundFile=solrConfig.getBool(prefix+"/useCompoundFile", def.useCompoundFile);
+ maxBufferedDocs=solrConfig.getInt(prefix+"/maxBufferedDocs",def.maxBufferedDocs);
+ maxMergeDocs=solrConfig.getInt(prefix+"/maxMergeDocs",def.maxMergeDocs);
+ mergeFactor=solrConfig.getInt(prefix+"/mergeFactor",def.mergeFactor);
+ maxFieldLength=solrConfig.getInt(prefix+"/maxFieldLength",def.maxFieldLength);
+ writeLockTimeout=solrConfig.getInt(prefix+"/writeLockTimeout", def.writeLockTimeout);
+ commitLockTimeout=solrConfig.getInt(prefix+"/commitLockTimeout", def.commitLockTimeout);
+ lockType=solrConfig.get(prefix+"/lockType", def.lockType);
}
}
Modified: lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java Sat Sep 8 12:03:54 2007
@@ -61,13 +61,14 @@
protected Vector<SolrEventListener> optimizeCallbacks = new Vector<SolrEventListener>();
private void parseEventListeners() {
- NodeList nodes = (NodeList) SolrConfig.config.evaluate("updateHandler/listener[@event=\"postCommit\"]", XPathConstants.NODESET);
+ final SolrConfig solrConfig = core.getSolrConfig();
+ NodeList nodes = (NodeList) solrConfig.evaluate("updateHandler/listener[@event=\"postCommit\"]", XPathConstants.NODESET);
if (nodes!=null) {
for (int i=0; i<nodes.getLength(); i++) {
Node node = nodes.item(i);
try {
String className = DOMUtil.getAttr(node,"class");
- SolrEventListener listener = (SolrEventListener)Config.newInstance(className);
+ SolrEventListener listener = core.createEventListener(className);
listener.init(DOMUtil.childNodesToNamedList(node));
// listener.init(DOMUtil.toMapExcept(node.getAttributes(),"class","synchronized"));
commitCallbacks.add(listener);
@@ -77,13 +78,13 @@
}
}
}
- nodes = (NodeList)SolrConfig.config.evaluate("updateHandler/listener[@event=\"postOptimize\"]", XPathConstants.NODESET);
+ nodes = (NodeList) solrConfig.evaluate("updateHandler/listener[@event=\"postOptimize\"]", XPathConstants.NODESET);
if (nodes!=null) {
for (int i=0; i<nodes.getLength(); i++) {
Node node = nodes.item(i);
try {
String className = DOMUtil.getAttr(node,"class");
- SolrEventListener listener = (SolrEventListener)Config.newInstance(className);
+ SolrEventListener listener = core.createEventListener(className);
listener.init(DOMUtil.childNodesToNamedList(node));
optimizeCallbacks.add(listener);
log.info("added SolarEventListener for postOptimize: " + listener);
@@ -113,11 +114,11 @@
idFieldType = idField!=null ? idField.getType() : null;
parseEventListeners();
- SolrInfoRegistry.getRegistry().put("updateHandler", this);
+ core.getInfoRegistry().put("updateHandler", this);
}
protected SolrIndexWriter createMainIndexWriter(String name) throws IOException {
- SolrIndexWriter writer = new SolrIndexWriter(name,core.getIndexDir(), false, schema,SolrCore.mainIndexConfig);
+ SolrIndexWriter writer = new SolrIndexWriter(name,core.getIndexDir(), false, schema, core.getSolrConfig().mainIndexConfig);
return writer;
}
Modified: lucene/solr/trunk/src/java/org/apache/solr/util/AbstractSolrTestCase.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/util/AbstractSolrTestCase.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/util/AbstractSolrTestCase.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/util/AbstractSolrTestCase.java Sat Sep 8 12:03:54 2007
@@ -18,6 +18,8 @@
package org.apache.solr.util;
+
+import org.apache.solr.core.SolrConfig;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.XML;
import org.apache.solr.request.*;
@@ -43,7 +45,7 @@
* @see #tearDown
*/
public abstract class AbstractSolrTestCase extends TestCase {
-
+ protected SolrConfig solrConfig;
/**
* Harness initialized by initTestHarness.
*
@@ -61,6 +63,13 @@
* </p>
*/
protected TestHarness.LocalRequestFactory lrf;
+ /**
+ * Subclasses may define this method to return the name of the
+ * Solr core they wish to use.
+ */
+ public String getCoreName() {
+ return this.getClass().getPackage().getName();
+ }
/**
* Subclasses must define this method to return the name of the
@@ -90,14 +99,23 @@
*
*/
public void setUp() throws Exception {
-
+ String coreName = getCoreName();
+ if (coreName != null) {
dataDir = new File(System.getProperty("java.io.tmpdir")
+ System.getProperty("file.separator")
- + getClass().getName() + "-" + getName() + "-"
+ System.currentTimeMillis());
+ } else {
+ dataDir = new File(System.getProperty("java.io.tmpdir")
+ + System.getProperty("file.separator")
+ + getClass().getName() + "-" + System.currentTimeMillis());
+
+ }
dataDir.mkdirs();
- h = new TestHarness(dataDir.getAbsolutePath(),
- getSolrConfigFile(),
+
+ solrConfig = h.createConfig(getSolrConfigFile());
+ h = new TestHarness(coreName,
+ dataDir.getAbsolutePath(),
+ solrConfig,
getSchemaFile());
lrf = h.getRequestFactory
("standard",0,20,"version","2.2");
Modified: lucene/solr/trunk/src/java/org/apache/solr/util/TestHarness.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/util/TestHarness.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/util/TestHarness.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/util/TestHarness.java Sat Sep 8 12:03:54 2007
@@ -66,14 +66,26 @@
private DocumentBuilder builder;
public XmlUpdateRequestHandler updater;
+ public static SolrConfig createConfig(String confFile) {
+ // set some system properties for use by tests
+ System.setProperty("solr.test.sys.prop1", "propone");
+ System.setProperty("solr.test.sys.prop2", "proptwo");
+ try {
+ return new SolrConfig(confFile);
+ }
+ catch(Exception xany) {
+ throw new RuntimeException(xany);
+ }
+ }
+
/**
* Assumes "solrconfig.xml" is the config file to use, and
* "schema.xml" is the schema path to use.
*
* @param dataDirectory path for index data, will not be cleaned up
*/
- public TestHarness(String dataDirectory) {
- this(dataDirectory, "schema.xml");
+ public TestHarness(String name, String dataDirectory) {
+ this(name, dataDirectory, "schema.xml");
}
/**
* Assumes "solrconfig.xml" is the config file to use.
@@ -81,24 +93,42 @@
* @param dataDirectory path for index data, will not be cleaned up
* @param schemaFile path of schema file
*/
- public TestHarness(String dataDirectory, String schemaFile) {
- this(dataDirectory, "solrconfig.xml", schemaFile);
+ public TestHarness(String name, String dataDirectory, String schemaFile) {
+ this(name, dataDirectory, "solrconfig.xml", schemaFile);
}
/**
+ * @param name the core name
* @param dataDirectory path for index data, will not be cleaned up
- * @param confFile solrconfig filename
+ * @param configFile solrconfig filename
* @param schemaFile schema filename
*/
- public TestHarness(String dataDirectory,
- String confFile,
+ public TestHarness(String name, String dataDirectory, String configFile, String schemaFile) {
+ this(name, dataDirectory, createConfig(configFile), schemaFile);
+ }
+ /**
+ * @param name the core name
+ * @param dataDirectory path for index data, will not be cleaned up
+ * @param solrConfig solronfig instance
+ * @param schemaFile schema filename
+ */
+ public TestHarness(String name,
+ String dataDirectory,
+ SolrConfig solrConfig,
String schemaFile) {
+ this(name, dataDirectory, solrConfig, new IndexSchema(solrConfig, schemaFile));
+ }
+ /**
+ * @param name the core name
+ * @param dataDirectory path for index data, will not be cleaned up
+ * @param solrConfig solrconfig instance
+ * @param schema schema instance
+ */
+ public TestHarness(String name,
+ String dataDirectory,
+ SolrConfig solrConfig,
+ IndexSchema indexSchema) {
try {
- // set some system properties for use by tests
- System.setProperty("solr.test.sys.prop1", "propone");
- System.setProperty("solr.test.sys.prop2", "proptwo");
-
- SolrConfig.initConfig(confFile);
- core = new SolrCore(dataDirectory, new IndexSchema(schemaFile));
+ core = new SolrCore(name, dataDirectory, solrConfig, indexSchema);
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
updater = new XmlUpdateRequestHandler();
@@ -108,7 +138,9 @@
}
}
-
+ public SolrCore getCore() {
+ return core;
+ }
/**
* Processes an "update" (add, commit or optimize) and
@@ -125,7 +157,7 @@
StringReader req = new StringReader(xml);
StringWriter writer = new StringWriter(32000);
- updater.doLegacyUpdate(req, writer);
+ updater.doLegacyUpdate(core, req, writer);
return writer.toString();
}
@@ -287,10 +319,6 @@
}
- public SolrCore getCore() {
- return core;
- }
-
/**
* Shuts down and frees any resources
*/
Modified: lucene/solr/trunk/src/java/org/apache/solr/util/plugin/AbstractPluginLoader.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/util/plugin/AbstractPluginLoader.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/util/plugin/AbstractPluginLoader.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/util/plugin/AbstractPluginLoader.java Sat Sep 8 12:03:54 2007
@@ -24,6 +24,7 @@
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.DOMUtil;
import org.apache.solr.core.Config;
+import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrConfig;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -77,8 +78,10 @@
* @param node - the XML node defining this plugin
*/
@SuppressWarnings("unchecked")
- protected T create( String name, String className, Node node ) throws Exception
+ protected T create( SolrCore core, String name, String className, Node node ) throws Exception
{
+ if (core != null)
+ return (T) core.createInstance(className, null, "plug-in");
return (T) Config.newInstance( className, getDefaultPackages() );
}
@@ -120,7 +123,10 @@
* If a default element is defined, it will be returned from this function.
*
*/
- public T load( NodeList nodes )
+ public T load( NodeList nodes ) {
+ return load(null, nodes);
+ }
+ public T load( SolrCore core, NodeList nodes )
{
List<PluginInitInfo> info = new ArrayList<PluginInitInfo>();
T defaultPlugin = null;
@@ -136,7 +142,7 @@
String className = DOMUtil.getAttr(node,"class", type);
String defaultStr = DOMUtil.getAttr(node,"default", null );
- T plugin = create(name, className, node );
+ T plugin = create(core, name, className, node );
log.info("created "+name+": " + plugin.getClass().getName() );
// Either initialize now or wait till everything has been registered
Modified: lucene/solr/trunk/src/java/org/apache/solr/util/xslt/TransformerProvider.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/util/xslt/TransformerProvider.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/util/xslt/TransformerProvider.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/util/xslt/TransformerProvider.java Sat Sep 8 12:03:54 2007
@@ -28,7 +28,7 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;
-import org.apache.solr.core.Config;
+import org.apache.solr.core.SolrConfig;
/** Singleton that creates a Transformer for the XSLTServletFilter.
* For now, only caches the last created Transformer, but
@@ -64,7 +64,7 @@
/** Return a new Transformer, possibly created from our cached Templates object
* @throws TransformerConfigurationException
*/
- public synchronized Transformer getTransformer(String filename,int cacheLifetimeSeconds) throws IOException {
+ public synchronized Transformer getTransformer(SolrConfig solrConfig, String filename,int cacheLifetimeSeconds) throws IOException {
// For now, the Templates are blindly reloaded once cacheExpires is over.
// It'd be better to check the file modification time to reload only if needed.
if(lastTemplates!=null && filename.equals(lastFilename) && System.currentTimeMillis() < cacheExpires) {
@@ -72,7 +72,7 @@
log.fine("Using cached Templates:" + filename);
}
} else {
- lastTemplates = getTemplates(filename,cacheLifetimeSeconds);
+ lastTemplates = getTemplates(solrConfig, filename,cacheLifetimeSeconds);
}
Transformer result = null;
@@ -90,7 +90,7 @@
}
/** Return a Templates object for the given filename */
- private Templates getTemplates(String filename,int cacheLifetimeSeconds) throws IOException {
+ private Templates getTemplates(SolrConfig solrConfig, String filename,int cacheLifetimeSeconds) throws IOException {
Templates result = null;
lastFilename = null;
@@ -98,7 +98,7 @@
if(log.isLoggable(Level.FINE)) {
log.fine("compiling XSLT templates:" + filename);
}
- final InputStream xsltStream = Config.openResource("xslt/" + filename);
+ final InputStream xsltStream = solrConfig.openResource("xslt/" + filename);
result = tFactory.newTemplates(new StreamSource(xsltStream));
} catch (Exception e) {
log.throwing(getClass().getName(), "newTemplates", e);
Modified: lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java Sat Sep 8 12:03:54 2007
@@ -48,6 +48,7 @@
public String getSchemaFile() { return "schema.xml"; }
public String getSolrConfigFile() { return "solrconfig.xml"; }
+ public String getCoreName() { return "basic"; }
public void setUp() throws Exception {
// if you override setUp or tearDown, you better call
@@ -292,7 +293,7 @@
public void testTermVectorFields() {
- IndexSchema ischema = new IndexSchema(getSchemaFile());
+ IndexSchema ischema = new IndexSchema(solrConfig, getSchemaFile());
SchemaField f; // Solr field type
Field luf; // Lucene field
@@ -1172,7 +1173,7 @@
}
public void testCompressableFieldType() {
- IndexSchema ischema = new IndexSchema(getSchemaFile());
+ IndexSchema ischema = new IndexSchema(solrConfig, getSchemaFile());
SchemaField f; // Solr field type
Field luf; // Lucene field
Added: lucene/solr/trunk/src/test/org/apache/solr/analysis/AnalysisTestCase.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/AnalysisTestCase.java?rev=573893&view=auto
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/AnalysisTestCase.java (added)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/AnalysisTestCase.java Sat Sep 8 12:03:54 2007
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.analysis;
+import org.apache.solr.core.SolrConfig;
+import org.apache.solr.util.TestHarness;
+import junit.framework.TestCase;
+/**
+ *
+ * @author hbiestro
+ */
+public class AnalysisTestCase extends TestCase {
+ protected SolrConfig solrConfig;
+ /** Creates a new instance of AnalysisTestCase */
+ public AnalysisTestCase() {
+ }
+
+ public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ public void setUp() throws Exception {
+ // if you override setUp or tearDown, you better call
+ // the super classes version
+ super.setUp();
+ solrConfig = TestHarness.createConfig(getSolrConfigFile());
+ }
+}
Propchange: lucene/solr/trunk/src/test/org/apache/solr/analysis/AnalysisTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: lucene/solr/trunk/src/test/org/apache/solr/analysis/AnalysisTestCase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: lucene/solr/trunk/src/test/org/apache/solr/analysis/BaseTokenTestCase.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/BaseTokenTestCase.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/BaseTokenTestCase.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/BaseTokenTestCase.java Sat Sep 8 12:03:54 2007
@@ -31,7 +31,7 @@
/**
* General token testing helper functions
*/
-public abstract class BaseTokenTestCase extends TestCase
+public abstract class BaseTokenTestCase extends AnalysisTestCase
{
public static String tsToString(TokenStream in) throws IOException {
StringBuffer out = new StringBuffer();
Modified: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestCapitalizationFilter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/TestCapitalizationFilter.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/TestCapitalizationFilter.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/TestCapitalizationFilter.java Sat Sep 8 12:03:54 2007
@@ -22,7 +22,7 @@
/**
- * @version $Id:$
+ * @version $Id$
*/
public class TestCapitalizationFilter extends BaseTokenTestCase {
@@ -33,7 +33,7 @@
args.put( CapitalizationFilterFactory.ONLY_FIRST_WORD, "true" );
CapitalizationFilterFactory factory = new CapitalizationFilterFactory();
- factory.init( args );
+ factory.init( solrConfig, args );
assertEquals( "Kitten", factory.processWord( "kiTTEN", 0 ) );
factory.forceFirstLetter = true;
@@ -63,7 +63,7 @@
// Now try some prefixes
factory = new CapitalizationFilterFactory();
args.put( "okPrefix", "McK" ); // all words
- factory.init( args );
+ factory.init( solrConfig, args );
out = tsToString( factory.create( new IterTokenStream( "McKinley" ) ) );
assertEquals( "McKinley", out );
Modified: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestKeepWordFilter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/TestKeepWordFilter.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/TestKeepWordFilter.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/TestKeepWordFilter.java Sat Sep 8 12:03:54 2007
@@ -44,7 +44,7 @@
// Test Stopwords
KeepWordFilterFactory factory = new KeepWordFilterFactory();
args.put( "ignoreCase", "true" );
- factory.init( args );
+ factory.init( solrConfig, args );
factory.setWords( words );
List<Token> expect = tokens( "aaa BBB" );
@@ -53,7 +53,7 @@
// Now force case
args.put( "ignoreCase", "false" );
- factory.init( args );
+ factory.init( solrConfig, args );
expect = tokens( "aaa" );
real = getTokens(factory.create( new IterTokenStream(input) ));
Modified: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternReplaceFilter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternReplaceFilter.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternReplaceFilter.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternReplaceFilter.java Sat Sep 8 12:03:54 2007
@@ -27,7 +27,7 @@
/**
* @version $Id:$
*/
-public class TestPatternReplaceFilter extends TestCase {
+public class TestPatternReplaceFilter extends AnalysisTestCase {
public void testReplaceAll() throws Exception {
String input = "aabfooaabfooabfoob ab caaaaaaaaab";
Modified: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternTokenizerFactory.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternTokenizerFactory.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternTokenizerFactory.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternTokenizerFactory.java Sat Sep 8 12:03:54 2007
@@ -26,7 +26,7 @@
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
-public class TestPatternTokenizerFactory extends TestCase
+public class TestPatternTokenizerFactory extends AnalysisTestCase
{
public void testSplitting() throws Exception
{
@@ -50,7 +50,7 @@
args.put( PatternTokenizerFactory.PATTERN, test[1] );
PatternTokenizerFactory tokenizer = new PatternTokenizerFactory();
- tokenizer.init( args );
+ tokenizer.init(solrConfig, args );
TokenStream stream = tokenizer.create( new StringReader( test[2] ) );
String out = TestHyphenatedWordsFilter.tsToString( stream );
Modified: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPhoneticFilter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPhoneticFilter.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPhoneticFilter.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPhoneticFilter.java Sat Sep 8 12:03:54 2007
@@ -40,24 +40,24 @@
PhoneticFilterFactory ff = new PhoneticFilterFactory();
try {
- ff.init( args );
+ ff.init( solrConfig, args );
fail( "missing encoder parameter" );
}
catch( Exception ex ) {}
args.put( PhoneticFilterFactory.ENCODER, "XXX" );
try {
- ff.init( args );
+ ff.init( solrConfig, args );
fail( "unknown encoder parameter" );
}
catch( Exception ex ) {}
args.put( PhoneticFilterFactory.ENCODER, "Metaphone" );
- ff.init( args );
+ ff.init( solrConfig, args );
assertTrue( ff.encoder instanceof Metaphone );
assertTrue( ff.inject ); // default
args.put( PhoneticFilterFactory.INJECT, "false" );
- ff.init( args );
+ ff.init( solrConfig, args );
assertFalse( ff.inject );
}
Modified: lucene/solr/trunk/src/test/org/apache/solr/analysis/TestRemoveDuplicatesTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/analysis/TestRemoveDuplicatesTokenFilter.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/analysis/TestRemoveDuplicatesTokenFilter.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/analysis/TestRemoveDuplicatesTokenFilter.java Sat Sep 8 12:03:54 2007
@@ -23,7 +23,7 @@
import java.util.Iterator;
import java.util.Arrays;
-public class TestRemoveDuplicatesTokenFilter extends TestCase {
+public class TestRemoveDuplicatesTokenFilter extends AnalysisTestCase {
public static Token tok(int pos, String t, int start, int end) {
Token tok = new Token(t,start,end);
Modified: lucene/solr/trunk/src/test/org/apache/solr/core/RequestHandlersTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/core/RequestHandlersTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/core/RequestHandlersTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/core/RequestHandlersTest.java Sat Sep 8 12:03:54 2007
@@ -28,7 +28,7 @@
public void testLazyLoading() {
- SolrCore core = SolrCore.getSolrCore();
+ SolrCore core = h.getCore();
SolrRequestHandler handler = core.getRequestHandler( "lazy" );
assertFalse( handler instanceof StandardRequestHandler );
@@ -65,7 +65,7 @@
public void testPathNormalization()
{
- SolrCore core = SolrCore.getSolrCore();
+ SolrCore core = h.getCore();
SolrRequestHandler h1 = core.getRequestHandler("/update/csv" );
assertNotNull( h1 );
Modified: lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java Sat Sep 8 12:03:54 2007
@@ -30,7 +30,7 @@
public void testRequestHandlerRegistry() {
// property values defined in build.xml
- SolrCore core = SolrCore.getSolrCore();
+ SolrCore core = h.getCore();
EmptyRequestHandler handler1 = new EmptyRequestHandler();
EmptyRequestHandler handler2 = new EmptyRequestHandler();
Modified: lucene/solr/trunk/src/test/org/apache/solr/core/TestBadConfig.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/core/TestBadConfig.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/core/TestBadConfig.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/core/TestBadConfig.java Sat Sep 8 12:03:54 2007
@@ -1,51 +1,52 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.core;
-
-import org.apache.solr.util.AbstractSolrTestCase;
-import org.apache.solr.util.TestHarness;
-import java.io.File;
-
-public class TestBadConfig extends AbstractSolrTestCase {
-
- public String getSchemaFile() { return "schema.xml"; }
- public String getSolrConfigFile() { return "bad_solrconfig.xml"; }
-
- public void setUp() throws Exception {
-
- dataDir = new File(System.getProperty("java.io.tmpdir")
- + System.getProperty("file.separator")
- + getClass().getName() + "-" + getName() + "-"
- + System.currentTimeMillis());
- dataDir.mkdirs();
- try {
- h = new TestHarness(dataDir.getAbsolutePath(),
- getSolrConfigFile(),
- getSchemaFile());
- fail("Exception should have been thrown");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("unset.sys.property"));
- }
- }
-
-
- public void testNothing() {
- // Empty test case as the real test is that the initialization of the TestHarness fails
- assertTrue(true);
- }
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.core;
+
+import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.util.TestHarness;
+import java.io.File;
+
+public class TestBadConfig extends AbstractSolrTestCase {
+
+ public String getSchemaFile() { return "schema.xml"; }
+ public String getSolrConfigFile() { return "bad_solrconfig.xml"; }
+
+ public void setUp() throws Exception {
+
+ dataDir = new File(System.getProperty("java.io.tmpdir")
+ + System.getProperty("file.separator")
+ + getClass().getName());
+ dataDir.mkdirs();
+ try {
+ solrConfig = new SolrConfig(getSolrConfigFile());
+ h = new TestHarness(getName() + "-" + System.currentTimeMillis(),
+ dataDir.getAbsolutePath(),
+ solrConfig,
+ getSchemaFile());
+ fail("Exception should have been thrown");
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("unset.sys.property"));
+ }
+ }
+
+
+ public void testNothing() {
+ // Empty test case as the real test is that the initialization of the TestHarness fails
+ assertTrue(true);
+ }
}
Modified: lucene/solr/trunk/src/test/org/apache/solr/core/TestConfig.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/core/TestConfig.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/core/TestConfig.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/core/TestConfig.java Sat Sep 8 12:03:54 2007
@@ -1,53 +1,53 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.core;
-
-import org.apache.solr.util.AbstractSolrTestCase;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.xml.xpath.XPathConstants;
-
-public class TestConfig extends AbstractSolrTestCase {
-
- public String getSchemaFile() { return "schema.xml"; }
- public String getSolrConfigFile() { return "solrconfig.xml"; }
-
- public void testJavaProperty() {
- // property values defined in build.xml
-
- String s = SolrConfig.config.get("propTest");
- assertEquals("prefix-proptwo-suffix", s);
-
- s = SolrConfig.config.get("propTest/@attr1", "default");
- assertEquals("propone-${literal}", s);
-
- s = SolrConfig.config.get("propTest/@attr2", "default");
- assertEquals("default-from-config", s);
-
- s = SolrConfig.config.get("propTest[@attr2='default-from-config']", "default");
- assertEquals("prefix-proptwo-suffix", s);
-
- NodeList nl = (NodeList) SolrConfig.config.evaluate("propTest", XPathConstants.NODESET);
- assertEquals(1, nl.getLength());
- assertEquals("prefix-proptwo-suffix", nl.item(0).getTextContent());
-
- Node node = SolrConfig.config.getNode("propTest", true);
- assertEquals("prefix-proptwo-suffix", node.getTextContent());
- }
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.core;
+
+import org.apache.solr.util.AbstractSolrTestCase;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.xpath.XPathConstants;
+
+public class TestConfig extends AbstractSolrTestCase {
+
+ public String getSchemaFile() { return "schema.xml"; }
+ public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ public void testJavaProperty() {
+ // property values defined in build.xml
+
+ String s = solrConfig.get("propTest");
+ assertEquals("prefix-proptwo-suffix", s);
+
+ s = solrConfig.get("propTest/@attr1", "default");
+ assertEquals("propone-${literal}", s);
+
+ s = solrConfig.get("propTest/@attr2", "default");
+ assertEquals("default-from-config", s);
+
+ s = solrConfig.get("propTest[@attr2='default-from-config']", "default");
+ assertEquals("prefix-proptwo-suffix", s);
+
+ NodeList nl = (NodeList) solrConfig.evaluate("propTest", XPathConstants.NODESET);
+ assertEquals(1, nl.getLength());
+ assertEquals("prefix-proptwo-suffix", nl.item(0).getTextContent());
+
+ Node node = solrConfig.getNode("propTest", true);
+ assertEquals("prefix-proptwo-suffix", node.getTextContent());
+ }
}
Modified: lucene/solr/trunk/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java Sat Sep 8 12:03:54 2007
@@ -45,8 +45,8 @@
public void testInterface()
{
+ SolrCore core = h.getCore();
MoreLikeThisHandler mlt = new MoreLikeThisHandler();
- SolrCore core = SolrCore.getSolrCore();
Map<String,String[]> params = new HashMap<String,String[]>();
MultiMapSolrParams mmparams = new MultiMapSolrParams( params );
Modified: lucene/solr/trunk/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java Sat Sep 8 12:03:54 2007
@@ -41,6 +41,7 @@
}
public void testSorting() throws Exception {
+ SolrCore core = h.getCore();
assertU(adoc("id", "10", "title", "test", "val_s", "aaa"));
assertU(adoc("id", "11", "title", "test", "val_s", "bbb"));
assertU(adoc("id", "12", "title", "test", "val_s", "ccc"));
@@ -49,7 +50,7 @@
Map<String,String> args = new HashMap<String, String>();
args.put( CommonParams.Q, "title:test" );
args.put( "indent", "true" );
- SolrQueryRequest req = new LocalSolrQueryRequest( SolrCore.getSolrCore(), new MapSolrParams( args) );
+ SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
assertQ("Make sure they got in", req
Modified: lucene/solr/trunk/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java Sat Sep 8 12:03:54 2007
@@ -1,5 +1,6 @@
package org.apache.solr.handler;
+import org.apache.solr.util.AbstractSolrTestCase;
import java.io.StringReader;
import java.util.Collection;
@@ -12,14 +13,18 @@
import org.apache.solr.common.SolrInputDocument;
-public class XmlUpdateRequestHandlerTest extends TestCase
+public class XmlUpdateRequestHandlerTest extends AbstractSolrTestCase
{
private XMLInputFactory inputFactory = BaseXMLInputFactory.newInstance();
- protected XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler();
+ protected XmlUpdateRequestHandler handler;
+
+@Override public String getSchemaFile() { return "schema.xml"; }
+@Override public String getSolrConfigFile() { return "solrconfig.xml"; }
@Override
public void setUp() throws Exception {
super.setUp();
+ handler = new XmlUpdateRequestHandler();
}
@Override
Modified: lucene/solr/trunk/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/schema/BadIndexSchemaTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/schema/BadIndexSchemaTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/schema/BadIndexSchemaTest.java Sat Sep 8 12:03:54 2007
@@ -55,7 +55,7 @@
public void testSevereErrorsForDuplicateNames()
{
- SolrCore core = SolrCore.getSolrCore();
+ SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();
for( Throwable t : SolrConfig.severeErrors ) {
Modified: lucene/solr/trunk/src/test/org/apache/solr/schema/IndexSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/schema/IndexSchemaTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/schema/IndexSchemaTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/schema/IndexSchemaTest.java Sat Sep 8 12:03:54 2007
@@ -50,13 +50,14 @@
*/
public void testDynamicCopy()
{
+ SolrCore core = h.getCore();
assertU(adoc("id", "10", "title", "test", "aaa_dynamic", "aaa"));
assertU(commit());
Map<String,String> args = new HashMap<String, String>();
args.put( CommonParams.Q, "title:test" );
args.put( "indent", "true" );
- SolrQueryRequest req = new LocalSolrQueryRequest( SolrCore.getSolrCore(), new MapSolrParams( args) );
+ SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
assertQ("Make sure they got in", req
,"//*[@numFound='1']"
@@ -66,7 +67,7 @@
args = new HashMap<String, String>();
args.put( CommonParams.Q, "aaa_dynamic:aaa" );
args.put( "indent", "true" );
- req = new LocalSolrQueryRequest( SolrCore.getSolrCore(), new MapSolrParams( args) );
+ req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
assertQ("dynamic source", req
,"//*[@numFound='1']"
,"//result/doc[1]/int[@name='id'][.='10']"
@@ -75,7 +76,7 @@
args = new HashMap<String, String>();
args.put( CommonParams.Q, "dynamic_aaa:aaa" );
args.put( "indent", "true" );
- req = new LocalSolrQueryRequest( SolrCore.getSolrCore(), new MapSolrParams( args) );
+ req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
assertQ("dynamic destination", req
,"//*[@numFound='1']"
,"//result/doc[1]/int[@name='id'][.='10']"
Modified: lucene/solr/trunk/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java Sat Sep 8 12:03:54 2007
@@ -45,7 +45,7 @@
public void testSchemaLoading()
{
- SolrCore core = SolrCore.getSolrCore();
+ SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();
SchemaField uniqueKey = schema.getUniqueKeyField();
Modified: lucene/solr/trunk/src/test/org/apache/solr/schema/RequiredFieldsTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/schema/RequiredFieldsTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/schema/RequiredFieldsTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/schema/RequiredFieldsTest.java Sat Sep 8 12:03:54 2007
@@ -43,8 +43,7 @@
public void testRequiredFieldsConfig() {
-
- SolrCore core = SolrCore.getSolrCore();
+ SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();
SchemaField uniqueKey = schema.getUniqueKeyField();
@@ -59,6 +58,7 @@
}
public void testRequiredFieldsSingleAdd() {
+ SolrCore core = h.getCore();
// Add a single document
assertU("adding document",
adoc("id", "529", "name", "document with id, name, and subject", "field_t", "what's inside?", "subject", "info"));
@@ -74,12 +74,12 @@
assertU(commit());
// Add another document without a subject, which has a default in schema
- String subjectDefault = SolrCore.getSolrCore().getSchema().getField("subject").getDefaultValue();
+ String subjectDefault = core.getSchema().getField("subject").getDefaultValue();
assertNotNull("subject has no default value", subjectDefault);
assertQ("should find one with subject="+subjectDefault, req("id:530 subject:"+subjectDefault) ,"//result[@numFound=1]" );
// Add another document without a required name, which has no default
- assertNull(SolrCore.getSolrCore().getSchema().getField("name").getDefaultValue());
+ assertNull(core.getSchema().getField("name").getDefaultValue());
assertFailedU("adding doc without required field",
adoc("id", "531", "subject", "no name document", "field_t", "what's inside?") );
assertU(commit());
Modified: lucene/solr/trunk/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java Sat Sep 8 12:03:54 2007
@@ -33,7 +33,7 @@
public void setUp() throws Exception
{
super.setUp();
- direct = new DirectSolrConnection();
+ direct = new DirectSolrConnection(h.getCore());
}
// Check that a request gets back the echoParams call
Modified: lucene/solr/trunk/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/servlet/SolrRequestParserTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/servlet/SolrRequestParserTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/servlet/SolrRequestParserTest.java Sat Sep 8 12:03:54 2007
@@ -48,7 +48,7 @@
public void setUp() throws Exception {
super.setUp();
- parser = new SolrRequestParsers( SolrCore.getSolrCore(), SolrConfig.config );
+ parser = new SolrRequestParsers(h.getCore() );
}
public void testStreamBody() throws Exception
Modified: lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java Sat Sep 8 12:03:54 2007
@@ -54,8 +54,8 @@
}
public void testMaxDocs() throws Exception {
-
- DirectUpdateHandler2 updater = (DirectUpdateHandler2)SolrCore.getSolrCore().getUpdateHandler();
+ SolrCore core = h.getCore();
+ DirectUpdateHandler2 updater = (DirectUpdateHandler2)core.getUpdateHandler();
DirectUpdateHandler2.CommitTracker tracker = updater.tracker;
tracker.timeUpperBound = 100000;
tracker.docsUpperBound = 14;
@@ -63,7 +63,6 @@
XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler();
handler.init( null );
- SolrCore core = SolrCore.getSolrCore();
MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
// Add a single document
@@ -122,8 +121,8 @@
}
public void testMaxTime() throws Exception {
-
- DirectUpdateHandler2 updater = (DirectUpdateHandler2)SolrCore.getSolrCore().getUpdateHandler();
+ SolrCore core = h.getCore();
+ DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
DirectUpdateHandler2.CommitTracker tracker = updater.tracker;
tracker.timeUpperBound = 500;
tracker.docsUpperBound = -1;
@@ -131,7 +130,6 @@
XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler();
handler.init( null );
- SolrCore core = SolrCore.getSolrCore();
MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
// Add a single document
@@ -165,9 +163,9 @@
// now make the call 10 times really fast and make sure it
// only commits once
req.setContentStreams( toContentStreams(
- adoc("id", "500" ), null ) );
+ adoc("id", "500" ), null ) );
for( int i=0;i<10; i++ ) {
- handler.handleRequest( req, rsp );
+ handler.handleRequest( req, rsp );
}
assertQ("should not be there yet", req("id:500") ,"//result[@numFound=0]" );
assertEquals( 2, tracker.autoCommitCount );
Modified: lucene/solr/trunk/src/test/org/apache/solr/update/DocumentBuilderTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/update/DocumentBuilderTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/update/DocumentBuilderTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/update/DocumentBuilderTest.java Sat Sep 8 12:03:54 2007
@@ -35,7 +35,7 @@
public void testBuildDocument() throws Exception
{
- SolrCore core = SolrCore.getSolrCore();
+ SolrCore core = h.getCore();
// undefined field
try {
Modified: lucene/solr/trunk/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java Sat Sep 8 12:03:54 2007
@@ -32,7 +32,7 @@
public void testConfiguration() throws Exception
{
- SolrCore core = SolrCore.getSolrCore();
+ SolrCore core = h.getCore();
// make sure it loaded the factories
ChainedUpdateProcessorFactory chained =
Modified: lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml (original)
+++ lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml Sat Sep 8 12:03:54 2007
@@ -44,6 +44,7 @@
<writeLockTimeout>1000</writeLockTimeout>
<commitLockTimeout>10000</commitLockTimeout>
+ <lockType>single</lockType>
</indexDefaults>
<mainIndex>
Modified: lucene/solr/trunk/src/webapp/resources/admin/_info.jsp
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/resources/admin/_info.jsp?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/resources/admin/_info.jsp (original)
+++ lucene/solr/trunk/src/webapp/resources/admin/_info.jsp Sat Sep 8 12:03:54 2007
@@ -25,7 +25,9 @@
<%@ page import="org.apache.lucene.LucenePackage"%>
<%
- SolrCore core = SolrCore.getSolrCore();
+ Object ocore = request.getAttribute("org.apache.solr.SolrCore");
+ SolrCore core = ocore instanceof SolrCore? (SolrCore) ocore : SolrCore.getSolrCore();
+ SolrConfig solrConfig = core.getSolrConfig();
int port = request.getServerPort();
IndexSchema schema = core.getSchema();
@@ -33,7 +35,7 @@
// and has no effect on local server function. If there is no healthcheck
// configured, don't put any status on the admin pages.
String enabledStatus = null;
- String enabledFile = SolrConfig.config.get("admin/healthcheck/text()",null);
+ String enabledFile = solrConfig.get("admin/healthcheck/text()",null);
boolean isEnabled = false;
if (enabledFile!=null) {
isEnabled = new File(enabledFile).exists();
@@ -47,7 +49,7 @@
{
StringWriter tmp = new StringWriter();
XML.escapeCharData
- (SolrConfig.config.get("admin/defaultQuery/text()", null), tmp);
+ (solrConfig.get("admin/defaultQuery/text()", null), tmp);
defaultSearch = tmp.toString();
}
Modified: lucene/solr/trunk/src/webapp/resources/admin/get-file.jsp
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/resources/admin/get-file.jsp?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/resources/admin/get-file.jsp (original)
+++ lucene/solr/trunk/src/webapp/resources/admin/get-file.jsp Sat Sep 8 12:03:54 2007
@@ -16,15 +16,18 @@
limitations under the License.
--%>
<%@ page import="org.apache.solr.core.Config,
+ org.apache.solr.core.SolrCore,
org.apache.solr.core.SolrConfig,
java.io.InputStream,
java.io.InputStreamReader,
java.io.Reader,
java.util.StringTokenizer"%>
<%
+ Object ocore = request.getAttribute("org.apache.solr.SolrCore");
+ SolrCore core = ocore instanceof SolrCore? (SolrCore) ocore : SolrCore.getSolrCore();
String fname = request.getParameter("file");
String optional = request.getParameter("optional");
- String gettableFiles = SolrConfig.config.get("admin/gettableFiles","");
+ String gettableFiles = core.getSolrConfig().get("admin/gettableFiles","");
StringTokenizer st = new StringTokenizer(gettableFiles);
InputStream is;
boolean isValid = false;
@@ -40,7 +43,7 @@
}
if (isValid) {
try {
- is= Config.openResource(fname);
+ is= core.getSolrConfig().openResource(fname);
Reader input = new InputStreamReader(is);
char[] buf = new char[4096];
while (true) {
Modified: lucene/solr/trunk/src/webapp/resources/admin/index.jsp
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/resources/admin/index.jsp?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/resources/admin/index.jsp (original)
+++ lucene/solr/trunk/src/webapp/resources/admin/index.jsp Sat Sep 8 12:03:54 2007
@@ -34,8 +34,8 @@
<h3>Solr</h3>
</td>
<td>
- [<a href="get-file.jsp?file=schema.xml">Schema</a>]
- [<a href="get-file.jsp?file=solrconfig.xml">Config</a>]
+ [<a href="get-file.jsp?file=<%=core.getSchemaFile()%>">Schema</a>]
+ [<a href="get-file.jsp?file=<%=core.getConfigFile()%>">Config</a>]
[<a href="analysis.jsp?highlight=on">Analysis</a>]
<br>
[<a href="stats.jsp">Statistics</a>]
Modified: lucene/solr/trunk/src/webapp/resources/admin/ping.jsp
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/resources/admin/ping.jsp?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/resources/admin/ping.jsp (original)
+++ lucene/solr/trunk/src/webapp/resources/admin/ping.jsp Sat Sep 8 12:03:54 2007
@@ -17,7 +17,7 @@
--%>
<%@ page import="org.apache.solr.core.SolrConfig,
org.apache.solr.core.SolrCore,
- org.apache.solr.util.XML,
+ org.apache.solr.common.util.XML,
org.apache.solr.core.SolrException"%>
<%@ page import="org.apache.solr.request.LocalSolrQueryRequest"%>
<%@ page import="org.apache.solr.request.SolrQueryResponse"%>
@@ -29,12 +29,13 @@
<solr>
<ping>
<%
- SolrCore core = SolrCore.getSolrCore();
+ Object ocore = request.getAttribute("org.apache.solr.SolrCore");
+ SolrCore core = ocore instanceof SolrCore? (SolrCore) ocore : SolrCore.getSolrCore();
SolrQueryRequest req = null;
if (null == request.getQueryString()) {
- req = SolrConfig.getPingQueryRequest(core);
+ req = core.getPingQueryRequest();
} else {
req = new LocalSolrQueryRequest(core, new ServletSolrParams(request));
}
Modified: lucene/solr/trunk/src/webapp/resources/admin/raw-schema.jsp
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/resources/admin/raw-schema.jsp?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/resources/admin/raw-schema.jsp (original)
+++ lucene/solr/trunk/src/webapp/resources/admin/raw-schema.jsp Sat Sep 8 12:03:54 2007
@@ -21,7 +21,8 @@
<%@ page import="java.io.Reader"%>
<%@ page contentType="text/plain;charset=UTF-8" language="java" %>
<%
- SolrCore core = SolrCore.getSolrCore();
+ Object ocore = request.getAttribute("org.apache.solr.SolrCore");
+ SolrCore core = ocore instanceof SolrCore? (SolrCore) ocore : SolrCore.getSolrCore();
IndexSchema schema = core.getSchema();
Reader input = new InputStreamReader(schema.getInputStream());
char[] buf = new char[4096];
Modified: lucene/solr/trunk/src/webapp/resources/admin/stats.jsp
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/resources/admin/stats.jsp?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/resources/admin/stats.jsp (original)
+++ lucene/solr/trunk/src/webapp/resources/admin/stats.jsp Sat Sep 8 12:03:54 2007
@@ -35,7 +35,7 @@
%>
<<%= cat.toString() %>>
<%
- Map<String,SolrInfoMBean> reg = SolrInfoRegistry.getRegistry();
+ Map<String,SolrInfoMBean> reg = core.getInfoRegistry();
synchronized(reg) {
for (Map.Entry<String,SolrInfoMBean> entry : reg.entrySet()) {
String key = entry.getKey();
Modified: lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java (original)
+++ lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java Sat Sep 8 12:03:54 2007
@@ -59,7 +59,7 @@
public DirectSolrConnection()
{
core = SolrCore.getSolrCore();
- parser = new SolrRequestParsers( core, SolrConfig.config );
+ parser = new SolrRequestParsers( core );
}
/**
@@ -68,7 +68,7 @@
public DirectSolrConnection( SolrCore c )
{
core = c;
- parser = new SolrRequestParsers( core, SolrConfig.config );
+ parser = new SolrRequestParsers( core );
}
/**
@@ -110,15 +110,17 @@
}
Config.setInstanceDir( instanceDir );
}
+ SolrConfig config = SolrConfig.createInstance("solrconfig.xml");
- // If the Data directory is specified, initalize SolrCore directly
+ // If the Data directory is specified, initialize SolrCore directly
if( dataDir != null ) {
- core = new SolrCore( dataDir, new IndexSchema(instanceDir+"/conf/schema.xml"));
+ IndexSchema schema = new IndexSchema(config, instanceDir+"/conf/schema.xml");
+ core = new SolrCore( dataDir, config, schema );
}
else {
core = SolrCore.getSolrCore();
}
- parser = new SolrRequestParsers( core, SolrConfig.config );
+ parser = new SolrRequestParsers( core );
}
Modified: lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java?rev=573893&r1=573892&r2=573893&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java (original)
+++ lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java Sat Sep 8 12:03:54 2007
@@ -68,7 +68,7 @@
log.info("user.dir=" + System.getProperty("user.dir"));
core = SolrCore.getSolrCore();
- parsers = new SolrRequestParsers( core, SolrConfig.config );
+ parsers = new SolrRequestParsers( core );
}
catch( Throwable t ) {
// catch this so our filter still works