Apache Solr open-source search software
SOLR-17481: Resolve use of -n flag in CLI commands (#2745)
Eric Pugha4cc5809c52e
diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.javaindex ea1e6da17bf..7690f6839f2 100644--- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java+++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java@@ -94,7 +94,7 @@ public class RunExampleTool extends ToolBase {@Overridepublic List<Option> getOptions() {return List.of(- Option.builder("n")+ Option.builder().longOpt("no-prompt").required(false).desc(diff --git a/solr/prometheus-exporter/bin/solr-exporter b/solr/prometheus-exporter/bin/solr-exporterindex 0d5e8529a1d..87109649151 100755--- a/solr/prometheus-exporter/bin/solr-exporter+++ b/solr/prometheus-exporter/bin/solr-exporter@@ -116,7 +116,7 @@ if [[ -n "$SCRAPE_INTERVAL" ]]; thenfiif [[ -n "$NUM_THREADS" ]]; then- EXPORTER_ARGS+=(-n "$NUM_THREADS")+ EXPORTER_ARGS+=(--num-threads "$NUM_THREADS")fiif [[ -n "$ZK_HOST" ]]; thendiff --git a/solr/prometheus-exporter/bin/solr-exporter.cmd b/solr/prometheus-exporter/bin/solr-exporter.cmdindex 417ab6c1273..aa861da7c97 100644--- a/solr/prometheus-exporter/bin/solr-exporter.cmd+++ b/solr/prometheus-exporter/bin/solr-exporter.cmd@@ -79,7 +79,7 @@ set EXPORTER_ARGS=IF NOT "%CONFIG_FILE%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% --config-file %CONFIG_FILE%IF NOT "%PORT%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -p %PORT%IF NOT "%SCRAPE_INTERVAL%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% --scrape-interval %SCRAPE_INTERVAL%-IF NOT "%NUM_THREADS%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -n %NUM_THREADS%+IF NOT "%NUM_THREADS%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% --num-threads %NUM_THREADS%IF NOT "%ZK_HOST%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -z %ZK_HOST%IF NOT "%SOLR_URL%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -b %SOLR_URL%IF NOT "%CLUSTER_ID%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -i "%CLUSTER_ID%"diff --git a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.javaindex 68534978188..a6924cded36 100644--- a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java+++ b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java@@ -214,7 +214,7 @@ public class SolrExporter {mainOptions.addOption(clusterIdOption);Option numThreadsOption =- Option.builder("n")+ Option.builder().longOpt("num-threads").hasArg().argName("NUM_THREADS")@@ -225,6 +225,23 @@ public class SolrExporter {+ ".").build();mainOptions.addOption(numThreadsOption);+ Option numThreadsOptionDeprecated =+ Option.builder("n")+ .hasArg()+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --num-threads instead")+ .get())+ .argName("NUM_THREADS")+ .type(Integer.class)+ .desc(+ "Specify the number of threads. solr-exporter creates a thread pools for request to Solr. If you need to improve request latency via solr-exporter, you can increase the number of threads; the default is "+ + DEFAULT_NUM_THREADS+ + ".")+ .build();+ mainOptions.addOption(numThreadsOptionDeprecated);Option portOption =Option.builder("p")@@ -366,6 +383,12 @@ public class SolrExporter {} else if (commandLine.hasOption(configOption)) {configFile = commandLine.getOptionValue(configOption);}+ int numberOfThreads = DEFAULT_NUM_THREADS;+ if (commandLine.hasOption("num-threads")) {+ numberOfThreads = commandLine.getParsedOptionValue("num-threads");+ } else if (commandLine.hasOption("n")) {+ numberOfThreads = commandLine.getParsedOptionValue("n");+ }int scrapeInterval = DEFAULT_SCRAPE_INTERVAL;if (commandLine.hasOption("s")) {@@ -377,7 +400,7 @@ public class SolrExporter {SolrExporter solrExporter =new SolrExporter(port,- commandLine.getParsedOptionValue(numThreadsOption, DEFAULT_NUM_THREADS),+ numberOfThreads,scrapeInterval,scrapeConfiguration,loadMetricsConfiguration(configFile),diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adocindex d6ce94d6c59..eb2b8d94c29 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc@@ -62,14 +62,14 @@ Linux::[source,bash]----$ cd prometheus-exporter-$ ./bin/solr-exporter -p 9854 -b http://localhost:8983/solr --config-file ./conf/solr-exporter-config.xml -n 8+$ ./bin/solr-exporter -p 9854 -b http://localhost:8983/solr --config-file ./conf/solr-exporter-config.xml --num-threads 8----.SolrCloud[source,bash]----$ cd prometheus-exporter-$ ./bin/solr-exporter -p 9854 -z localhost:2181/solr --config-file ./conf/solr-exporter-config.xml -n 16+$ ./bin/solr-exporter -p 9854 -z localhost:2181/solr --config-file ./conf/solr-exporter-config.xml --num-threads 16----====@@ -80,14 +80,14 @@ Windows::[source,text]----> cd prometheus-exporter-> .\bin\solr-exporter.cmd -p 9854 -b http://localhost:8983/solr --config-file .\conf\solr-exporter-config.xml -n 8+> .\bin\solr-exporter.cmd -p 9854 -b http://localhost:8983/solr --config-file .\conf\solr-exporter-config.xml --num-threads 8----.SolrCloud[source,text]----> cd prometheus-exporter-> .\bin\solr-exporter -p 9854 -z localhost:2181/solr --config-file .\conf\solr-exporter-config.xml -n 16+> .\bin\solr-exporter -p 9854 -z localhost:2181/solr --config-file .\conf\solr-exporter-config.xml --num-threads 16----==========@@ -148,7 +148,7 @@ If neither the `-b` parameter nor the `-z` parameter are defined, the `-b` param+The path to the configuration file that defines the Solr metrics to read.-`-n`, `--num-threads`, `$NUM_THREADS`::+`--num-threads`, `$NUM_THREADS`::+[%autowidth,frame=none]|===@@ -285,7 +285,7 @@ $ cd prometheus-exporter$ export JAVA_OPTS="-Djavax.net.ssl.trustStore=truststore.p12 -Djavax.net.ssl.trustStorePassword=truststorePassword -Dsolr.httpclient.builder.factory=org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory -Dsolr.httpclient.config=basicauth.properties"$ export ZK_CREDS_AND_ACLS="-DzkCredentialsProvider=org.apache.solr.common.cloud.VMParamsSingleSetCredentialsDigestZkCredentialsProvider -DzkDigestUsername=readonly-user -DzkDigestPassword=zkUserPassword"$ export CLASSPATH_PREFIX="../server/solr-webapp/webapp/WEB-INF/lib/commons-codec-1.11.jar"-$ ./bin/solr-exporter -p 9854 -z zk1:2181,zk2:2181,zk3:2181 --config-file ./conf/solr-exporter-config.xml -n 16+$ ./bin/solr-exporter -p 9854 -z zk1:2181,zk2:2181,zk3:2181 --config-file ./conf/solr-exporter-config.xml --num-threads 16----NOTE:: The Exporter needs the `commons-codec` library for SSL/BasicAuth, but does not bring it.