You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/08/31 15:40:44 UTC
[lucene-solr] 01/03: @647 Bring a few things back.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit f50dd42959d4cc788e8be9a98d7ac73e41938618
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Mon Aug 31 10:14:44 2020 -0500
@647 Bring a few things back.
---
.../java/org/apache/solr/core/SolrXmlConfig.java | 79 +++++++++++++++-------
.../java/org/apache/solr/core/XmlConfigFile.java | 3 +-
.../test/org/apache/solr/core/TestBadConfig.java | 3 +-
.../java/org/apache/solr/cloud/ZkTestServer.java | 4 +-
.../solr/core/AbstractBadConfigTestBase.java | 5 +-
5 files changed, 61 insertions(+), 33 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
index 3ba5912..fff409e 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
@@ -77,32 +77,36 @@ public class SolrXmlConfig {
private static XPathExpression transientCoreCacheFactoryExp;
private static XPathExpression tracerConfigExp;
+ private static XPathExpression coreLoadThreadsExp;
+ private static XPathExpression persistentExp;
+ private static XPathExpression sharedLibExp;
+ private static XPathExpression zkHostExp;
+ private static XPathExpression coresExp;
- static String shardHandlerFactoryPath = "solr/shardHandlerFactory";
+ static String shardHandlerFactoryPath = "solr/shardHandlerFactory";
static String counterExpPath = "solr/metrics/suppliers/counter";
static String meterPath = "solr/metrics/suppliers/meter";
-
static String timerPath = "solr/metrics/suppliers/timer";
-
static String histoPath = "solr/metrics/suppliers/histogram";
-
static String historyPath = "solr/metrics/history";
-
static String transientCoreCacheFactoryPath = "solr/transientCoreCacheFactory";
-
static String tracerConfigPath = "solr/tracerConfig";
+ static String coreLoadThreadsPath = "solr/@coreLoadThreads";
+ static String persistentPath = "solr/@persistent";
+ static String sharedLibPath = "solr/@sharedLib";
+ static String zkHostPath = "solr/@zkHost";
+ static String coresPath = "solr/cores";
+
static {
XPath xPath = XmlConfigFile.getXpath();
try {
-
shardHandlerFactoryExp = xPath.compile(shardHandlerFactoryPath);
} catch (XPathExpressionException e) {
log.error("", e);
}
-
try {
counterExp = xPath.compile(counterExpPath);
} catch (XPathExpressionException e) {
@@ -139,6 +143,31 @@ public class SolrXmlConfig {
log.error("", e);
}
+ try {
+ coreLoadThreadsExp = xPath.compile(coreLoadThreadsPath);
+ } catch (XPathExpressionException e) {
+ log.error("", e);
+ }
+ try {
+ persistentExp = xPath.compile(persistentPath);
+ } catch (XPathExpressionException e) {
+ log.error("", e);
+ }
+ try {
+ sharedLibExp = xPath.compile(sharedLibPath);
+ } catch (XPathExpressionException e) {
+ log.error("", e);
+ }
+ try {
+ zkHostExp = xPath.compile(zkHostPath);
+ } catch (XPathExpressionException e) {
+ log.error("", e);
+ }
+ try {
+ coresExp = xPath.compile(coresPath);
+ } catch (XPathExpressionException e) {
+ log.error("", e);
+ }
}
public static NodeConfig fromConfig(Path solrHome, XmlConfigFile config, boolean fromZookeeper) {
@@ -254,17 +283,17 @@ public class SolrXmlConfig {
}
private static void checkForIllegalConfig(XmlConfigFile config) {
- // woah! it's best if we don't do this - resource killer - note: perhaps not as bad now that xml is more efficient?
-// failIfFound(config, "solr/@coreLoadThreads");
-// failIfFound(config, "solr/@persistent");
-// failIfFound(config, "solr/@sharedLib");
-// failIfFound(config, "solr/@zkHost");
-// failIfFound(config, "solr/cores");
-//
-// assertSingleInstance("solrcloud", config);
-// assertSingleInstance("logging", config);
-// assertSingleInstance("logging/watcher", config);
-// assertSingleInstance("backup", config);
+ // was resource killer - note: perhaps not as bad now that xml is more efficient?
+ failIfFound(config, coreLoadThreadsExp, coreLoadThreadsPath);
+ failIfFound(config, persistentExp, persistentPath);
+ failIfFound(config, sharedLibExp, sharedLibPath);
+ failIfFound(config, zkHostExp, zkHostPath);
+ failIfFound(config, coresExp, coresPath);
+
+ assertSingleInstance("solrcloud", config);
+ assertSingleInstance("logging", config);
+ assertSingleInstance("logging/watcher", config);
+ assertSingleInstance("backup", config);
}
private static void assertSingleInstance(String section, XmlConfigFile config) {
@@ -272,13 +301,11 @@ public class SolrXmlConfig {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Multiple instances of " + section + " section found in solr.xml");
}
- // nocommit - we should be able to bring this back now
- 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 +
-// "\n. Please upgrade your solr.xml: https://lucene.apache.org/solr/guide/format-of-solr-xml.html");
-// }
+ private static void failIfFound(XmlConfigFile config, XPathExpression xPath, String path) {
+ if (config.getVal(xPath, path,false) != null) {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Should not have found " + xPath +
+ "\n. Please upgrade your solr.xml: https://lucene.apache.org/solr/guide/format-of-solr-xml.html");
+ }
}
private static Properties loadProperties(XmlConfigFile config) {
diff --git a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
index a0d946b..b97bbe1 100644
--- a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
+++ b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
@@ -320,7 +320,8 @@ public class XmlConfigFile { // formerly simply "Config"
}
}
- public NodeList getNodeList (String path,boolean errIfMissing){
+ // TODO: more precompiled expressions
+ public NodeList getNodeList (String path, boolean errIfMissing){
String xstr = normalize(path);
try {
diff --git a/solr/core/src/test/org/apache/solr/core/TestBadConfig.java b/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
index 5a957f3..4fc8b2b 100644
--- a/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
+++ b/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
@@ -44,7 +44,8 @@ public class TestBadConfig extends AbstractBadConfigTestBase {
"useCompoundFile");
}
- @Ignore // nocommit debug
+ @Ignore // this fails because a small change is that currently, a SolrCore failing in CoreContainer#load will
+ // not fail with an exception, though the exception will be logged - we should check the core init exceptions here
public void testUpdateLogButNoVersionField() throws Exception {
System.setProperty("enable.update.log", "true");
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java
index 17dd48b..dc7393a 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java
@@ -410,8 +410,8 @@ public class ZkTestServer implements Closeable {
cnxnFactory.shutdown();
cnxnFactory.join();
- // eats some extra sleep time not to do this, but I think it can cause spurious fails
- //((Thread)zkServer.zooKeeperServer.getSessionTracker()).interrupt();
+ // NOT IDEAL, BUT THIS CAN SLEEP A BIT BEFORE EXIT
+ ((Thread)zkServer.zooKeeperServer.getSessionTracker()).interrupt();
((Thread)zkServer.zooKeeperServer.getSessionTracker()).join();
return cnxnFactory;
});
diff --git a/solr/test-framework/src/java/org/apache/solr/core/AbstractBadConfigTestBase.java b/solr/test-framework/src/java/org/apache/solr/core/AbstractBadConfigTestBase.java
index 17fe188..7430b06 100644
--- a/solr/test-framework/src/java/org/apache/solr/core/AbstractBadConfigTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/core/AbstractBadConfigTestBase.java
@@ -61,8 +61,7 @@ public abstract class AbstractBadConfigTestBase extends SolrTestCaseJ4 {
if (matches(entry.getValue().exception, errString))
return;
}
- }
- catch (Exception e) {
+ } catch (Throwable e) {
ParWork.propegateInterrupt(e);
if (matches(e, errString))
return;
@@ -75,7 +74,7 @@ public abstract class AbstractBadConfigTestBase extends SolrTestCaseJ4 {
fail("Did not encounter any exception from: " + solrconfigFile + " using " + schemaFile);
}
- private static boolean matches(Exception e, String errString) {
+ private static boolean matches(Throwable e, String errString) {
for (Throwable t = e; t != null; t = t.getCause()) {
if (t.getMessage() != null && -1 != t.getMessage().indexOf(errString))
return true;