SOLR-10628: Less verbose output from bin/solr commands

This commit is contained in:
Jan Høydahl 2017-08-22 12:50:53 +02:00
parent ea14a0721d
commit b67424ee58
6 changed files with 284 additions and 112 deletions

View File

@ -150,6 +150,8 @@ Other Changes
* SOLR-5129: Timeout property for waiting ZK get started. (Cao Manh Dat, Hrishikesh Gadre, Varun Thacker) * SOLR-5129: Timeout property for waiting ZK get started. (Cao Manh Dat, Hrishikesh Gadre, Varun Thacker)
* SOLR-10628: Less verbose output from bin/solr commands. (Jason Gerlowski, janhoy)
================== 7.0.0 ================== ================== 7.0.0 ==================
Versions of Major Components Versions of Major Components

View File

@ -380,12 +380,14 @@ function print_usage() {
echo "" echo ""
elif [ "$CMD" == "healthcheck" ]; then elif [ "$CMD" == "healthcheck" ]; then
echo "" echo ""
echo "Usage: solr healthcheck [-c collection] [-z zkHost]" echo "Usage: solr healthcheck [-c collection] [-z zkHost] [-V]"
echo "" echo ""
echo " -c <collection> Collection to run healthcheck against." echo " -c <collection> Collection to run healthcheck against."
echo "" echo ""
echo " -z <zkHost> Zookeeper connection string; default is localhost:9983" echo " -z <zkHost> Zookeeper connection string; default is localhost:9983"
echo "" echo ""
echo " -V Enable more verbose output"
echo ""
elif [ "$CMD" == "status" ]; then elif [ "$CMD" == "status" ]; then
echo "" echo ""
echo "Usage: solr status" echo "Usage: solr status"
@ -394,7 +396,7 @@ function print_usage() {
echo "" echo ""
elif [ "$CMD" == "create" ]; then elif [ "$CMD" == "create" ]; then
echo "" echo ""
echo "Usage: solr create [-c name] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port]" echo "Usage: solr create [-c name] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port] [-V]"
echo "" echo ""
echo " Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud" echo " Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud"
echo " mode (collection). In other words, this action detects which mode Solr is running in, and then takes" echo " mode (collection). In other words, this action detects which mode Solr is running in, and then takes"
@ -408,7 +410,7 @@ function print_usage() {
echo "" echo ""
elif [ "$CMD" == "delete" ]; then elif [ "$CMD" == "delete" ]; then
echo "" echo ""
echo "Usage: solr delete [-c name] [-deleteConfig true|false] [-p port]" echo "Usage: solr delete [-c name] [-deleteConfig true|false] [-p port] [-V]"
echo "" echo ""
echo " Deletes a core or collection depending on whether Solr is running in standalone (core) or SolrCloud" echo " Deletes a core or collection depending on whether Solr is running in standalone (core) or SolrCloud"
echo " mode (collection). If you're deleting a collection in SolrCloud mode, the default behavior is to also" echo " mode (collection). If you're deleting a collection in SolrCloud mode, the default behavior is to also"
@ -423,9 +425,11 @@ function print_usage() {
echo " If not specified, the script will search the local system for a running" echo " If not specified, the script will search the local system for a running"
echo " Solr instance and will use the port of the first server it finds." echo " Solr instance and will use the port of the first server it finds."
echo "" echo ""
echo " -V Enables more verbose output."
echo ""
elif [ "$CMD" == "create_core" ]; then elif [ "$CMD" == "create_core" ]; then
echo "" echo ""
echo "Usage: solr create_core [-c core] [-d confdir] [-p port]" echo "Usage: solr create_core [-c core] [-d confdir] [-p port] [-V]"
echo "" echo ""
echo " -c <core> Name of core to create" echo " -c <core> Name of core to create"
echo "" echo ""
@ -444,9 +448,11 @@ function print_usage() {
echo " If not specified, the script will search the local system for a running" echo " If not specified, the script will search the local system for a running"
echo " Solr instance and will use the port of the first server it finds." echo " Solr instance and will use the port of the first server it finds."
echo "" echo ""
echo " -V Enable more verbose output."
echo ""
elif [ "$CMD" == "create_collection" ]; then elif [ "$CMD" == "create_collection" ]; then
echo "" echo ""
echo "Usage: solr create_collection [-c collection] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port]" echo "Usage: solr create_collection [-c collection] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port] [-V]"
echo "" echo ""
echo " -c <collection> Name of collection to create" echo " -c <collection> Name of collection to create"
echo "" echo ""
@ -478,6 +484,8 @@ function print_usage() {
echo " If not specified, the script will search the local system for a running" echo " If not specified, the script will search the local system for a running"
echo " Solr instance and will use the port of the first server it finds." echo " Solr instance and will use the port of the first server it finds."
echo "" echo ""
echo " -V Enable more verbose output."
echo ""
elif [ "$CMD" == "zk" ]; then elif [ "$CMD" == "zk" ]; then
print_short_zk_usage "" print_short_zk_usage ""
echo " Be sure to check the Solr logs in case of errors." echo " Be sure to check the Solr logs in case of errors."
@ -485,6 +493,8 @@ function print_usage() {
echo " -z zkHost Optional Zookeeper connection string for all commands. If specified it" echo " -z zkHost Optional Zookeeper connection string for all commands. If specified it"
echo " overrides the 'ZK_HOST=...'' defined in solr.in.sh." echo " overrides the 'ZK_HOST=...'' defined in solr.in.sh."
echo "" echo ""
echo " -V Enable more verbose output."
echo ""
echo " upconfig uploads a configset from the local machine to Zookeeper. (Backcompat: -upconfig)" echo " upconfig uploads a configset from the local machine to Zookeeper. (Backcompat: -upconfig)"
echo "" echo ""
echo " downconfig downloads a configset from Zookeeper to the local machine. (Backcompat: -downconfig)" echo " downconfig downloads a configset from Zookeeper to the local machine. (Backcompat: -downconfig)"
@ -554,10 +564,10 @@ function print_usage() {
echo "" echo ""
elif [ "$CMD" == "auth" ]; then elif [ "$CMD" == "auth" ]; then
echo "" echo ""
echo "Usage: solr auth enable [-type basicAuth] -credentials user:pass [-blockUnknown <true|false>] [-updateIncludeFileOnly <true|false>]" echo "Usage: solr auth enable [-type basicAuth] -credentials user:pass [-blockUnknown <true|false>] [-updateIncludeFileOnly <true|false>] [-V]"
echo " solr auth enable [-type basicAuth] -prompt <true|false> [-blockUnknown <true|false>] [-updateIncludeFileOnly <true|false>]" echo " solr auth enable [-type basicAuth] -prompt <true|false> [-blockUnknown <true|false>] [-updateIncludeFileOnly <true|false>] [-V]"
echo " solr auth enable -type kerberos -config \"<kerberos configs>\" [-updateIncludeFileOnly <true|false>]" echo " solr auth enable -type kerberos -config \"<kerberos configs>\" [-updateIncludeFileOnly <true|false>] [-V]"
echo " solr auth disable [-updateIncludeFileOnly <true|false>]" echo " solr auth disable [-updateIncludeFileOnly <true|false>] [-V]"
echo "" echo ""
echo " -type <type> The authentication mechanism (basicAuth or kerberos) to enable. Defaults to 'basicAuth'." echo " -type <type> The authentication mechanism (basicAuth or kerberos) to enable. Defaults to 'basicAuth'."
echo "" echo ""
@ -584,6 +594,8 @@ function print_usage() {
echo " -s <dir> Specify the Solr home directory. This is where any credentials or authentication" echo " -s <dir> Specify the Solr home directory. This is where any credentials or authentication"
echo " configuration files (e.g. basicAuth.conf) would be placed." echo " configuration files (e.g. basicAuth.conf) would be placed."
echo "" echo ""
echo " -V Enable more verbose output."
echo ""
fi fi
} # end print_usage } # end print_usage
@ -811,6 +823,8 @@ fi
# run a healthcheck and exit if requested # run a healthcheck and exit if requested
if [ "$SCRIPT_CMD" == "healthcheck" ]; then if [ "$SCRIPT_CMD" == "healthcheck" ]; then
VERBOSE=""
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
while true; do while true; do
case "$1" in case "$1" in
@ -834,6 +848,10 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
print_usage "$SCRIPT_CMD" print_usage "$SCRIPT_CMD"
exit 0 exit 0
;; ;;
-V|--verbose)
VERBOSE="-verbose"
shift
;;
--) --)
shift shift
break break
@ -860,7 +878,7 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
exit 1 exit 1
fi fi
run_tool healthcheck -zkHost "$ZK_HOST" -collection "$HEALTHCHECK_COLLECTION" run_tool healthcheck -zkHost "$ZK_HOST" -collection "$HEALTHCHECK_COLLECTION" $VERBOSE
exit $? exit $?
fi fi
@ -871,6 +889,7 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
CREATE_NUM_SHARDS=1 CREATE_NUM_SHARDS=1
CREATE_REPFACT=1 CREATE_REPFACT=1
FORCE=false FORCE=false
VERBOSE=""
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
while true; do while true; do
@ -923,6 +942,10 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
CREATE_PORT="$2" CREATE_PORT="$2"
shift 2 shift 2
;; ;;
-V|--verbose)
VERBOSE="-verbose"
shift
;;
-force) -force)
FORCE=true FORCE=true
shift shift
@ -994,13 +1017,15 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
fi fi
if [ "$SCRIPT_CMD" == "create_core" ]; then if [ "$SCRIPT_CMD" == "create_core" ]; then
run_tool create_core -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$CREATE_PORT/solr" \ run_tool create_core -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$CREATE_PORT/solr" \
-confdir "$CREATE_CONFDIR" -configsetsDir "$SOLR_TIP/server/solr/configsets" -confdir "$CREATE_CONFDIR" -configsetsDir "$SOLR_TIP/server/solr/configsets" \
$VERBOSE
exit $? exit $?
else else
run_tool "$SCRIPT_CMD" -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$CREATE_PORT/solr" \ run_tool "$SCRIPT_CMD" -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$CREATE_PORT/solr" \
-shards "$CREATE_NUM_SHARDS" -replicationFactor "$CREATE_REPFACT" \ -shards "$CREATE_NUM_SHARDS" -replicationFactor "$CREATE_REPFACT" \
-confname "$CREATE_CONFNAME" -confdir "$CREATE_CONFDIR" \ -confname "$CREATE_CONFNAME" -confdir "$CREATE_CONFDIR" \
-configsetsDir "$SOLR_TIP/server/solr/configsets" -configsetsDir "$SOLR_TIP/server/solr/configsets" \
$VERBOSE
exit $? exit $?
fi fi
fi fi
@ -1008,6 +1033,8 @@ fi
# delete a core or collection # delete a core or collection
if [[ "$SCRIPT_CMD" == "delete" ]]; then if [[ "$SCRIPT_CMD" == "delete" ]]; then
VERBOSE=""
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
while true; do while true; do
case "$1" in case "$1" in
@ -1035,6 +1062,10 @@ if [[ "$SCRIPT_CMD" == "delete" ]]; then
DELETE_CONFIG="$2" DELETE_CONFIG="$2"
shift 2 shift 2
;; ;;
-V|--verbose)
VERBOSE="-verbose"
shift
;;
-help|-usage) -help|-usage)
print_usage "$SCRIPT_CMD" print_usage "$SCRIPT_CMD"
exit 0 exit 0
@ -1083,7 +1114,8 @@ if [[ "$SCRIPT_CMD" == "delete" ]]; then
fi fi
run_tool delete -name "$DELETE_NAME" -deleteConfig "$DELETE_CONFIG" \ run_tool delete -name "$DELETE_NAME" -deleteConfig "$DELETE_CONFIG" \
-solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$DELETE_PORT/solr" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$DELETE_PORT/solr" \
$VERBOSE
exit $? exit $?
fi fi
@ -1093,6 +1125,8 @@ ZK_RECURSE=false
# necessary for back-compat # necessary for back-compat
if [[ "$SCRIPT_CMD" == "zk" ]]; then if [[ "$SCRIPT_CMD" == "zk" ]]; then
VERBOSE=""
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
while true; do while true; do
case "$1" in case "$1" in
@ -1129,6 +1163,10 @@ if [[ "$SCRIPT_CMD" == "zk" ]]; then
ZK_RECURSE="true" ZK_RECURSE="true"
shift shift
;; ;;
-V|--verbose)
VERBOSE="-verbose"
shift
;;
-help|-usage|-h) -help|-usage|-h)
print_usage "$SCRIPT_CMD" print_usage "$SCRIPT_CMD"
exit 0 exit 0
@ -1192,34 +1230,34 @@ if [[ "$SCRIPT_CMD" == "zk" ]]; then
case "$ZK_OP" in case "$ZK_OP" in
upconfig) upconfig)
run_tool "$ZK_OP" -confname "$CONFIGSET_CONFNAME" -confdir "$CONFIGSET_CONFDIR" -zkHost "$ZK_HOST" -configsetsDir "$SOLR_TIP/server/solr/configsets" run_tool "$ZK_OP" -confname "$CONFIGSET_CONFNAME" -confdir "$CONFIGSET_CONFDIR" -zkHost "$ZK_HOST" -configsetsDir "$SOLR_TIP/server/solr/configsets" $VERBOSE
;; ;;
downconfig) downconfig)
run_tool "$ZK_OP" -confname "$CONFIGSET_CONFNAME" -confdir "$CONFIGSET_CONFDIR" -zkHost "$ZK_HOST" run_tool "$ZK_OP" -confname "$CONFIGSET_CONFNAME" -confdir "$CONFIGSET_CONFDIR" -zkHost "$ZK_HOST" $VERBOSE
;; ;;
rm) rm)
if [ -z "$ZK_SRC" ]; then if [ -z "$ZK_SRC" ]; then
print_short_zk_usage "Zookeeper path to remove must be specified when using the 'rm' command" print_short_zk_usage "Zookeeper path to remove must be specified when using the 'rm' command"
fi fi
run_tool "$ZK_OP" -path "$ZK_SRC" -zkHost "$ZK_HOST" -recurse "$ZK_RECURSE" run_tool "$ZK_OP" -path "$ZK_SRC" -zkHost "$ZK_HOST" -recurse "$ZK_RECURSE" $VERBOSE
;; ;;
mv) mv)
run_tool "$ZK_OP" -src "$ZK_SRC" -dst "$ZK_DST" -zkHost "$ZK_HOST" run_tool "$ZK_OP" -src "$ZK_SRC" -dst "$ZK_DST" -zkHost "$ZK_HOST" $VERBOSE
;; ;;
cp) cp)
run_tool "$ZK_OP" -src "$ZK_SRC" -dst "$ZK_DST" -zkHost "$ZK_HOST" -recurse "$ZK_RECURSE" run_tool "$ZK_OP" -src "$ZK_SRC" -dst "$ZK_DST" -zkHost "$ZK_HOST" -recurse "$ZK_RECURSE" $VERBOSE
;; ;;
ls) ls)
if [ -z "$ZK_SRC" ]; then if [ -z "$ZK_SRC" ]; then
print_short_zk_usage "Zookeeper path to list must be specified when using the 'ls' command" print_short_zk_usage "Zookeeper path to list must be specified when using the 'ls' command"
fi fi
run_tool "$ZK_OP" -path "$ZK_SRC" -recurse "$ZK_RECURSE" -zkHost "$ZK_HOST" run_tool "$ZK_OP" -path "$ZK_SRC" -recurse "$ZK_RECURSE" -zkHost "$ZK_HOST" $VERBOSE
;; ;;
mkroot) mkroot)
if [ -z "$ZK_SRC" ]; then if [ -z "$ZK_SRC" ]; then
print_short_zk_usage "Zookeeper path to list must be specified when using the 'mkroot' command" print_short_zk_usage "Zookeeper path to list must be specified when using the 'mkroot' command"
fi fi
run_tool "$ZK_OP" -path "$ZK_SRC" -zkHost "$ZK_HOST" run_tool "$ZK_OP" -path "$ZK_SRC" -zkHost "$ZK_HOST" $VERBOSE
;; ;;
*) *)
print_short_zk_usage "Unrecognized Zookeeper operation $ZK_OP" print_short_zk_usage "Unrecognized Zookeeper operation $ZK_OP"
@ -1230,6 +1268,9 @@ if [[ "$SCRIPT_CMD" == "zk" ]]; then
fi fi
if [[ "$SCRIPT_CMD" == "auth" ]]; then if [[ "$SCRIPT_CMD" == "auth" ]]; then
VERBOSE=""
declare -a AUTH_PARAMS declare -a AUTH_PARAMS
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
while true; do while true; do
@ -1277,6 +1318,10 @@ if [[ "$SCRIPT_CMD" == "auth" ]]; then
shift shift
break break
;; ;;
-V|--verbose)
VERBOSE="-verbose"
shift
;;
-d|-dir) -d|-dir)
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
print_usage "$SCRIPT_CMD" "Server directory is required when using the $1 option!" print_usage "$SCRIPT_CMD" "Server directory is required when using the $1 option!"
@ -1358,7 +1403,7 @@ if [[ "$SCRIPT_CMD" == "auth" ]]; then
fi fi
done done
fi fi
run_tool auth ${AUTH_PARAMS[@]} -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$AUTH_PORT/solr" -authConfDir "$SOLR_HOME" run_tool auth ${AUTH_PARAMS[@]} -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$AUTH_PORT/solr" -authConfDir "$SOLR_HOME" $VERBOSE
exit $? exit $?
fi fi

