You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ge...@apache.org on 2018/02/18 00:12:55 UTC

lucene-solr:master: SOLR-11108: Shorten/improve _default-configset msg

Repository: lucene-solr
Updated Branches:
  refs/heads/master d91e4cbea -> b4f8cd7ea


SOLR-11108: Shorten/improve _default-configset msg

The bin/solr scripts print a warning message when a user creates a
collection that makes use of the default config (which has settings
not recommended for production).

While helpful, this warning was a little too noisy.  It also suggested
users resolve the issue with a provided curl command, but bin/solr is
also capable of performing the same action.

This commit cleans up the error message a bit.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/b4f8cd7e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/b4f8cd7e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/b4f8cd7e

Branch: refs/heads/master
Commit: b4f8cd7ea6bcbf3974228857ff9d92b545e2c33e
Parents: d91e4cb
Author: Jason Gerlowski <ge...@apache.org>
Authored: Sat Feb 17 19:08:26 2018 -0500
Committer: Jason Gerlowski <ge...@apache.org>
Committed: Sat Feb 17 19:08:26 2018 -0500

----------------------------------------------------------------------
 solr/bin/solr                                   | 14 +++++----
 solr/bin/solr.cmd                               | 19 ++++++++---
 .../src/java/org/apache/solr/util/SolrCLI.java  | 33 ++++++++++++++++++--
 3 files changed, 52 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b4f8cd7e/solr/bin/solr
----------------------------------------------------------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index 1ef18fc..4e178de 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -295,7 +295,7 @@ function print_usage() {
   if [ -z "$CMD" ]; then
     echo ""
     echo "Usage: solr COMMAND OPTIONS"
-    echo "       where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert"
+    echo "       where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config"
     echo ""
     echo "  Standalone server example (start Solr running in the background on port 8984):"
     echo ""
@@ -895,6 +895,11 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
   exit $?
 fi
 
+if [[ "$SCRIPT_CMD" == "config" ]]; then
+  run_tool config $*
+  exit $?
+fi
+
 # create a core or collection
 if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMD" == "create_collection" ]]; then
 
@@ -1015,11 +1020,8 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
   fi
 
   if [[ "$CREATE_CONFDIR" == "_default" ]] && ([[ "$CREATE_CONFNAME" == "" ]] || [[ "$CREATE_CONFNAME" == "_default" ]]); then
-    echo "WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is"
-    echo "         NOT RECOMMENDED for production use."
-    echo
-    echo "         To turn it off:"
-    echo "            curl http://$SOLR_TOOL_HOST:$CREATE_PORT/solr/$CREATE_NAME/config -d '{\"set-user-property\": {\"update.autoCreateFields\":\"false\"}}'"
+    echo "WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use."
+    echo "         To turn off: bin/solr config -c $CREATE_NAME -p $CREATE_PORT -property update.autoCreateFields -value false"
   fi
 
   if [[ "$(whoami)" == "root" ]] && [[ "$FORCE" == "false" ]] ; then

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b4f8cd7e/solr/bin/solr.cmd
----------------------------------------------------------------------
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index 40a0cf3..dcff0c6 100644
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -200,6 +200,7 @@ IF "%1"=="version" goto get_version
 IF "%1"=="-v" goto get_version
 IF "%1"=="-version" goto get_version
 IF "%1"=="assert" goto run_assert
+if "%1"=="config" goto run_config
 
 REM Only allow the command to be the first argument, assume start if not supplied
 IF "%1"=="start" goto set_script_cmd
@@ -268,7 +269,7 @@ goto done
 :script_usage
 @echo.
 @echo Usage: solr COMMAND OPTIONS
-@echo        where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert
+@echo        where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config
 @echo.
 @echo   Standalone server example (start Solr running in the background on port 8984):
 @echo.
@@ -1363,6 +1364,16 @@ if errorlevel 1 (
 )
 goto done
 
+:run_config
+"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
+  -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
+  -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
+  org.apache.solr.util.SolrCLI %* 
+if errorlevel 1 (
+   exit /b 1
+)
+goto done
+
 :get_version
 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
   -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
@@ -1475,10 +1486,8 @@ if "!CREATE_PORT!"=="" (
 )
 
 if "!CREATE_CONFDIR!"=="_default" (
-  echo WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is
-  echo          NOT RECOMMENDED for production use.
-  echo          To turn it off:
-  echo             curl http://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr/!CREATE_NAME!/config -d '{"set-user-property": {"update.autoCreateFields":"false"}}'
+  echo WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.
+  echo          To turn off: bin\solr config -c !CREATE_NAME! -p !CREATE_PORT! -property update.autoCreateFields -value false
 )
 
 if "%SCRIPT_CMD%"=="create_core" (

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b4f8cd7e/solr/core/src/java/org/apache/solr/util/SolrCLI.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
index f4cd7c7..266ef3a 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
@@ -238,7 +238,8 @@ public class SolrCLI {
         .hasArg()
         .isRequired(false)
         .withDescription("Name of collection; no default")
-        .create("collection"),
+        .withLongOpt("collection")
+        .create("c"),
     OptionBuilder
         .isRequired(false)
         .withDescription("Enable more verbose command output.")
@@ -2525,13 +2526,39 @@ public class SolrCLI {
               .hasArg()
               .isRequired(false)
               .withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")
-              .create("solrUrl")
+              .create("solrUrl"),
+          OptionBuilder
+              .withArgName("PORT")
+              .hasArg()
+              .isRequired(false)
+              .withDescription("The port of the Solr node to use when applying configuration change")
+              .withLongOpt("port")
+              .create('p'),
+          OptionBuilder
+              .withArgName("SCHEME")
+              .hasArg()
+              .isRequired(false)
+              .withDescription("The scheme for accessing Solr.  Accepted values: http or https.  Default: http")
+              .withLongOpt("scheme")
+              .create('s')
       };
       return joinOptions(configOptions, cloudOptions);
     }
 
     protected void runImpl(CommandLine cli) throws Exception {
-      String solrUrl = resolveSolrUrl(cli);
+      String solrUrl;
+      try {
+        solrUrl = resolveSolrUrl(cli);
+      } catch (IllegalStateException e) {
+        // Fallback to using the provided scheme and port
+        final String scheme = cli.getOptionValue("scheme", "http");
+        if (cli.hasOption("port")) {
+          solrUrl = scheme + "://localhost:" + cli.getOptionValue("port", "8983") + "/solr";
+        } else {
+          throw e;
+        }
+      }
+
       String action = cli.getOptionValue("action", "set-property");
       String collection = cli.getOptionValue("collection", "gettingstarted");
       String property = cli.getOptionValue("property");