Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion dev-tools/scripts/cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ start(){
echo "Final NUM_NODES is $NUM_NODES"
for i in `seq 1 $NUM_NODES`; do
mkdir -p "${CLUSTER_WD}/n${i}"
argsArray=(-c -s $CLUSTER_WD_FULL/n${i} -z localhost:${ZK_PORT}/solr_${SAFE_DEST} -p 898${i} -m $MEMORY \
argsArray=(-c --solr-home $CLUSTER_WD_FULL/n${i} -z localhost:${ZK_PORT}/solr_${SAFE_DEST} -p 898${i} -m $MEMORY \
-a "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=500${i} \
-Dsolr.log.dir=$CLUSTER_WD_FULL/n${i} $JVM_ARGS")
FINAL_COMMAND="${SOLR}/bin/solr ${argsArray[@]}"
Expand Down
4 changes: 2 additions & 2 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] [-s solr.solr.home] [-t solr.data.home] [--jvm-opts \"jvm-opts\"] [-V]"
echo "Usage: solr $CMD [-f] [-c] [--host host] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [-t 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 @@ -393,7 +393,7 @@ function print_usage() {
echo " -m/--memory <memory> Sets the min (-Xms) and max (-Xmx) heap size for the JVM, such as: -m 4g"
echo " results in: -Xms4g -Xmx4g; by default, this script sets the heap size to 512m"
echo ""
echo " -s <dir> Sets the solr.solr.home system property; Solr will create core directories under"
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 " specified directory should contain a solr.xml file, unless solr.xml exists in Zookeeper."
Expand Down
4 changes: 2 additions & 2 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] [-s solr.solr.home] [-t solr.data.home] [--jvm-opts "jvm-opts"] [-V]
@echo Usage: solr %SCRIPT_CMD% [-f] [-c] [--host hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [-t 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 @@ -333,7 +333,7 @@ goto done
@echo -m memory Sets the min (-Xms) and max (-Xmx) heap size for the JVM, such as: -m 4g
@echo results in: -Xms4g -Xmx4g; by default, this script sets the heap size to 512m
@echo.
@echo -s dir Sets the solr.solr.home system property; Solr will create core directories under
@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 specified directory should contain a solr.xml file, unless solr.xml exists in Zookeeper.
Expand Down
37 changes: 31 additions & 6 deletions solr/core/src/java/org/apache/solr/cli/AssertTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DeprecatedAttributes;
import org.apache.commons.cli.Option;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
Expand Down Expand Up @@ -65,18 +66,40 @@ public List<Option> getOptions() {
.longOpt("not-root")
.build(),
Option.builder("r").desc("Asserts that we are the root user.").longOpt("root").build(),
Option.builder("S")
Option.builder()
.desc("Asserts that Solr is NOT running on a certain URL. Default timeout is 1000ms.")
.longOpt("not-started")
.hasArg(true)
.argName("url")
.build(),
Option.builder("s")
Option.builder("S")
.desc("Asserts that Solr is NOT running on a certain URL. Default timeout is 1000ms.")
.deprecated(
DeprecatedAttributes.builder()
.setForRemoval(true)
.setSince("9.8")
.setDescription("Use --not-started instead")
.get())
.hasArg(true)
.argName("url")
.build(),
Option.builder()
.desc("Asserts that Solr is running on a certain URL. Default timeout is 1000ms.")
.longOpt("started")
.hasArg(true)
.argName("url")
.build(),
Option.builder("s")
.desc("Asserts that Solr is running on a certain URL. Default timeout is 1000ms.")
.deprecated(
DeprecatedAttributes.builder()
.setForRemoval(true)
.setSince("9.8")
.setDescription("Use --started instead")
.get())
.hasArg(true)
.argName("url")
.build(),
Option.builder()
.desc("Asserts that we run as same user that owns <directory>.")
.longOpt("same-user")
Expand Down Expand Up @@ -201,15 +224,17 @@ protected int runAssert(CommandLine cli) throws Exception {
if (cli.hasOption("same-user")) {
ret += sameUser(cli.getOptionValue("same-user"));
}
if (cli.hasOption("s")) {
if (cli.hasOption("s") || cli.hasOption("started")) {
ret +=
assertSolrRunning(
cli.getOptionValue("s"), cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));
SolrCLI.getOptionWithDeprecatedAndDefault(cli, "started", "s", null),
cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));
}
if (cli.hasOption("S")) {
if (cli.hasOption("S") || cli.hasOption("not-started")) {
ret +=
assertSolrNotRunning(
cli.getOptionValue("S"), cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));
SolrCLI.getOptionWithDeprecatedAndDefault(cli, "not-started", "S", null),
cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));
}
if (cli.hasOption("c")) {
ret +=
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/AuthTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/ConfigTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/CreateTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/DeleteTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/PackageTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public List<Option> getOptions() {
.required(true)
.desc("Name of the example to launch, one of: cloud, techproducts, schemaless, films.")
.build(),
Option.builder("s")
Option.builder()
.longOpt("script")
.hasArg()
.argName("PATH")
Expand Down Expand Up @@ -636,7 +636,7 @@ protected Map<String, Object> startSolr(
String startCmd =
String.format(
Locale.ROOT,
"\"%s\" start %s -p %d -s \"%s\" %s %s %s %s %s %s %s",
"\"%s\" start %s -p %d --solr-home \"%s\" %s %s %s %s %s %s %s",
callScript,
cloudModeArg,
port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public List<Option> getOptions() {
return List.of(
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
Option.builder("c")
.longOpt("name")
.argName("NAME")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public List<Option> getOptions() {
return List.of(
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
Option.builder("c")
.longOpt("name")
.argName("NAME")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public List<Option> getOptions() {
return List.of(
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
Option.builder("c")
.longOpt("name")
.argName("NAME")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public List<Option> getOptions() {
return List.of(
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
Option.builder("c")
.longOpt("name")
.argName("NAME")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public List<Option> getOptions() {
return List.of(
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
Option.builder("c")
.longOpt("name")
.argName("NAME")
Expand Down
31 changes: 27 additions & 4 deletions solr/core/src/java/org/apache/solr/cli/SolrCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public class SolrCLI implements CLIO {
+ '.')
.build();
public static final Option OPTION_SOLRURL =
Option.builder("url")
Option.builder("s")
.longOpt("solr-url")
.argName("HOST")
.hasArg()
Expand All @@ -145,6 +145,22 @@ public class SolrCLI implements CLIO {
+ getDefaultSolrUrl()
+ '.')
.build();
public static final Option OPTION_SOLRURL_DEPRECATED_SHORT =
Option.builder("url")
.argName("HOST")
.hasArg()
.required(false)
.deprecated(
DeprecatedAttributes.builder()
.setForRemoval(true)
.setSince("9.7")
.setDescription("Use -s instead")
.get())
.desc(
"Base Solr URL, which can be used to determine the zk-host if that's not known; defaults to: "
+ getDefaultSolrUrl()
+ '.')
.build();

public static final Option OPTION_VERBOSE =
Option.builder()
Expand Down Expand Up @@ -392,7 +408,7 @@ public static String getOptionWithDeprecatedAndDefault(
return val == null ? def : val;
}

// TODO: SOLR-17429 - remove the custom logic when CommonsCLI is upgraded and
// TODO: SOLR-17429 - remove the custom logic when Commons CLI is upgraded and
// makes stderr the default, or makes Option.toDeprecatedString() public.
private static void deprecatedHandlerStdErr(Option o) {
if (o.isDeprecated()) {
Expand Down Expand Up @@ -709,8 +725,15 @@ public static String normalizeSolrUrl(String solrUrl, boolean logUrlFormatWarnin
* ZooKeeper.
*/
public static String normalizeSolrUrl(CommandLine cli) throws Exception {
String solrUrl =
cli.hasOption("solr-url") ? cli.getOptionValue("solr-url") : cli.getOptionValue("solrUrl");
String solrUrl = null;
if (cli.hasOption("solr-url")) {
solrUrl = cli.getOptionValue("solr-url");
} else if (cli.hasOption("solrUrl")) {
solrUrl = cli.getOptionValue("solrUrl");
} else if (cli.hasOption("url")) {
solrUrl = cli.getOptionValue("url");
}

if (solrUrl == null) {
String zkHost =
cli.hasOption("zk-host") ? cli.getOptionValue("zk-host") : cli.getOptionValue("zkHost");
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/ZkCpTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public List<Option> getOptions() {
SolrCLI.OPTION_RECURSE,
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/ZkLsTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public List<Option> getOptions() {
SolrCLI.OPTION_RECURSE,
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/ZkMkrootTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public List<Option> getOptions() {
.build(),
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/ZkMvTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public List<Option> getOptions() {
return List.of(
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/ZkRmTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public List<Option> getOptions() {
SolrCLI.OPTION_RECURSE,
SolrCLI.OPTION_SOLRURL,
SolrCLI.OPTION_SOLRURL_DEPRECATED,
SolrCLI.OPTION_SOLRURL_DEPRECATED_SHORT,
SolrCLI.OPTION_ZKHOST,
SolrCLI.OPTION_ZKHOST_DEPRECATED,
SolrCLI.OPTION_CREDENTIALS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public int execute(org.apache.commons.exec.CommandLine cmd) throws IOException {
return startStandaloneSolr(args);
}

String solrHomeDir = getArg("-s", args);
String solrHomeDir = getArg("--solr-home", args);
int port = Integer.parseInt(getArg("-p", args));
String solrxml =
Files.readString(
Expand Down Expand Up @@ -226,7 +226,7 @@ protected int startStandaloneSolr(String[] args) {

int port = Integer.parseInt(getArg("-p", args));

File solrHomeDir = new File(getArg("-s", args));
File solrHomeDir = new File(getArg("--solr-home", args));

System.setProperty("host", "localhost");
System.setProperty("jetty.port", String.valueOf(port));
Expand Down Expand Up @@ -584,7 +584,7 @@ public void testFailExecuteScript() throws Exception {
"--server-dir", solrServerDir.getAbsolutePath(),
"--example-dir", solrExampleDir.getAbsolutePath(),
"-p", String.valueOf(bindPort),
"-script", toExecute.getAbsolutePath()
"--script", toExecute.getAbsolutePath()
};

// capture tool output to stdout
Expand Down
3 changes: 3 additions & 0 deletions solr/packaging/test/test_assert.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ teardown() {
}

@test "assert for non cloud mode" {
solr assert --not-started http://localhost:${SOLR_PORT} --timeout 5000
run solr start
solr assert --started http://localhost:${SOLR_PORT} --timeout 5000

run solr assert --not-cloud http://localhost:${SOLR_PORT}/solr
assert_output --partial "needn't include Solr's context-root"
Expand All @@ -43,6 +45,7 @@ teardown() {

@test "assert for cloud mode" {
run solr start -c
solr assert --started http://localhost:${SOLR_PORT} --timeout 5000

run solr assert --cloud http://localhost:${SOLR_PORT}
refute_output --partial "ERROR"
Expand Down
2 changes: 1 addition & 1 deletion solr/prometheus-exporter/bin/solr-exporter
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ if [[ -n "$PORT" ]]; then
fi

if [[ -n "$SCRAPE_INTERVAL" ]]; then
EXPORTER_ARGS+=(-s "$SCRAPE_INTERVAL")
EXPORTER_ARGS+=(--scrape-interval "$SCRAPE_INTERVAL")
fi

if [[ -n "$NUM_THREADS" ]]; then
Expand Down
Loading
Loading