From 4e7cc1a6959140abdb873bd1a4535f46d611a700 Mon Sep 17 00:00:00 2001 From: Timothy Potter Date: Mon, 22 Sep 2014 17:23:14 +0000 Subject: [PATCH] SOLR-6509: Solr start scripts interactive mode doesn't honor -z argument git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1626847 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 ++ solr/bin/solr | 28 ++++++++++++++++++---------- solr/bin/solr.cmd | 23 +++++++++++++++++------ 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 51c990f31ca..726194266d5 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -192,6 +192,8 @@ Bug Fixes * SOLR-6484: SolrCLI's healthcheck action needs to check live nodes as part of reporting the status of a replica (Timothy Potter) +* SOLR-6509: Solr start scripts interactive mode doesn't honor -z argument (Timothy Potter) + Other Changes ---------------------- diff --git a/solr/bin/solr b/solr/bin/solr index 6c1ff5fbe72..9252691bae8 100755 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -698,11 +698,11 @@ if [ "$SOLR_MODE" == "solrcloud" ]; then fi CLOUD_MODE_OPTS="$CLOUD_MODE_OPTS -DzkRun" - - # and if collection1 needs to be bootstrapped - if [ -e "$SOLR_HOME/collection1/core.properties" ]; then - CLOUD_MODE_OPTS="$CLOUD_MODE_OPTS -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DnumShards=1" - fi + fi + + # and if collection1 needs to be bootstrapped + if [ -e "$SOLR_HOME/collection1/core.properties" ]; then + CLOUD_MODE_OPTS="$CLOUD_MODE_OPTS -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DnumShards=1" fi fi @@ -832,14 +832,22 @@ else SOLR_SERVER_DIR=$SOLR_TIP/node1 SOLR_HOME=$SOLR_TIP/node1/solr SOLR_PORT=${CLOUD_PORTS[0]} + if [ "$ZK_HOST" != "" ]; then + DASHZ="-z $ZK_HOST" + fi + echo -e "\nStarting up SolrCloud node1 on port ${CLOUD_PORTS[0]} using command:\n" - echo -e "solr start -cloud -d node1 -p $SOLR_PORT \n\n" + echo -e "solr start -cloud -d node1 -p $SOLR_PORT $DASHZ\n\n" # can't launch this node in the foreground else we can't run anymore commands - launch_solr "false" "$ADDITIONAL_CMD_OPTS" - - zk_port=$[$SOLR_PORT+1000] - zk_host=localhost:$zk_port + launch_solr "false" "" + + # if user did not define a specific -z parameter, assume embedded in first cloud node we launched above + zk_host=$ZK_HOST + if [ "$zk_host" == "" ]; then + zk_port=$[$SOLR_PORT+1000] + zk_host=localhost:$zk_port + fi for (( s=1; s<$CLOUD_NUM_NODES; s++ )) do diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index 7c0a89baba5..08e0b2c52bb 100644 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -418,8 +418,8 @@ IF "%SOLR_MODE%"=="solrcloud" ( ) ELSE ( IF "%verbose%"=="1" echo Configuring SolrCloud to launch an embedded ZooKeeper using -DzkRun set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -DzkRun" - IF EXIST "%SOLR_HOME%\collection1\core.properties" set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DnumShards=1" ) + IF EXIST "%SOLR_HOME%\collection1\core.properties" set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DnumShards=1" ) ELSE ( set CLOUD_MODE_OPTS= ) @@ -541,15 +541,26 @@ for /l %%x in (1, 1, !CLOUD_NUM_NODES!) do ( @echo Cloning %DEFAULT_SERVER_DIR% into %SOLR_TIP%\node%%x xcopy /Q /E /I "%DEFAULT_SERVER_DIR%" "%SOLR_TIP%\node%%x" ) - + IF %%x EQU 1 ( set EXAMPLE= - START "" "%SDIR%\solr" -f -c -p !NODE_PORT! -d node1 + 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! -d node1 !DASHZ! + START "" "%SDIR%\solr" -f -cloud -p !NODE_PORT! -d node1 !DASHZ! set NODE1_PORT=!NODE_PORT! ) ELSE ( - set /A ZK_PORT=!NODE1_PORT!+1000 - set "ZK_HOST=localhost:!ZK_PORT!" - START "" "%SDIR%\solr" -f -c -p !NODE_PORT! -d node%%x -z !ZK_HOST! + 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! -d node%%x -z !ZK_HOST! + START "" "%SDIR%\solr" -f -cloud -p !NODE_PORT! -d node%%x -z !ZK_HOST! ) timeout /T 10