Skip to content

Apache Lucene open-source search software

SOLR-4622: deprecate hardcoded hostContext and hostPort defaults

Chris M. Hostetter3d184a24526d
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e1f3d54be49..65da3c6dd63 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -68,6 +68,12 @@ Upgrading from Solr 4.2.0
eliminated the dist-war-excl-slf4j target and made dist-excl-slf4j
redundant.
+* SOLR-4622: The hardcoded SolrCloud defaults for 'hostContext="solr"' and
+ 'hostPort="8983"' have been deprecated and will be removed in Solr 5.0.
+ Existing solr.xml files that do not have these options explicitly specified
+ should be updated accordingly.
+
+
Detailed Change List
----------------------
@@ -155,6 +161,11 @@ Other Changes
* SOLR-4651: Remove dist-excl-slf4j build target. (Shawn Heisey)
+* SOLR-4622: The hardcoded SolrCloud defaults for 'hostContext="solr"' and
+ 'hostPort="8983"' have been deprecated and will be removed in Solr 5.0.
+ Existing solr.xml files that do not have these options explicitly specified
+ should be updated accordingly. (hossman)
+
================== 4.2.1 ==================
Versions of Major Components
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index f859020a34a..3feb6c4b15d 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -90,7 +90,9 @@ public class CoreContainer
{
private static final String LEADER_VOTE_WAIT = "180000"; // 3 minutes
private static final int CORE_LOAD_THREADS = 3;
+ /** @deprecated will be remove in Solr 5.0 (SOLR-4622) */
private static final String DEFAULT_HOST_CONTEXT = "solr";
+ /** @deprecated will be remove in Solr 5.0 (SOLR-4622) */
private static final String DEFAULT_HOST_PORT = "8983";
private static final int DEFAULT_ZK_CLIENT_TIMEOUT = 15000;
public static final String DEFAULT_DEFAULT_CORE_NAME = "collection1";
@@ -186,6 +188,21 @@ public class CoreContainer
if (zkRun == null && zookeeperHost == null)
return; // not in zk mode
+ // BEGIN: SOLR-4622: deprecated hardcoded defaults for hostPort & hostContext
+ if (null == hostPort) {
+ // throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
+ // "'hostPort' must be configured to run SolrCloud");
+ log.warn("Solr 'hostPort' has not be explicitly configured, using hardcoded default of " + DEFAULT_HOST_PORT + ". This default has been deprecated and will be removed in future versions of Solr, please configure this value explicitly");
+ hostPort = DEFAULT_HOST_PORT;
+ }
+ if (null == hostContext) {
+ // throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
+ // "'hostContext' must be configured to run SolrCloud");
+ log.warn("Solr 'hostContext' has not be explicitly configured, using hardcoded default of " + DEFAULT_HOST_CONTEXT + ". This default has been deprecated and will be removed in future versions of Solr, please configure this value explicitly");
+ hostContext = DEFAULT_HOST_CONTEXT;
+ }
+ // END: SOLR-4622
+
// zookeeper in quorum mode currently causes a failure when trying to
// register log4j mbeans. See SOLR-2369
// TODO: remove after updating to an slf4j based zookeeper
@@ -453,10 +470,12 @@ public class CoreContainer
distribUpdateConnTimeout = cfg.getInt(ConfigSolr.ConfLevel.SOLR_CORES, "distribUpdateConnTimeout", 0);
distribUpdateSoTimeout = cfg.getInt(ConfigSolr.ConfLevel.SOLR_CORES, "distribUpdateSoTimeout", 0);
-
- hostPort = cfg.get(ConfigSolr.ConfLevel.SOLR_CORES, "hostPort", DEFAULT_HOST_PORT);
- hostContext = cfg.get(ConfigSolr.ConfLevel.SOLR_CORES, "hostContext", DEFAULT_HOST_CONTEXT);
+ // Note: initZooKeeper will apply hardcoded default if cloud mode
+ hostPort = cfg.get(ConfigSolr.ConfLevel.SOLR_CORES, "hostPort", null);
+ // Note: initZooKeeper will apply hardcoded default if cloud mode
+ hostContext = cfg.get(ConfigSolr.ConfLevel.SOLR_CORES, "hostContext", null);
+
host = cfg.get(ConfigSolr.ConfLevel.SOLR_CORES, "host", null);
leaderVoteWait = cfg.get(ConfigSolr.ConfLevel.SOLR_CORES, "leaderVoteWait", LEADER_VOTE_WAIT);
diff --git a/solr/example/example-DIH/solr/solr.xml b/solr/example/example-DIH/solr/solr.xml
index 802b9b32e09..a9d924ba992 100644
--- a/solr/example/example-DIH/solr/solr.xml
+++ b/solr/example/example-DIH/solr/solr.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<solr sharedLib="lib" persistent="true">
- <cores adminPath="/admin/cores">
+ <cores adminPath="/admin/cores" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
<core default="true" instanceDir="db" name="db"/>
<core default="false" instanceDir="rss" name="rss"/>
<core default="false" instanceDir="mail" name="mail"/>
diff --git a/solr/example/multicore/solr.xml b/solr/example/multicore/solr.xml
index ff97c67722b..27079019bd6 100644
--- a/solr/example/multicore/solr.xml
+++ b/solr/example/multicore/solr.xml
@@ -28,7 +28,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via request handler
-->
- <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:}">
+ <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}">
<core name="core0" instanceDir="core0" />
<core name="core1" instanceDir="core1" />
</cores>
diff --git a/solr/example/solr/solr.xml b/solr/example/solr/solr.xml
index 4daccbb39a4..75da88a52f1 100644
--- a/solr/example/solr/solr.xml
+++ b/solr/example/solr/solr.xml
@@ -47,7 +47,7 @@
All of the attributes in cores after defaultCoreName only apply when running in SolrCloud mode.
You can read more about SolrCloud mode at http://wiki.apache.org/solr/SolrCloud
-->
- <cores adminPath="/admin/cores" defaultCoreName="collection1" host="${host:}" hostPort="${jetty.port:}" hostContext="${hostContext:}" zkClientTimeout="${zkClientTimeout:15000}">
+ <cores adminPath="/admin/cores" defaultCoreName="collection1" host="${host:}" hostPort="${jetty.port:8983}" hostContext="${hostContext:solr}" zkClientTimeout="${zkClientTimeout:15000}">
<core name="collection1" instanceDir="collection1" />
</cores>
</solr>
diff --git a/solr/solrj/src/test-files/solrj/solr/shared/solr.xml b/solr/solrj/src/test-files/solrj/solr/shared/solr.xml
index 38a8d8742f2..48e091b78ff 100644
--- a/solr/solrj/src/test-files/solrj/solr/shared/solr.xml
+++ b/solr/solrj/src/test-files/solrj/solr/shared/solr.xml
@@ -30,7 +30,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via REST
-->
- <cores adminPath="/admin/cores" defaultCoreName="core0" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:}" zkClientTimeout="8000">
+ <cores adminPath="/admin/cores" defaultCoreName="core0" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:solr}" zkClientTimeout="8000">
<core name="collection1" instanceDir="." />
<core name="core0" instanceDir="${theInstanceDir:./}" dataDir="${dataDir1}" collection="${collection:acollection}">
<property name="version" value="3.5"/>
diff --git a/solr/solrj/src/test-files/solrj/solr/solr.xml b/solr/solrj/src/test-files/solrj/solr/solr.xml
index 67505c189b8..44d0f78a33d 100644
--- a/solr/solrj/src/test-files/solrj/solr/solr.xml
+++ b/solr/solrj/src/test-files/solrj/solr/solr.xml
@@ -28,7 +28,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via request handler
-->
- <cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:}" zkClientTimeout="8000" numShards="${numShards:3}">
+ <cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:solr}" zkClientTimeout="8000" numShards="${numShards:3}">
<core name="collection1" instanceDir="collection1" shard="${shard:}" collection="${collection:collection1}" config="${solrconfig:solrconfig.xml}" schema="${schema:schema.xml}"/>
</cores>
</solr>
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
index 2b391ba6e0c..71a0716370e 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
@@ -194,8 +194,8 @@ public class TestSolrProperties extends AbstractEmbeddedSolrServerTestCase {
exists("/solr/cores[@hostPort='${hostPort:8983}']", document));
assertTrue("\"/solr/cores[@zkClientTimeout='8000']\" doesn't match in:\n" + solrPersistXml,
exists("/solr/cores[@zkClientTimeout='8000']", document));
- assertTrue("\"/solr/cores[@hostContext='solr']\" doesn't match in:\n" + solrPersistXml,
- exists("/solr/cores[@hostContext='solr']", document));
+ assertTrue("\"/solr/cores[@hostContext='${hostContext:solr}']\" doesn't match in:\n" + solrPersistXml,
+ exists("/solr/cores[@hostContext='${hostContext:solr}']", document));
} finally {
fis.close();