You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2015/03/05 10:54:07 UTC
svn commit: r1664292 [1/2] - in /lucene/dev/trunk/solr: ./
contrib/clustering/src/test-files/clustering/solr/
contrib/map-reduce/src/test/org/apache/solr/hadoop/
contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/
core/src/java/org/apache...
Author: romseygeek
Date: Thu Mar 5 09:54:06 2015
New Revision: 1664292
URL: http://svn.apache.org/r1664292
Log:
SOLR-7179: Stop using sysprops to configure test jettys
Added:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/client/
lucene/dev/trunk/solr/core/src/test/org/apache/solr/client/solrj/
lucene/dev/trunk/solr/core/src/test/org/apache/solr/client/solrj/embedded/
lucene/dev/trunk/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java (with props)
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/contrib/clustering/src/test-files/clustering/solr/solr.xml
lucene/dev/trunk/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java
lucene/dev/trunk/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/ResponseHeaderTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java
lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Thu Mar 5 09:54:06 2015
@@ -81,6 +81,9 @@ Upgrading from Solr 5.0
* SolrRequest.process() is now final. Subclasses should instead be parametrized
by their corresponding SolrResponse type, and implement createResponse()
+* The signature of SolrDispatchFilter.createCoreContainer() has changed to take
+ (String,Properties) arguments
+
Detailed Change List
----------------------
@@ -237,6 +240,10 @@ Other Changes
* SOLR-7151: SolrClient query methods throw IOException (Alan Woodward)
+* SOLR-7179: JettySolrRunner no longer passes configuration to
+ SolrDispatchFilter via system properties, but instead uses a Properties
+ object in the servlet context (Alan Woodward)
+
* SOLR-6275: Improve accuracy of QTime reporting (Ramkumar Aiyengar)
* SOLR-7174: DIH should reset TikaEntityProcessor so that it is capable
Modified: lucene/dev/trunk/solr/contrib/clustering/src/test-files/clustering/solr/solr.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/clustering/src/test-files/clustering/solr/solr.xml?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/clustering/src/test-files/clustering/solr/solr.xml (original)
+++ lucene/dev/trunk/solr/contrib/clustering/src/test-files/clustering/solr/solr.xml Thu Mar 5 09:54:06 2015
@@ -22,6 +22,9 @@
<solr>
+ <str name="coreRootDirectory">cores/</str>
+ <str name="configSetBaseDir"></str>
+
<shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
<str name="urlScheme">${urlScheme:}</str>
</shardHandlerFactory>
Modified: lucene/dev/trunk/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java (original)
+++ lucene/dev/trunk/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java Thu Mar 5 09:54:06 2015
@@ -80,6 +80,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
@ThreadLeakAction({Action.WARN})
@@ -744,19 +745,21 @@ public class MorphlineGoLiveMiniMRTest e
String shardList, String solrConfigOverride, String schemaOverride)
throws Exception {
- JettySolrRunner jetty
- = new JettySolrRunner(solrHome.getAbsolutePath(), solrConfigOverride, schemaOverride, buildJettyConfig(context));
+ Properties props = new Properties();
+ if (solrConfigOverride != null)
+ props.setProperty("solrconfig", solrConfigOverride);
+ if (schemaOverride != null)
+ props.setProperty("schema", schemaOverride);
+ props.setProperty("shards", shardList);
+
+ String collection = System.getProperty("collection");
+ if (collection == null)
+ collection = "collection1";
+ props.setProperty("collection", collection);
- jetty.setShards(shardList);
-
- if (System.getProperty("collection") == null) {
- System.setProperty("collection", "collection1");
- }
-
+ JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, buildJettyConfig(context));
jetty.start();
- System.clearProperty("collection");
-
return jetty;
}
Modified: lucene/dev/trunk/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java (original)
+++ lucene/dev/trunk/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/AbstractSolrMorphlineZkTestBase.java Thu Mar 5 09:54:06 2015
@@ -41,6 +41,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.Locale;
+import java.util.Properties;
public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistribZkTestBase {
private static File solrHomeDirectory;
@@ -144,19 +145,23 @@ public abstract class AbstractSolrMorphl
throws Exception {
writeCoreProperties(solrHome.toPath(), DEFAULT_TEST_CORENAME);
- JettySolrRunner jetty
- = new JettySolrRunner(solrHome.getAbsolutePath(), solrConfigOverride, schemaOverride, buildJettyConfig(context));
- jetty.setShards(shardList);
-
- if (System.getProperty("collection") == null) {
- System.setProperty("collection", "collection1");
- }
-
+ Properties props = new Properties();
+ if (solrConfigOverride != null)
+ props.setProperty("solrconfig", solrConfigOverride);
+ if (schemaOverride != null)
+ props.setProperty("schema", schemaOverride);
+ if (shardList != null)
+ props.setProperty("shards", shardList);
+
+ String collection = System.getProperty("collection");
+ if (collection == null)
+ collection = "collection1";
+ props.setProperty("collection", collection);
+
+ JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, buildJettyConfig(context));
jetty.start();
- System.clearProperty("collection");
-
return jetty;
}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java Thu Mar 5 09:54:06 2015
@@ -32,9 +32,10 @@ import org.eclipse.jetty.servlet.Servlet
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlets.GzipFilter;
import org.eclipse.jetty.util.component.LifeCycle;
-import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
@@ -51,6 +52,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.EnumSet;
import java.util.LinkedList;
+import java.util.Properties;
import java.util.Random;
import java.util.SortedMap;
import java.util.concurrent.TimeUnit;
@@ -63,41 +65,28 @@ import java.util.concurrent.atomic.Atomi
*/
public class JettySolrRunner {
- private static final AtomicLong JETTY_ID_COUNTER = new AtomicLong();
+ private static final Logger logger = LoggerFactory.getLogger(JettySolrRunner.class);
Server server;
FilterHolder dispatchFilter;
FilterHolder debugFilter;
- private String solrConfigFilename;
- private String schemaFilename;
- private final String coreRootDirectory;
-
private boolean waitOnSolr = false;
-
private int lastPort = -1;
- private final JettyConfig config;
-
- private String shards;
- private String dataDir;
- private String solrUlogDir;
+ private final JettyConfig config;
+ private final String solrHome;
+ private final Properties nodeProperties;
private volatile boolean startedBefore = false;
- private final String solrHome;
-
- private String coreNodeName;
-
- private final String name;
-
private LinkedList<FilterHolder> extraFilters;
private int proxyPort = -1;
public static class DebugFilter implements Filter {
- public int requestsToKeep = 10;
+
private AtomicLong nRequests = new AtomicLong();
public long getTotalRequests() {
@@ -105,13 +94,8 @@ public class JettySolrRunner {
}
- // TODO: keep track of certain number of last requests
- private LinkedList<HttpServletRequest> requests = new LinkedList<>();
-
-
@Override
- public void init(FilterConfig filterConfig) throws ServletException {
- }
+ public void init(FilterConfig filterConfig) throws ServletException { }
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
@@ -120,25 +104,49 @@ public class JettySolrRunner {
}
@Override
- public void destroy() {
- }
+ public void destroy() { }
+
}
+ private static Properties defaultNodeProperties(String solrconfigFilename, String schemaFilename) {
+ Properties props = new Properties();
+ props.setProperty("solrconfig", solrconfigFilename);
+ props.setProperty("schema", schemaFilename);
+ return props;
+ }
+
+ /**
+ * Create a new JettySolrRunner.
+ *
+ * After construction, you must start the jetty with {@link #start()}
+ *
+ * @param solrHome the solr home directory to use
+ * @param context the context to run in
+ * @param port the port to run on
+ */
public JettySolrRunner(String solrHome, String context, int port) {
this(solrHome, JettyConfig.builder().setContext(context).setPort(port).build());
}
+ /**
+ * @deprecated use {@link #JettySolrRunner(String,Properties,JettyConfig)}
+ */
+ @Deprecated
public JettySolrRunner(String solrHome, String context, int port, String solrConfigFilename, String schemaFileName) {
- this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
+ this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName), JettyConfig.builder()
.setContext(context)
.setPort(port)
.build());
}
+ /**
+ * @deprecated use {@link #JettySolrRunner(String,Properties,JettyConfig)}
+ */
@Deprecated
public JettySolrRunner(String solrHome, String context, int port,
String solrConfigFilename, String schemaFileName, boolean stopAtShutdown) {
- this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
+ this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName),
+ JettyConfig.builder()
.setContext(context)
.setPort(port)
.stopAtShutdown(stopAtShutdown)
@@ -148,13 +156,14 @@ public class JettySolrRunner {
/**
* Constructor taking an ordered list of additional (servlet holder -> path spec) mappings
* to add to the servlet context
- * @deprecated use {@link #JettySolrRunner(String,String,String,JettyConfig)}
+ * @deprecated use {@link JettySolrRunner#JettySolrRunner(String,Properties,JettyConfig)}
*/
@Deprecated
public JettySolrRunner(String solrHome, String context, int port,
String solrConfigFilename, String schemaFileName, boolean stopAtShutdown,
SortedMap<ServletHolder,String> extraServlets) {
- this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
+ this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName),
+ JettyConfig.builder()
.setContext(context)
.setPort(port)
.stopAtShutdown(stopAtShutdown)
@@ -162,10 +171,14 @@ public class JettySolrRunner {
.build());
}
+ /**
+ * @deprecated use {@link #JettySolrRunner(String,Properties,JettyConfig)}
+ */
@Deprecated
public JettySolrRunner(String solrHome, String context, int port, String solrConfigFilename, String schemaFileName,
boolean stopAtShutdown, SortedMap<ServletHolder, String> extraServlets, SSLConfig sslConfig) {
- this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
+ this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName),
+ JettyConfig.builder()
.setContext(context)
.setPort(port)
.stopAtShutdown(stopAtShutdown)
@@ -174,11 +187,15 @@ public class JettySolrRunner {
.build());
}
+ /**
+ * @deprecated use {@link #JettySolrRunner(String,Properties,JettyConfig)}
+ */
@Deprecated
public JettySolrRunner(String solrHome, String context, int port, String solrConfigFilename, String schemaFileName,
boolean stopAtShutdown, SortedMap<ServletHolder, String> extraServlets, SSLConfig sslConfig,
SortedMap<Class<? extends Filter>, String> extraRequestFilters) {
- this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
+ this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName),
+ JettyConfig.builder()
.setContext(context)
.setPort(port)
.stopAtShutdown(stopAtShutdown)
@@ -191,39 +208,35 @@ public class JettySolrRunner {
/**
* Construct a JettySolrRunner
*
+ * After construction, you must start the jetty with {@link #start()}
+ *
* @param solrHome the base path to run from
- * @param jettyConfig the configuration
+ * @param config the configuration
*/
- public JettySolrRunner(String solrHome, JettyConfig jettyConfig) {
- this(solrHome, null, null, jettyConfig);
+ public JettySolrRunner(String solrHome, JettyConfig config) {
+ this(solrHome, new Properties(), config);
}
/**
* Construct a JettySolrRunner
*
- * @param solrHome the base path to run from
- * @param solrConfigFilename the name of the solrconfig file to use
- * @param schemaFileName the name of the schema file to use
- * @param jettyConfig the configuration
+ * After construction, you must start the jetty with {@link #start()}
+ *
+ * @param solrHome the solrHome to use
+ * @param nodeProperties the container properties
+ * @param config the configuration
*/
- public JettySolrRunner(String solrHome, String solrConfigFilename, String schemaFileName, JettyConfig jettyConfig) {
-
- this.solrConfigFilename = solrConfigFilename;
- this.schemaFilename = schemaFileName;
-
- this.name = "jetty-" + JETTY_ID_COUNTER.incrementAndGet();
- this.coreRootDirectory = System.getProperty("coreRootDirectory", null);
+ public JettySolrRunner(String solrHome, Properties nodeProperties, JettyConfig config) {
- this.config = jettyConfig;
this.solrHome = solrHome;
+ this.config = config;
+ this.nodeProperties = nodeProperties;
this.init(this.config.port);
}
private void init(int port) {
- System.setProperty("solr.solr.home", solrHome);
-
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setMaxThreads(10000);
qtp.setIdleTimeout((int) TimeUnit.SECONDS.toMillis(5));
@@ -281,7 +294,6 @@ public class JettySolrRunner {
@Override
public void lifeCycleStopping(LifeCycle arg0) {
- System.clearProperty("hostPort");
}
@Override
@@ -299,14 +311,13 @@ public class JettySolrRunner {
public void lifeCycleStarted(LifeCycle arg0) {
lastPort = getFirstConnectorPort();
+ nodeProperties.setProperty("hostPort", Integer.toString(lastPort));
+ nodeProperties.setProperty("hostContext", config.context);
- System.setProperty("hostPort", Integer.toString(lastPort));
- if (solrConfigFilename != null) System.setProperty("solrconfig",
- solrConfigFilename);
- if (schemaFilename != null) System.setProperty("schema",
- schemaFilename);
- if (coreRootDirectory != null)
- System.setProperty("coreRootDirectory", coreRootDirectory);
+ root.getServletContext().setAttribute(SolrDispatchFilter.PROPERTIES_ATTRIBUTE, nodeProperties);
+ root.getServletContext().setAttribute(SolrDispatchFilter.SOLRHOME_ATTRIBUTE, solrHome);
+
+ logger.info("Jetty properties: {}", nodeProperties);
debugFilter = root.addFilter(DebugFilter.class, "*", EnumSet.of(DispatcherType.REQUEST) );
extraFilters = new LinkedList<>();
@@ -322,9 +333,6 @@ public class JettySolrRunner {
dispatchFilter = root.addFilter(SolrDispatchFilter.class, "*", EnumSet.of(DispatcherType.REQUEST) );
- if (solrConfigFilename != null) System.clearProperty("solrconfig");
- if (schemaFilename != null) System.clearProperty("schema");
- System.clearProperty("solr.solr.home");
}
@Override
@@ -338,8 +346,6 @@ public class JettySolrRunner {
}
-
-
public FilterHolder getDispatchFilter() {
return dispatchFilter;
}
@@ -355,11 +361,12 @@ public class JettySolrRunner {
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
+ /**
+ * Start the Jetty server
+ *
+ * @throws Exception if an error occurs on startup
+ */
public void start() throws Exception {
- start(true);
- }
-
- public void start(boolean waitForSolr) throws Exception {
// if started before, make a new server
if (startedBefore) {
waitOnSolr = false;
@@ -367,50 +374,33 @@ public class JettySolrRunner {
} else {
startedBefore = true;
}
-
- if (dataDir != null) {
- System.setProperty("solr.data.dir", dataDir);
- }
- if (solrUlogDir != null) {
- System.setProperty("solr.ulog.dir", solrUlogDir);
- }
- if (shards != null) {
- System.setProperty("shard", shards);
- }
- if (coreNodeName != null) {
- System.setProperty("coreNodeName", coreNodeName);
+
+ if (!server.isRunning()) {
+ server.start();
}
- try {
-
- if (!server.isRunning()) {
- server.start();
- }
- synchronized (JettySolrRunner.this) {
- int cnt = 0;
- while (!waitOnSolr) {
- this.wait(100);
- if (cnt++ == 5) {
- throw new RuntimeException("Jetty/Solr unresponsive");
- }
+ synchronized (JettySolrRunner.this) {
+ int cnt = 0;
+ while (!waitOnSolr) {
+ this.wait(100);
+ if (cnt++ == 5) {
+ throw new RuntimeException("Jetty/Solr unresponsive");
}
}
- } finally {
-
- System.clearProperty("shard");
- System.clearProperty("solr.data.dir");
- System.clearProperty("coreNodeName");
- System.clearProperty("solr.ulog.dir");
}
-
+
}
+ /**
+ * Stop the Jetty server
+ *
+ * @throws Exception if an error occurs on shutdown
+ */
public void stop() throws Exception {
Filter filter = dispatchFilter.getFilter();
server.stop();
- //server.destroy();
if (server.getState().equals(Server.FAILED)) {
filter.destroy();
if (extraFilters != null) {
@@ -512,118 +502,42 @@ public class JettySolrRunner {
}
}
+ /**
+ * @deprecated set properties in the Properties passed to the constructor
+ */
+ @Deprecated
public void setShards(String shardList) {
- this.shards = shardList;
+ nodeProperties.setProperty("shard", shardList);
}
+ /**
+ * @deprecated set properties in the Properties passed to the constructor
+ */
+ @Deprecated
public void setDataDir(String dataDir) {
- this.dataDir = dataDir;
+ nodeProperties.setProperty("solr.data.dir", dataDir);
}
-
+
+ /**
+ * @deprecated set properties in the Properties passed to the constructor
+ */
+ @Deprecated
public void setUlogDir(String ulogDir) {
- this.solrUlogDir = ulogDir;
+ nodeProperties.setProperty("solr.ulog.dir", ulogDir);
}
+ /**
+ * @deprecated set properties in the Properties passed to the constructor
+ */
+ @Deprecated
public void setCoreNodeName(String coreNodeName) {
- this.coreNodeName = coreNodeName;
+ nodeProperties.setProperty("coreNodeName", coreNodeName);
}
+ /**
+ * @return the Solr home directory of this JettySolrRunner
+ */
public String getSolrHome() {
return solrHome;
}
}
-
-class NoLog implements Logger {
- private static boolean debug = System.getProperty("DEBUG", null) != null;
-
- private final String name;
-
- public NoLog() {
- this(null);
- }
-
- public NoLog(String name) {
- this.name = name == null ? "" : name;
- }
-
- @Override
- public boolean isDebugEnabled() {
- return debug;
- }
-
- @Override
- public void setDebugEnabled(boolean enabled) {
- debug = enabled;
- }
-
- @Override
- public void debug(String msg, Throwable th) {
- }
-
- @Override
- public Logger getLogger(String name) {
- if ((name == null && this.name == null)
- || (name != null && name.equals(this.name)))
- return this;
- return new NoLog(name);
- }
-
- @Override
- public String toString() {
- return "NOLOG[" + name + "]";
- }
-
- @Override
- public void debug(Throwable arg0) {
-
- }
-
- @Override
- public void debug(String arg0, Object... arg1) {
-
- }
-
- @Override
- public void debug(String s, long l) {
-
- }
-
- @Override
- public String getName() {
- return toString();
- }
-
- @Override
- public void ignore(Throwable arg0) {
-
- }
-
- @Override
- public void info(Throwable arg0) {
-
- }
-
- @Override
- public void info(String arg0, Object... arg1) {
-
- }
-
- @Override
- public void info(String arg0, Throwable arg1) {
-
- }
-
- @Override
- public void warn(Throwable arg0) {
-
- }
-
- @Override
- public void warn(String arg0, Object... arg1) {
-
- }
-
- @Override
- public void warn(String arg0, Throwable arg1) {
- }
-}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java Thu Mar 5 09:54:06 2015
@@ -161,14 +161,19 @@ public class CoreContainer {
* @see #load()
*/
public CoreContainer(NodeConfig config) {
- this(config, new CorePropertiesLocator(config.getCoreRootDirectory()));
+ this(config, new Properties());
}
- public CoreContainer(NodeConfig config, CoresLocator locator) {
+ public CoreContainer(NodeConfig config, Properties properties) {
+ this(config, properties, new CorePropertiesLocator(config.getCoreRootDirectory()));
+ }
+
+ public CoreContainer(NodeConfig config, Properties properties, CoresLocator locator) {
this.loader = config.getSolrResourceLoader();
this.solrHome = loader.getInstanceDir();
this.cfg = checkNotNull(config);
this.coresLocator = locator;
+ this.containerProperties = new Properties(properties);
}
/**
@@ -183,6 +188,7 @@ public class CoreContainer {
loader = null;
coresLocator = null;
cfg = null;
+ containerProperties = null;
}
/**
@@ -250,7 +256,7 @@ public class CoreContainer {
coreConfigService = ConfigSetService.createConfigSetService(cfg, loader, zkSys.zkController);
- containerProperties = cfg.getSolrProperties();
+ containerProperties.putAll(cfg.getSolrProperties());
// setup executor to load cores in parallel
// do not limit the size of the executor in zk mode since cores may try and wait for each other.
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java Thu Mar 5 09:54:06 2015
@@ -206,6 +206,8 @@ public class CoreDescriptor {
else {
cloudDesc = null;
}
+
+ System.out.println("CORE DESCRIPTOR: " + coreProperties);
}
/**
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java Thu Mar 5 09:54:06 2015
@@ -16,6 +16,7 @@ package org.apache.solr.handler.componen
* limitations under the License.
*/
+import com.google.common.base.Strings;
import org.apache.http.client.HttpClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
@@ -177,6 +178,8 @@ public class HttpShardHandler extends Sh
public void submit(final ShardRequest sreq, final String shard, final ModifiableSolrParams params) {
// do this outside of the callable for thread safety reasons
final List<String> urls = getURLs(sreq, shard);
+ if (Strings.isNullOrEmpty(shard))
+ System.out.println("Empty shard!");
Callable<ShardResponse> task = new Callable<ShardResponse>() {
@Override
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java Thu Mar 5 09:54:06 2015
@@ -96,10 +96,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.Set;
-import static java.util.Collections.singletonMap;
-
/**
* This filter looks at the incoming URL maps them to handlers defined in solrconfig.xml
*
@@ -120,6 +119,10 @@ public class SolrDispatchFilter extends
public SolrDispatchFilter() {
}
+
+ public static final String PROPERTIES_ATTRIBUTE = "solr.properties";
+
+ public static final String SOLRHOME_ATTRIBUTE = "solr.solr.home";
@Override
public void init(FilterConfig config) throws ServletException
@@ -130,7 +133,16 @@ public class SolrDispatchFilter extends
// web.xml configuration
this.pathPrefix = config.getInitParameter( "path-prefix" );
- this.cores = createCoreContainer();
+ Properties extraProperties = (Properties) config.getServletContext().getAttribute(PROPERTIES_ATTRIBUTE);
+ if (extraProperties == null)
+ extraProperties = new Properties();
+
+ String solrHome = (String) config.getServletContext().getAttribute(SOLRHOME_ATTRIBUTE);
+ if (solrHome == null)
+ solrHome = SolrResourceLoader.locateSolrHome();
+
+ this.cores = createCoreContainer(solrHome, extraProperties);
+
log.info("user.dir=" + System.getProperty("user.dir"));
}
catch( Throwable t ) {
@@ -145,7 +157,20 @@ public class SolrDispatchFilter extends
log.info("SolrDispatchFilter.init() done");
}
- private NodeConfig loadConfigSolr(SolrResourceLoader loader) {
+ /**
+ * Override this to change CoreContainer initialization
+ * @return a CoreContainer to hold this server's cores
+ */
+ protected CoreContainer createCoreContainer(String solrHome, Properties extraProperties) {
+ NodeConfig nodeConfig = loadNodeConfig(solrHome, extraProperties);
+ cores = new CoreContainer(nodeConfig, extraProperties);
+ cores.load();
+ return cores;
+ }
+
+ private NodeConfig loadNodeConfig(String solrHome, Properties nodeProperties) {
+
+ SolrResourceLoader loader = new SolrResourceLoader(solrHome, null, nodeProperties);
String solrxmlLocation = System.getProperty("solr.solrxml.location", "solrhome");
@@ -158,34 +183,19 @@ public class SolrDispatchFilter extends
if (StringUtils.isEmpty(zkHost))
throw new SolrException(ErrorCode.SERVER_ERROR,
"Could not load solr.xml from zookeeper: zkHost system property not set");
- SolrZkClient zkClient = new SolrZkClient(zkHost, 30000);
- try {
+ try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
if (!zkClient.exists("/solr.xml", true))
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not load solr.xml from zookeeper: node not found");
byte[] data = zkClient.getData("/solr.xml", null, null, true);
return SolrXmlConfig.fromInputStream(loader, new ByteArrayInputStream(data));
} catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not load solr.xml from zookeeper", e);
- } finally {
- zkClient.close();
}
}
throw new SolrException(ErrorCode.SERVER_ERROR,
"Bad solr.solrxml.location set: " + solrxmlLocation + " - should be 'solrhome' or 'zookeeper'");
}
-
- /**
- * Override this to change CoreContainer initialization
- * @return a CoreContainer to hold this server's cores
- */
- protected CoreContainer createCoreContainer() {
- SolrResourceLoader loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
- NodeConfig config = loadConfigSolr(loader);
- CoreContainer cores = new CoreContainer(config);
- cores.load();
- return cores;
- }
public CoreContainer getCores() {
return cores;
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestTolerantSearch.java Thu Mar 5 09:54:06 2015
@@ -58,7 +58,7 @@ public class TestTolerantSearch extends
@BeforeClass
public static void createThings() throws Exception {
solrHome = createSolrHome();
- createJetty(solrHome.getAbsolutePath(), null, null);
+ createJetty(solrHome.getAbsolutePath());
String url = jetty.getBaseUrl().toString();
collection1 = new HttpSolrClient(url + "/collection1");
collection2 = new HttpSolrClient(url + "/collection2");
Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java?rev=1664292&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java (added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java Thu Mar 5 09:54:06 2015
@@ -0,0 +1,74 @@
+package org.apache.solr.client.solrj.embedded;
+
+/*
+ * 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.
+ */
+
+import com.google.common.base.Charsets;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.junit.Test;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+
+public class TestJettySolrRunner extends SolrTestCaseJ4 {
+
+ @Test
+ public void testPassSolrHomeToRunner() throws Exception {
+
+ // We set a non-standard coreRootDirectory, create a core, and check that it has been
+ // built in the correct place
+
+ Path solrHome = createTempDir();
+ Path coresDir = createTempDir("crazy_path_to_cores");
+
+ Path configsets = Paths.get(TEST_HOME()).resolve("configsets");
+
+ String solrxml
+ = "<solr><str name=\"configSetBaseDir\">CONFIGSETS</str><str name=\"coreRootDirectory\">COREROOT</str></solr>"
+ .replace("CONFIGSETS", configsets.toString())
+ .replace("COREROOT", coresDir.toString());
+ Files.write(solrHome.resolve("solr.xml"), solrxml.getBytes(Charsets.UTF_8));
+
+ JettyConfig jettyConfig = buildJettyConfig("/solr");
+
+ JettySolrRunner runner = new JettySolrRunner(solrHome.toString(), new Properties(), jettyConfig);
+ try {
+ runner.start();
+
+ SolrClient client = new HttpSolrClient(runner.getBaseUrl().toString());
+
+ CoreAdminRequest.Create createReq = new CoreAdminRequest.Create();
+ createReq.setCoreName("newcore");
+ createReq.setConfigSet("minimal");
+
+ client.request(createReq);
+
+ assertTrue(Files.exists(coresDir.resolve("newcore").resolve("core.properties")));
+
+ }
+ finally {
+ runner.stop();
+ }
+
+ }
+
+}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Thu Mar 5 09:54:06 2015
@@ -100,7 +100,7 @@ import static org.apache.solr.common.clo
*/
@Slow
public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
-
+
private static final String DEFAULT_COLLECTION = "collection1";
private static final boolean DEBUG = false;
@@ -646,6 +646,7 @@ public class CollectionsAPIDistributedZk
if (random().nextBoolean()) {
JettySolrRunner jetty = jettys.get(random().nextInt(jettys.size()));
ChaosMonkey.stop(jetty);
+ log.info("============ Restarting jetty");
ChaosMonkey.start(jetty);
for (Entry<String,List<Integer>> entry : collectionInfosEntrySet) {
@@ -665,6 +666,7 @@ public class CollectionsAPIDistributedZk
// sometimes we restart zookeeper
if (random().nextBoolean()) {
zkServer.shutdown();
+ log.info("============ Restarting zookeeper");
zkServer = new ZkTestServer(zkServer.getZkDir(), zkServer.getPort());
zkServer.run();
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java Thu Mar 5 09:54:06 2015
@@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Properties;
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
@@ -81,9 +82,16 @@ public class SSLMigrationTest extends Ab
.withFilters(getExtraRequestFilters())
.withSSLConfig(sslConfig)
.build();
- JettySolrRunner newRunner = new JettySolrRunner(runner.getSolrHome(), getSolrConfigFile(), getSchemaFile(), config);
- newRunner.setDataDir(getDataDir(testDir + "/shard" + i + "/data"));
- newRunner.start(true);
+
+ Properties props = new Properties();
+ if (getSolrConfigFile() != null)
+ props.setProperty("solrconfig", getSolrConfigFile());
+ if (getSchemaFile() != null)
+ props.setProperty("schema", getSchemaFile());
+ props.setProperty("solr.data.dir", getDataDir(testDir + "/shard" + i + "/data"));
+
+ JettySolrRunner newRunner = new JettySolrRunner(runner.getSolrHome(), props, config);
+ newRunner.start();
jettys.set(i, newRunner);
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java Thu Mar 5 09:54:06 2015
@@ -20,7 +20,6 @@ package org.apache.solr.cloud;
import org.junit.BeforeClass;
import org.junit.Test;
-
public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {
String collection = DEFAULT_COLLECTION; // enable this to be configurable (more work needs to be done)
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java Thu Mar 5 09:54:06 2015
@@ -23,7 +23,6 @@ import org.apache.solr.common.SolrExcept
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.NodeConfig;
-import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.junit.After;
import org.junit.Before;
@@ -36,6 +35,7 @@ import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
+import java.util.Properties;
public class SolrXmlInZkTest extends SolrTestCaseJ4 {
@@ -74,8 +74,6 @@ public class SolrXmlInZkTest extends Sol
FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr-stress-new.xml"), new File(solrHome, "solr.xml"));
}
- System.setProperty("solr.solr.home", solrHome.getAbsolutePath());
-
ignoreException("No UpdateLog found - cannot sync");
ignoreException("No UpdateLog found - cannot recover");
@@ -100,14 +98,15 @@ public class SolrXmlInZkTest extends Sol
log.info("####SETUP_START " + getTestName());
// set some system properties for use by tests
- System.setProperty("solr.test.sys.prop1", "propone");
- System.setProperty("solr.test.sys.prop2", "proptwo");
+ Properties props = new Properties();
+ props.setProperty("solr.test.sys.prop1", "propone");
+ props.setProperty("solr.test.sys.prop2", "proptwo");
- Method method = SolrDispatchFilter.class.getDeclaredMethod("loadConfigSolr", SolrResourceLoader.class);
+ Method method = SolrDispatchFilter.class.getDeclaredMethod("loadNodeConfig", String.class, Properties.class);
method.setAccessible(true);
if (solrDispatchFilter != null) solrDispatchFilter.destroy();
solrDispatchFilter = new SolrDispatchFilter();
- Object obj = method.invoke(solrDispatchFilter, new SolrResourceLoader(null));
+ Object obj = method.invoke(solrDispatchFilter, solrHome.getAbsolutePath(), props);
cfg = (NodeConfig) obj;
log.info("####SETUP_END " + getTestName());
@@ -208,11 +207,11 @@ public class SolrXmlInZkTest extends Sol
// Should see an error when zkHost is not defined but solr.solrxml.location is set to zookeeper.
System.clearProperty("zkHost");
try {
- Method method = SolrDispatchFilter.class.getDeclaredMethod("loadConfigSolr", SolrResourceLoader.class);
+ Method method = SolrDispatchFilter.class.getDeclaredMethod("loadNodeConfig", String.class, Properties.class);
method.setAccessible(true);
if (solrDispatchFilter != null) solrDispatchFilter.destroy();
solrDispatchFilter = new SolrDispatchFilter();
- method.invoke(solrDispatchFilter, new SolrResourceLoader(null));
+ method.invoke(solrDispatchFilter, "", new Properties());
fail("Should have thrown an exception");
} catch (InvocationTargetException ite) {
assertTrue("Should be catching a SolrException", ite.getTargetException() instanceof SolrException);
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java Thu Mar 5 09:54:06 2015
@@ -36,6 +36,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.regex.Pattern;
@@ -203,7 +204,7 @@ public class TestCoreContainer extends S
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
- final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), cl);
+ final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
CoreDescriptor badcore = new CoreDescriptor(cc, "badcore", "badcore", "configSet", "nosuchconfigset");
cl.add(badcore);
@@ -452,7 +453,7 @@ public class TestCoreContainer extends S
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
- final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), cl);
+ final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
cl.add(new CoreDescriptor(cc, "col_ok", "col_ok", "configSet", "minimal"));
cl.add(new CoreDescriptor(cc, "col_bad", "col_bad", "configSet", "bad-mergepolicy"));
cc.load();
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Thu Mar 5 09:54:06 2015
@@ -1050,7 +1050,7 @@ public class TestReplicationHandler exte
// tries to
// replicate
masterJetty.stop();
- masterJetty.start(true);
+ masterJetty.start();
// masterClient = createNewSolrClient(masterJetty.getLocalPort());
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java Thu Mar 5 09:54:06 2015
@@ -42,7 +42,7 @@ public class ShowFileRequestHandlerTest
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
public void test404ViaHttp() throws SolrServerException, IOException {
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java Thu Mar 5 09:54:06 2015
@@ -64,7 +64,7 @@ public class DistributedDebugComponentTe
@BeforeClass
public static void createThings() throws Exception {
solrHome = createSolrHome();
- createJetty(solrHome.getAbsolutePath(), null, null);
+ createJetty(solrHome.getAbsolutePath());
String url = jetty.getBaseUrl().toString();
collection1 = new HttpSolrClient(url + "/collection1");
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestRemoteStreaming.java Thu Mar 5 09:54:06 2015
@@ -57,7 +57,7 @@ public class TestRemoteStreaming extends
//this one has handleSelect=true which a test here needs
solrHomeDirectory = createTempDir(LuceneTestCase.getTestClass().getSimpleName()).toFile();
setupJettyTestHome(solrHomeDirectory, "collection1");
- createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
+ createJetty(solrHomeDirectory.getAbsolutePath());
}
@AfterClass
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/TestBinaryField.java Thu Mar 5 09:54:06 2015
@@ -71,7 +71,7 @@ public class TestBinaryField extends Sol
coreProps.store(w, "");
}
- createJetty(homeDir.getAbsolutePath(), null, null);
+ createJetty(homeDir.getAbsolutePath());
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java Thu Mar 5 09:54:06 2015
@@ -18,15 +18,6 @@ package org.apache.solr.servlet;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.util.Arrays;
-import java.util.Date;
-
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpRequestBase;
@@ -36,6 +27,15 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.Date;
+
/**
* A test case for the several HTTP cache headers emitted by Solr
*/
@@ -46,7 +46,7 @@ public class CacheHeaderTest extends Cac
public static void beforeTest() throws Exception {
solrHomeDirectory = createTempDir().toFile();
setupJettyTestHome(solrHomeDirectory, "collection1");
- createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
+ createJetty(solrHomeDirectory.getAbsolutePath());
}
@AfterClass
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/ResponseHeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/ResponseHeaderTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/ResponseHeaderTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/ResponseHeaderTest.java Thu Mar 5 09:54:06 2015
@@ -17,13 +17,6 @@ package org.apache.solr.servlet;
* limitations under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
import org.apache.commons.io.FileUtils;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
@@ -40,6 +33,13 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
public class ResponseHeaderTest extends SolrJettyTestBase {
@@ -51,7 +51,7 @@ public class ResponseHeaderTest extends
setupJettyTestHome(solrHomeDirectory, "collection1");
String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
FileUtils.copyFile(new File(top, "solrconfig-headers.xml"), new File(solrHomeDirectory + "/collection1/conf", "solrconfig.xml"));
- createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
+ createJetty(solrHomeDirectory.getAbsolutePath());
}
@AfterClass
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java Thu Mar 5 09:54:06 2015
@@ -90,9 +90,12 @@ public class SolrCmdDistributorTest exte
protected void createServers(int numShards) throws Exception {
System.setProperty("configSetBaseDir", TEST_HOME());
- System.setProperty("coreRootDirectory", testDir.toPath().resolve("control").toString());
- writeCoreProperties(testDir.toPath().resolve("control/cores"), DEFAULT_TEST_CORENAME);
- controlJetty = createJetty(new File(getSolrHome()), testDir + "/control/data", null, getSolrConfigFile(), getSchemaFile());
+
+ File controlHome = testDir.toPath().resolve("control").toFile();
+
+ seedSolrHome(controlHome);
+ writeCoreProperties(controlHome.toPath().resolve("cores").resolve(DEFAULT_TEST_CORENAME), DEFAULT_TEST_CORENAME);
+ controlJetty = createJetty(controlHome, testDir + "/control/data", null, getSolrConfigFile(), getSchemaFile());
controlClient = createNewSolrClient(controlJetty.getLocalPort());
@@ -101,10 +104,11 @@ public class SolrCmdDistributorTest exte
for (int i = 0; i < numShards; i++) {
if (sb.length() > 0) sb.append(',');
String shardname = "shard" + i;
- Path coresPath = testDir.toPath().resolve(shardname).resolve("cores");
- writeCoreProperties(coresPath, DEFAULT_TEST_CORENAME);
- System.setProperty("coreRootDirectory", testDir.toPath().resolve(shardname).toString());
- JettySolrRunner j = createJetty(new File(getSolrHome()),
+ Path shardHome = testDir.toPath().resolve(shardname);
+ seedSolrHome(shardHome.toFile());
+ Path coresPath = shardHome.resolve("cores");
+ writeCoreProperties(coresPath.resolve(DEFAULT_TEST_CORENAME), DEFAULT_TEST_CORENAME);
+ JettySolrRunner j = createJetty(shardHome.toFile(),
testDir + "/shard" + i + "/data", null, getSolrConfigFile(),
getSchemaFile());
jettys.add(j);
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java Thu Mar 5 09:54:06 2015
@@ -87,6 +87,7 @@ import java.util.concurrent.Future;
*/
@SuppressWarnings("serial")
public class CloudSolrClient extends SolrClient {
+
protected static final Logger log = LoggerFactory.getLogger(CloudSolrClient.class);
private volatile ZkStateReader zkStateReader;
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java Thu Mar 5 09:54:06 2015
@@ -32,7 +32,7 @@ import org.junit.BeforeClass;
public class SolrExampleBinaryTest extends SolrExampleTests {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
@Override
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java Thu Mar 5 09:54:06 2015
@@ -31,7 +31,7 @@ import org.junit.BeforeClass;
public class SolrExampleXMLTest extends SolrExampleTests {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
@Override
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java Thu Mar 5 09:54:06 2015
@@ -68,7 +68,7 @@ public class SolrSchemalessExampleTest e
} catch (Exception ignore){}
}
}
- createJetty(tempSolrHome.getAbsolutePath(), null, null);
+ createJetty(tempSolrHome.getAbsolutePath());
}
@Test
public void testArbitraryJsonIndexing() throws Exception {
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java Thu Mar 5 09:54:06 2015
@@ -41,7 +41,7 @@ public class TestBatchUpdate extends Sol
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
static final int numdocs = 1000;
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java Thu Mar 5 09:54:06 2015
@@ -46,6 +46,7 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Properties;
import java.util.Set;
/**
@@ -309,13 +310,14 @@ public class TestLBHttpSolrClient extend
}
public void startJetty() throws Exception {
- jetty = new JettySolrRunner(getHomeDir(), "bad_solrconfig.xml", null, JettyConfig.builder()
- .setContext("/solr")
- .stopAtShutdown(true)
- .setPort(port)
- .withSSLConfig(sslConfig)
- .build());
- jetty.setDataDir(getDataDir());
+
+ Properties props = new Properties();
+ props.setProperty("solrconfig", "bad_solrconfig.xml");
+ props.setProperty("solr.data.dir", getDataDir());
+
+ JettyConfig jettyConfig = JettyConfig.builder(buildJettyConfig("/solr")).setPort(port).build();
+
+ jetty = new JettySolrRunner(getHomeDir(), props, jettyConfig);
jetty.start();
int newPort = jetty.getLocalPort();
if (port != 0 && newPort != port) {
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java Thu Mar 5 09:54:06 2015
@@ -27,6 +27,6 @@ import org.junit.BeforeClass;
public class LargeVolumeBinaryJettyTest extends LargeVolumeTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
}
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java Thu Mar 5 09:54:06 2015
@@ -24,6 +24,6 @@ import org.junit.BeforeClass;
public class LargeVolumeJettyTest extends LargeVolumeTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
}
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java Thu Mar 5 09:54:06 2015
@@ -46,7 +46,7 @@ public class SolrExampleJettyTest extend
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
@Test
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java Thu Mar 5 09:54:06 2015
@@ -44,7 +44,7 @@ public class SolrExampleStreamingTest ex
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
@Override
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java Thu Mar 5 09:54:06 2015
@@ -27,6 +27,7 @@ import org.apache.solr.client.solrj.Solr
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
@@ -36,6 +37,7 @@ import org.apache.solr.common.SolrInputD
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.util.SSLTestConfig;
+import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -147,13 +149,13 @@ public class BasicHttpSolrClientTest ext
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
- jetty.getDispatchFilter().getServletHandler()
- .addServletWithMapping(RedirectServlet.class, "/redirect/*");
- jetty.getDispatchFilter().getServletHandler()
- .addServletWithMapping(SlowServlet.class, "/slow/*");
- jetty.getDispatchFilter().getServletHandler()
- .addServletWithMapping(DebugServlet.class, "/debug/*");
+ JettyConfig jettyConfig = JettyConfig.builder()
+ .withServlet(new ServletHolder(RedirectServlet.class), "/redirect/*")
+ .withServlet(new ServletHolder(SlowServlet.class), "/slow/*")
+ .withServlet(new ServletHolder(DebugServlet.class), "/debug/*")
+ .withSSLConfig(sslConfig)
+ .build();
+ createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
}
@Test
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java Thu Mar 5 09:54:06 2015
@@ -19,10 +19,12 @@ package org.apache.solr.client.solrj.imp
import org.apache.http.HttpResponse;
import org.apache.solr.SolrJettyTestBase;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.SolrjNamedThreadFactory;
+import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -123,9 +125,11 @@ public class ConcurrentUpdateSolrClientT
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
- jetty.getDispatchFilter().getServletHandler()
- .addServletWithMapping(TestServlet.class, "/cuss/*");
+ JettyConfig jettyConfig = JettyConfig.builder()
+ .withServlet(new ServletHolder(TestServlet.class), "/cuss/*")
+ .withSSLConfig(sslConfig)
+ .build();
+ createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
}
@Test
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java Thu Mar 5 09:54:06 2015
@@ -25,6 +25,8 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
+import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -32,9 +34,11 @@ import org.junit.Test;
public class ExternalHttpClientTest extends SolrJettyTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
- jetty.getDispatchFilter().getServletHandler()
- .addServletWithMapping(BasicHttpSolrClientTest.SlowServlet.class, "/slow/*");
+ JettyConfig jettyConfig = JettyConfig.builder()
+ .withServlet(new ServletHolder(BasicHttpSolrClientTest.SlowServlet.class), "/slow/*")
+ .withSSLConfig(sslConfig)
+ .build();
+ createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
}
/**
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java Thu Mar 5 09:54:06 2015
@@ -55,7 +55,7 @@ public class NoOpResponseParserTest exte
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(legacyExampleCollection1SolrHome(), null, null);
+ createJetty(legacyExampleCollection1SolrHome());
}
@Before
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java Thu Mar 5 09:54:06 2015
@@ -310,8 +310,7 @@ public abstract class BaseDistributedSea
Path jettyHome = testDir.toPath().resolve("control");
File jettyHomeFile = jettyHome.toFile();
seedSolrHome(jettyHomeFile);
- seedCoreRootDirWithDefaultTestCore(jettyHome);
- System.setProperty("coreRootDirectory", jettyHome.toString());
+ seedCoreRootDirWithDefaultTestCore(jettyHome.resolve("cores"));
JettySolrRunner jetty = createJetty(jettyHomeFile, null, null, getSolrConfigFile(), getSchemaFile());
return jetty;
}
@@ -331,10 +330,8 @@ public abstract class BaseDistributedSea
Path jettyHome = testDir.toPath().resolve(shardname);
File jettyHomeFile = jettyHome.toFile();
seedSolrHome(jettyHomeFile);
- seedCoreRootDirWithDefaultTestCore(jettyHome);
- System.setProperty("coreRootDirectory", jettyHome.toString());
+ seedCoreRootDirWithDefaultTestCore(jettyHome.resolve("cores"));
JettySolrRunner j = createJetty(jettyHomeFile, null, null, getSolrConfigFile(), getSchemaFile());
-
jettys.add(j);
clients.add(createNewSolrClient(j.getLocalPort()));
String shardStr = buildUrl(j.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME;
@@ -396,18 +393,29 @@ public abstract class BaseDistributedSea
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, boolean explicitCoreNodeName) throws Exception {
- JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), solrConfigOverride, schemaOverride, JettyConfig.builder()
+ Properties props = new Properties();
+ if (solrConfigOverride != null)
+ props.setProperty("solrconfig", solrConfigOverride);
+ if (schemaOverride != null)
+ props.setProperty("schema", schemaOverride);
+ if (shardList != null)
+ props.setProperty("shards", shardList);
+ if (dataDir != null) {
+ props.setProperty("solr.data.dir", dataDir);
+ }
+ if (explicitCoreNodeName) {
+ props.setProperty("coreNodeName", Integer.toString(nodeCnt.incrementAndGet()));
+ }
+ props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
+
+ JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, JettyConfig.builder()
.stopAtShutdown(true)
.setContext(context)
.withFilters(getExtraRequestFilters())
.withServlets(getExtraServlets())
.withSSLConfig(sslConfig)
.build());
- jetty.setShards(shardList);
- jetty.setDataDir(dataDir);
- if (explicitCoreNodeName) {
- jetty.setCoreNodeName(Integer.toString(nodeCnt.incrementAndGet()));
- }
+
jetty.start();
return jetty;
@@ -1051,7 +1059,7 @@ public abstract class BaseDistributedSea
* directory with the contents of {@link #getSolrHome} and ensures that the proper {@link #getSolrXml}
* file is in place.
*/
- private void seedSolrHome(File jettyHome) throws IOException {
+ protected void seedSolrHome(File jettyHome) throws IOException {
FileUtils.copyDirectory(new File(getSolrHome()), jettyHome);
String solrxml = getSolrXml();
if (solrxml != null) {
@@ -1087,7 +1095,7 @@ public abstract class BaseDistributedSea
coreProperties.setProperty("schema", "${schema:schema.xml}");
coreProperties.setProperty("coreNodeName", "${coreNodeName:}");
- writeCoreProperties(jettyHome.toPath().resolve("cores/collection1"), coreProperties, "collection1");
+ writeCoreProperties(jettyHome.toPath().resolve("cores").resolve("collection1"), coreProperties, "collection1");
// <core name="collection1" instanceDir="collection1" shard="${shard:}"
// collection="${collection:collection1}" config="${solrconfig:solrconfig.xml}" schema="${schema:schema.xml}"
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java Thu Mar 5 09:54:06 2015
@@ -57,13 +57,47 @@ abstract public class SolrJettyTestBase
boolean stopAtShutdown, SortedMap<ServletHolder,String> extraServlets)
throws Exception {
// creates the data dir
+
+ context = context==null ? "/solr" : context;
+ SolrJettyTestBase.context = context;
+
+ JettyConfig jettyConfig = JettyConfig.builder()
+ .setContext(context)
+ .stopAtShutdown(stopAtShutdown)
+ .withServlets(extraServlets)
+ .withSSLConfig(sslConfig)
+ .build();
+
+ Properties nodeProps = new Properties();
+ if (configFile != null)
+ nodeProps.setProperty("solrconfig", configFile);
+ if (schemaFile != null)
+ nodeProps.setProperty("schema", schemaFile);
+ if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
+ nodeProps.setProperty("solr.data.dir", createTempDir().toFile().getCanonicalPath());
+ }
+
+ return createJetty(solrHome, nodeProps, jettyConfig);
+ }
+
+ public static JettySolrRunner createJetty(String solrHome, String configFile, String context) throws Exception {
+ return createJetty(solrHome, configFile, null, context, true, null);
+ }
+
+ public static JettySolrRunner createJetty(String solrHome, JettyConfig jettyConfig) throws Exception {
+ return createJetty(solrHome, new Properties(), jettyConfig);
+ }
+
+ public static JettySolrRunner createJetty(String solrHome) throws Exception {
+ return createJetty(solrHome, new Properties(), JettyConfig.builder().withSSLConfig(sslConfig).build());
+ }
+
+ public static JettySolrRunner createJetty(String solrHome, Properties nodeProperties, JettyConfig jettyConfig) throws Exception {
+
initCore(null, null, solrHome);
Path coresDir = createTempDir().resolve("cores");
- System.setProperty("coreRootDirectory", coresDir.toString());
- System.setProperty("configSetBaseDir", solrHome);
-
Properties props = new Properties();
props.setProperty("name", DEFAULT_TEST_CORENAME);
props.setProperty("configSet", "collection1");
@@ -72,35 +106,19 @@ abstract public class SolrJettyTestBase
writeCoreProperties(coresDir.resolve("core"), props, "RestTestBase");
- ignoreException("maxWarmingSearchers");
-
- context = context==null ? "/solr" : context;
- SolrJettyTestBase.context = context;
-
- JettyConfig jettyConfig = JettyConfig.builder()
- .setContext(context)
- .stopAtShutdown(stopAtShutdown)
- .withServlets(extraServlets)
- .withSSLConfig(sslConfig)
- .build();
+ Properties nodeProps = new Properties(nodeProperties);
+ nodeProps.setProperty("coreRootDirectory", coresDir.toString());
+ nodeProps.setProperty("configSetBaseDir", solrHome);
- jetty = new JettySolrRunner(solrHome, configFile, schemaFile, jettyConfig);
+ ignoreException("maxWarmingSearchers");
- // this sets the property for jetty starting SolrDispatchFilter
- if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
- jetty.setDataDir(createTempDir().toFile().getCanonicalPath());
- }
-
+ jetty = new JettySolrRunner(solrHome, nodeProps, jettyConfig);
jetty.start();
port = jetty.getLocalPort();
log.info("Jetty Assigned Port#" + port);
return jetty;
}
- public static JettySolrRunner createJetty(String solrHome, String configFile, String context) throws Exception {
- return createJetty(solrHome, configFile, null, context, true, null);
- }
-
@AfterClass
public static void afterSolrJettyTestBase() throws Exception {
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1664292&r1=1664291&r2=1664292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Thu Mar 5 09:54:06 2015
@@ -76,6 +76,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -281,7 +282,6 @@ public abstract class AbstractFullDistri
File controlJettyDir = createTempDir("control").toFile();
setupJettySolrHome(controlJettyDir);
- System.setProperty("coreRootDirectory", controlJettyDir.toPath().resolve("cores").toString());
controlJetty = createJetty(controlJettyDir, useJettyDataDir ? getDataDir(testDir
+ "/control/data") : null); // don't pass shard name... let it default to
// "shard1"
@@ -391,8 +391,7 @@ public abstract class AbstractFullDistri
jettyDir.mkdirs();
setupJettySolrHome(jettyDir);
- log.info("create jetty " + i);
- System.setProperty("coreRootDirectory", jettyDir.toPath().resolve("cores").toString());
+ log.info("create jetty {} in directory {}", i, jettyDir);
JettySolrRunner j = createJetty(jettyDir, useJettyDataDir ? getDataDir(testDir + "/jetty"
+ cnt) : null, null, "solrconfig.xml", null);
jettys.add(j);
@@ -453,13 +452,13 @@ public abstract class AbstractFullDistri
int cnt = this.jettyIntCntr.incrementAndGet();
- File jettyDir = createTempDir("jetty").toFile();
- jettyDir.mkdirs();
- org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir);
- JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
- jettys.add(j);
- SolrClient client = createNewSolrClient(j.getLocalPort());
- clients.add(client);
+ File jettyDir = createTempDir("jetty").toFile();
+ jettyDir.mkdirs();
+ setupJettySolrHome(jettyDir);
+ JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
+ jettys.add(j);
+ SolrClient client = createNewSolrClient(j.getLocalPort());
+ clients.add(client);
int retries = 60;
while (--retries >= 0) {
@@ -502,11 +501,15 @@ public abstract class AbstractFullDistri
.withFilters(getExtraRequestFilters())
.withSSLConfig(sslConfig)
.build();
+
+ Properties props = new Properties();
+ props.setProperty("solr.data.dir", getDataDir(dataDir));
+ props.setProperty("shards", shardList);
+ props.setProperty("solr.ulog.dir", ulogDir);
+ props.setProperty("solrconfig", solrConfigOverride);
- JettySolrRunner jetty = new JettySolrRunner(getSolrHome(), solrConfigOverride, null, jettyconfig);
+ JettySolrRunner jetty = new JettySolrRunner(getSolrHome(), props, jettyconfig);
- jetty.setShards(shardList);
- jetty.setDataDir(getDataDir(dataDir));
jetty.start();
return jetty;
@@ -525,11 +528,19 @@ public abstract class AbstractFullDistri
.withFilters(getExtraRequestFilters())
.withSSLConfig(sslConfig)
.build();
-
- JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), solrConfigOverride, schemaOverride, jettyconfig);
- jetty.setShards(shardList);
- jetty.setDataDir(getDataDir(dataDir));
+ Properties props = new Properties();
+ if (solrConfigOverride != null)
+ props.setProperty("solrconfig", solrConfigOverride);
+ if (schemaOverride != null)
+ props.setProperty("schema", schemaOverride);
+ if (shardList != null)
+ props.setProperty("shards", shardList);
+ if (dataDir != null)
+ props.setProperty("solr.data.dir", getDataDir(dataDir));
+ props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
+
+ JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), props, jettyconfig);
jetty.start();
return jetty;
@@ -552,9 +563,18 @@ public abstract class AbstractFullDistri
.withSSLConfig(sslConfig)
.build();
- JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), solrConfigOverride, schemaOverride, jettyconfig);
- jetty.setShards(shardList);
- jetty.setDataDir(getDataDir(dataDir));
+ Properties props = new Properties();
+ if (solrConfigOverride != null)
+ props.setProperty("solrconfig", solrConfigOverride);
+ if (schemaOverride != null)
+ props.setProperty("schema", schemaOverride);
+ if (shardList != null)
+ props.setProperty("shards", shardList);
+ if (dataDir != null)
+ props.setProperty("solr.data.dir", getDataDir(dataDir));
+ props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
+
+ JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), props, jettyconfig);
SocketProxy proxy = new SocketProxy(0, sslConfig != null && sslConfig.isSSLMode());
jetty.setProxyPort(proxy.getListenPort());