SOLR-14999: Option to set the advertised port for Solr. (#2089)

This commit is contained in:
Houston Putman 2021-01-08 18:21:41 -05:00 committed by GitHub
parent 86934787fe
commit 4be49cbdf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 5 deletions

View File

@ -338,6 +338,8 @@ Other Changes
* SOLR-15057: Avoid unnecessary object retention in FacetRangeProcessor. (Christine Poerschke)
* SOLR-14999: New option for specifying the advertised Solr Port (hostPort). Still defaults to "jetty.port". (Houston Putman)
================== 8.7.0 ==================
Consult the lucene/CHANGES.txt file for additional, low level, changes in this release.

View File

@ -1892,6 +1892,10 @@ if [ -z "$SOLR_PORT" ]; then
SOLR_PORT=8983
fi
if [ -n "$SOLR_PORT_ADVERTISE" ]; then
SOLR_OPTS+=("-Dsolr.port.advertise=$SOLR_PORT_ADVERTISE")
fi
if [ -n "$SOLR_JETTY_HOST" ]; then
SOLR_OPTS+=("-Dsolr.jetty.host=$SOLR_JETTY_HOST")
fi

View File

@ -1088,6 +1088,10 @@ IF "!IS_RESTART!"=="1" set SCRIPT_CMD=start
IF "%SOLR_PORT%"=="" set SOLR_PORT=8983
IF "%STOP_PORT%"=="" set /A STOP_PORT=%SOLR_PORT% - 1000
IF DEFINED SOLR_PORT_ADVERTISE (
set "SOLR_OPTS=%SOLR_OPTS% -Dsolr.port.advertise=%SOLR_PORT_ADVERTISE%"
)
IF DEFINED SOLR_JETTY_HOST (
set "SOLR_OPTS=%SOLR_OPTS% -Dsolr.jetty.host=%SOLR_JETTY_HOST%"
)

View File

@ -434,8 +434,12 @@ public class SolrXmlConfig {
private static CloudConfig fillSolrCloudSection(NamedList<Object> nl, XmlConfigFile config, String defaultZkHost) {
int hostPort = parseInt("hostPort", removeValue(nl, "hostPort"));
if (hostPort <= 0) {
// Default to the port that jetty is listening on, or 8983 if that is not provided.
hostPort = parseInt("jetty.port", System.getProperty("jetty.port", "8983"));
}
String hostName = required("solrcloud", "host", removeValue(nl, "host"));
int hostPort = parseInt("hostPort", required("solrcloud", "hostPort", removeValue(nl, "hostPort")));
String hostContext = required("solrcloud", "hostContext", removeValue(nl, "hostContext"));
CloudConfig.CloudConfigBuilder builder = new CloudConfig.CloudConfigBuilder(hostName, hostPort, hostContext);

View File

@ -35,7 +35,7 @@
<solrcloud>
<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
<int name="hostPort">${solr.port.advertise:0}</int>
<str name="hostContext">${hostContext:solr}</str>
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>

View File

@ -34,7 +34,7 @@ You can find `solr.xml` in your `$SOLR_HOME` directory (usually `server/solr` or
<solrcloud>
<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
<int name="hostPort">${solr.port.advertise:0}</int>
<str name="hostContext">${hostContext:solr}</str>
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
<int name="zkClientTimeout">${zkClientTimeout:30000}</int>
@ -134,9 +134,13 @@ The hostname Solr uses to access cores.
The url context path.
`hostPort`::
The port Solr uses to access cores.
The port Solr uses to access cores, and advertise Solr node locations through liveNodes.
This option is only necessary if a Solr instance is listening on a different port than it wants other nodes to contact it at.
For example, if the Solr node is running behind a proxy or in a cloud environment that allows for port mapping, such as Kubernetes.
`hostPort` is the port that the Solr instance wants other nodes to contact it at.
+
In the default `solr.xml` file, this is set to `${jetty.port:8983}`, which will use the Solr port defined in Jetty, and otherwise fall back to 8983.
In the default `solr.xml` file, this is set to `${solr.port.advertise:0}`.
If no port is passed via the `solr.xml` (i.e. `0`), then Solr will default to the port that jetty is listening on, defined by `${jetty.port}`.
`leaderVoteWait`::
When SolrCloud is starting up, how long each Solr node will wait for all known replicas for that shard to be found before assuming that any nodes that haven't reported are down.