SOLR-1722: Allowing changing the "special" default core name, and as a default default core name, switch to using collection1 rather than DEFAULT_CORE

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@908197 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2010-02-09 20:14:31 +00:00
parent 3eb663ea10
commit 9bb44206b6
3 changed files with 13 additions and 8 deletions

View File

@ -70,7 +70,7 @@ New Features
* SOLR-1177: Distributed Search support for TermsComponent (Matt Weber via shalin)
* SOLR-1621: Allow current single core deployments to be specified by solr.xml (Mark Miller , noble)
* SOLR-1621, SOLR-1722: Allow current single core deployments to be specified by solr.xml (Mark Miller , noble)
* SOLR-1532: Allow StreamingUpdateSolrServer to use a provided HttpClient (Gabriele Renzi via shalin)

View File

@ -28,7 +28,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via request handler
-->
<cores adminPath="/admin/cores">
<core name="DEFAULT_CORE" instanceDir="." />
<cores adminPath="/admin/cores" defaultCoreName="collection1">
<core name="collection1" instanceDir="." />
</cores>
</solr>

View File

@ -50,7 +50,7 @@ import org.xml.sax.SAXException;
*/
public class CoreContainer
{
private static final String DEFAULT_CORE_NAME = "DEFAULT_CORE";
private static final String DEFAULT_DEFAULT_CORE_NAME = "collection1";
protected static Logger log = LoggerFactory.getLogger(CoreContainer.class);
@ -70,6 +70,8 @@ public class CoreContainer
protected String solrHome;
protected String solrConfigFilenameOverride;
private String defaultCoreName = DEFAULT_DEFAULT_CORE_NAME;
public CoreContainer() {
solrHome = SolrResourceLoader.locateSolrHome();
}
@ -210,7 +212,10 @@ public class CoreContainer
solrHome = loader.getInstanceDir();
try {
Config cfg = new Config(loader, null, cfgis, null);
String dcoreName = cfg.get("solr/@defaultCoreName", null);
if(dcoreName != null) {
defaultCoreName = dcoreName;
}
persistent = cfg.getBool( "solr/@persistent", false );
libDir = cfg.get( "solr/@sharedLib", null);
adminPath = cfg.get( "solr/cores/@adminPath", null );
@ -248,7 +253,7 @@ public class CoreContainer
Node node = nodes.item(i);
try {
String name = DOMUtil.getAttr(node, "name", null);
if(name.equals(DEFAULT_CORE_NAME)){
if(name.equals(defaultCoreName)){
if(defaultCoreFound) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Only one 'DEFAULT_CORE' is allowed ");
defaultCoreFound = true;
name="";
@ -488,7 +493,7 @@ public class CoreContainer
}
private String checkDefault(String name) {
return name.length() == 0 || DEFAULT_CORE_NAME.equals(name) || name.trim().length() == 0 ? "" : name;
return name.length() == 0 || defaultCoreName.equals(name) || name.trim().length() == 0 ? "" : name;
}
/**
@ -769,7 +774,7 @@ public class CoreContainer
private static final String DEF_SOLR_XML ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
"<solr persistent=\"false\">\n" +
" <cores adminPath=\"/admin/cores\">\n" +
" <core name=\""+ DEFAULT_CORE_NAME + "\" instanceDir=\".\" />\n" +
" <core name=\""+ DEFAULT_DEFAULT_CORE_NAME + "\" instanceDir=\".\" />\n" +
" </cores>\n" +
"</solr>";
}