SOLR-3745: Proper error reporting if SolrCloud mode is used w/o necessary "_version_" field in schema.xml

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1377898 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2012-08-27 23:01:11 +00:00
parent 2afa06672f
commit a8b57fa9de
2 changed files with 23 additions and 0 deletions

View File

@ -85,6 +85,9 @@ Bug Fixes
* SOLR-3746: Proper error reporting if updateLog is configured w/o necessary
"_version_" field in schema.xml (hossman)
* SOLR-3745: Proper error reporting if SolrCloud mode is used w/o
necessary "_version_" field in schema.xml (hossman)
Other Changes
----------------------

View File

@ -65,6 +65,7 @@ import org.apache.solr.search.ValueSourceParser;
import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.update.SolrIndexWriter;
import org.apache.solr.update.UpdateHandler;
import org.apache.solr.update.VersionInfo;
import org.apache.solr.update.processor.DistributedUpdateProcessorFactory;
import org.apache.solr.update.processor.LogUpdateProcessorFactory;
import org.apache.solr.update.processor.RunUpdateProcessorFactory;
@ -593,6 +594,25 @@ public final class SolrCore implements SolrInfoMBean {
schema = new IndexSchema(config, IndexSchema.DEFAULT_SCHEMA_FILE, null);
}
if (null != cd && null != cd.getCloudDescriptor()) {
// we are evidently running in cloud mode.
//
// In cloud mode, version field is required for correct consistency
// ideally this check would be more fine grained, and individual features
// would assert it when they initialize, but DistribuedUpdateProcessor
// is currently a big ball of wax that does more then just distributing
// updates (ie: partial document updates), so it needs to work in no cloud
// mode as well, and can't assert version field support on init.
try {
Object ignored = VersionInfo.getAndCheckVersionField(schema);
} catch (SolrException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Schema will not work with SolrCloud mode: " +
e.getMessage(), e);
}
}
//Initialize JMX
if (config.jmxConfig.enabled) {
infoRegistry = new JmxMonitoredMap<String, SolrInfoMBean>(name, String.valueOf(this.hashCode()), config.jmxConfig);