Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-17488: CLI: Resolve -d conflicts #2754

Merged
merged 6 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions solr/bin/solr
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ function print_usage() {

if [[ "$CMD" == "start" || "$CMD" == "restart" ]]; then
echo ""
echo "Usage: solr $CMD [-f] [-c] [--host host] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [--data-home solr.data.home] [--jvm-opts \"jvm-opts\"] [-V]"
echo "Usage: solr $CMD [-f] [-c] [--host host] [-p port] [--server-dir directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [--data-home solr.data.home] [--jvm-opts \"jvm-opts\"] [-V]"
echo ""
echo " -f Start Solr in foreground; default starts Solr in the background"
echo " and sends stdout / stderr to solr-PORT-console.log"
Expand All @@ -383,7 +383,7 @@ function print_usage() {
echo " STOP_PORT=(\$SOLR_PORT-1000) and JMX RMI listen port RMI_PORT=(\$SOLR_PORT+10000). "
echo " For instance, if you set -p 8985, then the STOP_PORT=7985 and RMI_PORT=18985"
echo ""
echo " -d <dir> Specify the Solr server directory; defaults to server"
echo " --server-dir <dir> Specify the Solr server directory; defaults to server"
echo ""
echo " -z/--zk-host <zkHost> Zookeeper connection string; only used when running in SolrCloud mode using -c"
echo " If neither ZK_HOST is defined in solr.in.sh nor the -z parameter is specified,"
Expand All @@ -395,7 +395,7 @@ function print_usage() {
echo ""
echo " --solr-home <dir> Sets the solr.solr.home system property; Solr will create core directories under"
echo " this directory. This allows you to run multiple Solr instances on the same host"
echo " while reusing the same server directory set using the -d parameter. If set, the"
echo " while reusing the same server directory set using the --server-dir parameter. If set, the"
echo " specified directory should contain a solr.xml file, unless solr.xml exists in Zookeeper."
echo " This parameter is ignored when running examples (-e), as the solr.solr.home depends"
echo " on which example is run. The default value is server/solr. If passed relative dir,"
Expand Down Expand Up @@ -742,7 +742,7 @@ if [ $# -gt 0 ]; then
PASS_TO_RUN_EXAMPLE+=("-c")
shift
;;
-d|--dir|-dir)
-d|--dir|-dir|--server-dir)
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
print_usage "$SCRIPT_CMD" "Server directory is required when using the $1 option!"
exit 1
Expand Down Expand Up @@ -930,7 +930,7 @@ fi
# otherwise let this script proceed to process the user request
#
if [ -n "${EXAMPLE:-}" ] && [ "$SCRIPT_CMD" == "start" ]; then
run_tool run_example -e "$EXAMPLE" -d "$SOLR_SERVER_DIR" --url-scheme "$SOLR_URL_SCHEME" "${PASS_TO_RUN_EXAMPLE[@]}"
run_tool run_example -e "$EXAMPLE" --server-dir "$SOLR_SERVER_DIR" --url-scheme "$SOLR_URL_SCHEME" "${PASS_TO_RUN_EXAMPLE[@]}"
exit $?
fi

Expand Down
11 changes: 6 additions & 5 deletions solr/bin/solr.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ goto done

:start_usage
@echo.
@echo Usage: solr %SCRIPT_CMD% [-f] [-c] [--host hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [--data-home solr.data.home] [--jvm-opts "jvm-opts"] [-V]
@echo Usage: solr %SCRIPT_CMD% [-f] [-c] [--host hostname] [-p port] [--server-dir directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [--data-home solr.data.home] [--jvm-opts "jvm-opts"] [-V]
@echo.
@echo -f Start Solr in foreground; default starts Solr in the background
@echo and sends stdout / stderr to solr-PORT-console.log
Expand All @@ -323,7 +323,7 @@ goto done
@echo STOP_PORT=(%%SOLR_PORT%%-1000) and JMX RMI listen port RMI_PORT=(%%SOLR_PORT%%+10000).
@echo For instance, if you set -p 8985, then the STOP_PORT=7985 and RMI_PORT=18985
@echo.
@echo -d dir Specify the Solr server directory; defaults to server
@echo --server-dir dir Specify the Solr server directory; defaults to server
@echo.
@echo -z zkHost Zookeeper connection string; only used when running in SolrCloud mode using -c
@echo If neither ZK_HOST is defined in solr.in.cmd nor the -z parameter is specified,
Expand All @@ -335,13 +335,13 @@ goto done
@echo.
@echo --solr.home dir Sets the solr.solr.home system property; Solr will create core directories under
@echo this directory. This allows you to run multiple Solr instances on the same host
@echo while reusing the same server directory set using the -d parameter. If set, the
@echo while reusing the same server directory set using the --server-dir parameter. If set, the
@echo specified directory should contain a solr.xml file, unless solr.xml exists in Zookeeper.
@echo This parameter is ignored when running examples (-e), as the solr.solr.home depends
@echo on which example is run. The default value is server/solr. If passed a relative dir
@echo validation with the current dir will be done before trying the default server/^<dir^>
@echo.
@echo --data-hone dir Sets the solr.data.home system property, where Solr will store index data in ^<instance_dir^>/data subdirectories.
@echo --data-home dir Sets the solr.data.home system property, where Solr will store index data in ^<instance_dir^>/data subdirectories.
@echo If not set, Solr uses solr.solr.home for both config and data.
@echo.
@echo -e example Name of the example to run; available examples:
Expand Down Expand Up @@ -406,6 +406,7 @@ IF "%1"=="-cloud" goto set_cloud_mode
IF "%1"=="--cloud" goto set_cloud_mode
IF "%1"=="-d" goto set_server_dir
IF "%1"=="--dir" goto set_server_dir
IF "%1"=="--server-dir" goto set_server_dir
IF "%1"=="-s" goto set_solr_home_dir
IF "%1"=="--solr-home" goto set_solr_home_dir
IF "%1"=="-t" goto set_solr_data_dir
Expand Down Expand Up @@ -1202,7 +1203,7 @@ REM Run the requested example
-Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
-Dsolr.install.symDir="%SOLR_TIP%" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.cli.SolrCLI run_example --script "%SDIR%\solr.cmd" -e %EXAMPLE% -d "%SOLR_SERVER_DIR%" ^
org.apache.solr.cli.SolrCLI run_example --script "%SDIR%\solr.cmd" -e %EXAMPLE% --server-dir "%SOLR_SERVER_DIR%" ^
--url-scheme !SOLR_URL_SCHEME! !PASS_TO_RUN_EXAMPLE!

REM End of run_example
Expand Down
15 changes: 15 additions & 0 deletions solr/core/src/java/org/apache/solr/cli/DeleteTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ public List<Option> getOptions() {
.desc("Name of the core / collection to delete.")
.build(),
Option.builder("d")
.deprecated(
DeprecatedAttributes.builder()
.setForRemoval(true)
.setSince("9.8")
.setDescription("Use --delete-config instead")
.get())
.hasArg()
.argName("true|false")
.required(false)
.desc(
"Flag to indicate if the underlying configuration directory for a collection should also be deleted; default is true.")
.build(),
Option.builder()
.longOpt("delete-config")
.hasArg()
.argName("true|false")
Expand Down Expand Up @@ -188,6 +201,8 @@ protected void deleteCollection(CloudSolrClient cloudSolrClient, CommandLine cli
boolean deleteConfig = true;
if (cli.hasOption("delete-config")) {
deleteConfig = "true".equals(cli.getOptionValue("delete-config"));
} else if (cli.hasOption("d")) {
deleteConfig = "true".equals(cli.getOptionValue("d"));
} else if (cli.hasOption("deleteConfig")) {
deleteConfig = "true".equals(cli.getOptionValue("deleteConfig"));
}
Expand Down
22 changes: 20 additions & 2 deletions solr/core/src/java/org/apache/solr/cli/PostTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,19 @@ public List<Option> getOptions() {
.desc("For web crawl, how deep to go. default: 1")
.build(),
Option.builder("d")
.deprecated(
DeprecatedAttributes.builder()
.setForRemoval(true)
.setSince("9.8")
.setDescription("Use --delay instead")
.get())
.hasArg()
.argName("delay")
.required(false)
.desc(
"If recursive then delay will be the wait time between posts. default: 10 for web, 0 for files")
.build(),
Option.builder()
.longOpt("delay")
.hasArg()
.argName("delay")
Expand Down Expand Up @@ -327,8 +340,13 @@ public void runImpl(CommandLine cli) throws Exception {
fileTypes = cli.getOptionValue("filetypes");
}

int defaultDelay = (mode.equals((DATA_MODE_WEB)) ? 10 : 0);
delay = Integer.parseInt(cli.getOptionValue("delay", String.valueOf(defaultDelay)));
delay = (mode.equals((DATA_MODE_WEB)) ? 10 : 0);
if (cli.hasOption("delay")) {
delay = Integer.parseInt(cli.getOptionValue("delay"));
} else if (cli.hasOption("d")) {
delay = Integer.parseInt(cli.getOptionValue("d"));
}

recursive = Integer.parseInt(cli.getOptionValue("recursive", "1"));

out = cli.hasOption("out") ? CLIO.getOutStream() : null;
Expand Down
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public List<Option> getOptions() {
.required(false)
.desc("Path to the bin/solr script.")
.build(),
Option.builder("d")
Option.builder()
.longOpt("server-dir")
.hasArg()
.argName("DIR")
Expand Down
Loading