Skip to content

Commit 19cf21e

Browse files
authored
SOLR-17488: CLI: Resolve -d conflicts (#2754)
1 parent 0dbf31d commit 19cf21e

File tree

7 files changed

+59
-23
lines changed

7 files changed

+59
-23
lines changed

solr/bin/solr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ function print_usage() {
367367

368368
if [[ "$CMD" == "start" || "$CMD" == "restart" ]]; then
369369
echo ""
370-
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]"
370+
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]"
371371
echo ""
372372
echo " -f Start Solr in foreground; default starts Solr in the background"
373373
echo " and sends stdout / stderr to solr-PORT-console.log"
@@ -383,7 +383,7 @@ function print_usage() {
383383
echo " STOP_PORT=(\$SOLR_PORT-1000) and JMX RMI listen port RMI_PORT=(\$SOLR_PORT+10000). "
384384
echo " For instance, if you set -p 8985, then the STOP_PORT=7985 and RMI_PORT=18985"
385385
echo ""
386-
echo " -d <dir> Specify the Solr server directory; defaults to server"
386+
echo " --server-dir <dir> Specify the Solr server directory; defaults to server"
387387
echo ""
388388
echo " -z/--zk-host <zkHost> Zookeeper connection string; only used when running in SolrCloud mode using -c"
389389
echo " If neither ZK_HOST is defined in solr.in.sh nor the -z parameter is specified,"
@@ -395,7 +395,7 @@ function print_usage() {
395395
echo ""
396396
echo " --solr-home <dir> Sets the solr.solr.home system property; Solr will create core directories under"
397397
echo " this directory. This allows you to run multiple Solr instances on the same host"
398-
echo " while reusing the same server directory set using the -d parameter. If set, the"
398+
echo " while reusing the same server directory set using the --server-dir parameter. If set, the"
399399
echo " specified directory should contain a solr.xml file, unless solr.xml exists in Zookeeper."
400400
echo " This parameter is ignored when running examples (-e), as the solr.solr.home depends"
401401
echo " on which example is run. The default value is server/solr. If passed relative dir,"
@@ -742,7 +742,7 @@ if [ $# -gt 0 ]; then
742742
PASS_TO_RUN_EXAMPLE+=("-c")
743743
shift
744744
;;
745-
-d|--dir|-dir)
745+
-d|--dir|-dir|--server-dir)
746746
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
747747
print_usage "$SCRIPT_CMD" "Server directory is required when using the $1 option!"
748748
exit 1
@@ -930,7 +930,7 @@ fi
930930
# otherwise let this script proceed to process the user request
931931
#
932932
if [ -n "${EXAMPLE:-}" ] && [ "$SCRIPT_CMD" == "start" ]; then
933-
run_tool run_example -e "$EXAMPLE" -d "$SOLR_SERVER_DIR" --url-scheme "$SOLR_URL_SCHEME" "${PASS_TO_RUN_EXAMPLE[@]}"
933+
run_tool run_example -e "$EXAMPLE" --server-dir "$SOLR_SERVER_DIR" --url-scheme "$SOLR_URL_SCHEME" "${PASS_TO_RUN_EXAMPLE[@]}"
934934
exit $?
935935
fi
936936

@@ -1372,7 +1372,7 @@ function start_solr() {
13721372
cd "$SOLR_SERVER_DIR" || (echo -e "\nCd to SOLR_SERVER_DIR failed" && exit 1)
13731373

13741374
if [ ! -e "$SOLR_SERVER_DIR/start.jar" ]; then
1375-
echo -e "\nERROR: start.jar file not found in $SOLR_SERVER_DIR!\nPlease check your -d parameter to set the correct Solr server directory.\n"
1375+
echo -e "\nERROR: start.jar file not found in $SOLR_SERVER_DIR!\nPlease check your --server-dir parameter to set the correct Solr server directory.\n"
13761376
exit 1
13771377
fi
13781378

solr/bin/solr.cmd

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ goto done
307307

308308
:start_usage
309309
@echo.
310-
@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]
310+
@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]
311311
@echo.
312312
@echo -f Start Solr in foreground; default starts Solr in the background
313313
@echo and sends stdout / stderr to solr-PORT-console.log
@@ -323,7 +323,7 @@ goto done
323323
@echo STOP_PORT=(%%SOLR_PORT%%-1000) and JMX RMI listen port RMI_PORT=(%%SOLR_PORT%%+10000).
324324
@echo For instance, if you set -p 8985, then the STOP_PORT=7985 and RMI_PORT=18985
325325
@echo.
326-
@echo -d dir Specify the Solr server directory; defaults to server
326+
@echo --server-dir dir Specify the Solr server directory; defaults to server
327327
@echo.
328328
@echo -z zkHost Zookeeper connection string; only used when running in SolrCloud mode using -c
329329
@echo If neither ZK_HOST is defined in solr.in.cmd nor the -z parameter is specified,
@@ -335,13 +335,13 @@ goto done
335335
@echo.
336336
@echo --solr.home dir Sets the solr.solr.home system property; Solr will create core directories under
337337
@echo this directory. This allows you to run multiple Solr instances on the same host
338-
@echo while reusing the same server directory set using the -d parameter. If set, the
338+
@echo while reusing the same server directory set using the --server-dir parameter. If set, the
339339
@echo specified directory should contain a solr.xml file, unless solr.xml exists in Zookeeper.
340340
@echo This parameter is ignored when running examples (-e), as the solr.solr.home depends
341341
@echo on which example is run. The default value is server/solr. If passed a relative dir
342342
@echo validation with the current dir will be done before trying the default server/^<dir^>
343343
@echo.
344-
@echo --data-hone dir Sets the solr.data.home system property, where Solr will store index data in ^<instance_dir^>/data subdirectories.
344+
@echo --data-home dir Sets the solr.data.home system property, where Solr will store index data in ^<instance_dir^>/data subdirectories.
345345
@echo If not set, Solr uses solr.solr.home for both config and data.
346346
@echo.
347347
@echo -e example Name of the example to run; available examples:
@@ -406,6 +406,7 @@ IF "%1"=="-cloud" goto set_cloud_mode
406406
IF "%1"=="--cloud" goto set_cloud_mode
407407
IF "%1"=="-d" goto set_server_dir
408408
IF "%1"=="--dir" goto set_server_dir
409+
IF "%1"=="--server-dir" goto set_server_dir
409410
IF "%1"=="-s" goto set_solr_home_dir
410411
IF "%1"=="--solr-home" goto set_solr_home_dir
411412
IF "%1"=="-t" goto set_solr_data_dir
@@ -1202,7 +1203,7 @@ REM Run the requested example
12021203
-Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
12031204
-Dsolr.install.symDir="%SOLR_TIP%" ^
12041205
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
1205-
org.apache.solr.cli.SolrCLI run_example --script "%SDIR%\solr.cmd" -e %EXAMPLE% -d "%SOLR_SERVER_DIR%" ^
1206+
org.apache.solr.cli.SolrCLI run_example --script "%SDIR%\solr.cmd" -e %EXAMPLE% --server-dir "%SOLR_SERVER_DIR%" ^
12061207
--url-scheme !SOLR_URL_SCHEME! !PASS_TO_RUN_EXAMPLE!
12071208

