git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@778652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2009-05-26 11:17:40 +00:00
parent 03a7c58b3e
commit d79ea7ce69
1 changed files with 24 additions and 1 deletions

View File

@ -26,6 +26,9 @@ import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.text.SimpleDateFormat;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -66,6 +69,7 @@ public class CoreContainer
protected SolrResourceLoader loader = null; protected SolrResourceLoader loader = null;
protected java.lang.ref.WeakReference<SolrCore> adminCore = null; protected java.lang.ref.WeakReference<SolrCore> adminCore = null;
protected Properties containerProperties; protected Properties containerProperties;
protected Map<String ,IndexSchema> indexSchemaCache;
public CoreContainer() { public CoreContainer() {
} }
@ -173,6 +177,10 @@ public class CoreContainer
persistent = cfg.getBool( "solr/@persistent", false ); persistent = cfg.getBool( "solr/@persistent", false );
libDir = cfg.get( "solr/@sharedLib", null); libDir = cfg.get( "solr/@sharedLib", null);
adminPath = cfg.get( "solr/cores/@adminPath", null ); adminPath = cfg.get( "solr/cores/@adminPath", null );
String shareSchema = cfg.get( "solr/cores/@shareSchema", null );
if(Boolean.parseBoolean(shareSchema)){
indexSchemaCache = new ConcurrentHashMap<String ,IndexSchema>();
}
String adminHandler = cfg.get( "solr/cores/@adminHandler", null ); String adminHandler = cfg.get( "solr/cores/@adminHandler", null );
managementPath = cfg.get("solr/cores/@managementPath", null ); managementPath = cfg.get("solr/cores/@managementPath", null );
@ -345,7 +353,22 @@ public class CoreContainer
// Initialize the solr config // Initialize the solr config
SolrResourceLoader solrLoader = new SolrResourceLoader(instanceDir, libLoader, dcore.getCoreProperties()); SolrResourceLoader solrLoader = new SolrResourceLoader(instanceDir, libLoader, dcore.getCoreProperties());
SolrConfig config = new SolrConfig(solrLoader, dcore.getConfigName(), null); SolrConfig config = new SolrConfig(solrLoader, dcore.getConfigName(), null);
IndexSchema schema = new IndexSchema(config, dcore.getSchemaName(), null); IndexSchema schema = null;
if(indexSchemaCache != null){
//schema sharing is enabled. so check if it already is loaded
File schemFile = new File(dcore.getInstanceDir() + dcore.getSchemaName());
if(schemFile. exists()){
String key = schemFile.getAbsolutePath()+":"+new SimpleDateFormat("yyyyMMddhhmmss").format(new Date(schemFile.lastModified()));
schema = indexSchemaCache.get(key);
if(schema == null){
schema = new IndexSchema(config, dcore.getSchemaName(), null);
indexSchemaCache.put(key,schema);
}
}
}
if(schema == null){
schema = new IndexSchema(config, dcore.getSchemaName(), null);
}
SolrCore core = new SolrCore(dcore.getName(), null, config, schema, dcore); SolrCore core = new SolrCore(dcore.getName(), null, config, schema, dcore);
return core; return core;
} }