SOLR-12434: bin/solr {config,healthcheck} ignore ZK_HOST in solr.in.{sh,cmd}

This commit is contained in:
Steve Rowe 2018-06-12 20:01:20 -04:00
parent 23da90813c
commit ba62472bd3
5 changed files with 76 additions and 8 deletions

View File

@ -79,6 +79,8 @@ Bug Fixes
* SOLR-12449: Response /autoscaling/diagnostics shows improper json (noble)
* SOLR-12434: bin/solr {config,healthcheck} ignore ZK_HOST in solr.in.{sh,cmd} (Steve Rowe)
Optimizations
----------------------
@ -96,6 +98,7 @@ Other Changes
AddUpdateCommand and it's relationship with DirectUpdateHandler2 was reworked substantially. (Moshe Bla, David Smiley)
* SOLR-12208: Renamed the autoscaling variable 'INDEX.sizeInBytes' to 'INDEX.sizeInGB' (noble)
================== 7.4.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -908,7 +908,34 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
fi
if [[ "$SCRIPT_CMD" == "config" ]]; then
run_tool config $*
CONFIG_PARAMS=()
if [ $# -gt 0 ]; then
while true; do
case "$1" in
-z|-zkhost|-zkHost)
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
print_usage "$SCRIPT_CMD" "ZooKeeper connection string is required when using the $1 option!"
exit 1
fi
ZK_HOST="$2"
shift 2
;;
-s|-scheme)
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
print_usage "$SCRIPT_CMD" "URL scheme is required when using the $1 option!"
exit 1
fi
SOLR_URL_SCHEME="$2"
shift 2
;;
*) # Pass through all other params
CONFIG_PARAMS+=($1)
;;
esac
done
fi
run_tool config -zkHost "$ZK_HOST" -scheme "$SOLR_URL_SCHEME" "${CONFIG_PARAMS[@]}"
exit $?
fi

43
solr/bin/solr.cmd Normal file → Executable file
View File

@ -208,7 +208,6 @@ IF "%1"=="version" goto get_version
IF "%1"=="-v" goto get_version
IF "%1"=="-version" goto get_version
IF "%1"=="assert" goto run_assert
if "%1"=="config" goto run_config
REM Only allow the command to be the first argument, assume start if not supplied
IF "%1"=="start" goto set_script_cmd
@ -246,12 +245,18 @@ IF "%1"=="zk" (
set ZK_RECURSE=false
goto parse_zk_args
)
IF "%1"=="auth" (
set SCRIPT_CMD=auth
SHIFT
goto run_auth
)
IF "%1"=="config" (
REM config uses different arg parsing strategy
set SCRIPT_CMD=config
SHIFT
set CONFIG_ARGS=
goto parse_config_args
)
goto parse_args
@ -530,7 +535,7 @@ echo.
echo. ^<src^>, ^<dest^> : [file:][/]path/to/local/file or zk:/path/to/zk/node
echo NOTE: ^<src^> and ^<dest^> may both be Zookeeper resources prefixed by 'zk:'
echo When ^<src^> is a zk resource, ^<dest^> may be '.'
echo If ^<dest^> ends with '/', then ^<dest^> will be a local folder or parent znode and the last
echo If ^<dest^> ends with '/', then ^<dest^> will be a local folder or parent znode and the last
echo element of the ^<src^> path will be appended unless ^<src^> also ends in a slash.
echo ^<dest^> may be zk:, which may be useful when using the cp -r form to backup/restore
echo the entire zk state.
@ -667,6 +672,7 @@ IF "%1"=="-p" goto set_port
IF "%1"=="-port" goto set_port
IF "%1"=="-z" goto set_zookeeper
IF "%1"=="-zkhost" goto set_zookeeper
IF "%1"=="-zkHost" goto set_zookeeper
IF "%1"=="-a" goto set_addl_opts
IF "%1"=="-addlopts" goto set_addl_opts
IF "%1"=="-j" goto set_addl_jetty_config
@ -1352,6 +1358,7 @@ IF "%1"=="-c" goto set_healthcheck_collection
IF "%1"=="-collection" goto set_healthcheck_collection
IF "%1"=="-z" goto set_healthcheck_zk
IF "%1"=="-zkhost" goto set_healthcheck_zk
IF "%1"=="-zkHost" goto set_healthcheck_zk
IF "%1"=="-help" goto usage
IF "%1"=="-usage" goto usage
IF "%1"=="/?" goto usage
@ -1369,7 +1376,7 @@ SHIFT
goto parse_healthcheck_args
:set_healthcheck_zk
set HEALTHCHECK_ZK_HOST=%~2
set ZK_HOST=%~2
SHIFT
SHIFT
goto parse_healthcheck_args
@ -1378,10 +1385,11 @@ goto parse_healthcheck_args
IF NOT DEFINED HEALTHCHECK_COLLECTION goto healthcheck_usage
IF NOT DEFINED HEALTHCHECK_VERBOSE set "HEALTHCHECK_VERBOSE="
IF NOT DEFINED HEALTHCHECK_ZK_HOST set "HEALTHCHECK_ZK_HOST=localhost:9983"
echo ZK_HOST: !ZK_HOST!
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI healthcheck -collection !HEALTHCHECK_COLLECTION! -zkHost !HEALTHCHECK_ZK_HOST! %HEALTHCHECK_VERBOSE%
org.apache.solr.util.SolrCLI healthcheck -collection !HEALTHCHECK_COLLECTION! -zkHost !ZK_HOST! %HEALTHCHECK_VERBOSE%
goto done
:run_assert
@ -1394,11 +1402,34 @@ if errorlevel 1 (
)
goto done
:parse_config_args
IF [%1]==[] goto run_config
IF "%1"=="-z" goto set_config_zk
IF "%1"=="-zkhost" goto set_config_zk
IF "%1"=="-zkHost" goto set_config_zk
IF "%1"=="-s" goto set_config_url_scheme
IF "%1"=="-scheme" goto set_config_url_scheme
set "CONFIG_ARGS=!CONFIG_ARGS! %1"
SHIFT
goto parse_config_args
:set_config_zk
set ZK_HOST=%~2
SHIFT
SHIFT
goto parse_config_args
:set_config_url_scheme
set SOLR_URL_SCHEME=%~2
SHIFT
SHIFT
goto parse_config_args
:run_config
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configurationFile="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j2.xml" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI %*
org.apache.solr.util.SolrCLI config -zkHost !ZK_HOST! -scheme !SOLR_URL_SCHEME! !CONFIG_ARGS!
if errorlevel 1 (
exit /b 1
)

2
solr/bin/solr.in.cmd Normal file → Executable file
View File

@ -39,7 +39,7 @@ REM set GC_TUNE=-XX:NewRatio=3 -XX:SurvivorRatio=4 etc.
REM Set the ZooKeeper connection string if using an external ZooKeeper ensemble
REM e.g. host1:2181,host2:2181/chroot
REM Leave empty if not using SolrCloud
REM set ZK_HOST=
set ZK_HOST=localhost:2181
REM Set the ZooKeeper client timeout (for SolrCloud mode)
REM set ZK_CLIENT_TIMEOUT=15000

7
solr/core/src/java/org/apache/solr/util/SolrCLI.java Normal file → Executable file
View File

@ -2531,6 +2531,13 @@ public class SolrCLI {
.isRequired(false)
.withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")
.create("solrUrl"),
OptionBuilder
.withArgName("HOST")
.hasArg()
.isRequired(false)
.withDescription("Address of the Zookeeper ensemble")
.withLongOpt("zkHost")
.create('z'),
OptionBuilder
.withArgName("PORT")
.hasArg()