View File

@ -360,11 +360,13 @@ goto done
@echo. @echo.
@echo -z zkHost Zookeeper connection string; default is localhost:9983 @echo -z zkHost Zookeeper connection string; default is localhost:9983
@echo. @echo.
@echo -V Enable more verbose output
@echo.
goto done goto done
:create_usage :create_usage
echo. echo.
echo Usage: solr create [-c name] [-d confdir] [-n confname] [-shards #] [-replicationFactor #] [-p port] echo Usage: solr create [-c name] [-d confdir] [-n confname] [-shards #] [-replicationFactor #] [-p port] [-V]
echo. echo.
echo Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud echo Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud
echo mode (collection). In other words, this action detects which mode Solr is running in, and then takes echo mode (collection). In other words, this action detects which mode Solr is running in, and then takes
@ -380,7 +382,7 @@ goto done
:delete_usage :delete_usage
echo. echo.
echo Usage: solr delete [-c name] [-deleteConfig boolean] [-p port] echo Usage: solr delete [-c name] [-deleteConfig boolean] [-p port] [-V]
echo. echo.
echo Deletes a core or collection depending on whether Solr is running in standalone (core) or SolrCloud echo Deletes a core or collection depending on whether Solr is running in standalone (core) or SolrCloud
echo mode (collection). If you're deleting a collection in SolrCloud mode, the default behavior is to also echo mode (collection). If you're deleting a collection in SolrCloud mode, the default behavior is to also
@ -395,11 +397,13 @@ echo -p port Port of a local Solr instance where you want to create the ne
echo If not specified, the script will search the local system for a running echo If not specified, the script will search the local system for a running
echo Solr instance and will use the port of the first server it finds. echo Solr instance and will use the port of the first server it finds.
echo. echo.
echo -V Enable more verbose output.
echo.
goto done goto done
:create_core_usage :create_core_usage
echo. echo.
echo Usage: solr create_core [-c name] [-d confdir] [-p port] echo Usage: solr create_core [-c name] [-d confdir] [-p port] [-V]
echo. echo.
echo -c name Name of core to create echo -c name Name of core to create
echo. echo.
@ -418,11 +422,13 @@ echo -p port Port of a local Solr instance where you want to create the ne
echo If not specified, the script will search the local system for a running echo If not specified, the script will search the local system for a running
echo Solr instance and will use the port of the first server it finds. echo Solr instance and will use the port of the first server it finds.
echo. echo.
echo -V Enable more verbose output.
echo.
goto done goto done
:create_collection_usage :create_collection_usage
echo. echo.
echo Usage: solr create_collection [-c name] [-d confdir] [-n confname] [-shards #] [-replicationFactor #] [-p port] echo Usage: solr create_collection [-c name] [-d confdir] [-n confname] [-shards #] [-replicationFactor #] [-p port] [-V]
echo. echo.
echo -c name Name of collection to create echo -c name Name of collection to create
echo. echo.
@ -454,6 +460,8 @@ echo -p port Port of a local Solr instance where you want to cre
echo If not specified, the script will search the local system for a running echo If not specified, the script will search the local system for a running
echo Solr instance and will use the port of the first server it finds. echo Solr instance and will use the port of the first server it finds.
echo. echo.
echo -V Enable more verbose output.
echo.
goto done goto done
:zk_usage :zk_usage
@ -465,6 +473,8 @@ echo.
echo -z zkHost Optional Zookeeper connection string for all commands. If specified it echo -z zkHost Optional Zookeeper connection string for all commands. If specified it
echo overrides the 'ZK_HOST=...'' defined in solr.in.sh. echo overrides the 'ZK_HOST=...'' defined in solr.in.sh.
echo. echo.
echo -V Enable more verbose output.
echo.
echo upconfig uploads a configset from the local machine to Zookeeper. (Backcompat: -upconfig) echo upconfig uploads a configset from the local machine to Zookeeper. (Backcompat: -upconfig)
echo. echo.
echo downconfig downloads a configset from Zookeeper to the local machine. (Backcompat: -downconfig) echo downconfig downloads a configset from Zookeeper to the local machine. (Backcompat: -downconfig)
@ -554,9 +564,9 @@ IF "%ZK_FULL%"=="true" (
goto done goto done
:auth_usage :auth_usage
echo Usage: solr auth enable [-type basicAuth] -credentials user:pass [-blockUnknown ^<true|false^>] [-updateIncludeFileOnly ^<true|false^>] echo Usage: solr auth enable [-type basicAuth] -credentials user:pass [-blockUnknown ^<true|false^>] [-updateIncludeFileOnly ^<true|false^>] [-V]
echo solr auth enable [-type basicAuth] -prompt ^<true|false^> [-blockUnknown ^<true|false^>] [-updateIncludeFileOnly ^<true|false^>] echo solr auth enable [-type basicAuth] -prompt ^<true|false^> [-blockUnknown ^<true|false^>] [-updateIncludeFileOnly ^<true|false^>] [-V]
echo solr auth disable [-updateIncludeFileOnly ^<true|false^>] echo solr auth disable [-updateIncludeFileOnly ^<true|false^>] [-V]
echo echo
echo -type ^<type^> The authentication mechanism to enable. Defaults to 'basicAuth'. echo -type ^<type^> The authentication mechanism to enable. Defaults to 'basicAuth'.
echo echo
@ -581,6 +591,8 @@ echo
echo -s <dir> Specify the Solr home directory. This is where any credentials or authentication" echo -s <dir> Specify the Solr home directory. This is where any credentials or authentication"
echo configuration files (e.g. basicAuth.conf) would be placed." echo configuration files (e.g. basicAuth.conf) would be placed."
echo echo
echo -V Enable more verbose output
echo
goto done goto done
REM Really basic command-line arg parsing REM Really basic command-line arg parsing
@ -1292,6 +1304,7 @@ goto done
:parse_healthcheck_args :parse_healthcheck_args
IF [%1]==[] goto run_healthcheck IF [%1]==[] goto run_healthcheck
IF "%1"=="-V" goto set_healthcheck_verbose
IF "%1"=="-c" goto set_healthcheck_collection IF "%1"=="-c" goto set_healthcheck_collection
IF "%1"=="-collection" goto set_healthcheck_collection IF "%1"=="-collection" goto set_healthcheck_collection
IF "%1"=="-z" goto set_healthcheck_zk IF "%1"=="-z" goto set_healthcheck_zk
@ -1301,6 +1314,11 @@ IF "%1"=="-usage" goto usage
IF "%1"=="/?" goto usage IF "%1"=="/?" goto usage
goto run_healthcheck goto run_healthcheck
:set_healthcheck_verbose
set HEALTHCHECK_VERBOSE="-verbose"
SHIFT
goto parse_healthcheck_args
:set_healthcheck_collection :set_healthcheck_collection
set HEALTHCHECK_COLLECTION=%~2 set HEALTHCHECK_COLLECTION=%~2
SHIFT SHIFT
@ -1315,11 +1333,12 @@ goto parse_healthcheck_args
:run_healthcheck :run_healthcheck
IF NOT DEFINED HEALTHCHECK_COLLECTION goto healthcheck_usage 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" IF NOT DEFINED HEALTHCHECK_ZK_HOST set "HEALTHCHECK_ZK_HOST=localhost:9983"
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -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! org.apache.solr.util.SolrCLI healthcheck -collection !HEALTHCHECK_COLLECTION! -zkHost !HEALTHCHECK_ZK_HOST! %HEALTHCHECK_VERBOSE%
goto done goto done
:run_assert :run_assert
@ -1354,6 +1373,7 @@ goto done
:parse_create_args :parse_create_args
IF [%1]==[] goto run_create IF [%1]==[] goto run_create
IF "%1"=="-V" goto set_create_verbose
IF "%1"=="-c" goto set_create_name IF "%1"=="-c" goto set_create_name
IF "%1"=="-core" goto set_create_name IF "%1"=="-core" goto set_create_name
IF "%1"=="-collection" goto set_create_name IF "%1"=="-collection" goto set_create_name
@ -1372,6 +1392,12 @@ IF "%1"=="-usage" goto usage
IF "%1"=="/?" goto usage IF "%1"=="/?" goto usage
goto run_create goto run_create
:set_create_verbose
set CREATE_VERBOSE="-verbose"
SHIFT
goto parse_create_args
:set_create_name :set_create_name
set CREATE_NAME=%~2 set CREATE_NAME=%~2
SHIFT SHIFT
@ -1413,6 +1439,7 @@ IF "!CREATE_NAME!"=="" (
set "SCRIPT_ERROR=Name (-c) is a required parameter for %SCRIPT_CMD%" set "SCRIPT_ERROR=Name (-c) is a required parameter for %SCRIPT_CMD%"
goto invalid_cmd_line goto invalid_cmd_line
) )
IF NOT DEFINED CREATE_VERBOSE set "CREATE_VERBOSE="
IF "!CREATE_CONFDIR!"=="" set CREATE_CONFDIR=_default IF "!CREATE_CONFDIR!"=="" set CREATE_CONFDIR=_default
IF "!CREATE_NUM_SHARDS!"=="" set CREATE_NUM_SHARDS=1 IF "!CREATE_NUM_SHARDS!"=="" set CREATE_NUM_SHARDS=1
IF "!CREATE_REPFACT!"=="" set CREATE_REPFACT=1 IF "!CREATE_REPFACT!"=="" set CREATE_REPFACT=1
@ -1447,20 +1474,21 @@ if "%SCRIPT_CMD%"=="create_core" (
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI create_core -name !CREATE_NAME! -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr ^ org.apache.solr.util.SolrCLI create_core -name !CREATE_NAME! -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr ^
-confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" %CREATE_VERBOSE%
) else ( ) else (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%"^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%"^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI create -name !CREATE_NAME! -shards !CREATE_NUM_SHARDS! -replicationFactor !CREATE_REPFACT! ^ org.apache.solr.util.SolrCLI create -name !CREATE_NAME! -shards !CREATE_NUM_SHARDS! -replicationFactor !CREATE_REPFACT! ^
-confname !CREATE_CONFNAME! -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" ^ -confname !CREATE_CONFNAME! -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" ^
-solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr %CREATE_VERBOSE%
) )
goto done goto done
:parse_delete_args :parse_delete_args
IF [%1]==[] goto run_delete IF [%1]==[] goto run_delete
IF "%1"=="-V" goto set_delete_verbose
IF "%1"=="-c" goto set_delete_name IF "%1"=="-c" goto set_delete_name
IF "%1"=="-core" goto set_delete_name IF "%1"=="-core" goto set_delete_name
IF "%1"=="-collection" goto set_delete_name IF "%1"=="-collection" goto set_delete_name
@ -1472,6 +1500,11 @@ IF "%1"=="-usage" goto usage
IF "%1"=="/?" goto usage IF "%1"=="/?" goto usage
goto run_delete goto run_delete
:set_delete_verbose
set DELETE_VERBOSE="-verbose"
SHIFT
goto parse_delete_args
:set_delete_name :set_delete_name
set DELETE_NAME=%~2 set DELETE_NAME=%~2
SHIFT SHIFT
@ -1491,6 +1524,7 @@ SHIFT
goto parse_delete_args goto parse_delete_args
:run_delete :run_delete
IF NOT DEFINED DELETE_VERBOSE set "DELETE_VERBOSE="
IF "!DELETE_NAME!"=="" ( IF "!DELETE_NAME!"=="" (
set "SCRIPT_ERROR=Name (-c) is a required parameter for %SCRIPT_CMD%" set "SCRIPT_ERROR=Name (-c) is a required parameter for %SCRIPT_CMD%"
goto invalid_cmd_line goto invalid_cmd_line
@ -1521,7 +1555,7 @@ if "!DELETE_CONFIG!"=="" (
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI delete -name !DELETE_NAME! -deleteConfig !DELETE_CONFIG! ^ org.apache.solr.util.SolrCLI delete -name !DELETE_NAME! -deleteConfig !DELETE_CONFIG! ^
-solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!DELETE_PORT!/solr -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!DELETE_PORT!/solr %DELETE_VERBOSE%
goto done goto done
@ -1529,6 +1563,8 @@ REM Clumsy to do the state machine thing for -d and -n, but that's required for
:parse_zk_args :parse_zk_args
IF "%1"=="-upconfig" ( IF "%1"=="-upconfig" (
goto set_zk_op goto set_zk_op
) ELSE IF "%1"=="-V" (
goto set_zk_verbose
) ELSE IF "%1"=="upconfig" ( ) ELSE IF "%1"=="upconfig" (
goto set_zk_op goto set_zk_op
) ELSE IF "%1"=="-downconfig" ( ) ELSE IF "%1"=="-downconfig" (
@ -1586,6 +1622,11 @@ set ZK_OP=%~1
SHIFT SHIFT
goto parse_zk_args goto parse_zk_args
:set_zk_verbose
set ZK_VERBOSE="-verbose"
SHIFT
goto parse_zk_args
:set_config_name :set_config_name
set CONFIGSET_NAME=%~2 set CONFIGSET_NAME=%~2
SHIFT SHIFT
@ -1649,7 +1690,7 @@ IF "!ZK_OP!"=="upconfig" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -confname !CONFIGSET_NAME! -confdir !CONFIGSET_DIR! -zkHost !ZK_HOST! ^ org.apache.solr.util.SolrCLI !ZK_OP! -confname !CONFIGSET_NAME! -confdir !CONFIGSET_DIR! -zkHost !ZK_HOST! %ZK_VERBOSE%^
-configsetsDir "%SOLR_TIP%/server/solr/configsets" -configsetsDir "%SOLR_TIP%/server/solr/configsets"
) ELSE IF "!ZK_OP!"=="downconfig" ( ) ELSE IF "!ZK_OP!"=="downconfig" (
IF "!CONFIGSET_NAME!"=="" ( IF "!CONFIGSET_NAME!"=="" (
@ -1663,7 +1704,7 @@ IF "!ZK_OP!"=="upconfig" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -confname !CONFIGSET_NAME! -confdir !CONFIGSET_DIR! -zkHost !ZK_HOST! org.apache.solr.util.SolrCLI !ZK_OP! -confname !CONFIGSET_NAME! -confdir !CONFIGSET_DIR! -zkHost !ZK_HOST! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="cp" ( ) ELSE IF "!ZK_OP!"=="cp" (
IF "%ZK_SRC%"=="" ( IF "%ZK_SRC%"=="" (
set ERROR_MSG="<src> must be specified for 'cp' command" set ERROR_MSG="<src> must be specified for 'cp' command"
@ -1682,7 +1723,7 @@ IF "!ZK_OP!"=="upconfig" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -src !ZK_SRC! -dst !ZK_DST! -recurse !ZK_RECURSE! org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -src !ZK_SRC! -dst !ZK_DST! -recurse !ZK_RECURSE! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="mv" ( ) ELSE IF "!ZK_OP!"=="mv" (
IF "%ZK_SRC%"=="" ( IF "%ZK_SRC%"=="" (
set ERROR_MSG="<src> must be specified for 'mv' command" set ERROR_MSG="<src> must be specified for 'mv' command"
@ -1695,7 +1736,7 @@ IF "!ZK_OP!"=="upconfig" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -src !ZK_SRC! -dst !ZK_DST! org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -src !ZK_SRC! -dst !ZK_DST! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="rm" ( ) ELSE IF "!ZK_OP!"=="rm" (
IF "%ZK_SRC"=="" ( IF "%ZK_SRC"=="" (
set ERROR_MSG="Zookeeper path to remove must be specified when using the 'rm' command" set ERROR_MSG="Zookeeper path to remove must be specified when using the 'rm' command"
@ -1704,7 +1745,7 @@ IF "!ZK_OP!"=="upconfig" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE! org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="ls" ( ) ELSE IF "!ZK_OP!"=="ls" (
IF "%ZK_SRC"=="" ( IF "%ZK_SRC"=="" (
set ERROR_MSG="Zookeeper path to remove must be specified when using the 'ls' command" set ERROR_MSG="Zookeeper path to remove must be specified when using the 'ls' command"
@ -1713,7 +1754,7 @@ IF "!ZK_OP!"=="upconfig" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE! org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE! %ZK_VERBOSE%
) ELSE IF "!ZK_OP!"=="mkroot" ( ) ELSE IF "!ZK_OP!"=="mkroot" (
IF "%ZK_SRC"=="" ( IF "%ZK_SRC"=="" (
set ERROR_MSG="Zookeeper path to create must be specified when using the 'mkroot' command" set ERROR_MSG="Zookeeper path to create must be specified when using the 'mkroot' command"
@ -1722,7 +1763,7 @@ IF "!ZK_OP!"=="upconfig" (
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^ "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^ -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! %ZK_VERBOSE%
) ELSE ( ) ELSE (
set ERROR_MSG="Unknown zk option !ZK_OP!" set ERROR_MSG="Unknown zk option !ZK_OP!"
goto zk_short_usage goto zk_short_usage

View File

@ -73,6 +73,7 @@ import org.apache.solr.request.SolrRequestInfo;
import org.apache.solr.security.AuthenticationPlugin; import org.apache.solr.security.AuthenticationPlugin;
import org.apache.solr.security.PKIAuthenticationPlugin; import org.apache.solr.security.PKIAuthenticationPlugin;
import org.apache.solr.util.SolrFileCleaningTracker; import org.apache.solr.util.SolrFileCleaningTracker;
import org.apache.solr.util.StartupLoggingUtils;
import org.apache.solr.util.configuration.SSLConfigurationsFactory; import org.apache.solr.util.configuration.SSLConfigurationsFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -159,6 +160,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
} }
String logLevel = System.getProperty(SOLR_LOG_LEVEL); String logLevel = System.getProperty(SOLR_LOG_LEVEL);
if (logLevel != null) { if (logLevel != null) {
log.info("Log level override, property solr.log.level=" + logLevel);
StartupLoggingUtils.changeLogLevel(logLevel); StartupLoggingUtils.changeLogLevel(logLevel);
} }

View File

@ -154,6 +154,12 @@ public class SolrCLI {
this.stdout = stdout; this.stdout = stdout;
} }
protected void echoIfVerbose(final String msg, CommandLine cli) {
if (cli.hasOption("verbose")) {
echo(msg);
}
}
protected void echo(final String msg) { protected void echo(final String msg) {
stdout.println(msg); stdout.println(msg);
} }
@ -192,6 +198,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = cli.getOptionValue("zkHost", ZK_HOST); String zkHost = cli.getOptionValue("zkHost", ZK_HOST);
log.debug("Connecting to Solr cluster: " + zkHost); log.debug("Connecting to Solr cluster: " + zkHost);
@ -230,7 +237,11 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(false) .isRequired(false)
.withDescription("Name of collection; no default") .withDescription("Name of collection; no default")
.create("collection") .create("collection"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
private static void exit(int exitStatus) { private static void exit(int exitStatus) {
@ -322,6 +333,12 @@ public class SolrCLI {
} }
} }
private static void raiseLogLevelUnlessVerbose(CommandLine cli) {
if (! cli.hasOption("verbose")) {
StartupLoggingUtils.changeLogLevel("WARN");
}
}
/** /**
* Support options common to all tools. * Support options common to all tools.
*/ */
@ -1160,7 +1177,7 @@ public class SolrCLI {
@Override @Override
protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) throws Exception { protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String collection = cli.getOptionValue("collection"); String collection = cli.getOptionValue("collection");
if (collection == null) if (collection == null)
throw new IllegalArgumentException("Must provide a collection to run a healthcheck against!"); throw new IllegalArgumentException("Must provide a collection to run a healthcheck against!");
@ -1335,7 +1352,12 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Path to configsets directory on the local system.") .withDescription("Path to configsets directory on the local system.")
.create("configsetsDir") .create("configsetsDir"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
/** /**
@ -1463,8 +1485,10 @@ public class SolrCLI {
return CREATE_COLLECTION_OPTIONS; return CREATE_COLLECTION_OPTIONS;
} }
protected void runImpl(CommandLine cli) throws Exception {
protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
if (zkHost == null) { if (zkHost == null) {
throw new IllegalStateException("Solr at "+cli.getOptionValue("solrUrl")+ throw new IllegalStateException("Solr at "+cli.getOptionValue("solrUrl")+
@ -1473,7 +1497,7 @@ public class SolrCLI {
} }
try (CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zkHost).build()) { try (CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zkHost).build()) {
echo("\nConnecting to ZooKeeper at " + zkHost+" ..."); echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost+" ...", cli);
cloudSolrClient.connect(); cloudSolrClient.connect();
runCloudTool(cloudSolrClient, cli); runCloudTool(cloudSolrClient, cli);
} }
@ -1521,8 +1545,8 @@ public class SolrCLI {
Path confPath = ZkConfigManager.getConfigsetPath(confdir, Path confPath = ZkConfigManager.getConfigsetPath(confdir,
configsetsDir); configsetsDir);
echo("Uploading " + confPath.toAbsolutePath().toString() + echoIfVerbose("Uploading " + confPath.toAbsolutePath().toString() +
" for config " + confname + " to ZooKeeper at " + cloudSolrClient.getZkHost()); " for config " + confname + " to ZooKeeper at " + cloudSolrClient.getZkHost(), cli);
((ZkClientClusterStateProvider) cloudSolrClient.getClusterStateProvider()).uploadConfig(confPath, confname); ((ZkClientClusterStateProvider) cloudSolrClient.getClusterStateProvider()).uploadConfig(confPath, confname);
} }
@ -1547,7 +1571,7 @@ public class SolrCLI {
createCollectionUrl = createCollectionUrl + String.format(Locale.ROOT, "&collection.configName=%s", confname); createCollectionUrl = createCollectionUrl + String.format(Locale.ROOT, "&collection.configName=%s", confname);
} }
echo("\nCreating new collection '"+collectionName+"' using command:\n"+createCollectionUrl+"\n"); echoIfVerbose("\nCreating new collection '"+collectionName+"' using command:\n"+createCollectionUrl+"\n", cli);
Map<String,Object> json = null; Map<String,Object> json = null;
try { try {
@ -1556,9 +1580,19 @@ public class SolrCLI {
throw new Exception("Failed to create collection '"+collectionName+"' due to: "+sse.getMessage()); throw new Exception("Failed to create collection '"+collectionName+"' due to: "+sse.getMessage());
} }
if (cli.hasOption("verbose")) {
CharArr arr = new CharArr(); CharArr arr = new CharArr();
new JSONWriter(arr, 2).write(json); new JSONWriter(arr, 2).write(json);
echo(arr.toString()); echo(arr.toString());
} else {
String endMessage = String.format(Locale.ROOT, "Created collection '%s' with %d shard(s), %d replica(s)",
collectionName, numShards, replicationFactor);
if (confname != null && !"".equals(confname.trim())) {
endMessage += String.format(Locale.ROOT, " with config-set '%s'", confname);
}
echo(endMessage);
}
} }
protected int optionAsInt(CommandLine cli, String option, int defaultVal) { protected int optionAsInt(CommandLine cli, String option, int defaultVal) {
@ -1601,12 +1635,15 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Path to configsets directory on the local system.") .withDescription("Path to configsets directory on the local system.")
.create("configsetsDir") .create("configsetsDir"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
String solrUrl = cli.getOptionValue("solrUrl", DEFAULT_SOLR_URL); String solrUrl = cli.getOptionValue("solrUrl", DEFAULT_SOLR_URL);
if (!solrUrl.endsWith("/")) if (!solrUrl.endsWith("/"))
solrUrl += "/"; solrUrl += "/";
@ -1673,7 +1710,7 @@ public class SolrCLI {
throw new IllegalArgumentException("\n"+configSetDir.getAbsolutePath()+" doesn't contain a conf subdirectory or solrconfig.xml\n"); throw new IllegalArgumentException("\n"+configSetDir.getAbsolutePath()+" doesn't contain a conf subdirectory or solrconfig.xml\n");
} }
} }
echo("\nCopying configuration to new core instance directory:\n" + coreInstanceDir.getAbsolutePath()); echoIfVerbose("\nCopying configuration to new core instance directory:\n" + coreInstanceDir.getAbsolutePath(), cli);
} }
String createCoreUrl = String createCoreUrl =
@ -1683,14 +1720,18 @@ public class SolrCLI {
coreName, coreName,
coreName); coreName);
echo("\nCreating new core '" + coreName + "' using command:\n" + createCoreUrl + "\n"); echoIfVerbose("\nCreating new core '" + coreName + "' using command:\n" + createCoreUrl + "\n", cli);
try { try {
Map<String,Object> json = getJson(createCoreUrl); Map<String,Object> json = getJson(createCoreUrl);
if (cli.hasOption("verbose")) {
CharArr arr = new CharArr(); CharArr arr = new CharArr();
new JSONWriter(arr, 2).write(json); new JSONWriter(arr, 2).write(json);
echo(arr.toString()); echo(arr.toString());
echo("\n"); echo("\n");
} else {
echo(String.format(Locale.ROOT, "\nCreated new core '%s'", coreName));
}
} catch (Exception e) { } catch (Exception e) {
/* create-core failed, cleanup the copied configset before propagating the error. */ /* create-core failed, cleanup the copied configset before propagating the error. */
FileUtils.deleteDirectory(coreInstanceDir); FileUtils.deleteDirectory(coreInstanceDir);
@ -1714,7 +1755,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String solrUrl = cli.getOptionValue("solrUrl", DEFAULT_SOLR_URL); String solrUrl = cli.getOptionValue("solrUrl", DEFAULT_SOLR_URL);
if (!solrUrl.endsWith("/")) if (!solrUrl.endsWith("/"))
solrUrl += "/"; solrUrl += "/";
@ -1774,7 +1815,11 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST) .withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST)
.create("zkHost") .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
@ -1784,6 +1829,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
if (zkHost == null) { if (zkHost == null) {
throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") + throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") +
@ -1792,7 +1838,7 @@ public class SolrCLI {
String confName = cli.getOptionValue("confname"); String confName = cli.getOptionValue("confname");
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
echo("\nConnecting to ZooKeeper at " + zkHost + " ..."); echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);
Path confPath = ZkConfigManager.getConfigsetPath(cli.getOptionValue("confdir"), cli.getOptionValue("configsetsDir")); Path confPath = ZkConfigManager.getConfigsetPath(cli.getOptionValue("confdir"), cli.getOptionValue("configsetsDir"));
echo("Uploading " + confPath.toAbsolutePath().toString() + echo("Uploading " + confPath.toAbsolutePath().toString() +
@ -1803,7 +1849,6 @@ public class SolrCLI {
log.error("Could not complete upconfig operation for reason: " + e.getMessage()); log.error("Could not complete upconfig operation for reason: " + e.getMessage());
throw (e); throw (e);
} }
} }
} }
@ -1837,7 +1882,11 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST) .withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST)
.create("zkHost") .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
@ -1846,7 +1895,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
if (zkHost == null) { if (zkHost == null) {
throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") + throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") +
@ -1855,7 +1904,7 @@ public class SolrCLI {
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
echo("\nConnecting to ZooKeeper at " + zkHost + " ..."); echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);
String confName = cli.getOptionValue("confname"); String confName = cli.getOptionValue("confname");
String confDir = cli.getOptionValue("confdir"); String confDir = cli.getOptionValue("confdir");
Path configSetPath = Paths.get(confDir); Path configSetPath = Paths.get(confDir);
@ -1909,7 +1958,11 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST) .withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST)
.create("zkHost") .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
@ -1918,7 +1971,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
if (zkHost == null) { if (zkHost == null) {
@ -1935,7 +1988,7 @@ public class SolrCLI {
if (znode.equals("/")) { if (znode.equals("/")) {
throw new SolrServerException("You may not remove the root ZK node ('/')!"); throw new SolrServerException("You may not remove the root ZK node ('/')!");
} }
echo("\nConnecting to ZooKeeper at " + zkHost + " ..."); echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
if (recurse == false && zkClient.getChildren(znode, null, true).size() != 0) { if (recurse == false && zkClient.getChildren(znode, null, true).size() != 0) {
throw new SolrServerException("Zookeeper node " + znode + " has children and recurse has NOT been specified"); throw new SolrServerException("Zookeeper node " + znode + " has children and recurse has NOT been specified");
@ -1982,7 +2035,11 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST) .withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST)
.create("zkHost") .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
@ -1991,7 +2048,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
if (zkHost == null) { if (zkHost == null) {
@ -2001,12 +2058,12 @@ public class SolrCLI {
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
echo("\nConnecting to ZooKeeper at " + zkHost + " ..."); echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);
String znode = cli.getOptionValue("path"); String znode = cli.getOptionValue("path");
Boolean recurse = Boolean.parseBoolean(cli.getOptionValue("recurse")); Boolean recurse = Boolean.parseBoolean(cli.getOptionValue("recurse"));
echo("Getting listing for Zookeeper node " + znode + " from ZooKeeper at " + zkHost + echoIfVerbose("Getting listing for Zookeeper node " + znode + " from ZooKeeper at " + zkHost +
" recurse: " + Boolean.toString(recurse)); " recurse: " + Boolean.toString(recurse), cli);
stdout.print(zkClient.listZnode(znode, recurse)); stdout.print(zkClient.listZnode(znode, recurse));
} catch (Exception e) { } catch (Exception e) {
log.error("Could not complete ls operation for reason: " + e.getMessage()); log.error("Could not complete ls operation for reason: " + e.getMessage());
@ -2040,7 +2097,11 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST) .withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST)
.create("zkHost") .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
@ -2049,7 +2110,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
if (zkHost == null) { if (zkHost == null) {
@ -2059,7 +2120,7 @@ public class SolrCLI {
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
echo("\nConnecting to ZooKeeper at " + zkHost + " ..."); echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);
String znode = cli.getOptionValue("path"); String znode = cli.getOptionValue("path");
echo("Creating Zookeeper path " + znode + " on ZooKeeper at " + zkHost); echo("Creating Zookeeper path " + znode + " on ZooKeeper at " + zkHost);
@ -2110,7 +2171,11 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST) .withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST)
.create("zkHost") .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
@ -2119,7 +2184,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
if (zkHost == null) { if (zkHost == null) {
throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") + throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") +
@ -2127,7 +2192,7 @@ public class SolrCLI {
} }
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
echo("\nConnecting to ZooKeeper at " + zkHost + " ..."); echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);
String src = cli.getOptionValue("src"); String src = cli.getOptionValue("src");
String dst = cli.getOptionValue("dst"); String dst = cli.getOptionValue("dst");
Boolean recurse = Boolean.parseBoolean(cli.getOptionValue("recurse")); Boolean recurse = Boolean.parseBoolean(cli.getOptionValue("recurse"));
@ -2190,7 +2255,11 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(true) .isRequired(true)
.withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST) .withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST)
.create("zkHost") .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
@ -2199,7 +2268,7 @@ public class SolrCLI {
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
if (zkHost == null) { if (zkHost == null) {
throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") + throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") +
@ -2208,7 +2277,7 @@ public class SolrCLI {
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
echo("\nConnecting to ZooKeeper at " + zkHost + " ..."); echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);
String src = cli.getOptionValue("src"); String src = cli.getOptionValue("src");
String dst = cli.getOptionValue("dst"); String dst = cli.getOptionValue("dst");
@ -2276,12 +2345,16 @@ public class SolrCLI {
.hasArg() .hasArg()
.isRequired(false) .isRequired(false)
.withDescription("Address of the Zookeeper ensemble; defaults to: "+ZK_HOST) .withDescription("Address of the Zookeeper ensemble; defaults to: "+ZK_HOST)
.create("zkHost") .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
protected void runImpl(CommandLine cli) throws Exception { protected void runImpl(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
String solrUrl = cli.getOptionValue("solrUrl", DEFAULT_SOLR_URL); String solrUrl = cli.getOptionValue("solrUrl", DEFAULT_SOLR_URL);
if (!solrUrl.endsWith("/")) if (!solrUrl.endsWith("/"))
solrUrl += "/"; solrUrl += "/";
@ -2303,7 +2376,7 @@ public class SolrCLI {
protected void deleteCollection(CommandLine cli) throws Exception { protected void deleteCollection(CommandLine cli) throws Exception {
String zkHost = getZkHost(cli); String zkHost = getZkHost(cli);
try (CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zkHost).build()) { try (CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zkHost).build()) {
echo("Connecting to ZooKeeper at " + zkHost); echoIfVerbose("Connecting to ZooKeeper at " + zkHost, cli);
cloudSolrClient.connect(); cloudSolrClient.connect();
deleteCollection(cloudSolrClient, cli); deleteCollection(cloudSolrClient, cli);
} }
@ -2357,7 +2430,7 @@ public class SolrCLI {
baseUrl, baseUrl,
collectionName); collectionName);
echo("\nDeleting collection '" + collectionName + "' using command:\n" + deleteCollectionUrl + "\n"); echoIfVerbose("\nDeleting collection '" + collectionName + "' using command:\n" + deleteCollectionUrl + "\n", cli);
Map<String,Object> json = null; Map<String,Object> json = null;
try { try {
@ -2371,7 +2444,7 @@ public class SolrCLI {
try { try {
zkStateReader.getZkClient().clean(configZnode); zkStateReader.getZkClient().clean(configZnode);
} catch (Exception exc) { } catch (Exception exc) {
System.err.println("\nWARNING: Failed to delete configuration directory "+configZnode+" in ZooKeeper due to: "+ echo("\nWARNING: Failed to delete configuration directory "+configZnode+" in ZooKeeper due to: "+
exc.getMessage()+"\nYou'll need to manually delete this znode using the zkcli script."); exc.getMessage()+"\nYou'll need to manually delete this znode using the zkcli script.");
} }
} }
@ -2382,6 +2455,8 @@ public class SolrCLI {
echo(arr.toString()); echo(arr.toString());
echo("\n"); echo("\n");
} }
echo("Deleted collection '" + collectionName + "' using command:\n" + deleteCollectionUrl);
} }
protected void deleteCore(CommandLine cli, CloseableHttpClient httpClient, String solrUrl) throws Exception { protected void deleteCore(CommandLine cli, CloseableHttpClient httpClient, String solrUrl) throws Exception {
@ -2404,8 +2479,8 @@ public class SolrCLI {
if (json != null) { if (json != null) {
CharArr arr = new CharArr(); CharArr arr = new CharArr();
new JSONWriter(arr, 2).write(json); new JSONWriter(arr, 2).write(json);
echo(arr.toString()); echoIfVerbose(arr.toString(), cli);
echo("\n"); echoIfVerbose("\n", cli);
} }
} }
} // end DeleteTool class } // end DeleteTool class
@ -3597,11 +3672,16 @@ public class SolrCLI {
.hasArg() .hasArg()
.withDescription("ZooKeeper host") .withDescription("ZooKeeper host")
.create("zkHost"), .create("zkHost"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
.create("verbose")
}; };
} }
@Override @Override
public int runTool(CommandLine cli) throws Exception { public int runTool(CommandLine cli) throws Exception {
raiseLogLevelUnlessVerbose(cli);
if (cli.getOptions().length == 0 || cli.getArgs().length == 0 || cli.getArgs().length > 1 || cli.hasOption("h")) { if (cli.getOptions().length == 0 || cli.getArgs().length == 0 || cli.getArgs().length > 1 || cli.hasOption("h")) {
new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this)); new HelpFormatter().printHelp("bin/solr auth <enable|disable> [OPTIONS]", getToolOptions(this));
return 1; return 1;
@ -3674,7 +3754,7 @@ public class SolrCLI {
if (!updateIncludeFileOnly) { if (!updateIncludeFileOnly) {
if (!zkInaccessible) { if (!zkInaccessible) {
System.out.println("Uploading following security.json: " + securityJson); echoIfVerbose("Uploading following security.json: " + securityJson, cli);
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 10000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 10000)) {
zkClient.setData("/security.json", securityJson.getBytes(StandardCharsets.UTF_8), true); zkClient.setData("/security.json", securityJson.getBytes(StandardCharsets.UTF_8), true);
} catch (Exception ex) { } catch (Exception ex) {
@ -3702,8 +3782,8 @@ public class SolrCLI {
} }
// update the solr.in.sh file to contain the necessary authentication lines // update the solr.in.sh file to contain the necessary authentication lines
updateIncludeFileEnableAuth(includeFile, null, config); updateIncludeFileEnableAuth(includeFile, null, config, cli);
System.out.println("Please restart any running Solr nodes."); echo("Successfully enabled Kerberos authentication; please restart any running Solr nodes.");
return 0; return 0;
case "disable": case "disable":
@ -3714,7 +3794,7 @@ public class SolrCLI {
exit(1); exit(1);
} }
System.out.println("Uploading following security.json: {}"); echoIfVerbose("Uploading following security.json: {}", cli);
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 10000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 10000)) {
zkClient.setData("/security.json", "{}".getBytes(StandardCharsets.UTF_8), true); zkClient.setData("/security.json", "{}".getBytes(StandardCharsets.UTF_8), true);
@ -3730,7 +3810,7 @@ public class SolrCLI {
} }
// update the solr.in.sh file to comment out the necessary authentication lines // update the solr.in.sh file to comment out the necessary authentication lines
updateIncludeFileDisableAuth(includeFile); updateIncludeFileDisableAuth(includeFile, cli);
return 0; return 0;
default: default:
@ -3824,7 +3904,7 @@ public class SolrCLI {
"\n}"; "\n}";
if (!updateIncludeFileOnly) { if (!updateIncludeFileOnly) {
System.out.println("Uploading following security.json: " + securityJson); echoIfVerbose("Uploading following security.json: " + securityJson, cli);
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 10000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 10000)) {
zkClient.setData("/security.json", securityJson.getBytes(StandardCharsets.UTF_8), true); zkClient.setData("/security.json", securityJson.getBytes(StandardCharsets.UTF_8), true);
} }
@ -3850,7 +3930,10 @@ public class SolrCLI {
"httpBasicAuthUser=" + username + "\nhttpBasicAuthPassword=" + password, StandardCharsets.UTF_8); "httpBasicAuthUser=" + username + "\nhttpBasicAuthPassword=" + password, StandardCharsets.UTF_8);
// update the solr.in.sh file to contain the necessary authentication lines // update the solr.in.sh file to contain the necessary authentication lines
updateIncludeFileEnableAuth(includeFile, basicAuthConfFile.getAbsolutePath(), null); updateIncludeFileEnableAuth(includeFile, basicAuthConfFile.getAbsolutePath(), null, cli);
final String successMessage = String.format(Locale.ROOT,
"Successfully enabled basic auth with username [%s] and password [%s].", username, password);
echo(successMessage);
return 0; return 0;
case "disable": case "disable":
@ -3861,7 +3944,7 @@ public class SolrCLI {
exit(1); exit(1);
} }
System.out.println("Uploading following security.json: {}"); echoIfVerbose("Uploading following security.json: {}", cli);
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 10000)) { try (SolrZkClient zkClient = new SolrZkClient(zkHost, 10000)) {
zkClient.setData("/security.json", "{}".getBytes(StandardCharsets.UTF_8), true); zkClient.setData("/security.json", "{}".getBytes(StandardCharsets.UTF_8), true);
@ -3877,7 +3960,7 @@ public class SolrCLI {
} }
// update the solr.in.sh file to comment out the necessary authentication lines // update the solr.in.sh file to comment out the necessary authentication lines
updateIncludeFileDisableAuth(includeFile); updateIncludeFileDisableAuth(includeFile, cli);
return 0; return 0;
default: default:
@ -3918,7 +4001,7 @@ public class SolrCLI {
* @param basicAuthConfFile If basicAuth, the path of the file containing credentials. If not, null. * @param basicAuthConfFile If basicAuth, the path of the file containing credentials. If not, null.
* @param kerberosConfig If kerberos, the config string containing startup parameters. If not, null. * @param kerberosConfig If kerberos, the config string containing startup parameters. If not, null.
*/ */
private void updateIncludeFileEnableAuth(File includeFile, String basicAuthConfFile, String kerberosConfig) throws IOException { private void updateIncludeFileEnableAuth(File includeFile, String basicAuthConfFile, String kerberosConfig, CommandLine cli) throws IOException {
assert !(basicAuthConfFile != null && kerberosConfig != null); // only one of the two needs to be populated assert !(basicAuthConfFile != null && kerberosConfig != null); // only one of the two needs to be populated
List<String> includeFileLines = FileUtils.readLines(includeFile, StandardCharsets.UTF_8); List<String> includeFileLines = FileUtils.readLines(includeFile, StandardCharsets.UTF_8);
for (int i=0; i<includeFileLines.size(); i++) { for (int i=0; i<includeFileLines.size(); i++) {
@ -3957,12 +4040,12 @@ public class SolrCLI {
FileUtils.writeLines(includeFile, StandardCharsets.UTF_8.name(), includeFileLines); FileUtils.writeLines(includeFile, StandardCharsets.UTF_8.name(), includeFileLines);
if (basicAuthConfFile != null) { if (basicAuthConfFile != null) {
System.out.println("Written out credentials file: " + basicAuthConfFile); echoIfVerbose("Written out credentials file: " + basicAuthConfFile, cli);
} }
System.out.println("Updated Solr include file: " + includeFile.getAbsolutePath()); echoIfVerbose("Updated Solr include file: " + includeFile.getAbsolutePath(), cli);
} }
private void updateIncludeFileDisableAuth(File includeFile) throws IOException { private void updateIncludeFileDisableAuth(File includeFile, CommandLine cli) throws IOException {
List<String> includeFileLines = FileUtils.readLines(includeFile, StandardCharsets.UTF_8); List<String> includeFileLines = FileUtils.readLines(includeFile, StandardCharsets.UTF_8);
boolean hasChanged = false; boolean hasChanged = false;
for (int i=0; i<includeFileLines.size(); i++) { for (int i=0; i<includeFileLines.size(); i++) {
@ -3979,7 +4062,7 @@ public class SolrCLI {
} }
if (hasChanged) { if (hasChanged) {
FileUtils.writeLines(includeFile, StandardCharsets.UTF_8.name(), includeFileLines); FileUtils.writeLines(includeFile, StandardCharsets.UTF_8.name(), includeFileLines);
System.out.println("Commented out necessary lines from " + includeFile.getAbsolutePath()); echoIfVerbose("Commented out necessary lines from " + includeFile.getAbsolutePath(), cli);
} }
} }
@Override @Override

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.solr.servlet; package org.apache.solr.util;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.util.Enumeration; import java.util.Enumeration;
@ -30,20 +30,20 @@ import org.slf4j.LoggerFactory;
import org.slf4j.impl.StaticLoggerBinder; import org.slf4j.impl.StaticLoggerBinder;
/** /**
* Handles dynamic modification of during startup, before CoreContainer is created * Handles programmatic modification of logging during startup
* <p> * <p>
* WARNING: This class should only be used during startup. For modifying log levels etc * WARNING: This class should only be used during startup. For modifying log levels etc
* during runtime, SLF4J and LogWatcher must be used. * during runtime, SLF4J and LogWatcher must be used.
* </p> * </p>
*/ */
final class StartupLoggingUtils { public final class StartupLoggingUtils {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private final static StaticLoggerBinder binder = StaticLoggerBinder.getSingleton(); private final static StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
/** /**
* Checks whether mandatory log dir is given * Checks whether mandatory log dir is given
*/ */
static void checkLogDir() { public static void checkLogDir() {
if (System.getProperty("solr.log.dir") == null) { if (System.getProperty("solr.log.dir") == null) {
log.error("Missing Java Option solr.log.dir. Logging may be missing or incomplete."); log.error("Missing Java Option solr.log.dir. Logging may be missing or incomplete.");
} }
@ -55,7 +55,7 @@ final class StartupLoggingUtils {
* @return true if ok or else false if something happened, e.g. log4j classes were not in classpath * @return true if ok or else false if something happened, e.g. log4j classes were not in classpath
*/ */
@SuppressForbidden(reason = "Legitimate log4j access") @SuppressForbidden(reason = "Legitimate log4j access")
static boolean muteConsole() { public static boolean muteConsole() {
try { try {
if (!isLog4jActive()) { if (!isLog4jActive()) {
logNotSupported("Could not mute logging to console."); logNotSupported("Could not mute logging to console.");
@ -83,13 +83,12 @@ final class StartupLoggingUtils {
* @return true if ok or else false if something happened, e.g. log4j classes were not in classpath * @return true if ok or else false if something happened, e.g. log4j classes were not in classpath
*/ */
@SuppressForbidden(reason = "Legitimate log4j access") @SuppressForbidden(reason = "Legitimate log4j access")
static boolean changeLogLevel(String logLevel) { public static boolean changeLogLevel(String logLevel) {
try { try {
if (!isLog4jActive()) { if (!isLog4jActive()) {
logNotSupported("Could not mute logging to console."); logNotSupported("Could not change log level.");
return false; return false;
} }
log.info("Log level override, property solr.log.level=" + logLevel);
LogManager.getRootLogger().setLevel(Level.toLevel(logLevel, Level.INFO)); LogManager.getRootLogger().setLevel(Level.toLevel(logLevel, Level.INFO));
return true; return true;
} catch (Exception e) { } catch (Exception e) {