You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2015/08/05 06:23:52 UTC
svn commit: r1694137 [1/2] - in /lucene/dev/branches/branch_5x: ./ lucene/
solr/ solr/bin/ solr/core/ solr/core/src/java/org/apache/solr/util/
solr/core/src/test/org/apache/solr/cloud/
solr/core/src/test/org/apache/solr/util/ solr/licenses/
Author: thelabdude
Date: Wed Aug 5 04:23:51 2015
New Revision: 1694137
URL: http://svn.apache.org/r1694137
Log:
SOLR-7847: Implement run example logic in Java instead of OS-specific scripts in bin/solr
Added:
lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
- copied unchanged from r1694083, lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
lucene/dev/branches/branch_5x/solr/licenses/commons-exec-1.3.jar.sha1
- copied unchanged from r1694083, lucene/dev/trunk/solr/licenses/commons-exec-1.3.jar.sha1
lucene/dev/branches/branch_5x/solr/licenses/commons-exec-LICENSE-ASL.txt
- copied unchanged from r1694083, lucene/dev/trunk/solr/licenses/commons-exec-LICENSE-ASL.txt
lucene/dev/branches/branch_5x/solr/licenses/commons-exec-NOTICE.txt
- copied unchanged from r1694083, lucene/dev/trunk/solr/licenses/commons-exec-NOTICE.txt
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/ivy-versions.properties (contents, props changed)
lucene/dev/branches/branch_5x/solr/ (props changed)
lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/solr/bin/ (props changed)
lucene/dev/branches/branch_5x/solr/bin/solr
lucene/dev/branches/branch_5x/solr/bin/solr.cmd
lucene/dev/branches/branch_5x/solr/core/ (props changed)
lucene/dev/branches/branch_5x/solr/core/ivy.xml
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java
lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
lucene/dev/branches/branch_5x/solr/licenses/ (props changed)
Modified: lucene/dev/branches/branch_5x/lucene/ivy-versions.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/ivy-versions.properties?rev=1694137&r1=1694136&r2=1694137&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/ivy-versions.properties (original)
+++ lucene/dev/branches/branch_5x/lucene/ivy-versions.properties Wed Aug 5 04:23:51 2015
@@ -90,6 +90,7 @@ com.sun.jersey.version = 1.9
/org.apache.ant/ant = 1.8.2
/org.apache.avro/avro = 1.7.5
/org.apache.commons/commons-compress = 1.8.1
+/org.apache.commons/commons-exec = 1.3
/org.apache.commons/commons-math3 = 3.4.1
org.apache.curator.version = 2.8.0
Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1694137&r1=1694136&r2=1694137&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Wed Aug 5 04:23:51 2015
@@ -342,6 +342,9 @@ Other Changes
* SOLR-7832: bin/post now allows either -url or -c, rather than requiring both. (ehatcher)
+* SOLR-7847: Implement run example logic in Java instead of OS-specific scripts in
+ bin/solr and bin\solr.cmd (Timothy Potter)
+
================== 5.2.1 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
Modified: lucene/dev/branches/branch_5x/solr/bin/solr
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/bin/solr?rev=1694137&r1=1694136&r2=1694137&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/bin/solr (original)
+++ lucene/dev/branches/branch_5x/solr/bin/solr Wed Aug 5 04:23:51 2015
@@ -809,12 +809,14 @@ fi
FG="false"
noprompt=false
SOLR_OPTS=($SOLR_OPTS)
+PASS_TO_RUN_EXAMPLE=
if [ $# -gt 0 ]; then
while true; do
case "$1" in
-c|-cloud)
SOLR_MODE="solrcloud"
+ PASS_TO_RUN_EXAMPLE+=" -c"
shift
;;
-d|-dir)
@@ -864,6 +866,7 @@ if [ $# -gt 0 ]; then
exit 1
fi
SOLR_HOST="$2"
+ PASS_TO_RUN_EXAMPLE+=" -h $SOLR_HOST"
shift 2
;;
-m|-memory)
@@ -872,6 +875,7 @@ if [ $# -gt 0 ]; then
exit 1
fi
SOLR_HEAP="$2"
+ PASS_TO_RUN_EXAMPLE+=" -m $SOLR_HEAP"
shift 2
;;
-p|-port)
@@ -880,6 +884,7 @@ if [ $# -gt 0 ]; then
exit 1
fi
SOLR_PORT="$2"
+ PASS_TO_RUN_EXAMPLE+=" -p $SOLR_PORT"
shift 2
;;
-z|-zkhost)
@@ -889,10 +894,12 @@ if [ $# -gt 0 ]; then
fi
ZK_HOST="$2"
SOLR_MODE="solrcloud"
+ PASS_TO_RUN_EXAMPLE+=" -z $ZK_HOST"
shift 2
;;
-a|-addlopts)
ADDITIONAL_CMD_OPTS="$2"
+ PASS_TO_RUN_EXAMPLE+=" -a \"$ADDITIONAL_CMD_OPTS\""
shift 2
;;
-k|-key)
@@ -905,10 +912,12 @@ if [ $# -gt 0 ]; then
;;
-noprompt)
noprompt=true
+ PASS_TO_RUN_EXAMPLE+=" -noprompt"
shift
;;
-V|-verbose)
verbose=true
+ PASS_TO_RUN_EXAMPLE+=" --verbose"
shift
;;
-all)
@@ -923,6 +932,7 @@ if [ $# -gt 0 ]; then
if [ "${1:0:2}" == "-D" ]; then
# pass thru any opts that begin with -D (java system props)
SOLR_OPTS+=("$1")
+ PASS_TO_RUN_EXAMPLE+=" $1"
shift
else
if [ "$1" != "" ]; then
@@ -937,18 +947,6 @@ if [ $# -gt 0 ]; then
done
fi
-if $verbose ; then
- echo "Using Solr root directory: $SOLR_TIP"
- echo "Using Java: $JAVA"
- "$JAVA" -version
-fi
-
-if [ "$SOLR_HOST" != "" ]; then
- SOLR_HOST_ARG=("-Dhost=$SOLR_HOST")
-else
- SOLR_HOST_ARG=()
-fi
-
if [ -z "$SOLR_SERVER_DIR" ]; then
SOLR_SERVER_DIR="$DEFAULT_SERVER_DIR"
fi
@@ -958,126 +956,32 @@ if [ ! -e "$SOLR_SERVER_DIR" ]; then
exit 1
fi
-CLOUD_NUM_NODES=2
-declare -a CLOUD_PORTS=('8983' '7574' '8984' '7575');
+if [[ "$FG" == 'true' && "$EXAMPLE" != "" ]]; then
+ FG='false'
+ echo -e "\nWARNING: Foreground mode (-f) not supported when running examples.\n"
+fi
-# select solr.solr.home based on the desired example
-if [ "$EXAMPLE" != "" ]; then
- case $EXAMPLE in
- cloud)
- #
- # Engage in an interactive session with user to setup the SolrCloud example
- #
- echo -e "\nWelcome to the SolrCloud example!\n\n"
- if $noprompt ; then
- CLOUD_NUM_NODES=2
- echo -e "Starting up $CLOUD_NUM_NODES Solr nodes for your example SolrCloud cluster."
- else
- echo -e "This interactive session will help you launch a SolrCloud cluster on your local workstation.\n"
- read -e -p "To begin, how many Solr nodes would you like to run in your local cluster? (specify 1-4 nodes) [2] " USER_INPUT
- while true
- do
- CLOUD_NUM_NODES=`echo $USER_INPUT | tr -d ' '`
- if [ -z "$CLOUD_NUM_NODES" ]; then
- CLOUD_NUM_NODES=2
- fi
- if [[ $CLOUD_NUM_NODES > 4 || $CLOUD_NUM_NODES < 1 ]]; then
- read -e -p "Please provide a node count between 1 and 4 [2] " USER_INPUT
- else
- break;
- fi
- done
-
- echo -e "Ok, let's start up $CLOUD_NUM_NODES Solr nodes for your example SolrCloud cluster.\n"
- for (( s=0; s<$CLOUD_NUM_NODES; s++ ))
- do
- read -e -p "Please enter the port for node$[$s+1] [${CLOUD_PORTS[$s]}] " USER_INPUT
- while true
- do
- # trim whitespace out of the user input
- CLOUD_PORT=`echo $USER_INPUT | tr -d ' '`
-
- # handle the default selection or empty input
- if [ -z "$CLOUD_PORT" ]; then
- CLOUD_PORT=${CLOUD_PORTS[$s]}
- fi
-
- # check to see if something is already bound to that port
- if hash lsof 2>/dev/null ; then # hash returns true if lsof is on the path
- PORT_IN_USE=`lsof -PniTCP:$CLOUD_PORT -sTCP:LISTEN`
- if [ "$PORT_IN_USE" != "" ]; then
- read -e -p "Oops! Looks like port $CLOUD_PORT is already being used by another process. Please choose a different port. " USER_INPUT
- else
- CLOUD_PORTS[$s]=$CLOUD_PORT
- echo $CLOUD_PORT
- break;
- fi
- else
- CLOUD_PORTS[$s]=$CLOUD_PORT
- echo $CLOUD_PORT
- break;
- fi
- done
- done
- fi
-
- # setup a unqiue solr.solr.home directory for each node
- CLOUD_EXAMPLE_DIR="$SOLR_TIP/example/cloud"
- if [ ! -d "$CLOUD_EXAMPLE_DIR/node1/solr" ]; then
- echo "Creating Solr home directory $CLOUD_EXAMPLE_DIR/node1/solr"
- mkdir -p "$CLOUD_EXAMPLE_DIR/node1/solr"
- cp "$DEFAULT_SERVER_DIR/solr/solr.xml" "$CLOUD_EXAMPLE_DIR/node1/solr/"
- cp "$DEFAULT_SERVER_DIR/solr/zoo.cfg" "$CLOUD_EXAMPLE_DIR/node1/solr/"
- fi
+#
+# If the user specified an example to run, invoke the run_example tool (Java app) and exit
+# otherwise let this script proceed to process the user request
+#
+if [ -n "$EXAMPLE" ] && [ "$SCRIPT_CMD" == "start" ]; then
+ run_tool run_example -e $EXAMPLE -d "$SOLR_SERVER_DIR" -urlScheme $SOLR_URL_SCHEME $PASS_TO_RUN_EXAMPLE
+ exit $?
+fi
- for (( s=1; s<$CLOUD_NUM_NODES; s++ ))
- do
- ndx=$[$s+1]
- if [ ! -d "$CLOUD_EXAMPLE_DIR/node$ndx" ]; then
- echo "Cloning Solr home directory $CLOUD_EXAMPLE_DIR/node1 into $CLOUD_EXAMPLE_DIR/node$ndx"
- cp -r "$CLOUD_EXAMPLE_DIR/node1" "$CLOUD_EXAMPLE_DIR/node$ndx"
- fi
- done
- SOLR_MODE="solrcloud"
- SOLR_SERVER_DIR="$SOLR_TIP/server"
- SOLR_HOME="$CLOUD_EXAMPLE_DIR/node1/solr"
- SOLR_PORT="${CLOUD_PORTS[0]}"
- shift
- ;;
- techproducts)
- SOLR_HOME="$SOLR_TIP/example/techproducts/solr"
- mkdir -p "$SOLR_HOME"
- if [ ! -f "$SOLR_HOME/solr.xml" ]; then
- cp "$DEFAULT_SERVER_DIR/solr/solr.xml" "$SOLR_HOME/solr.xml"
- cp "$DEFAULT_SERVER_DIR/solr/zoo.cfg" "$SOLR_HOME/zoo.cfg"
- fi
- EXAMPLE_CONFIGSET='sample_techproducts_configs'
- shift
- ;;
- dih)
- SOLR_HOME="$SOLR_TIP/example/example-DIH/solr"
- shift
- ;;
- schemaless)
- SOLR_HOME="$SOLR_TIP/example/schemaless/solr"
- mkdir -p "$SOLR_HOME"
- if [ ! -f "$SOLR_HOME/solr.xml" ]; then
- cp "$DEFAULT_SERVER_DIR/solr/solr.xml" "$SOLR_HOME/solr.xml"
- cp "$DEFAULT_SERVER_DIR/solr/zoo.cfg" "$SOLR_HOME/zoo.cfg"
- fi
- EXAMPLE_CONFIGSET='data_driven_schema_configs'
- shift
- ;;
- *)
- print_usage "start" "Unsupported example $EXAMPLE! Please choose one of: cloud, dih, schemaless, or techproducts"
- exit 1
- ;;
- esac
+############# start/stop logic below here ################
+
+if $verbose ; then
+ echo "Using Solr root directory: $SOLR_TIP"
+ echo "Using Java: $JAVA"
+ "$JAVA" -version
fi
-if [[ "$FG" == 'true' && "$EXAMPLE" != "" ]]; then
- FG='false'
- echo -e "\nWARNING: Foreground mode (-f) not supported when running examples.\n"
+if [ "$SOLR_HOST" != "" ]; then
+ SOLR_HOST_ARG=("-Dhost=$SOLR_HOST")
+else
+ SOLR_HOST_ARG=()
fi
if [ -z "$STOP_KEY" ]; then
@@ -1409,7 +1313,7 @@ function launch_solr() {
# no lsof on cygwin though
if hash lsof 2>/dev/null ; then # hash returns true if lsof is on the path
- echo -n "Waiting to see Solr listening on port $SOLR_PORT"
+ echo -n "Waiting up to 30 seconds to see Solr running on port $SOLR_PORT"
# Launch in a subshell to show the spinner
(loops=0
while true
@@ -1441,152 +1345,6 @@ function launch_solr() {
fi
}
-if [ "$EXAMPLE" != "cloud" ]; then
- launch_solr "$FG" "$ADDITIONAL_CMD_OPTS"
-
- # create the core/collection for the requested example after launching Solr
- if [[ "$EXAMPLE" == "schemaless" || "$EXAMPLE" == "techproducts" ]]; then
-
- if [ "$EXAMPLE" == "schemaless" ]; then
- EXAMPLE_NAME=gettingstarted
- else
- EXAMPLE_NAME="$EXAMPLE"
- fi
-
- run_tool create -name "$EXAMPLE_NAME" -shards 1 -replicationFactor 1 \
- -confname "$EXAMPLE_NAME" -confdir "$EXAMPLE_CONFIGSET" \
- -configsetsDir "$SOLR_TIP/server/solr/configsets" -solrUrl $SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr
- if [ $? -ne 0 ]; then
- exit 1
- fi
-
- if [ "$EXAMPLE" == "techproducts" ]; then
- echo "Indexing tech product example docs from $SOLR_TIP/example/exampledocs"
- "$JAVA" $SOLR_SSL_OPTS -Durl="$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr/$EXAMPLE/update" \
- -jar "$SOLR_TIP/example/exampledocs/post.jar" "$SOLR_TIP/example/exampledocs"/*.xml
- fi
-
- echo -e "\nSolr $EXAMPLE example launched successfully. Direct your Web browser to $SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr to visit the Solr Admin UI\n"
- fi
-else
- #
- # SolrCloud example is a bit involved so needs special handling here
- #
- SOLR_SERVER_DIR="$SOLR_TIP/server"
- SOLR_HOME="$SOLR_TIP/example/cloud/node1/solr"
- SOLR_PORT="${CLOUD_PORTS[0]}"
-
- if [ "$ZK_HOST" != "" ]; then
- DASHZ="-z $ZK_HOST"
- fi
-
- if [ "$SOLR_HEAP" != "" ]; then
- DASHM="-m $SOLR_HEAP"
- fi
-
- if [ "$ADDITIONAL_CMD_OPTS" != "" ]; then
- DASHA="-a $ADDITIONAL_CMD_OPTS"
- fi
-
- echo -e "\nStarting up SolrCloud node1 on port ${CLOUD_PORTS[0]} using command:\n"
- echo -e "solr start -cloud -s example/cloud/node1/solr -p $SOLR_PORT $DASHZ $DASHM $DASHA\n\n"
-
- # can't launch this node in the foreground else we can't run anymore commands
- launch_solr "false" "$ADDITIONAL_CMD_OPTS"
-
- # if user did not define a specific -z parameter, assume embedded in first cloud node we launched above
- zk_host="$ZK_HOST"
- if [ -z "$zk_host" ]; then
- zk_port=$[$SOLR_PORT+1000]
- zk_host="localhost:$zk_port"
- fi
-
- for (( s=1; s<$CLOUD_NUM_NODES; s++ ))
- do
- ndx=$[$s+1]
- next_port="${CLOUD_PORTS[$s]}"
- echo -e "\n\nStarting node$ndx on port $next_port using command:\n"
- echo -e "solr start -cloud -s example/cloud/node$ndx/solr -p $next_port -z $zk_host $DASHM $DASHA \n\n"
- # call this script again with correct args for next node
- "$SOLR_TIP/bin/solr" start -cloud -s "$SOLR_TIP/example/cloud/node$ndx/solr" -p "$next_port" -z "$zk_host" $DASHM $DASHA
- done
-
- # TODO: better (shorter) name??
- CLOUD_COLLECTION='gettingstarted'
-
- if $noprompt ; then
- CLOUD_NUM_SHARDS=2
- CLOUD_REPFACT=2
- CLOUD_CONFIG='data_driven_schema_configs'
- else
- echo -e "\nNow let's create a new collection for indexing documents in your $CLOUD_NUM_NODES-node cluster.\n"
- read -e -p "Please provide a name for your new collection: [gettingstarted] " USER_INPUT
- # trim whitespace out of the user input
- CLOUD_COLLECTION=`echo "$USER_INPUT" | tr -d ' '`
-
- # handle the default selection or empty input
- if [ -z "$CLOUD_COLLECTION" ]; then
- CLOUD_COLLECTION='gettingstarted'
- fi
- echo $CLOUD_COLLECTION
-
- USER_INPUT=
- read -e -p "How many shards would you like to split $CLOUD_COLLECTION into? [2] " USER_INPUT
- # trim whitespace out of the user input
- CLOUD_NUM_SHARDS=`echo "$USER_INPUT" | tr -d ' '`
-
- # handle the default selection or empty input
- if [ -z "$CLOUD_NUM_SHARDS" ]; then
- CLOUD_NUM_SHARDS=2
- fi
- echo $CLOUD_NUM_SHARDS
-
- USER_INPUT=
- read -e -p "How many replicas per shard would you like to create? [2] " USER_INPUT
- # trim whitespace out of the user input
- CLOUD_REPFACT=`echo $USER_INPUT | tr -d ' '`
-
- # handle the default selection or empty input
- if [ -z "$CLOUD_REPFACT" ]; then
- CLOUD_REPFACT=2
- fi
- echo $CLOUD_REPFACT
-
- USER_INPUT=
- echo "Please choose a configuration for the $CLOUD_COLLECTION collection, available options are:"
- read -e -p "basic_configs, data_driven_schema_configs, or sample_techproducts_configs [data_driven_schema_configs] " USER_INPUT
- while true
- do
- # trim whitespace out of the user input
- CLOUD_CONFIG=`echo "$USER_INPUT" | tr -d ' '`
-
- # handle the default selection or empty input
- if [ -z "$CLOUD_CONFIG" ]; then
- CLOUD_CONFIG='data_driven_schema_configs'
- fi
-
- # validate the confdir arg
- if [[ ! -d "$SOLR_TIP/server/solr/configsets/$CLOUD_CONFIG" && ! -d "$CLOUD_CONFIG" ]]; then
- echo -e "\nOops! Specified configuration $CLOUD_CONFIG not found!"
- read -e -p "Choose one of: basic_configs, data_driven_schema_configs, or sample_techproducts_configs [data_driven_schema_configs] " USER_INPUT
- CLOUD_CONFIG=
- else
- break;
- fi
- done
-
- fi
-
- run_tool create_collection -name "$CLOUD_COLLECTION" -shards $CLOUD_NUM_SHARDS -replicationFactor $CLOUD_REPFACT \
- -confname "$CLOUD_COLLECTION" -confdir "$CLOUD_CONFIG" \
- -configsetsDir "$SOLR_TIP/server/solr/configsets" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr"
-
- # enable soft-autocommits for the gettingstarted collection
- echo -e "\nEnabling auto soft-commits with maxTime 3 secs using the Config API"
- run_tool config -collection "$CLOUD_COLLECTION" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr" \
- -property updateHandler.autoSoftCommit.maxTime -value 3000
-
- echo -e "\n\nSolrCloud example running, please visit $SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr \n\n"
-fi
+launch_solr "$FG" "$ADDITIONAL_CMD_OPTS"
exit $?
Modified: lucene/dev/branches/branch_5x/solr/bin/solr.cmd
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/bin/solr.cmd?rev=1694137&r1=1694136&r2=1694137&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/bin/solr.cmd (original)
+++ lucene/dev/branches/branch_5x/solr/bin/solr.cmd Wed Aug 5 04:23:51 2015
@@ -18,6 +18,8 @@
IF "%OS%"=="Windows_NT" setlocal enabledelayedexpansion enableextensions
+set "PASS_TO_RUN_EXAMPLE="
+
REM Determine top-level Solr directory
set SDIR=%~dp0
IF "%SDIR:~-1%"=="\" set SDIR=%SDIR:~0,-1%
@@ -378,6 +380,7 @@ goto parse_args
:set_verbose
set verbose=1
+set "PASS_TO_RUN_EXAMPLE=--verbose !PASS_TO_RUN_EXAMPLE!"
SHIFT
goto parse_args
@@ -461,6 +464,7 @@ IF "%firstChar%"=="-" (
)
set SOLR_HEAP=%~2
+set "PASS_TO_RUN_EXAMPLE=-m %~2 !PASS_TO_RUN_EXAMPLE!"
SHIFT
SHIFT
goto parse_args
@@ -479,6 +483,7 @@ IF "%firstChar%"=="-" (
)
set SOLR_HOST=%~2
+set "PASS_TO_RUN_EXAMPLE=-h %~2 !PASS_TO_RUN_EXAMPLE!"
SHIFT
SHIFT
goto parse_args
@@ -497,6 +502,7 @@ IF "%firstChar%"=="-" (
)
set SOLR_PORT=%~2
+set "PASS_TO_RUN_EXAMPLE=-p %~2 !PASS_TO_RUN_EXAMPLE!"
SHIFT
SHIFT
goto parse_args
@@ -538,6 +544,7 @@ IF "%firstChar%"=="-" (
)
set "ZK_HOST=%~2"
+set "PASS_TO_RUN_EXAMPLE=-z %~2 !PASS_TO_RUN_EXAMPLE!"
SHIFT
SHIFT
goto parse_args
@@ -556,12 +563,15 @@ IF NOT "%SOLR_OPTS%"=="" (
) ELSE (
set "SOLR_OPTS=%PASSTHRU%"
)
+set "PASS_TO_RUN_EXAMPLE=%PASSTHRU% !PASS_TO_RUN_EXAMPLE!"
SHIFT
SHIFT
goto parse_args
:set_noprompt
set NO_USER_PROMPT=1
+set "PASS_TO_RUN_EXAMPLE=-noprompt !PASS_TO_RUN_EXAMPLE!"
+
SHIFT
goto parse_args
@@ -588,41 +598,7 @@ IF NOT EXIST "%SOLR_SERVER_DIR%" (
goto err
)
-IF "%EXAMPLE%"=="" (
- IF NOT "%SOLR_HOME%"=="" (
- REM Absolutize a relative solr home
- IF EXIST "%cd%\%SOLR_HOME%" set "SOLR_HOME=%cd%\%SOLR_HOME%"
- )
- REM Otherwise SOLR_HOME just becomes %SOLR_SERVER_DIR%/solr
-) ELSE IF "%EXAMPLE%"=="techproducts" (
- mkdir "%SOLR_TIP%\example\techproducts\solr"
- set "SOLR_HOME=%SOLR_TIP%\example\techproducts\solr"
- IF NOT EXIST "!SOLR_HOME!\solr.xml" (
- copy "%DEFAULT_SERVER_DIR%\solr\solr.xml" "!SOLR_HOME!\solr.xml"
- )
- IF NOT EXIST "!SOLR_HOME!\zoo.cfg" (
- copy "%DEFAULT_SERVER_DIR%\solr\zoo.cfg" "!SOLR_HOME!\zoo.cfg"
- )
-) ELSE IF "%EXAMPLE%"=="cloud" (
- set SOLR_MODE=solrcloud
- goto cloud_example_start
-) ELSE IF "%EXAMPLE%"=="dih" (
- set "SOLR_HOME=%SOLR_TIP%\example\example-DIH\solr"
-) ELSE IF "%EXAMPLE%"=="schemaless" (
- mkdir "%SOLR_TIP%\example\schemaless\solr"
- set "SOLR_HOME=%SOLR_TIP%\example\schemaless\solr"
- IF NOT EXIST "!SOLR_HOME!\solr.xml" (
- copy "%DEFAULT_SERVER_DIR%\solr\solr.xml" "!SOLR_HOME!\solr.xml"
- )
- IF NOT EXIST "!SOLR_HOME!\zoo.cfg" (
- copy "%DEFAULT_SERVER_DIR%\solr\zoo.cfg" "!SOLR_HOME!\zoo.cfg"
- )
-) ELSE (
- @echo.
- @echo 'Unrecognized example %EXAMPLE%!'
- @echo.
- goto start_usage
-)
+IF NOT "%EXAMPLE%"=="" goto run_example
:start_solr
IF "%SOLR_HOME%"=="" set "SOLR_HOME=%SOLR_SERVER_DIR%\solr"
@@ -904,9 +880,6 @@ IF "%JAVA_VENDOR%" == "IBM J9" (
set "GCLOG_OPT=-Xloggc"
)
-@echo.
-CALL :safe_echo "Starting Solr on port %SOLR_PORT% from %SOLR_SERVER_DIR%"
-@echo.
IF "%FG%"=="1" (
REM run solr in the foreground
title "Solr-%SOLR_PORT%"
@@ -917,211 +890,25 @@ IF "%FG%"=="1" (
START /B "Solr-%SOLR_PORT%" /D "%SOLR_SERVER_DIR%" "%JAVA%" %SERVEROPT% -Xss256k %SOLR_JAVA_MEM% %START_OPTS% %GCLOG_OPT%:"!SOLR_LOGS_DIR!"/solr_gc.log -Dlog4j.configuration="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^
-Djetty.port=%SOLR_PORT% -Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" -Djetty.home="%SOLR_SERVER_DIR%" -Djava.io.tmpdir="%SOLR_SERVER_DIR%\tmp" -jar start.jar "%SOLR_JETTY_CONFIG%" > "!SOLR_LOGS_DIR!\solr-%SOLR_PORT%-console.log"
echo %SOLR_PORT%>"%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
-)
-
-set EXAMPLE_NAME=%EXAMPLE%
-set CREATE_EXAMPLE_CONFIG=
-IF "%EXAMPLE%"=="schemaless" (
- set EXAMPLE_NAME=gettingstarted
- set CREATE_EXAMPLE_CONFIG=data_driven_schema_configs
-)
-IF "%EXAMPLE%"=="techproducts" (
- set CREATE_EXAMPLE_CONFIG=sample_techproducts_configs
-)
-
-IF NOT "!CREATE_EXAMPLE_CONFIG!"=="" (
- timeout /T 10
- IF "%SOLR_MODE%"=="solrcloud" (
- "%JAVA%" %SOLR_SSL_OPTS% -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 create_collection -name !EXAMPLE_NAME! -shards 1 -replicationFactor 1 ^
- -confdir !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr
- ) ELSE (
- "%JAVA%" %SOLR_SSL_OPTS% -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 create_core -name !EXAMPLE_NAME! -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr ^
- -confdir !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets"
- )
-)
-IF "%EXAMPLE%"=="techproducts" (
- @echo.
- @echo Indexing tech product example docs from "%SOLR_TIP%\example\exampledocs"
- "%JAVA%" %SOLR_SSL_OPTS% -Durl=!SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr/%EXAMPLE%/update -jar "%SOLR_TIP%/example/exampledocs/post.jar" "%SOLR_TIP%/example/exampledocs/*.xml"
+ REM now wait to see Solr come online ...
+ "%JAVA%" %SOLR_SSL_OPTS% -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 status -maxWaitSecs 30 -solr !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr
)
-@echo.
-IF NOT "%EXAMPLE%"=="" (
- @echo Solr %EXAMPLE% example launched successfully.
-)
-@echo Direct your Web browser to !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr to visit the Solr Admin UI
-@echo.
-
goto done
-:cloud_example_start
-REM Launch interactive session to guide the user through the SolrCloud example
-
-CLS
-@echo.
-@echo Welcome to the SolrCloud example
-@echo.
-@echo.
-
-IF "%NO_USER_PROMPT%"=="1" (
- set CLOUD_NUM_NODES=2
- @echo Starting up %CLOUD_NUM_NODES% Solr nodes for your example SolrCloud cluster.
- goto start_cloud_nodes
-) ELSE (
- @echo This interactive session will help you launch a SolrCloud cluster on your local workstation.
- @echo.
- SET /P "USER_INPUT=To begin, how many Solr nodes would you like to run in your local cluster (specify 1-4 nodes) [2]: "
- goto while_num_nodes_not_valid
-)
-
-:while_num_nodes_not_valid
-IF "%USER_INPUT%"=="" set USER_INPUT=2
-SET /A INPUT_AS_NUM=!USER_INPUT!*1
-IF %INPUT_AS_NUM% GEQ 1 IF %INPUT_AS_NUM% LEQ 4 set CLOUD_NUM_NODES=%INPUT_AS_NUM%
-IF NOT DEFINED CLOUD_NUM_NODES (
- SET USER_INPUT=
- SET /P "USER_INPUT=Please enter a number between 1 and 4 [2]: "
- goto while_num_nodes_not_valid
-)
-@echo Ok, let's start up %CLOUD_NUM_NODES% Solr nodes for your example SolrCloud cluster.
-
-:start_cloud_nodes
-
-set "CLOUD_EXAMPLE_DIR=%SOLR_TIP%\example\cloud"
-
-@echo Creating Solr home "%CLOUD_EXAMPLE_DIR%\node1\solr"
-mkdir "%CLOUD_EXAMPLE_DIR%\node1\solr"
-copy "%DEFAULT_SERVER_DIR%\solr\solr.xml" "%CLOUD_EXAMPLE_DIR%\node1\solr\solr.xml"
-copy "%DEFAULT_SERVER_DIR%\solr\zoo.cfg" "%CLOUD_EXAMPLE_DIR%\node1\solr\zoo.cfg"
-
-for /l %%x in (2, 1, !CLOUD_NUM_NODES!) do (
- IF NOT EXIST "%SOLR_TIP%\node%%x" (
- @echo Cloning "%CLOUD_EXAMPLE_DIR%\node1" into "%CLOUD_EXAMPLE_DIR%\node%%x"
- xcopy /Q /E /I "%CLOUD_EXAMPLE_DIR%\node1" "%CLOUD_EXAMPLE_DIR%\node%%x"
- )
-)
-
-for /l %%x in (1, 1, !CLOUD_NUM_NODES!) do (
- set USER_INPUT=
- set /A idx=%%x-1
- set DEF_PORT=8983
- IF %%x EQU 2 (
- set DEF_PORT=7574
- ) ELSE (
- IF %%x EQU 3 (
- set DEF_PORT=8984
- ) ELSE (
- IF %%x EQU 4 (
- set DEF_PORT=7575
- )
- )
- )
-
- IF "%NO_USER_PROMPT%"=="1" (
- set NODE_PORT=!DEF_PORT!
- ) ELSE (
- set /P "USER_INPUT=Please enter the port for node%%x [!DEF_PORT!]: "
- IF "!USER_INPUT!"=="" set USER_INPUT=!DEF_PORT!
- set NODE_PORT=!USER_INPUT!
- echo node%%x port: !NODE_PORT!
- @echo.
- )
-
- IF NOT "!SOLR_HEAP!"=="" (
- set "DASHM=-m !SOLR_HEAP!"
- ) ELSE (
- set "DASHM="
- )
-
- IF %%x EQU 1 (
- set EXAMPLE=
- IF NOT "!ZK_HOST!"=="" (
- set "DASHZ=-z !ZK_HOST!"
- ) ELSE (
- set "DASHZ="
- )
- @echo Starting node1 on port !NODE_PORT! using command:
- @echo solr -cloud -p !NODE_PORT! -s example\node1\solr !DASHZ! !DASHM!
- START "Solr-!NODE_PORT!" /D "%SDIR%" solr -f -cloud -p !NODE_PORT! !DASHZ! !DASHM! -s "%CLOUD_EXAMPLE_DIR%\node1\solr"
- set NODE1_PORT=!NODE_PORT!
- echo !NODE_PORT!>"%SOLR_TIP%"\bin\solr-!NODE_PORT!.port
- ) ELSE (
- IF "!ZK_HOST!"=="" (
- set /A ZK_PORT=!NODE1_PORT!+1000
- set "ZK_HOST=localhost:!ZK_PORT!"
- )
- @echo Starting node%%x on port !NODE_PORT! using command:
- @echo solr -cloud -p !NODE_PORT! -s example\node%%x\solr -z !ZK_HOST! !DASHM!
- START "Solr-!NODE_PORT!" /D "%SDIR%" solr -f -cloud -p !NODE_PORT! -z !ZK_HOST! !DASHM! -s "%CLOUD_EXAMPLE_DIR%\node%%x\solr"
- echo !NODE_PORT!>"%SOLR_TIP%"\bin\solr-!NODE_PORT!.port
- )
-
- timeout /T 10
-)
-
-set USER_INPUT=
-echo.
-echo Now let's create a new collection for indexing documents in your %CLOUD_NUM_NODES%-node cluster.
-IF "%NO_USER_PROMPT%"=="1" (
- set CLOUD_COLLECTION=gettingstarted
- set CLOUD_NUM_SHARDS=2
- set CLOUD_REPFACT=2
- set CLOUD_CONFIG=data_driven_schema_configs
- goto create_collection
-) ELSE (
- goto get_create_collection_params
-)
+:run_example
+REM Run the requested example
-:get_create_collection_params
-set /P "USER_INPUT=Please provide a name for your new collection: [gettingstarted] "
-IF "!USER_INPUT!"=="" set USER_INPUT=gettingstarted
-set CLOUD_COLLECTION=!USER_INPUT!
-echo !CLOUD_COLLECTION!
-set USER_INPUT=
-echo.
-set /P "USER_INPUT=How many shards would you like to split !CLOUD_COLLECTION! into? [2] "
-IF "!USER_INPUT!"=="" set USER_INPUT=2
-set CLOUD_NUM_SHARDS=!USER_INPUT!
-echo !CLOUD_NUM_SHARDS!
-set USER_INPUT=
-echo.
-set /P "USER_INPUT=How many replicas per shard would you like to create? [2] "
-IF "!USER_INPUT!"=="" set USER_INPUT=2
-set CLOUD_REPFACT=!USER_INPUT!
-echo !CLOUD_REPFACT!
-set USER_INPUT=
-echo.
-set /P "USER_INPUT=Please choose a configuration for the !CLOUD_COLLECTION! collection, available options are: basic_configs, data_driven_schema_configs, or sample_techproducts_configs [data_driven_schema_configs]"
-IF "!USER_INPUT!"=="" set USER_INPUT=data_driven_schema_configs
-set CLOUD_CONFIG=!USER_INPUT!
-echo !CLOUD_CONFIG!
-goto create_collection
-
-:create_collection
"%JAVA%" %SOLR_SSL_OPTS% -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 create_collection -name !CLOUD_COLLECTION! -shards !CLOUD_NUM_SHARDS! -replicationFactor !CLOUD_REPFACT! ^
- -confdir !CLOUD_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -zkHost %zk_host%
+ org.apache.solr.util.SolrCLI run_example -script "%SDIR%\solr.cmd" -e %EXAMPLE% -d "%SOLR_SERVER_DIR%" -urlScheme !SOLR_URL_SCHEME! !PASS_TO_RUN_EXAMPLE!
-@echo.
-echo Enabling auto soft-commits with maxTime 3 secs using the Config API
-"%JAVA%" %SOLR_SSL_OPTS% -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 config -collection !CLOUD_COLLECTION! -property updateHandler.autoSoftCommit.maxTime -value 3000 -zkHost %zk_host%
-
-echo.
-echo SolrCloud example is running, please visit !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%NODE1_PORT%/solr"
-echo.
-
-REM End of interactive cloud example
+REM End of run_example
goto done
-
:get_info
REM Find all Java processes, correlate with those listening on a port
REM and then try to contact via that port using the status tool
@@ -1387,10 +1174,8 @@ goto done
exit /b 1
:done
-
ENDLOCAL
-
-GOTO :eof
+exit /b 0
REM Tests what Java we have and sets some global variables
:resolve_java_info
Modified: lucene/dev/branches/branch_5x/solr/core/ivy.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/ivy.xml?rev=1694137&r1=1694136&r2=1694137&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/ivy.xml (original)
+++ lucene/dev/branches/branch_5x/solr/core/ivy.xml Wed Aug 5 04:23:51 2015
@@ -31,6 +31,7 @@
<dependencies>
<dependency org="commons-codec" name="commons-codec" rev="${/commons-codec/commons-codec}" conf="compile"/>
+ <dependency org="org.apache.commons" name="commons-exec" rev="${/org.apache.commons/commons-exec}" conf="compile"/>
<dependency org="commons-fileupload" name="commons-fileupload" rev="${/commons-fileupload/commons-fileupload}" conf="compile"/>
<dependency org="commons-cli" name="commons-cli" rev="${/commons-cli/commons-cli}" conf="compile"/>
<dependency org="commons-lang" name="commons-lang" rev="${/commons-lang/commons-lang}" conf="compile"/>