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/20 01:33:34 UTC

[lucene-solr] branch reference_impl_dev updated (29221c3 -> 3382f12)

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a change to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from 29221c3  @568 Some logging cleanup.
     new 54105e8  @569 Revert cloud.sh changes that were not meant to be committed.
     new cf68f7c  @570 A bit of XPath polish.
     new 3c771ff  @571 A better default.
     new 3382f12  @572 Fix non test shutdown.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../byTask/tasks/DeleteCollectionTask.java         | 85 ++++++++++++++++++++++
 solr/cloud-dev/cloud.sh                            |  9 ++-
 .../facet/LegacyAbstractAnalyticsFacetTest.java    |  6 +-
 .../src/java/org/apache/solr/core/SolrConfig.java  | 18 ++---
 .../java/org/apache/solr/core/SolrXmlConfig.java   | 20 ++---
 .../java/org/apache/solr/core/XmlConfigFile.java   | 34 ++++++---
 .../handler/component/QueryElevationComponent.java |  2 +-
 .../org/apache/solr/schema/AbstractEnumField.java  |  2 +-
 .../apache/solr/schema/FieldTypePluginLoader.java  | 16 ++--
 .../solr/schema/FileExchangeRateProvider.java      |  2 +-
 .../java/org/apache/solr/schema/IndexSchema.java   | 17 +----
 .../java/org/apache/solr/search/CacheConfig.java   |  3 +-
 .../org/apache/solr/update/SolrIndexConfig.java    | 11 +--
 .../java/org/apache/solr/util/SimplePostTool.java  |  2 +-
 .../solr/util/plugin/AbstractPluginLoader.java     |  5 +-
 .../org/apache/solr/core/TestCodecSupport.java     |  2 +-
 .../src/test/org/apache/solr/core/TestConfig.java  |  2 +-
 .../solr/schema/TestUseDocValuesAsStored.java      |  2 +-
 .../org/apache/solr/common/ParWorkExecutor.java    | 51 ++++++-------
 .../java/org/apache/solr/util/BaseTestHarness.java |  3 +-
 .../java/org/apache/solr/util/DOMUtilTestBase.java |  2 +-
 21 files changed, 191 insertions(+), 103 deletions(-)
 create mode 100644 solr/benchmark/src/java/org/apache/solr/benchmark/byTask/tasks/DeleteCollectionTask.java


[lucene-solr] 02/04: @570 A bit of XPath polish.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit cf68f7ccceac86ad1a4e3d71a19b52b7314658f2
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Aug 19 19:53:15 2020 -0500

    @570 A bit of XPath polish.
---
 .../facet/LegacyAbstractAnalyticsFacetTest.java    |  6 ++--
 .../src/java/org/apache/solr/core/SolrConfig.java  | 18 ++++++------
 .../java/org/apache/solr/core/SolrXmlConfig.java   | 20 ++++++-------
 .../java/org/apache/solr/core/XmlConfigFile.java   | 34 +++++++++++++++-------
 .../handler/component/QueryElevationComponent.java |  2 +-
 .../org/apache/solr/schema/AbstractEnumField.java  |  2 +-
 .../apache/solr/schema/FieldTypePluginLoader.java  | 16 +++++-----
 .../solr/schema/FileExchangeRateProvider.java      |  2 +-
 .../java/org/apache/solr/schema/IndexSchema.java   | 17 ++---------
 .../java/org/apache/solr/search/CacheConfig.java   |  3 +-
 .../org/apache/solr/update/SolrIndexConfig.java    | 11 +++----
 .../java/org/apache/solr/util/SimplePostTool.java  |  2 +-
 .../solr/util/plugin/AbstractPluginLoader.java     |  5 ++--
 .../org/apache/solr/core/TestCodecSupport.java     |  2 +-
 .../src/test/org/apache/solr/core/TestConfig.java  |  2 +-
 .../solr/schema/TestUseDocValuesAsStored.java      |  2 +-
 .../org/apache/solr/common/ParWorkExecutor.java    |  5 ----
 .../java/org/apache/solr/util/BaseTestHarness.java |  3 +-
 .../java/org/apache/solr/util/DOMUtilTestBase.java |  2 +-
 19 files changed, 78 insertions(+), 76 deletions(-)

diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java
index de2eba3..1d68585 100644
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java
+++ b/solr/contrib/analytics/src/test/org/apache/solr/analytics/legacy/facet/LegacyAbstractAnalyticsFacetTest.java
@@ -89,7 +89,7 @@ public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {
   }
 
   protected Node getNode(String xPath) throws XPathExpressionException {
-    return (Node) IndexSchema.getXpath().compile(xPath).evaluate(doc, XPathConstants.NODE);
+    return (Node) XmlConfigFile.getXpath().compile(xPath).evaluate(doc, XPathConstants.NODE);
   }
   private NodeList getNodes(String n1, String n2, String n3, String element, String n4) throws XPathExpressionException {
     // Construct the XPath expression. The form better not change or all these will fail.
@@ -98,7 +98,7 @@ public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {
     sb.append("/lst[@name='").append(n3).append("']");
     sb.append("/lst[@name!='(MISSING)']");
     sb.append("//").append(element).append("[@name='").append(n4).append("']");
-    return (NodeList) IndexSchema.getXpath().compile(sb.toString()).evaluate(doc, XPathConstants.NODESET);
+    return (NodeList) XmlConfigFile.getXpath().compile(sb.toString()).evaluate(doc, XPathConstants.NODESET);
 
   }
   protected ArrayList<String> getStringList(String n1, String n2, String n3, String element, String n4)
@@ -337,7 +337,7 @@ public class LegacyAbstractAnalyticsFacetTest extends SolrTestCaseJ4 {
 
   protected NodeList getNodes(String xPath) throws XPathExpressionException {
     StringBuilder sb = new StringBuilder(xPath);
-    return (NodeList) IndexSchema.getXpath().compile(sb.toString()).evaluate(doc, XPathConstants.NODESET);
+    return (NodeList) XmlConfigFile.getXpath().compile(sb.toString()).evaluate(doc, XPathConstants.NODESET);
   }
 
 }
diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
index 0bb02b9..713c2ed 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
@@ -132,28 +132,28 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
 
     try {
 
-      luceneMatchVersionExp = IndexSchema.getXpath().compile(luceneMatchVersionPath);
+      luceneMatchVersionExp = XmlConfigFile.getXpath().compile(luceneMatchVersionPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
 
     try {
-      indexDefaultsExp = IndexSchema.getXpath().compile(indexDefaultsPath);
+      indexDefaultsExp = XmlConfigFile.getXpath().compile(indexDefaultsPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      mainIndexExp = IndexSchema.getXpath().compile(mainIndexPath);
+      mainIndexExp = XmlConfigFile.getXpath().compile(mainIndexPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      nrtModeExp = IndexSchema.getXpath().compile(nrtModePath);
+      nrtModeExp = XmlConfigFile.getXpath().compile(nrtModePath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      unlockOnStartupExp = IndexSchema.getXpath().compile(unlockOnStartupPath);
+      unlockOnStartupExp = XmlConfigFile.getXpath().compile(unlockOnStartupPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
@@ -897,7 +897,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
     if (val != null) return Integer.parseInt(val.toString());
     try {
       path = super.normalize(path);
-      return super.getInt(IndexSchema.getXpath().compile(path), path, def);
+      return super.getInt(XmlConfigFile.getXpath().compile(path), path, def);
     } catch (XPathExpressionException e) {
       throw new SolrException(ErrorCode.BAD_REQUEST, e);
     }
@@ -908,7 +908,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
     if (val != null) return Boolean.parseBoolean(val.toString());
     try {
       path = super.normalize(path);
-      return super.getBool(IndexSchema.getXpath().compile(path), path, def);
+      return super.getBool(XmlConfigFile.getXpath().compile(path), path, def);
     } catch (XPathExpressionException e) {
       throw new SolrException(ErrorCode.BAD_REQUEST, e);
     }
@@ -918,7 +918,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
     Object val = overlay.getXPathProperty(path, true);
     try {
       path = super.normalize(path);
-      return val != null ? val.toString() : super.get(IndexSchema.getXpath().compile(path), path);
+      return val != null ? val.toString() : super.get(XmlConfigFile.getXpath().compile(path), path);
     } catch (XPathExpressionException e) {
       throw new SolrException(ErrorCode.BAD_REQUEST, e);
     }
@@ -928,7 +928,7 @@ public class SolrConfig extends XmlConfigFile implements MapSerializable {
     Object val = overlay.getXPathProperty(path, true);
     try {
       path = super.normalize(path);
-      return val != null ? val.toString() : super.get(IndexSchema.getXpath().compile(path), path, def);
+      return val != null ? val.toString() : super.get(XmlConfigFile.getXpath().compile(path), path, def);
     } catch (XPathExpressionException e) {
       throw new SolrException(ErrorCode.BAD_REQUEST, e);
     }
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 92cccb6..68e8510 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
@@ -95,46 +95,46 @@ public class SolrXmlConfig {
 
   static {
 
-
+    XPath xPath = XmlConfigFile.getXpath();
     try {
 
-      shardHandlerFactoryExp = IndexSchema.getXpath().compile(shardHandlerFactoryPath);
+      shardHandlerFactoryExp = xPath.compile(shardHandlerFactoryPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
 
     try {
-      counterExp = IndexSchema.getXpath().compile(counterExpPath);
+      counterExp = xPath.compile(counterExpPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      meterExp = IndexSchema.getXpath().compile(meterPath);
+      meterExp = xPath.compile(meterPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      timerExp = IndexSchema.getXpath().compile(timerPath);
+      timerExp = xPath.compile(timerPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      histoExp = IndexSchema.getXpath().compile(histoPath);
+      histoExp = xPath.compile(histoPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      historyExp = IndexSchema.getXpath().compile(historyPath);
+      historyExp = xPath.compile(historyPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      transientCoreCacheFactoryExp = IndexSchema.getXpath().compile(transientCoreCacheFactoryPath);
+      transientCoreCacheFactoryExp = xPath.compile(transientCoreCacheFactoryPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      tracerConfigExp = IndexSchema.getXpath().compile(tracerConfigPath);
+      tracerConfigExp = xPath.compile(tracerConfigPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
@@ -308,7 +308,7 @@ public class SolrXmlConfig {
   private static Properties loadProperties(XmlConfigFile config) {
     try {
       Node node = ((NodeList) config.evaluate("solr", XPathConstants.NODESET)).item(0);
-      XPath xpath = config.getXPath();
+      XPath xpath = XmlConfigFile.getXpath();
       NodeList props = (NodeList) xpath.evaluate("property", node, XPathConstants.NODESET);
       Properties properties = new Properties(config.getSubstituteProperties());
       for (int i = 0; i < props.getLength(); i++) {
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 76f3455..b311291 100644
--- a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
+++ b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
@@ -49,6 +49,7 @@ import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
+import javax.xml.xpath.XPathFactoryConfigurationException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.invoke.MethodHandles;
@@ -68,11 +69,18 @@ import java.util.TreeSet;
 public class XmlConfigFile { // formerly simply "Config"
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+
   public static final XMLErrorLogger xmllog = new XMLErrorLogger(log);
-  public static final XPathFactory xpathFactory = new XPathFactoryImpl();
+
+  protected final static ThreadLocal<XPath> THREAD_LOCAL_XPATH = new ThreadLocal<>();
+  public static final XPathFactoryImpl xpathFactory = new XPathFactoryImpl();
   public static final SaxonTransformerFactory tfactory = new BasicTransformerFactory();
   static  {
-   // tfactory.getConfiguration().setBooleanProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.TRUE);
+
+      xpathFactory.getConfiguration().setValidation(false);
+      xpathFactory.getConfiguration().setExpandAttributeDefaults(false);
+
+    // tfactory.getConfiguration().setBooleanProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.TRUE);
   }
   public static final Transformer tx = tfactory.newTransformer();
 
@@ -84,6 +92,16 @@ public class XmlConfigFile { // formerly simply "Config"
   private final Properties substituteProperties;
   private int zkVersion = -1;
 
+
+  public static XPath getXpath() {
+    XPath xPath = THREAD_LOCAL_XPATH.get();
+    if (xPath == null) {
+      xPath = XmlConfigFile.xpathFactory.newXPath();
+      THREAD_LOCAL_XPATH.set(xPath);
+    }
+    return xPath;
+  }
+
   /**
    * Builds a config from a resource name with no xpath prefix.  Does no property substitution.
    */
@@ -218,10 +236,6 @@ public class XmlConfigFile { // formerly simply "Config"
       return doc;
     }
 
-    public XPath getXPath () {
-      return IndexSchema.getXpath();
-    }
-
     String normalize(String path){
       return (prefix == null || path.startsWith("/")) ? path : prefix + path;
     }
@@ -231,7 +245,7 @@ public class XmlConfigFile { // formerly simply "Config"
         String xstr = normalize(path);
 
         // TODO: instead of prepending /prefix/, we could do the search rooted at /prefix...
-        Object o = IndexSchema.getXpath().evaluate(xstr, doc, type);
+        Object o = getXpath().evaluate(xstr, doc, type);
         return o;
 
       } catch (XPathExpressionException e) {
@@ -248,7 +262,7 @@ public class XmlConfigFile { // formerly simply "Config"
     public Node getNode (String expression, boolean errifMissing){
       String path = normalize(expression);
       try {
-        return getNode(IndexSchema.getXpath().compile(path), path, doc, errifMissing);
+        return getNode(getXpath().compile(path), path, doc, errifMissing);
       } catch (XPathExpressionException e) {
         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
       }
@@ -298,7 +312,7 @@ public class XmlConfigFile { // formerly simply "Config"
       String xstr = normalize(path);
 
       try {
-        NodeList nodeList = (NodeList) IndexSchema.getXpath()
+        NodeList nodeList = (NodeList) getXpath()
             .evaluate(xstr, doc, XPathConstants.NODESET);
 
         if (null == nodeList) {
@@ -397,7 +411,7 @@ public class XmlConfigFile { // formerly simply "Config"
     public String getVal (String expression, boolean errIfMissing){
       String xstr = normalize(expression);
       try {
-        return getVal(IndexSchema.getXpath().compile(xstr), expression, errIfMissing);
+        return getVal(getXpath().compile(xstr), expression, errIfMissing);
       } catch (XPathExpressionException e) {
         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
       }
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
index 3e62b15..4c2c077 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
@@ -394,7 +394,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
    */
   protected ElevationProvider loadElevationProvider(XmlConfigFile config) {
     Map<ElevatingQuery, ElevationBuilder> elevationBuilderMap = new LinkedHashMap<>();
-    XPath xpath = IndexSchema.getXpath();
+    XPath xpath = XmlConfigFile.getXpath();
     NodeList nodes = (NodeList) config.evaluate("elevate/query", XPathConstants.NODESET);
     for (int i = 0; i < nodes.getLength(); i++) {
       Node node = nodes.item(i);
diff --git a/solr/core/src/java/org/apache/solr/schema/AbstractEnumField.java b/solr/core/src/java/org/apache/solr/schema/AbstractEnumField.java
index fbbe168..493ccad 100644
--- a/solr/core/src/java/org/apache/solr/schema/AbstractEnumField.java
+++ b/solr/core/src/java/org/apache/solr/schema/AbstractEnumField.java
@@ -112,7 +112,7 @@ public abstract class AbstractEnumField extends PrimitiveFieldType {
       try {
         log.debug("Reloading enums config file from {}", enumsConfigFile);
         Document doc = SafeXMLParsing.parseConfigXML(log, loader, enumsConfigFile);
-        final XPath xpath = IndexSchema.getXpath();
+        final XPath xpath = XmlConfigFile.getXpath();
         final String xpathStr = String.format(Locale.ROOT, "/enumsConfig/enum[@name='%s']", enumName);
         final NodeList nodes = (NodeList) xpath.evaluate(xpathStr, doc, XPathConstants.NODESET);
         final int nodesLength = nodes.getLength();
diff --git a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
index 04efa40..1a719b0 100644
--- a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
+++ b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
@@ -27,6 +27,8 @@ import org.apache.solr.common.SolrException;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.core.SolrXmlConfig;
+import org.apache.solr.core.XmlConfigFile;
 import org.apache.solr.util.DOMUtil;
 import org.apache.solr.util.plugin.AbstractPluginLoader;
 import org.slf4j.Logger;
@@ -65,40 +67,40 @@ public final class FieldTypePluginLoader
 
   static {
     try {
-      analyzerQueryExp = IndexSchema.getXpath().compile("./analyzer[@type='query']");
+      analyzerQueryExp = XmlConfigFile.getXpath().compile("./analyzer[@type='query']");
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      analyzerMultiTermExp = IndexSchema.getXpath().compile("./analyzer[@type='multiterm']");
+      analyzerMultiTermExp = XmlConfigFile.getXpath().compile("./analyzer[@type='multiterm']");
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
 
     try {
-      analyzerIndexExp = IndexSchema.getXpath().compile("./analyzer[not(@type)] | ./analyzer[@type='index']");
+      analyzerIndexExp = XmlConfigFile.getXpath().compile("./analyzer[not(@type)] | ./analyzer[@type='index']");
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      similarityExp = IndexSchema.getXpath().compile("./similarity");
+      similarityExp = XmlConfigFile.getXpath().compile("./similarity");
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
 
 
     try {
-      charFilterExp = IndexSchema.getXpath().compile("./charFilter");
+      charFilterExp = XmlConfigFile.getXpath().compile("./charFilter");
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      tokenizerExp = IndexSchema.getXpath().compile("./tokenizer");
+      tokenizerExp = XmlConfigFile.getXpath().compile("./tokenizer");
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      filterExp = IndexSchema.getXpath().compile("./filter");
+      filterExp = XmlConfigFile.getXpath().compile("./filter");
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
diff --git a/solr/core/src/java/org/apache/solr/schema/FileExchangeRateProvider.java b/solr/core/src/java/org/apache/solr/schema/FileExchangeRateProvider.java
index 49e1510..0be9204 100644
--- a/solr/core/src/java/org/apache/solr/schema/FileExchangeRateProvider.java
+++ b/solr/core/src/java/org/apache/solr/schema/FileExchangeRateProvider.java
@@ -165,7 +165,7 @@ public class FileExchangeRateProvider implements ExchangeRateProvider {
 
     try {
       Document doc = SafeXMLParsing.parseConfigXML(log, loader, currencyConfigFile);
-      XPath xpath = ManagedIndexSchema.getXpath();
+      XPath xpath = XmlConfigFile.getXpath();
       
       // Parse exchange rates.
       NodeList nodes = (NodeList) xpath.evaluate("/currencyConfig/rates/rate", doc, XPathConstants.NODESET);
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index f964959..935b2c8 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -133,9 +133,6 @@ public class IndexSchema {
   private static final String TEXT_FUNCTION = "text()";
   private static final String XPATH_OR = " | ";
 
-
-  static XPath xpath = XmlConfigFile.xpathFactory.newXPath();
-
   private static XPathExpression xpathOrExp;
   private static XPathExpression schemaNameExp;
   private static XPathExpression schemaVersionExp;
@@ -160,6 +157,7 @@ public class IndexSchema {
   static String schemaUniqueKeyPath = stepsToPath(SCHEMA, UNIQUE_KEY, TEXT_FUNCTION);
 
   static {
+    XPath xpath = XmlConfigFile.getXpath();
     try {
       String expression = stepsToPath(SCHEMA, FIELD)
           + XPATH_OR + stepsToPath(SCHEMA, DYNAMIC_FIELD)
@@ -246,8 +244,6 @@ public class IndexSchema {
    */
   protected Map<SchemaField, Integer> copyFieldTargetCounts = new HashMap<>();
 
-  protected final static ThreadLocal<XPath> THREAD_LOCAL_XPATH = new ThreadLocal<>();
-
   /**
    * Constructs a schema using the specified resource name and stream.
    * By default, this follows the normal config path directory searching rules.
@@ -271,15 +267,6 @@ public class IndexSchema {
     this.substitutableProperties = substitutableProperties;
   }
 
-  public static XPath getXpath() {
-    XPath xPath = THREAD_LOCAL_XPATH.get();
-    if (xPath == null) {
-      xPath = XmlConfigFile.xpathFactory.newXPath();
-      THREAD_LOCAL_XPATH.set(xPath);
-    }
-    return xPath;
-  }
-
   /**
    * The resource loader to be used to load components related to the schema when the schema is loading
    * / initialising.
@@ -567,7 +554,7 @@ public class IndexSchema {
       // in the current case though, the stream is valid so we wont load the resource by name
       XmlConfigFile schemaConf = new XmlConfigFile(loader, SCHEMA, is, SLASH+SCHEMA+SLASH, substitutableProperties);
       Document document = schemaConf.getDocument();
-      final XPath xpath = schemaConf.getXPath();
+      final XPath xpath = XmlConfigFile.getXpath();
 
       Node nd = (Node) schemaNameExp.evaluate(document, XPathConstants.NODE);
       StringBuilder sb = new StringBuilder();
diff --git a/solr/core/src/java/org/apache/solr/search/CacheConfig.java b/solr/core/src/java/org/apache/solr/search/CacheConfig.java
index b206825..7910e8e 100644
--- a/solr/core/src/java/org/apache/solr/search/CacheConfig.java
+++ b/solr/core/src/java/org/apache/solr/search/CacheConfig.java
@@ -31,6 +31,7 @@ import org.apache.solr.common.MapSerializable;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.core.XmlConfigFile;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.util.DOMUtil;
 import org.slf4j.Logger;
@@ -102,7 +103,7 @@ public class CacheConfig implements MapSerializable{
     Node node = null;
     try {
       String path = IndexSchema.normalize(xpath, "/config/");
-      node = solrConfig.getNode(IndexSchema.getXpath().compile(path), path, false);
+      node = solrConfig.getNode(XmlConfigFile.getXpath().compile(path), path, false);
     } catch (XPathExpressionException e) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
     }
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java b/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
index ee316d1..dfd6033 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
@@ -39,6 +39,7 @@ import org.apache.solr.core.PluginInfo;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.core.XmlConfigFile;
 import org.apache.solr.index.DefaultMergePolicyFactory;
 import org.apache.solr.index.MergePolicyFactory;
 import org.apache.solr.index.MergePolicyFactoryArgs;
@@ -84,28 +85,28 @@ public class SolrIndexConfig implements MapSerializable {
 
     try {
 
-      indexConfigExp = IndexSchema.getXpath().compile(indexConfigPath);
+      indexConfigExp = XmlConfigFile.getXpath().compile(indexConfigPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
 
     try {
-      mergeSchedulerExp = IndexSchema.getXpath().compile(mergeSchedulerPath);
+      mergeSchedulerExp = XmlConfigFile.getXpath().compile(mergeSchedulerPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      mergePolicyExp = IndexSchema.getXpath().compile(mergePolicyPath);
+      mergePolicyExp = XmlConfigFile.getXpath().compile(mergePolicyPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      ramBufferSizeMBExp = IndexSchema.getXpath().compile(ramBufferSizeMBPath);
+      ramBufferSizeMBExp = XmlConfigFile.getXpath().compile(ramBufferSizeMBPath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
     try {
-      checkIntegrityAtMergeExp = IndexSchema.getXpath().compile(checkIntegrityAtMergePath);
+      checkIntegrityAtMergeExp = XmlConfigFile.getXpath().compile(checkIntegrityAtMergePath);
     } catch (XPathExpressionException e) {
       log.error("", e);
     }
diff --git a/solr/core/src/java/org/apache/solr/util/SimplePostTool.java b/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
index 025e478..5998b7c 100644
--- a/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
+++ b/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
@@ -1058,7 +1058,7 @@ public class SimplePostTool {
    * Gets all nodes matching an XPath
    */
   public static NodeList getNodesFromXP(Node n, String xpath) throws XPathExpressionException {
-    XPath xp = IndexSchema.getXpath();
+    XPath xp = XmlConfigFile.getXpath();
     XPathExpression expr = xp.compile(xpath);
     return (NodeList) expr.evaluate(n, XPathConstants.NODESET);
   }
diff --git a/solr/core/src/java/org/apache/solr/util/plugin/AbstractPluginLoader.java b/solr/core/src/java/org/apache/solr/util/plugin/AbstractPluginLoader.java
index e55fee9..5686ab6 100644
--- a/solr/core/src/java/org/apache/solr/util/plugin/AbstractPluginLoader.java
+++ b/solr/core/src/java/org/apache/solr/util/plugin/AbstractPluginLoader.java
@@ -25,6 +25,7 @@ import org.apache.solr.common.ParWork;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.core.XmlConfigFile;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.util.DOMUtil;
 import org.slf4j.Logger;
@@ -142,7 +143,7 @@ public abstract class AbstractPluginLoader<T>
   {
     List<PluginInitInfo> info = new ArrayList<>();
     T defaultPlugin = null;
-    XPath xpath = IndexSchema.getXpath();
+    XPath xpath = XmlConfigFile.getXpath();
     if (nodes !=null ) {
       for (int i=0; i<nodes.getLength(); i++) {
         Node node = nodes.item(i);
@@ -236,7 +237,7 @@ public abstract class AbstractPluginLoader<T>
     try {
       String name = DOMUtil.getAttr(node, NAME, requireName ? type : null);
       String className = DOMUtil.getAttr(node, "class", type);
-      plugin = create(loader, name, className, node, IndexSchema.getXpath());
+      plugin = create(loader, name, className, node, XmlConfigFile.getXpath());
       if (log.isDebugEnabled()) {
         log.debug("created {}: {}", name, plugin.getClass().getName());
       }
diff --git a/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java b/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java
index e61c170..7a379ef 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java
@@ -208,7 +208,7 @@ public class TestCodecSupport extends SolrTestCaseJ4 {
     assertEquals("Unexpected codec factory for this test.", "solr.SchemaCodecFactory", config.get("codecFactory/@class"));
     String path = IndexSchema.normalize("codecFactory", config.getPrefix());
     assertNull("Unexpected configuration of codec factory for this test. Expecting empty element", 
-        config.getNode(IndexSchema.getXpath().compile(path), path, false).getFirstChild());
+        config.getNode(XmlConfigFile.getXpath().compile(path), path, false).getFirstChild());
     IndexSchema schema = IndexSchemaFactory.buildIndexSchema("schema_codec.xml", config);
 
     CoreContainer coreContainer = h.getCoreContainer();
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfig.java b/solr/core/src/test/org/apache/solr/core/TestConfig.java
index 118e1f5..4f7b818 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfig.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfig.java
@@ -98,7 +98,7 @@ public class TestConfig extends SolrTestCaseJ4 {
     assertEquals(1, nl.getLength());
     assertEquals("prefix-proptwo-suffix", nl.item(0).getTextContent());
     String path = IndexSchema.normalize("propTest", solrConfig.getPrefix());
-    Node node = solrConfig.getNode(IndexSchema.getXpath().compile(path), path, true);
+    Node node = solrConfig.getNode(XmlConfigFile.getXpath().compile(path), path, true);
     assertEquals("prefix-proptwo-suffix", node.getTextContent());
   }
 
diff --git a/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java b/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
index 569d6bb..c453755 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestUseDocValuesAsStored.java
@@ -77,7 +77,7 @@ public class TestUseDocValuesAsStored extends AbstractBadConfigTestBase {
       DocumentBuilder builder = FieldTypeXmlAdapter.getDocumentBuilder();
       InputStream stream = TestUseDocValuesAsStored.class.getResourceAsStream("/solr/collection1/conf/enumsConfig.xml");
       Document doc = builder.parse(new InputSource(IOUtils.getDecodingReader(stream, StandardCharsets.UTF_8)));
-      XPath xpath = ManagedIndexSchema.getXpath();
+      XPath xpath = XmlConfigFile.getXpath();
       NodeList nodes = (NodeList)xpath.evaluate
           ("/enumsConfig/enum[@name='severity']/value", doc, XPathConstants.NODESET);
       SEVERITY = new String[nodes.getLength()];
diff --git a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
index e8bbd62..dc64869 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
@@ -1,20 +1,15 @@
 package org.apache.solr.common;
 
-import org.apache.solr.common.util.ExecutorUtil;
-import org.apache.solr.common.util.SolrNamedThreadFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.lang.invoke.MethodHandles;
 import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.ReentrantLock;
 
 public class ParWorkExecutor extends ThreadPoolExecutor {
   private static final Logger log = LoggerFactory
diff --git a/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java
index 01330e8..1ffb0c5 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java
@@ -18,6 +18,7 @@ package org.apache.solr.util;
 
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.util.XML;
+import org.apache.solr.core.XmlConfigFile;
 import org.apache.solr.rest.schema.FieldTypeXmlAdapter;
 import org.apache.solr.schema.IndexSchema;
 import org.w3c.dom.Document;
@@ -55,7 +56,7 @@ abstract public class BaseTestHarness {
   }
 
   public static XPath getXpath() {
-    return IndexSchema.getXpath();
+    return XmlConfigFile.getXpath();
   }
 
 
diff --git a/solr/test-framework/src/java/org/apache/solr/util/DOMUtilTestBase.java b/solr/test-framework/src/java/org/apache/solr/util/DOMUtilTestBase.java
index c32233d..af78575 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/DOMUtilTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/DOMUtilTestBase.java
@@ -46,7 +46,7 @@ public abstract class DOMUtilTestBase extends SolrTestCase {
   }
   
   public Node getNode( Document doc, String path ) throws Exception {
-    XPath xpath = IndexSchema.getXpath();
+    XPath xpath = XmlConfigFile.getXpath();
     return (Node)xpath.evaluate(path, doc, XPathConstants.NODE);
   }
   


[lucene-solr] 04/04: @572 Fix non test shutdown.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 3382f12aeb5f64d1cd273bcfdd14d4f09602f286
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Aug 19 20:29:35 2020 -0500

    @572 Fix non test shutdown.
---
 .../org/apache/solr/common/ParWorkExecutor.java    | 46 +++++++++++-----------
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
index dc64869..9e2ead1 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.solr.common;
 
 import org.slf4j.Logger;
@@ -14,7 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 public class ParWorkExecutor extends ThreadPoolExecutor {
   private static final Logger log = LoggerFactory
       .getLogger(MethodHandles.lookup().lookupClass());
-  public static final int KEEP_ALIVE_TIME = 5000;
+  public static final int KEEP_ALIVE_TIME = 15000;
 
   private static AtomicInteger threadNumber = new AtomicInteger(0);
   private volatile boolean closed;
@@ -32,17 +48,14 @@ public class ParWorkExecutor extends ThreadPoolExecutor {
     super(corePoolsSize, maxPoolsSize, keepalive, TimeUnit.MILLISECONDS, workQueue
     , new ThreadFactory() {
 
-          ThreadGroup group;
+          @Override
+          public Thread newThread(Runnable r) {
+            ThreadGroup group;
 
-          {
             SecurityManager s = System.getSecurityManager();
-            group = (s != null) ?
-                s.getThreadGroup() :
+            group = (s != null)? s.getThreadGroup() :
                 Thread.currentThread().getThreadGroup();
-          }
 
-          @Override
-          public Thread newThread(Runnable r) {
             Thread t = new Thread(group,
                 name + threadNumber.getAndIncrement()) {
               public void run() {
@@ -53,29 +66,14 @@ public class ParWorkExecutor extends ThreadPoolExecutor {
                 }
               }
             };
-            //t.setDaemon(true);
-
-            // t.setPriority(priority);
+            t.setDaemon(true);
             return t;
           }
         });
-
-    //setRejectedExecutionHandler(new CallerRunsPolicy());
   }
 
   public void shutdown() {
     this.closed = true;
-//    if (!isShutdown()) {
-//      // wake up idle threads!
-//      for (int i = 0; i < getPoolSize(); i++) {
-//        submit(new Runnable() {
-//          @Override
-//          public void run() {
-//
-//          }
-//        });
-//      }
-//    }
     super.shutdown();
   }
 }


[lucene-solr] 03/04: @571 A better default.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 3c771ffd4feab2478b5707bb926aa4bc3bfef1f9
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Aug 19 19:54:49 2020 -0500

    @571 A better default.
---
 solr/cloud-dev/cloud.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/solr/cloud-dev/cloud.sh b/solr/cloud-dev/cloud.sh
index ccbfce8..12daa1f 100644
--- a/solr/cloud-dev/cloud.sh
+++ b/solr/cloud-dev/cloud.sh
@@ -90,7 +90,7 @@
 #
 ##################################################################################
 
-DEFAULT_VCS_WORKSPACE='../code/lucene-solr'
+DEFAULT_VCS_WORKSPACE='../../'
 
 ############## Normally  no need to edit below this line ##############
 


[lucene-solr] 01/04: @569 Revert cloud.sh changes that were not meant to be committed.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 54105e8011348e1ebd104ba2016195833919548d
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Aug 19 19:51:11 2020 -0500

    @569 Revert cloud.sh changes that were not meant to be committed.
---
 .../byTask/tasks/DeleteCollectionTask.java         | 85 ++++++++++++++++++++++
 solr/cloud-dev/cloud.sh                            |  9 ++-
 2 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/solr/benchmark/src/java/org/apache/solr/benchmark/byTask/tasks/DeleteCollectionTask.java b/solr/benchmark/src/java/org/apache/solr/benchmark/byTask/tasks/DeleteCollectionTask.java
new file mode 100644
index 0000000..a9eac7e
--- /dev/null
+++ b/solr/benchmark/src/java/org/apache/solr/benchmark/byTask/tasks/DeleteCollectionTask.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.benchmark.byTask.tasks;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.tasks.PerfTask;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.client.solrj.response.UpdateResponse;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class CreateCollectionTask extends PerfTask {
+
+  static AtomicInteger count = new AtomicInteger();
+
+  private String name;
+  private String numShards;
+
+  private String numReplicas;
+
+  public CreateCollectionTask(PerfRunData runData) {
+    super(runData);
+  }
+
+
+  @Override
+  protected String getLogMessage(int recsCount) {
+    return "collection created";
+  }
+  
+  @Override
+  public int doLogic() throws Exception {
+    SolrClient solrServer = (SolrClient) getRunData().getPerfObject("solr.admin.client");
+    //String collectionName = "solrj_test" + count.incrementAndGet();
+
+    String collectionName = name;
+    CollectionAdminResponse response = CollectionAdminRequest
+        .createCollection(collectionName, "_default", 2, 4)
+        .setMaxShardsPerNode(100).process(solrServer);
+    
+    return 1;
+  }
+
+  /**
+   * Set the params (docSize only)
+   *
+   * @param params
+   *          docSize, or 0 for no limit.
+   */
+  @Override
+  public void setParams(String params) {
+    // can't call super because super doesn't understand our
+    // params syntax
+    this.params = params;
+    String [] splits = params.split(",");
+    for (int i = 0; i < splits.length; i++) {
+      if (splits[i].startsWith("name[") == true){
+        name = splits[i].substring("name[".length(),splits[i].length() - 1);
+      }
+      if (splits[i].startsWith("numShards[") == true){
+        numShards = splits[i].substring("numShards[".length(),splits[i].length() - 1);
+      }
+      if (splits[i].startsWith("numReplicas[") == true){
+        numReplicas = splits[i].substring("numReplicas[".length(),splits[i].length() - 1);
+      }
+    }
+  }
+  
+}
diff --git a/solr/cloud-dev/cloud.sh b/solr/cloud-dev/cloud.sh
index 0e7a5e3..ccbfce8 100644
--- a/solr/cloud-dev/cloud.sh
+++ b/solr/cloud-dev/cloud.sh
@@ -90,7 +90,7 @@
 #
 ##################################################################################
 
-DEFAULT_VCS_WORKSPACE='/data2/lucene-solr'
+DEFAULT_VCS_WORKSPACE='../code/lucene-solr'
 
 ############## Normally  no need to edit below this line ##############
 
@@ -254,7 +254,7 @@ cleanIfReq() {
 recompileIfReq() {
   if [[ "$RECOMPILE" = true ]]; then
     pushd "$VCS_WORK"/solr
-    ant clean server create-package
+    ant clean create-package
     if [[ "$?" -ne 0 ]]; then
       echo "BUILD FAIL - cloud.sh stopping, see above output for details"; popd; exit 7;
     fi
@@ -288,7 +288,10 @@ copyTarball() {
 # Assume that zookeeper holds it if it is   #
 #############################################
 testZookeeper() {
-  echo "no"
+  PORT_FOUND=$( netstat -an | grep '\b'${ZK_PORT}'\s' | grep LISTEN | awk '{print $4}' | sed -E 's/.*\b('${ZK_PORT}')\s*/\1/');
+  if [[ -z  "$PORT_FOUND" ]]; then
+    echo "No process listening on port ${ZK_PORT}. Please start zookeeper and try again"; exit 8;
+  fi
 }
 
 ##########################