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

View File

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