SOLR-12365: Renamed class Config to XmlConfigFile

This commit is contained in:
David Smiley 2019-01-05 10:08:36 -05:00
parent ca23040baa
commit ff19a3a261
9 changed files with 50 additions and 52 deletions

View File

@ -17,17 +17,8 @@
package org.apache.solr.core;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.params.CommonParams.PATH;
import static org.apache.solr.common.util.Utils.makeMap;
import static org.apache.solr.core.ConfigOverlay.ZNODEVER;
import static org.apache.solr.core.SolrConfig.PluginOpts.LAZY;
import static org.apache.solr.core.SolrConfig.PluginOpts.MULTI_OK;
import static org.apache.solr.core.SolrConfig.PluginOpts.NOOP;
import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_CLASS;
import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME;
import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME_IN_OVERLAY;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathConstants;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -51,9 +42,7 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathConstants;
import com.google.common.collect.ImmutableList;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.index.IndexDeletionPolicy;
import org.apache.lucene.search.BooleanQuery;
@ -93,7 +82,16 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.google.common.collect.ImmutableList;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.params.CommonParams.PATH;
import static org.apache.solr.common.util.Utils.makeMap;
import static org.apache.solr.core.ConfigOverlay.ZNODEVER;
import static org.apache.solr.core.SolrConfig.PluginOpts.LAZY;
import static org.apache.solr.core.SolrConfig.PluginOpts.MULTI_OK;
import static org.apache.solr.core.SolrConfig.PluginOpts.NOOP;
import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_CLASS;
import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME;
import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME_IN_OVERLAY;
/**
@ -101,7 +99,7 @@ import com.google.common.collect.ImmutableList;
* configuration data for a a Solr instance -- typically found in
* "solrconfig.xml".
*/
public class SolrConfig extends Config implements MapSerializable {
public class SolrConfig extends XmlConfigFile implements MapSerializable {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

View File

@ -64,7 +64,7 @@ public class SolrXmlConfig {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static NodeConfig fromConfig(Config config) {
public static NodeConfig fromConfig(XmlConfigFile config) {
checkForIllegalConfig(config);
@ -136,7 +136,7 @@ public class SolrXmlConfig {
try {
byte[] buf = IOUtils.toByteArray(is);
try (ByteArrayInputStream dup = new ByteArrayInputStream(buf)) {
Config config = new Config(loader, null, new InputSource(dup), null, false);
XmlConfigFile config = new XmlConfigFile(loader, null, new InputSource(dup), null, false);
return fromConfig(config);
}
} catch (SolrException exc) {
@ -155,7 +155,7 @@ public class SolrXmlConfig {
return fromSolrHome(loader, solrHome);
}
private static void checkForIllegalConfig(Config config) {
private static void checkForIllegalConfig(XmlConfigFile config) {
failIfFound(config, "solr/@coreLoadThreads");
failIfFound(config, "solr/@persistent");
failIfFound(config, "solr/@sharedLib");
@ -168,12 +168,12 @@ public class SolrXmlConfig {
assertSingleInstance("backup", config);
}
private static void assertSingleInstance(String section, Config config) {
private static void assertSingleInstance(String section, XmlConfigFile config) {
if (config.getNodeList("/solr/" + section, false).getLength() > 1)
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Multiple instances of " + section + " section found in solr.xml");
}
private static void failIfFound(Config config, String xPath) {
private static void failIfFound(XmlConfigFile config, String xPath) {
if (config.getVal(xPath, false) != null) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Should not have found " + xPath +
@ -181,7 +181,7 @@ public class SolrXmlConfig {
}
}
private static Properties loadProperties(Config config) {
private static Properties loadProperties(XmlConfigFile config) {
try {
Node node = ((NodeList) config.evaluate("solr", XPathConstants.NODESET)).item(0);
XPath xpath = config.getXPath();
@ -200,7 +200,7 @@ public class SolrXmlConfig {
}
}
private static NamedList<Object> readNodeListAsNamedList(Config config, String path, String section) {
private static NamedList<Object> readNodeListAsNamedList(XmlConfigFile config, String path, String section) {
NodeList nodes = config.getNodeList(path, false);
if (nodes == null) {
return null;
@ -416,7 +416,7 @@ public class SolrXmlConfig {
return builder.build();
}
private static LogWatcherConfig loadLogWatcherConfig(Config config, String loggingPath, String watcherPath) {
private static LogWatcherConfig loadLogWatcherConfig(XmlConfigFile config, String loggingPath, String watcherPath) {
String loggingClass = null;
boolean enabled = true;
@ -453,12 +453,12 @@ public class SolrXmlConfig {
}
private static PluginInfo getShardHandlerFactoryPluginInfo(Config config) {
private static PluginInfo getShardHandlerFactoryPluginInfo(XmlConfigFile config) {
Node node = config.getNode("solr/shardHandlerFactory", false);
return (node == null) ? null : new PluginInfo(node, "shardHandlerFactory", false, true);
}
private static PluginInfo[] getBackupRepositoryPluginInfos(Config config) {
private static PluginInfo[] getBackupRepositoryPluginInfos(XmlConfigFile config) {
NodeList nodes = (NodeList) config.evaluate("solr/backup/repository", XPathConstants.NODESET);
if (nodes == null || nodes.getLength() == 0)
return new PluginInfo[0];
@ -469,7 +469,7 @@ public class SolrXmlConfig {
return configs;
}
private static MetricsConfig getMetricsConfig(Config config) {
private static MetricsConfig getMetricsConfig(XmlConfigFile config) {
MetricsConfig.MetricsConfigBuilder builder = new MetricsConfig.MetricsConfigBuilder();
Node node = config.getNode("solr/metrics/suppliers/counter", false);
if (node != null) {
@ -499,7 +499,7 @@ public class SolrXmlConfig {
.build();
}
private static PluginInfo[] getMetricReporterPluginInfos(Config config) {
private static PluginInfo[] getMetricReporterPluginInfos(XmlConfigFile config) {
NodeList nodes = (NodeList) config.evaluate("solr/metrics/reporter", XPathConstants.NODESET);
List<PluginInfo> configs = new ArrayList<>();
boolean hasJmxReporter = false;
@ -527,7 +527,7 @@ public class SolrXmlConfig {
return configs.toArray(new PluginInfo[configs.size()]);
}
private static Set<String> getHiddenSysProps(Config config) {
private static Set<String> getHiddenSysProps(XmlConfigFile config) {
NodeList nodes = (NodeList) config.evaluate("solr/metrics/hiddenSysProps/str", XPathConstants.NODESET);
if (nodes == null || nodes.getLength() == 0) {
return NodeConfig.NodeConfigBuilder.DEFAULT_HIDDEN_SYS_PROPS;
@ -546,7 +546,7 @@ public class SolrXmlConfig {
}
}
private static PluginInfo getTransientCoreCacheFactoryPluginInfo(Config config) {
private static PluginInfo getTransientCoreCacheFactoryPluginInfo(XmlConfigFile config) {
Node node = config.getNode("solr/transientCoreCacheFactory", false);
return (node == null) ? null : new PluginInfo(node, "transientCoreCacheFactory", false, true);
}

View File

@ -64,7 +64,7 @@ import org.xml.sax.SAXException;
/**
* Wrapper around an XML DOM object to provide convenient accessors to it. Intended for XML config files.
*/
public class Config { // formerly simply "Config"
public class XmlConfigFile { // formerly simply "Config"
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final XMLErrorLogger xmllog = new XMLErrorLogger(log);
@ -80,12 +80,12 @@ public class Config { // formerly simply "Config"
/**
* Builds a config from a resource name with no xpath prefix.
*/
public Config(SolrResourceLoader loader, String name) throws ParserConfigurationException, IOException, SAXException
public XmlConfigFile(SolrResourceLoader loader, String name) throws ParserConfigurationException, IOException, SAXException
{
this( loader, name, null, null );
}
public Config(SolrResourceLoader loader, String name, InputSource is, String prefix) throws ParserConfigurationException, IOException, SAXException
public XmlConfigFile(SolrResourceLoader loader, String name, InputSource is, String prefix) throws ParserConfigurationException, IOException, SAXException
{
this(loader, name, is, prefix, true);
}
@ -105,7 +105,7 @@ public class Config { // formerly simply "Config"
* @param is the resource as a SAX InputSource
* @param prefix an optional prefix that will be prepended to all non-absolute xpath expressions
*/
public Config(SolrResourceLoader loader, String name, InputSource is, String prefix, boolean substituteProps) throws ParserConfigurationException, IOException, SAXException
public XmlConfigFile(SolrResourceLoader loader, String name, InputSource is, String prefix, boolean substituteProps) throws ParserConfigurationException, IOException, SAXException
{
if( loader == null ) {
loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
@ -174,7 +174,7 @@ public class Config { // formerly simply "Config"
return loader.getCoreProperties();
}
public Config(SolrResourceLoader loader, String name, Document doc) {
public XmlConfigFile(SolrResourceLoader loader, String name, Document doc) {
this.prefix = null;
this.doc = doc;
try {
@ -489,8 +489,8 @@ public class Config { // formerly simply "Config"
return zkVersion;
}
public Config getOriginalConfig() {
return new Config(loader, null, origDoc);
public XmlConfigFile getOriginalConfig() {
return new XmlConfigFile(loader, null, origDoc);
}
}

View File

@ -110,7 +110,7 @@ import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.core.Config.assertWarnOrFail;
import static org.apache.solr.core.XmlConfigFile.assertWarnOrFail;
/**
* <p> A Handler which provides a REST API for replication and serves replication requests from Slaves. </p>

View File

@ -70,7 +70,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.Config;
import org.apache.solr.core.XmlConfigFile;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.transform.ElevatedMarkerFactory;
@ -240,7 +240,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
} else {
configFileExists = true;
log.info("Loading QueryElevation from: " + fC.getAbsolutePath());
Config cfg = new Config(core.getResourceLoader(), configFileName);
XmlConfigFile cfg = new XmlConfigFile(core.getResourceLoader(), configFileName);
elevationProvider = loadElevationProvider(cfg);
}
elevationProviderCache.put(null, elevationProvider);
@ -360,13 +360,13 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
}
log.info("Loading QueryElevation from data dir: " + configFileName);
Config cfg;
XmlConfigFile cfg;
ZkController zkController = core.getCoreContainer().getZkController();
if (zkController != null) {
cfg = new Config(core.getResourceLoader(), configFileName, null, null);
cfg = new XmlConfigFile(core.getResourceLoader(), configFileName, null, null);
} else {
InputStream is = VersionedFile.getLatestFile(core.getDataDir(), configFileName);
cfg = new Config(core.getResourceLoader(), configFileName, new InputSource(is), null);
cfg = new XmlConfigFile(core.getResourceLoader(), configFileName, new InputSource(is), null);
}
ElevationProvider elevationProvider = loadElevationProvider(cfg);
assert elevationProvider != null;
@ -381,7 +381,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
* (either {@link RuntimeException} or {@link org.apache.solr.common.SolrException}).
*/
@SuppressWarnings("WeakerAccess")
protected ElevationProvider loadElevationProvider(Config config) throws IOException {
protected ElevationProvider loadElevationProvider(XmlConfigFile config) throws IOException {
Map<ElevatingQuery, ElevationBuilder> elevationBuilderMap = new LinkedHashMap<>();
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList nodes = (NodeList) config.evaluate("elevate/query", XPathConstants.NODESET);

View File

@ -33,7 +33,7 @@ import org.apache.lucene.analysis.util.TokenizerFactory;
import org.apache.lucene.util.Version;
import org.apache.solr.analysis.TokenizerChain;
import org.apache.solr.common.SolrException;
import org.apache.solr.core.Config;
import org.apache.solr.core.XmlConfigFile;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.util.DOMUtil;
import org.apache.solr.util.plugin.AbstractPluginLoader;
@ -231,7 +231,7 @@ public final class FieldTypePluginLoader
final String matchVersionStr = DOMUtil.getAttr(attrs, LUCENE_MATCH_VERSION_PARAM);
final Version luceneMatchVersion = (matchVersionStr == null) ?
schema.getDefaultLuceneMatchVersion() :
Config.parseLuceneVersionString(matchVersionStr);
XmlConfigFile.parseLuceneVersionString(matchVersionStr);
if (luceneMatchVersion == null) {
throw new SolrException
( SolrException.ErrorCode.SERVER_ERROR,
@ -362,7 +362,7 @@ public final class FieldTypePluginLoader
private Version parseConfiguredVersion(String configuredVersion, String pluginClassName) {
Version version = (configuredVersion != null) ?
Config.parseLuceneVersionString(configuredVersion) : schema.getDefaultLuceneMatchVersion();
XmlConfigFile.parseLuceneVersionString(configuredVersion) : schema.getDefaultLuceneMatchVersion();
if (!version.onOrAfter(Version.LUCENE_7_0_0)) {
log.warn(pluginClassName + " is using deprecated " + version +

View File

@ -59,7 +59,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.Pair;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.Config;
import org.apache.solr.core.XmlConfigFile;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.request.LocalSolrQueryRequest;
@ -446,7 +446,7 @@ public class IndexSchema {
try {
// pass the config resource loader to avoid building an empty one for no reason:
// in the current case though, the stream is valid so we wont load the resource by name
Config schemaConf = new Config(loader, SCHEMA, is, SLASH+SCHEMA+SLASH);
XmlConfigFile schemaConf = new XmlConfigFile(loader, SCHEMA, is, SLASH+SCHEMA+SLASH);
Document document = schemaConf.getDocument();
final XPath xpath = schemaConf.getXPath();
String expression = stepsToPath(SCHEMA, AT + NAME);

View File

@ -48,7 +48,7 @@ import org.apache.solr.util.SolrPluginUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.solr.core.Config.assertWarnOrFail;
import static org.apache.solr.core.XmlConfigFile.assertWarnOrFail;
/**
* This config object encapsulates IndexWriter config params,

View File

@ -17,7 +17,7 @@
package org.apache.solr.analysis;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.Config;
import org.apache.solr.core.XmlConfigFile;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.FieldType;
import org.apache.lucene.analysis.Analyzer;
@ -37,7 +37,7 @@ public class TestLuceneMatchVersion extends SolrTestCaseJ4 {
// this must match the solrconfig.xml version for this test
public static final Version DEFAULT_VERSION =
Config.parseLuceneVersionString(System.getProperty("tests.luceneMatchVersion", "LATEST"));
XmlConfigFile.parseLuceneVersionString(System.getProperty("tests.luceneMatchVersion", "LATEST"));
public void testStandardTokenizerVersions() throws Exception {
assertEquals(DEFAULT_VERSION, solrConfig.luceneMatchVersion);