12081209
REM End of run_example
@@ -1520,7 +1521,9 @@ for %%a in (%*) do (
15201521
) else (
15211522
set "option!option!=%%a"
15221523
if "!option!" equ "-d" set "SOLR_SERVER_DIR=%%a"
1524+
if "!option!" equ "--server-dir" set "SOLR_SERVER_DIR=%%a"
15231525
if "!option!" equ "-s" set "SOLR_HOME=%%a"
1526+
if "!option!" equ "--solr-home" set "SOLR_HOME=%%a"
15241527
if not "!option!" equ "-s" if not "!option!" equ "-d" (
15251528
set "AUTH_PARAMS=!AUTH_PARAMS! !option! %%a"
15261529
)

solr/core/src/java/org/apache/solr/cli/DeleteTool.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ public List<Option> getOptions() {
8181
.desc("Name of the core / collection to delete.")
8282
.build(),
8383
Option.builder("d")
84+
.deprecated(
85+
DeprecatedAttributes.builder()
86+
.setForRemoval(true)
87+
.setSince("9.8")
88+
.setDescription("Use --delete-config instead")
89+
.get())
90+
.hasArg()
91+
.argName("true|false")
92+
.required(false)
93+
.desc(
94+
"Flag to indicate if the underlying configuration directory for a collection should also be deleted; default is true.")
95+
.build(),
96+
Option.builder()
8497
.longOpt("delete-config")
8598
.hasArg()
8699
.argName("true|false")
@@ -188,6 +201,8 @@ protected void deleteCollection(CloudSolrClient cloudSolrClient, CommandLine cli
188201
boolean deleteConfig = true;
189202
if (cli.hasOption("delete-config")) {
190203
deleteConfig = "true".equals(cli.getOptionValue("delete-config"));
204+
} else if (cli.hasOption("d")) {
205+
deleteConfig = "true".equals(cli.getOptionValue("d"));
191206
} else if (cli.hasOption("deleteConfig")) {
192207
deleteConfig = "true".equals(cli.getOptionValue("deleteConfig"));
193208
}

solr/core/src/java/org/apache/solr/cli/PostTool.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,19 @@ public List<Option> getOptions() {
222222
.desc("For web crawl, how deep to go. default: 1")
223223
.build(),
224224
Option.builder("d")
225+
.deprecated(
226+
DeprecatedAttributes.builder()
227+
.setForRemoval(true)
228+
.setSince("9.8")
229+
.setDescription("Use --delay instead")
230+
.get())
231+
.hasArg()
232+
.argName("delay")
233+
.required(false)
234+
.desc(
235+
"If recursive then delay will be the wait time between posts. default: 10 for web, 0 for files")
236+
.build(),
237+
Option.builder()
225238
.longOpt("delay")
226239
.hasArg()
227240
.argName("delay")
@@ -327,8 +340,13 @@ public void runImpl(CommandLine cli) throws Exception {
327340
fileTypes = cli.getOptionValue("filetypes");
328341
}
329342

330-
int defaultDelay = (mode.equals((DATA_MODE_WEB)) ? 10 : 0);
331-
delay = Integer.parseInt(cli.getOptionValue("delay", String.valueOf(defaultDelay)));
343+
delay = (mode.equals((DATA_MODE_WEB)) ? 10 : 0);
344+
if (cli.hasOption("delay")) {
345+
delay = Integer.parseInt(cli.getOptionValue("delay"));
346+
} else if (cli.hasOption("d")) {
347+
delay = Integer.parseInt(cli.getOptionValue("d"));
348+
}
349+
332350
recursive = Integer.parseInt(cli.getOptionValue("recursive", "1"));
333351

334352
out = cli.hasOption("out") ? CLIO.getOutStream() : null;

solr/core/src/java/org/apache/solr/cli/RunExampleTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public List<Option> getOptions() {
126126
.required(false)
127127
.desc("Path to the bin/solr script.")
128128
.build(),
129-
Option.builder("d")
129+
Option.builder()
130130
.longOpt("server-dir")
131131
.hasArg()
132132
.argName("DIR")

solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ For more details, see the section <<SolrCloud Mode>> below.
9696
+
9797
*Example*: `bin/solr start -c`
9898

99-
`-d <dir>`::
99+
`--server-dir <dir>`::
100100
+
101101
[%autowidth,frame=none]
102102
|===
@@ -107,7 +107,7 @@ Define a server directory, defaults to `server` (as in, `$SOLR_TIP/server`).
107107
It is uncommon to override this option.
108108
When running multiple instances of Solr on the same host, it is more common to use the same server directory for each instance and use a unique Solr home directory using the `--solr-home` option.
109109
+
110-
*Example*: `bin/solr start -d newServerDir`
110+
*Example*: `bin/solr start --server-dir newServerDir`
111111

112112
`-e <name>`::
113113
+
@@ -203,7 +203,7 @@ If this is not specified, `8983` will be used.
203203
+
204204
Sets the `solr.solr.home` system property.
205205
Solr will create core directories under this directory.
206-
This allows you to run multiple Solr instances on the same host while reusing the same server directory set using the `-d` parameter.
206+
This allows you to run multiple Solr instances on the same host while reusing the same server directory set using the `--server-dir` parameter.
207207
If set, the specified directory should contain a solr.xml file, unless solr.xml exists in Zookeeper.
208208
+
209209
This parameter is ignored when running examples (`-e`), as the `solr.solr.home` depends on which example is run.
@@ -278,7 +278,7 @@ To emphasize how the default settings work take a moment to understand that the
278278

279279
`bin/solr start`
280280

281-
`bin/solr start --host localhost -p 8983 -d server --solr-home solr -m 512m`
281+
`bin/solr start --host localhost -p 8983 --server-dir server --solr-home solr -m 512m`
282282

283283
It is not necessary to define all of the options when starting if the defaults are fine for your needs.
284284

@@ -415,7 +415,7 @@ Stop key used to protect from stopping Solr inadvertently; default is "solrrocks
415415
+
416416
*Example*: `bin/solr stop -k solrrocks`
417417

418-
`-d` or `--verbose`::
418+
`--verbose`::
419419
+
420420
[%autowidth,frame=none]
421421
|===
@@ -797,7 +797,7 @@ The `delete` command detects the mode that Solr is running in and then deletes t
797797
If you're deleting a collection in SolrCloud mode, the default behavior is to also delete the configuration directory from Zookeeper so long as it is not being used by another collection.
798798

799799
For example, if you created a collection with `bin/solr create -c contacts`, then the delete command `bin/solr delete -c contacts` will check to see if the `/configs/contacts` configuration directory is being used by any other collections.
800-
If not, then the `/configs/contacts` directory is removed from ZooKeeper. You can override this behavior by passing -deleteConfig false when running this command.atom
800+
If not, then the `/configs/contacts` directory is removed from ZooKeeper. You can override this behavior by passing `--delete-config false` when running this command.atom
801801

802802
==== Delete Core or Collection Parameters
803803

@@ -821,7 +821,7 @@ Name of the core or collection to delete.
821821
+
822822
Whether or not the configuration directory should also be deleted from ZooKeeper.
823823
+
824-
If the configuration directory is being used by another collection, then it will not be deleted even if you pass `--deleteConfig` as `true`.
824+
If the configuration directory is being used by another collection, then it will not be deleted even if you pass `--delete-config` as `true`.
825825
+
826826
*Example*: `bin/solr delete --delete-config false`
827827

@@ -980,7 +980,7 @@ Defines the ZooKeeper connect string.
980980
This is useful if you want to enable authentication before all your Solr nodes have come up.
981981
Unnecessary if `ZK_HOST` is defined in `solr.in.sh` or `solr.in.cmd`.
982982

983-
`-d <dir>`::
983+
`--server-dir <dir>`::
984984
+
985985
[%autowidth,frame=none]
986986
|===

solr/solr-ref-guide/modules/indexing-guide/pages/post-tool.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The basic usage of `bin/solr post` is:
4343
----
4444
usage: post
4545
-c,--name <NAME> Name of the collection.
46-
-d,--delay <delay> If recursive then delay
46+
--delay <delay> If recursive then delay
4747
will be the wait time
4848
between posts. default:
4949
10 for web, 0 for files

0 commit comments

Comments
 (0)