SOLR-721 -- DirectSolrConnection now uses CoreContainers

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@702993 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2008-10-08 21:23:21 +00:00
parent 28ef53258d
commit 130a2022b1
1 changed files with 15 additions and 9 deletions

View File

@ -29,8 +29,11 @@ import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.request.QueryResponseWriter;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse;
@ -101,16 +104,19 @@ public class DirectSolrConnection
}
}
// Initialize SolrConfig
SolrConfig config = null;
try {
config = new SolrConfig(instanceDir, SolrConfig.DEFAULT_CONF_FILE, null);
instanceDir = config.getResourceLoader().getInstanceDir();
if( instanceDir == null ) {
instanceDir = SolrResourceLoader.locateInstanceDir();
}
// If the Data directory is specified, initialize SolrCore directly
IndexSchema schema = new IndexSchema(config, instanceDir+"/conf/schema.xml", null);
core = new SolrCore( null, dataDir, config, schema, null );
parser = new SolrRequestParsers( config );
// Initialize
try {
CoreContainer cores = new CoreContainer(new SolrResourceLoader(instanceDir));
SolrConfig solrConfig = new SolrConfig(instanceDir, SolrConfig.DEFAULT_CONF_FILE, null);
CoreDescriptor dcore = new CoreDescriptor(cores, "", solrConfig.getResourceLoader().getInstanceDir());
IndexSchema indexSchema = new IndexSchema(solrConfig, instanceDir+"/conf/schema.xml", null);
core = new SolrCore( null, dataDir, solrConfig, indexSchema, dcore);
cores.register("", core, false);
parser = new SolrRequestParsers( solrConfig );
}
catch (Exception ee) {
throw new RuntimeException(ee);