SOLR-3629: Typo in solr.xml persistence when overriding the solrconfig.xml file name using the "config" attribute prevented the override file from being used

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1363161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2012-07-18 22:41:58 +00:00
parent 5a2d0bc654
commit b20252f777
2 changed files with 36 additions and 19 deletions

View File

@ -108,6 +108,11 @@ Bug Fixes
* SOLR-3639: Update ZooKeeper to 3.3.5 for a variety of bug fixes. (Mark Miller)
* SOLR-3629: Typo in solr.xml persistence when overriding the solrconfig.xml
file name using the "config" attribute prevented the override file from being
used. (Ryan Zezeski, hossman)
Other Changes
----------------------

View File

@ -96,6 +96,18 @@ public class CoreContainer
protected static Logger log = LoggerFactory.getLogger(CoreContainer.class);
// solr.xml node constants
private static final String CORE_NAME = "name";
private static final String CORE_CONFIG = "config";
private static final String CORE_INSTDIR = "instanceDir";
private static final String CORE_DATADIR = "dataDir";
private static final String CORE_SCHEMA = "schema";
private static final String CORE_SHARD = "shard";
private static final String CORE_COLLECTION = "collection";
private static final String CORE_ROLES = "roles";
private static final String CORE_PROPERTIES = "properties";
protected final Map<String, SolrCore> cores = new LinkedHashMap<String, SolrCore>();
protected boolean persistent = false;
protected String adminPath = null;
@ -477,43 +489,43 @@ public class CoreContainer
for (int i=0; i<nodes.getLength(); i++) {
Node node = nodes.item(i);
try {
String rawName = DOMUtil.getAttr(node, "name", null);
String rawName = DOMUtil.getAttr(node, CORE_NAME, null);
if (null == rawName) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Each core in solr.xml must have a 'name'");
}
String name = rawName;
CoreDescriptor p = new CoreDescriptor(this, name, DOMUtil.getAttr(node, "instanceDir", null));
CoreDescriptor p = new CoreDescriptor(this, name, DOMUtil.getAttr(node, CORE_INSTDIR, null));
// deal with optional settings
String opt = DOMUtil.getAttr(node, "config", null);
String opt = DOMUtil.getAttr(node, CORE_CONFIG, null);
if (opt != null) {
p.setConfigName(opt);
}
opt = DOMUtil.getAttr(node, "schema", null);
opt = DOMUtil.getAttr(node, CORE_SCHEMA, null);
if (opt != null) {
p.setSchemaName(opt);
}
if (zkController != null) {
opt = DOMUtil.getAttr(node, "shard", null);
opt = DOMUtil.getAttr(node, CORE_SHARD, null);
if (opt != null && opt.length() > 0) {
p.getCloudDescriptor().setShardId(opt);
}
opt = DOMUtil.getAttr(node, "collection", null);
opt = DOMUtil.getAttr(node, CORE_COLLECTION, null);
if (opt != null) {
p.getCloudDescriptor().setCollectionName(opt);
}
opt = DOMUtil.getAttr(node, "roles", null);
opt = DOMUtil.getAttr(node, CORE_ROLES, null);
if(opt != null){
p.getCloudDescriptor().setRoles(opt);
}
}
opt = DOMUtil.getAttr(node, "properties", null);
opt = DOMUtil.getAttr(node, CORE_PROPERTIES, null);
if (opt != null) {
p.setPropertiesName(opt);
}
opt = DOMUtil.getAttr(node, CoreAdminParams.DATA_DIR, null);
opt = DOMUtil.getAttr(node, CORE_DATADIR, null);
if (opt != null) {
p.setDataDir(opt);
}
@ -1154,7 +1166,7 @@ public class CoreContainer
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
String name = DOMUtil.getAttr(node, "name", null);
String name = DOMUtil.getAttr(node, CORE_NAME, null);
if (origCoreName.equals(name)) {
coreNode = node;
if (coreName.equals(origCoreName)) {
@ -1168,7 +1180,7 @@ public class CoreContainer
// see if we match with substitution
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
String name = DOMUtil.getAttr(node, "name", null);
String name = DOMUtil.getAttr(node, CORE_NAME, null);
if (origCoreName.equals(DOMUtil.substituteProperty(name,
loader.getCoreProperties()))) {
coreNode = node;
@ -1181,28 +1193,28 @@ public class CoreContainer
}
}
coreAttribs.put("name", coreName);
coreAttribs.put(CORE_NAME, coreName);
String instanceDir = dcore.getInstanceDir();
addCoreProperty(coreAttribs, coreNode, "instanceDir", instanceDir, null);
addCoreProperty(coreAttribs, coreNode, CORE_INSTDIR, instanceDir, null);
// write config
String configName = dcore.getConfigName();
addCoreProperty(coreAttribs, coreNode, "conf", configName, dcore.getDefaultConfigName());
addCoreProperty(coreAttribs, coreNode, CORE_CONFIG, configName, dcore.getDefaultConfigName());
// write schema
String schema = dcore.getSchemaName();
addCoreProperty(coreAttribs, coreNode, "schema", schema, dcore.getDefaultSchemaName());
addCoreProperty(coreAttribs, coreNode, CORE_SCHEMA, schema, dcore.getDefaultSchemaName());
String dataDir = dcore.dataDir;
addCoreProperty(coreAttribs, coreNode, "dataDir", dataDir, null);
addCoreProperty(coreAttribs, coreNode, CORE_DATADIR, dataDir, null);
CloudDescriptor cd = dcore.getCloudDescriptor();
String shard = null;
if (cd != null) {
shard = cd.getShardId();
}
addCoreProperty(coreAttribs, coreNode, "shard", shard, null);
addCoreProperty(coreAttribs, coreNode, CORE_SHARD, shard, null);
String collection = null;
// only write out the collection name if it's not the default (the
@ -1212,12 +1224,12 @@ public class CoreContainer
collection = cd.getCollectionName();
}
addCoreProperty(coreAttribs, coreNode, "collection", collection, dcore.name);
addCoreProperty(coreAttribs, coreNode, CORE_COLLECTION, collection, dcore.name);
// we don't try and preserve sys prop defs in these
String opt = dcore.getPropertiesName();
if (opt != null) {
coreAttribs.put("properties", opt);
coreAttribs.put(CORE_PROPERTIES, opt);
}
SolrCoreXMLDef solrCoreXMLDef = new SolrCoreXMLDef();