Skip to content

Commit 5f920b1

Browse files
epughmalliaridis
andauthored
SOLR-17423: Remove -h as short option for --host, and use --host. (#2674)
Co-authored-by: Christos Malliaridis <[email protected]>
1 parent a963f7a commit 5f920b1

File tree

5 files changed

+23
-28
lines changed

5 files changed

+23
-28
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public List<Option> getOptions() {
160160
.desc("Specify the port to start the Solr HTTP listener on; default is 8983.")
161161
.longOpt("port")
162162
.build(),
163-
Option.builder("h")
163+
Option.builder()
164164
.argName("HOSTNAME")
165165
.hasArg()
166166
.required(false)
@@ -272,9 +272,6 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
272272
Map<String, Object> nodeStatus =
273273
startSolr(new File(exDir, "solr"), isCloudMode, cli, port, zkHost, 30);
274274

275-
// invoke the CreateTool
276-
File configsetsDir = new File(serverDir, "solr/configsets");
277-
278275
String solrUrl = (String) nodeStatus.get("baseUrl");
279276

280277
// If the example already exists then let the user know they should delete it, or
@@ -310,6 +307,7 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
310307
}
311308

312309
if (!alreadyExists) {
310+
// invoke the CreateTool
313311
String[] createArgs =
314312
new String[] {
315313
"--name", collectionName,
@@ -609,10 +607,10 @@ protected Map<String, Object> startSolr(
609607

610608
String extraArgs = readExtraArgs(cli.getArgs());
611609

612-
String host = cli.getOptionValue('h');
610+
String host = cli.getOptionValue("host");
613611
String memory = cli.getOptionValue('m');
614612

615-
String hostArg = (host != null && !"localhost".equals(host)) ? " -h " + host : "";
613+
String hostArg = (host != null && !"localhost".equals(host)) ? " --host " + host : "";
616614
String zkHostArg = (zkHost != null) ? " -z " + zkHost : "";
617615
String memArg = (memory != null) ? " -m " + memory : "";
618616
String cloudModeArg = cloudMode ? "--cloud " : "";

solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.List;
3737
import java.util.Map;
3838
import java.util.Optional;
39+
import org.apache.commons.exec.CommandLine;
3940
import org.apache.commons.exec.DefaultExecutor;
4041
import org.apache.commons.exec.ExecuteResultHandler;
4142
import org.apache.lucene.tests.util.LuceneTestCase;
@@ -83,7 +84,7 @@ public static void cleanupDirectoryFactory() {
8384
private static class RunExampleExecutor extends DefaultExecutor implements Closeable {
8485

8586
private PrintStream stdout;
86-
private List<org.apache.commons.exec.CommandLine> commandsExecuted = new ArrayList<>();
87+
private final List<CommandLine> commandsExecuted = new ArrayList<>();
8788
private MiniSolrCloudCluster solrCloudCluster;
8889
private JettySolrRunner standaloneSolr;
8990

@@ -121,9 +122,8 @@ public int execute(org.apache.commons.exec.CommandLine cmd) throws IOException {
121122
String solrHomeDir = getArg("-s", args);
122123
int port = Integer.parseInt(getArg("-p", args));
123124
String solrxml =
124-
new String(
125-
Files.readAllBytes(Paths.get(solrHomeDir).resolve("solr.xml")),
126-
Charset.defaultCharset());
125+
Files.readString(
126+
Paths.get(solrHomeDir).resolve("solr.xml"), Charset.defaultCharset());
127127

128128
JettyConfig jettyConfig = JettyConfig.builder().setPort(port).build();
129129
try {
@@ -405,9 +405,8 @@ protected void testExample(String exampleName) throws Exception {
405405
exampleSolrHomeDir.isDirectory());
406406

407407
if ("techproducts".equals(exampleName)) {
408-
SolrClient solrClient =
409-
getHttpSolrClient("http://localhost:" + bindPort + "/solr", exampleName);
410-
try {
408+
try (SolrClient solrClient =
409+
getHttpSolrClient("http://localhost:" + bindPort + "/solr", exampleName)) {
411410
SolrQuery query = new SolrQuery("*:*");
412411
QueryResponse qr = solrClient.query(query);
413412
long numFound = qr.getResults().getNumFound();
@@ -431,8 +430,6 @@ protected void testExample(String exampleName) throws Exception {
431430
+ toolOutput,
432431
32,
433432
numFound);
434-
} finally {
435-
solrClient.close();
436433
}
437434
}
438435

@@ -444,7 +441,7 @@ protected void testExample(String exampleName) throws Exception {
444441
/**
445442
* Tests the interactive SolrCloud example; we cannot test the non-interactive because we need
446443
* control over the port and can only test with one node since the test relies on setting the host
447-
* and jetty.port system properties, i.e. there is no test coverage for the --noprompt option.
444+
* and jetty.port system properties, i.e. there is no test coverage for the --no-prompt option.
448445
*/
449446
@Test
450447
public void testInteractiveSolrCloudExample() throws Exception {
@@ -587,14 +584,14 @@ public void testFailExecuteScript() throws Exception {
587584
"--server-dir", solrServerDir.getAbsolutePath(),
588585
"--example-dir", solrExampleDir.getAbsolutePath(),
589586
"-p", String.valueOf(bindPort),
590-
"-script", toExecute.getAbsolutePath().toString()
587+
"-script", toExecute.getAbsolutePath()
591588
};
592589

593590
// capture tool output to stdout
594591
ByteArrayOutputStream baos = new ByteArrayOutputStream();
595592
PrintStream stdoutSim = new PrintStream(baos, true, StandardCharsets.UTF_8.name());
596593

597-
DefaultExecutor executor = new DefaultExecutor();
594+
DefaultExecutor executor = DefaultExecutor.builder().get();
598595

599596
RunExampleTool tool = new RunExampleTool(executor, System.in, stdoutSim);
600597
int code = tool.runTool(SolrCLI.processCommandLineArgs(tool, toolArgs));

solr/solr-ref-guide/modules/deployment-guide/pages/docker-faq.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@ To run the Solr server:
107107
docker run -it solr
108108
----
109109

110-
Here "solr" is the name of the image, and there is no specific command, so the image defaults to run the "solr" command with "-f" to run it in the foreground.
110+
Here "solr" is the name of the image, and there is no specific command, so the image defaults to run the "solr" command with "start -f" to run it in the foreground.
111111

112112
To run the Solr server with extra arguments:
113113

114114
[source,bash]
115115
----
116-
docker run -it solr -h myhostname
116+
docker run -it solr --host myhostname
117117
----
118118

119119
This is the same as the previous one, but an additional argument is passed.
120-
The image will run the "solr" command with "-f -h myhostname".
120+
The image will run the "solr" command with "-f --host myhostname".
121121

122122
To run solr as an arbitrary command:
123123

@@ -135,7 +135,7 @@ For example:
135135

136136
[source,bash]
137137
----
138-
docker run -it solr bin/solr start -f -h myhostname
138+
docker run -it solr bin/solr start -f --host myhostname
139139
----
140140

141141
Finally, the Solr docker image offers several commands that do some work before then invoking the Solr server, like "solr-precreate" and "solr-demo".
@@ -162,7 +162,7 @@ whereas:
162162

163163
[source,bash]
164164
----
165-
docker run -it solr solr -f
165+
docker run -it solr solr start -f
166166
----
167167

168168
is slightly different: the "solr" there is a generic command, not treated in any special way by `docker-entrypoint.sh`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ To emphasize how the default settings work take a moment to understand that the
289289

290290
`bin/solr start`
291291

292-
`bin/solr start -h localhost -p 8983 -d server -s solr -m 512m`
292+
`bin/solr start --host localhost -p 8983 -d server -s solr -m 512m`
293293

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

solr/solr-ref-guide/modules/getting-started/pages/tutorial-aws.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Inside the `ec2-101-1-2-3.us-east-2.compute.amazonaws.com` (`solr-node-1`)
206206
$ cd $SOLR_HOME
207207
208208
# start Solr node on 8983 and ZooKeeper will start on 9983 (8983+1000)
209-
$ bin/solr start -c -p 8983 -h solr-node-1
209+
$ bin/solr start -c -p 8983 --host solr-node-1
210210
----
211211
+
212212
On the other node, `ec2-101-4-5-6.us-east-2.compute.amazonaws.com` (`solr-node-2`)
@@ -216,7 +216,7 @@ On the other node, `ec2-101-4-5-6.us-east-2.compute.amazonaws.com` (`solr-node-2
216216
$ cd $SOLR_HOME
217217
218218
# start Solr node on 8983 and connect to ZooKeeper running on first node
219-
$ bin/solr start -c -p 8983 -h solr-node-2 -z solr-node-1:9983
219+
$ bin/solr start -c -p 8983 --host solr-node-2 -z solr-node-1:9983
220220
----
221221

222222
. Inspect and Verify.
@@ -328,7 +328,7 @@ $ bin/zkServer.sh start
328328
$ cd $SOLR_HOME
329329
330330
# start Solr node on 8983 and connect to ZooKeeper running on ZooKeeper node
331-
$ bin/solr start -c -p 8983 -h solr-node-1 -z zookeeper-node:2181
331+
$ bin/solr start -c -p 8983 --host solr-node-1 -z zookeeper-node:2181
332332
----
333333
+
334334
. On the second Solr node (`solr-node-2`), again start Solr and tell it where to find ZooKeeper.
@@ -338,7 +338,7 @@ $ bin/solr start -c -p 8983 -h solr-node-1 -z zookeeper-node:2181
338338
$ cd $SOLR_HOME
339339
340340
# start Solr node on 8983 and connect to ZooKeeper running on ZooKeeper node
341-
$ bin/solr start -c -p 8983 -h solr-node-2 -z zookeeper-node:2181
341+
$ bin/solr start -c -p 8983 --host solr-node-2 -z zookeeper-node:2181
342342
----
343343

344344
[TIP]

0 commit comments

Comments
 (0)