From 3e489dad7d56b0a6a4084cd3f17a86ec41cb9fd5 Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Fri, 25 Jul 2014 17:23:11 -0500 Subject: [PATCH] Clean up Windows batch scripts patch by Josh McKenzie; reviewed by Ala' Alkhaldi for CASSANDRA-7619 --- CHANGES.txt | 1 + bin/cassandra-cli.bat | 21 +------ bin/cassandra-shuffle.bat | 20 +----- bin/cassandra.bat | 3 +- bin/cqlsh.bat | 68 ++++++++++---------- bin/debug-cql.bat | 100 ++++++++++++------------------ bin/nodetool.bat | 20 +----- bin/sstablekeys.bat | 26 +------- bin/sstableloader.bat | 102 ++++++++++++------------------ bin/sstablescrub.bat | 102 ++++++++++++------------------ bin/sstableupgrade.bat | 102 ++++++++++++------------------ bin/stop-server.bat | 110 ++++++++++++++++----------------- tools/bin/cassandra-stress.bat | 21 ++----- tools/bin/json2sstable.bat | 25 +------- tools/bin/sstable2json.bat | 25 +------- tools/bin/sstablemetadata.bat | 15 +---- tools/bin/sstablesplit.bat | 102 ++++++++++++------------------ 17 files changed, 320 insertions(+), 543 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d6dcfc9a70..0a1ba5140e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.0-final + * Clean up Windows batch scripts (CASSANDRA-7619) * Fix native protocol drop user type notification (CASSANDRA-7571) * Give read access to system.schema_usertypes to all authenticated users (CASSANDRA-7578) diff --git a/bin/cassandra-cli.bat b/bin/cassandra-cli.bat index 0d52bdf48c..621137104b 100644 --- a/bin/cassandra-cli.bat +++ b/bin/cassandra-cli.bat @@ -14,30 +14,15 @@ @REM See the License for the specific language governing permissions and @REM limitations under the License. - @echo off if "%OS%" == "Windows_NT" setlocal +pushd "%~dp0" +call cassandra.in.bat + if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. if NOT DEFINED JAVA_HOME goto :err -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH= - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift" -goto runCli - -:runCli echo Starting Cassandra Client "%JAVA_HOME%\bin\java" -cp %CASSANDRA_CLASSPATH% org.apache.cassandra.cli.CliMain %* goto finally diff --git a/bin/cassandra-shuffle.bat b/bin/cassandra-shuffle.bat index d920d09c32..494973c195 100644 --- a/bin/cassandra-shuffle.bat +++ b/bin/cassandra-shuffle.bat @@ -18,26 +18,12 @@ @echo off if "%OS%" == "Windows_NT" setlocal +pushd "%~dp0" +call cassandra.in.bat + if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. if NOT DEFINED JAVA_HOME goto :err -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH= - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift" -goto runCli - -:runCli echo Starting Cassandra Client "%JAVA_HOME%\bin\java" -cp %CASSANDRA_CLASSPATH% org.apache.cassandra.tools.Shuffle %* goto finally diff --git a/bin/cassandra.bat b/bin/cassandra.bat index 08c0520f12..1606dcc01f 100644 --- a/bin/cassandra.bat +++ b/bin/cassandra.bat @@ -86,7 +86,8 @@ goto :eof REM Include the build\classes\main directory so it works in development set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift" set CASSANDRA_PARAMS=-Dcassandra -Dcassandra-foreground=yes -set CASSANDRA_PARAMS=%CASSANDRA_PARAMS% "-Dcassandra.logdir=%CASSANDRA_HOME%\logs" "-Dcassandra.storagedir=%CASSANDRA_HOME%\data" +set CASSANDRA_PARAMS=%CASSANDRA_PARAMS% "-Dcassandra.logdir=%CASSANDRA_HOME%\logs" +set CASSANDRA_PARAMS=%CASSANDRA_PARAMS% "-Dcassandra.storagedir=%CASSANDRA_HOME%\data" if /i "%ARG%" == "INSTALL" goto doInstallOperation if /i "%ARG%" == "UNINSTALL" goto doInstallOperation goto runDaemon diff --git a/bin/cqlsh.bat b/bin/cqlsh.bat index 68235b62ae..066b1d0c3b 100644 --- a/bin/cqlsh.bat +++ b/bin/cqlsh.bat @@ -1,34 +1,34 @@ -@ECHO OFF -@REM -@REM Licensed to the Apache Software Foundation (ASF) under one or more -@REM contributor license agreements. See the NOTICE file distributed with -@REM this work for additional information regarding copyright ownership. -@REM The ASF licenses this file to You under the Apache License, Version 2.0 -@REM (the "License"); you may not use this file except in compliance with -@REM the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, software -@REM distributed under the License is distributed on an "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@REM See the License for the specific language governing permissions and -@REM limitations under the License. - -@echo off - -if "%OS%" == "Windows_NT" setlocal - -python -V >nul 2>&1 -if ERRORLEVEL 1 goto err - -python "%~dp0\cqlsh" %* -goto finally - -:err -echo Can't detect Python version! - -:finally - -ENDLOCAL - +@ECHO OFF +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one or more +@REM contributor license agreements. See the NOTICE file distributed with +@REM this work for additional information regarding copyright ownership. +@REM The ASF licenses this file to You under the Apache License, Version 2.0 +@REM (the "License"); you may not use this file except in compliance with +@REM the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. + +@echo off + +if "%OS%" == "Windows_NT" setlocal + +python -V >nul 2>&1 +if ERRORLEVEL 1 goto err + +python "%~dp0\cqlsh" %* +goto finally + +:err +echo Can't detect Python version! + +:finally + +ENDLOCAL + diff --git a/bin/debug-cql.bat b/bin/debug-cql.bat index 64b3cb9db1..121e0c1592 100644 --- a/bin/debug-cql.bat +++ b/bin/debug-cql.bat @@ -1,61 +1,39 @@ -@REM -@REM Licensed to the Apache Software Foundation (ASF) under one or more -@REM contributor license agreements. See the NOTICE file distributed with -@REM this work for additional information regarding copyright ownership. -@REM The ASF licenses this file to You under the Apache License, Version 2.0 -@REM (the "License"); you may not use this file except in compliance with -@REM the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, software -@REM distributed under the License is distributed on an "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@REM See the License for the specific language governing permissions and -@REM limitations under the License. - -@echo off -if "%OS%" == "Windows_NT" setlocal - -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. -if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF="%CASSANDRA_HOME%\conf" -if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.transport.Client -if NOT DEFINED JAVA_HOME goto :err - -REM ***** JAVA options ***** -set JAVA_OPTS=^ - -Dlogback.configurationFile=logback-tools.xml - -REM ***** CLASSPATH library setting ***** - -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";%CASSANDRA_CONF%;"%CASSANDRA_HOME%\build\classes\thrift" - -set CASSANDRA_PARAMS= -set TOOLS_PARAMS= - -goto runTool - -:runTool -"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* -goto finally - -:err -echo JAVA_HOME environment variable must be set! -pause - -:finally - -ENDLOCAL +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one or more +@REM contributor license agreements. See the NOTICE file distributed with +@REM this work for additional information regarding copyright ownership. +@REM The ASF licenses this file to You under the Apache License, Version 2.0 +@REM (the "License"); you may not use this file except in compliance with +@REM the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. + +@echo off +if "%OS%" == "Windows_NT" setlocal + +pushd "%~dp0" +call cassandra.in.bat +if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.transport.Client +if NOT DEFINED JAVA_HOME goto :err + +REM ***** JAVA options ***** +set JAVA_OPTS=^ + -Dlogback.configurationFile=logback-tools.xml + +set TOOLS_PARAMS= +"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* +goto finally + +:err +echo JAVA_HOME environment variable must be set! +pause + +:finally + +ENDLOCAL diff --git a/bin/nodetool.bat b/bin/nodetool.bat index 70a7bce67e..ec64db0499 100644 --- a/bin/nodetool.bat +++ b/bin/nodetool.bat @@ -17,26 +17,12 @@ @echo off if "%OS%" == "Windows_NT" setlocal +pushd "%~dp0" +call cassandra.in.bat + if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. if NOT DEFINED JAVA_HOME goto :err -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift" -goto runNodeTool - -:runNodeTool echo Starting NodeTool "%JAVA_HOME%\bin\java" -cp %CASSANDRA_CLASSPATH% -Dlogback.configurationFile=logback-tools.xml org.apache.cassandra.tools.NodeTool %* goto finally diff --git a/bin/sstablekeys.bat b/bin/sstablekeys.bat index 38e875c9f5..0d0cf95eb0 100644 --- a/bin/sstablekeys.bat +++ b/bin/sstablekeys.bat @@ -17,8 +17,9 @@ @echo off if "%OS%" == "Windows_NT" setlocal -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. -if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF="%CASSANDRA_HOME%\conf" +pushd "%~dp0" +call cassandra.in.bat + if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.SSTableExport if NOT DEFINED JAVA_HOME goto :err @@ -26,29 +27,8 @@ REM ***** JAVA options ***** set JAVA_OPTS=^ -Dlogback.configurationFile=logback-tools.xml -REM ***** CLASSPATH library setting ***** - -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";%CASSANDRA_CONF%;"%CASSANDRA_HOME%\build\classes\thrift" - -set CASSANDRA_PARAMS= set TOOLS_PARAMS= -goto runTool - -:runTool "%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %1 -e goto finally diff --git a/bin/sstableloader.bat b/bin/sstableloader.bat index b1a1a83bcc..13293f0c28 100644 --- a/bin/sstableloader.bat +++ b/bin/sstableloader.bat @@ -1,61 +1,41 @@ -@REM -@REM Licensed to the Apache Software Foundation (ASF) under one or more -@REM contributor license agreements. See the NOTICE file distributed with -@REM this work for additional information regarding copyright ownership. -@REM The ASF licenses this file to You under the Apache License, Version 2.0 -@REM (the "License"); you may not use this file except in compliance with -@REM the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, software -@REM distributed under the License is distributed on an "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@REM See the License for the specific language governing permissions and -@REM limitations under the License. - -@echo off -if "%OS%" == "Windows_NT" setlocal - -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. -if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF="%CASSANDRA_HOME%\conf" -if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.BulkLoader -if NOT DEFINED JAVA_HOME goto :err - -REM ***** JAVA options ***** -set JAVA_OPTS=^ - -Dlogback.configurationFile=logback-tools.xml - -REM ***** CLASSPATH library setting ***** - -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";%CASSANDRA_CONF%;"%CASSANDRA_HOME%\build\classes\thrift" - -set CASSANDRA_PARAMS= -set TOOLS_PARAMS= - -goto runTool - -:runTool -"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* -goto finally - -:err -echo JAVA_HOME environment variable must be set! -pause - -:finally - -ENDLOCAL +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one or more +@REM contributor license agreements. See the NOTICE file distributed with +@REM this work for additional information regarding copyright ownership. +@REM The ASF licenses this file to You under the Apache License, Version 2.0 +@REM (the "License"); you may not use this file except in compliance with +@REM the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. + +@echo off +if "%OS%" == "Windows_NT" setlocal + +pushd "%~dp0" +call cassandra.in.bat + +if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.BulkLoader +if NOT DEFINED JAVA_HOME goto :err + +REM ***** JAVA options ***** +set JAVA_OPTS=^ + -Dlogback.configurationFile=logback-tools.xml + +set TOOLS_PARAMS= + +"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* +goto finally + +:err +echo JAVA_HOME environment variable must be set! +pause + +:finally + +ENDLOCAL diff --git a/bin/sstablescrub.bat b/bin/sstablescrub.bat index 0226e1d640..62c140b508 100644 --- a/bin/sstablescrub.bat +++ b/bin/sstablescrub.bat @@ -1,61 +1,41 @@ -@REM -@REM Licensed to the Apache Software Foundation (ASF) under one or more -@REM contributor license agreements. See the NOTICE file distributed with -@REM this work for additional information regarding copyright ownership. -@REM The ASF licenses this file to You under the Apache License, Version 2.0 -@REM (the "License"); you may not use this file except in compliance with -@REM the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, software -@REM distributed under the License is distributed on an "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@REM See the License for the specific language governing permissions and -@REM limitations under the License. - -@echo off -if "%OS%" == "Windows_NT" setlocal - -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. -if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF="%CASSANDRA_HOME%\conf" -if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.StandaloneScrubber -if NOT DEFINED JAVA_HOME goto :err - -REM ***** JAVA options ***** -set JAVA_OPTS=^ - -Dlogback.configurationFile=logback-tools.xml - -REM ***** CLASSPATH library setting ***** - -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";%CASSANDRA_CONF%;"%CASSANDRA_HOME%\build\classes\thrift" - -set CASSANDRA_PARAMS= -set TOOLS_PARAMS= - -goto runTool - -:runTool -"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* -goto finally - -:err -echo JAVA_HOME environment variable must be set! -pause - -:finally - -ENDLOCAL +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one or more +@REM contributor license agreements. See the NOTICE file distributed with +@REM this work for additional information regarding copyright ownership. +@REM The ASF licenses this file to You under the Apache License, Version 2.0 +@REM (the "License"); you may not use this file except in compliance with +@REM the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. + +@echo off +if "%OS%" == "Windows_NT" setlocal + +pushd "%~dp0" +call cassandra.in.bat + +if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.StandaloneScrubber +if NOT DEFINED JAVA_HOME goto :err + +REM ***** JAVA options ***** +set JAVA_OPTS=^ + -Dlogback.configurationFile=logback-tools.xml + +set TOOLS_PARAMS= + +"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* +goto finally + +:err +echo JAVA_HOME environment variable must be set! +pause + +:finally + +ENDLOCAL diff --git a/bin/sstableupgrade.bat b/bin/sstableupgrade.bat index 5fa2230ea4..4025ae8f7f 100644 --- a/bin/sstableupgrade.bat +++ b/bin/sstableupgrade.bat @@ -1,61 +1,41 @@ -@REM -@REM Licensed to the Apache Software Foundation (ASF) under one or more -@REM contributor license agreements. See the NOTICE file distributed with -@REM this work for additional information regarding copyright ownership. -@REM The ASF licenses this file to You under the Apache License, Version 2.0 -@REM (the "License"); you may not use this file except in compliance with -@REM the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, software -@REM distributed under the License is distributed on an "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@REM See the License for the specific language governing permissions and -@REM limitations under the License. - -@echo off -if "%OS%" == "Windows_NT" setlocal - -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. -if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF="%CASSANDRA_HOME%\conf" -if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.StandaloneUpgrader -if NOT DEFINED JAVA_HOME goto :err - -REM ***** JAVA options ***** -set JAVA_OPTS=^ - -Dlogback.configurationFile=logback-tools.xml - -REM ***** CLASSPATH library setting ***** - -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";%CASSANDRA_CONF%;"%CASSANDRA_HOME%\build\classes\thrift" - -set CASSANDRA_PARAMS= -set TOOLS_PARAMS= - -goto runTool - -:runTool -"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* -goto finally - -:err -echo JAVA_HOME environment variable must be set! -pause - -:finally - -ENDLOCAL +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one or more +@REM contributor license agreements. See the NOTICE file distributed with +@REM this work for additional information regarding copyright ownership. +@REM The ASF licenses this file to You under the Apache License, Version 2.0 +@REM (the "License"); you may not use this file except in compliance with +@REM the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. + +@echo off +if "%OS%" == "Windows_NT" setlocal + +pushd "%~dp0" +call cassandra.in.bat + +if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.StandaloneUpgrader +if NOT DEFINED JAVA_HOME goto :err + +REM ***** JAVA options ***** +set JAVA_OPTS=^ + -Dlogback.configurationFile=logback-tools.xml + +set TOOLS_PARAMS= + +"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* +goto finally + +:err +echo JAVA_HOME environment variable must be set! +pause + +:finally + +ENDLOCAL diff --git a/bin/stop-server.bat b/bin/stop-server.bat index f4b25de98b..616c48c639 100644 --- a/bin/stop-server.bat +++ b/bin/stop-server.bat @@ -1,55 +1,55 @@ -@REM -@REM Licensed to the Apache Software Foundation (ASF) under one or more -@REM contributor license agreements. See the NOTICE file distributed with -@REM this work for additional information regarding copyright ownership. -@REM The ASF licenses this file to You under the Apache License, Version 2.0 -@REM (the "License"); you may not use this file except in compliance with -@REM the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, software -@REM distributed under the License is distributed on an "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@REM See the License for the specific language governing permissions and -@REM limitations under the License. - -@echo off -if "%OS%" == "Windows_NT" setlocal - -pushd %~dp0.. -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%CD% -popd - -REM ----------------------------------------------------------------------------- -REM See if we have the capabilities of running the powershell scripts -for /F "delims=" %%i in ('powershell Get-ExecutionPolicy') do set PERMISSION=%%i -if "%PERMISSION%" == "Unrestricted" goto runPowerShell -goto runLegacy - -REM ----------------------------------------------------------------------------- -:runPowerShell -REM Need to generate a random title for this command-prompt to determine its pid. -REM We detach and re-attach the console in stop-server.ps1 to send ctrl+c to the -REM running cassandra process and need to re-attach here to print results. -set /A rand=%random% %% (100000 - 1 + 1) + 1 -TITLE %rand% -FOR /F "tokens=2 delims= " %%A IN ('TASKLIST /FI ^"WINDOWTITLE eq %rand%^" /NH') DO set PID=%%A - -REM Start with /B -> the control+c event we generate in stop-server.ps1 percolates -REM up and hits this external batch file if we call powershell directly. -start /B powershell /file %CASSANDRA_HOME%/bin/stop-server.ps1 -batchpid %PID% %* -goto finally - -REM ----------------------------------------------------------------------------- -:runLegacy -echo WARNING! Powershell script execution unavailable. -echo Please use 'powershell Set-ExecutionPolicy Unrestricted' -echo on this user-account to run cassandra with fully featured -echo functionality on this platform. - -echo Cannot stop server without powershell access. -goto finally - -:finally -ENDLOCAL +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one or more +@REM contributor license agreements. See the NOTICE file distributed with +@REM this work for additional information regarding copyright ownership. +@REM The ASF licenses this file to You under the Apache License, Version 2.0 +@REM (the "License"); you may not use this file except in compliance with +@REM the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. + +@echo off +if "%OS%" == "Windows_NT" setlocal + +pushd %~dp0.. +if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%CD% +popd + +REM ----------------------------------------------------------------------------- +REM See if we have the capabilities of running the powershell scripts +for /F "delims=" %%i in ('powershell Get-ExecutionPolicy') do set PERMISSION=%%i +if "%PERMISSION%" == "Unrestricted" goto runPowerShell +goto runLegacy + +REM ----------------------------------------------------------------------------- +:runPowerShell +REM Need to generate a random title for this command-prompt to determine its pid. +REM We detach and re-attach the console in stop-server.ps1 to send ctrl+c to the +REM running cassandra process and need to re-attach here to print results. +set /A rand=%random% %% (100000 - 1 + 1) + 1 +TITLE %rand% +FOR /F "tokens=2 delims= " %%A IN ('TASKLIST /FI ^"WINDOWTITLE eq %rand%^" /NH') DO set PID=%%A + +REM Start with /B -> the control+c event we generate in stop-server.ps1 percolates +REM up and hits this external batch file if we call powershell directly. +start /B powershell /file %CASSANDRA_HOME%/bin/stop-server.ps1 -batchpid %PID% %* +goto finally + +REM ----------------------------------------------------------------------------- +:runLegacy +echo WARNING! Powershell script execution unavailable. +echo Please use 'powershell Set-ExecutionPolicy Unrestricted' +echo on this user-account to run cassandra with fully featured +echo functionality on this platform. + +echo Cannot stop server without powershell access. +goto finally + +:finally +ENDLOCAL diff --git a/tools/bin/cassandra-stress.bat b/tools/bin/cassandra-stress.bat index 288b8fed16..f1bbcc98a2 100644 --- a/tools/bin/cassandra-stress.bat +++ b/tools/bin/cassandra-stress.bat @@ -14,22 +14,9 @@ @REM limitations under the License. @echo off +if "%OS%" == "Windows_NT" setlocal -setlocal - -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%CD%\..\.. +pushd "%~dp0" +call cassandra.in.bat if NOT DEFINED STRESS_HOME set STRESS_HOME=%CD%\.. - -@REM Include the build\classes\main directory so it works in development -set CLASSPATH="%CASSANDRA_HOME%\build\classes\stress";"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift" - -for %%i in ("%STRESS_HOME%\lib\*.jar") do call :append "%%i" -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto start - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:start -"%JAVA_HOME%\bin\java" -cp %CLASSPATH% org.apache.cassandra.stress.Stress %* +"%JAVA_HOME%\bin\java" -cp %CASSANDRA_CLASSPATH% org.apache.cassandra.stress.Stress %* diff --git a/tools/bin/json2sstable.bat b/tools/bin/json2sstable.bat index 291fd22017..db0fa91611 100644 --- a/tools/bin/json2sstable.bat +++ b/tools/bin/json2sstable.bat @@ -17,8 +17,9 @@ @echo off if "%OS%" == "Windows_NT" setlocal -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. -if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF="%CASSANDRA_HOME%\conf" +pushd "%~dp0" +call cassandra.in.bat + if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.SSTableImport if NOT DEFINED JAVA_HOME goto :err @@ -26,28 +27,8 @@ REM ***** JAVA options ***** set JAVA_OPTS=^ -Dlogback.configurationFile=logback-tools.xml -REM ***** CLASSPATH library setting ***** - -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";%CASSANDRA_CONF%;"%CASSANDRA_HOME%\build\classes\thrift" - -set CASSANDRA_PARAMS= set TOOLS_PARAMS= - FOR %%A IN (%*) DO call :appendToolsParams %%A - goto runTool :appendToolsParams diff --git a/tools/bin/sstable2json.bat b/tools/bin/sstable2json.bat index b67c7ada8b..17669c0313 100644 --- a/tools/bin/sstable2json.bat +++ b/tools/bin/sstable2json.bat @@ -17,8 +17,9 @@ @echo off if "%OS%" == "Windows_NT" setlocal -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. -if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF="%CASSANDRA_HOME%\conf" +pushd "%~dp0" +call cassandra.in.bat + if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.SSTableExport if NOT DEFINED JAVA_HOME goto :err @@ -26,28 +27,8 @@ REM ***** JAVA options ***** set JAVA_OPTS=^ -Dlogback.configurationFile=logback-tools.xml -REM ***** CLASSPATH library setting ***** - -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";%CASSANDRA_CONF%;"%CASSANDRA_HOME%\build\classes\thrift" - -set CASSANDRA_PARAMS= set TOOLS_PARAMS= - FOR %%A IN (%*) DO call :appendToolsParams %%A - goto runTool :appendToolsParams diff --git a/tools/bin/sstablemetadata.bat b/tools/bin/sstablemetadata.bat index bf06bcab82..3cb630853d 100644 --- a/tools/bin/sstablemetadata.bat +++ b/tools/bin/sstablemetadata.bat @@ -15,18 +15,9 @@ @echo off -setlocal +if "%OS%" == "Windows_NT" setlocal -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%CD%\..\.. +pushd "%~dp0" +call cassandra.in.bat -set CLASSPATH="" -for %%i in ("%CASSANDRA_HOME%\build\*.jar") do call :append "%%i" -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto start - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:start "%JAVA_HOME%\bin\java" -cp %CLASSPATH% org.apache.cassandra.tools.SSTableMetadataViewer %* diff --git a/tools/bin/sstablesplit.bat b/tools/bin/sstablesplit.bat index 16ccac1e1c..2abed84e58 100644 --- a/tools/bin/sstablesplit.bat +++ b/tools/bin/sstablesplit.bat @@ -1,61 +1,41 @@ -@REM -@REM Licensed to the Apache Software Foundation (ASF) under one or more -@REM contributor license agreements. See the NOTICE file distributed with -@REM this work for additional information regarding copyright ownership. -@REM The ASF licenses this file to You under the Apache License, Version 2.0 -@REM (the "License"); you may not use this file except in compliance with -@REM the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, software -@REM distributed under the License is distributed on an "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@REM See the License for the specific language governing permissions and -@REM limitations under the License. - -@echo off -if "%OS%" == "Windows_NT" setlocal - -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. -if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF="%CASSANDRA_HOME%\conf" -if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.StandaloneSplitter -if NOT DEFINED JAVA_HOME goto :err - -REM ***** JAVA options ***** -set JAVA_OPTS=^ - -Dlogback.configurationFile=logback-tools.xml - -REM ***** CLASSPATH library setting ***** - -REM Ensure that any user defined CLASSPATH variables are not used on startup -set CLASSPATH="%CASSANDRA_HOME%\conf" - -REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable. -for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i" -goto okClasspath - -:append -set CLASSPATH=%CLASSPATH%;%1 -goto :eof - -:okClasspath -REM Include the build\classes\main directory so it works in development -set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";%CASSANDRA_CONF%;"%CASSANDRA_HOME%\build\classes\thrift" - -set CASSANDRA_PARAMS= -set TOOLS_PARAMS= - -goto runTool - -:runTool -"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* -goto finally - -:err -echo JAVA_HOME environment variable must be set! -pause - -:finally - -ENDLOCAL +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one or more +@REM contributor license agreements. See the NOTICE file distributed with +@REM this work for additional information regarding copyright ownership. +@REM The ASF licenses this file to You under the Apache License, Version 2.0 +@REM (the "License"); you may not use this file except in compliance with +@REM the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. + +@echo off +if "%OS%" == "Windows_NT" setlocal + +pushd "%~dp0" +call cassandra.in.bat + +if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.StandaloneSplitter +if NOT DEFINED JAVA_HOME goto :err + +REM ***** JAVA options ***** +set JAVA_OPTS=^ + -Dlogback.configurationFile=logback-tools.xml + +set TOOLS_PARAMS= + +"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %* +goto finally + +:err +echo JAVA_HOME environment variable must be set! +pause + +:finally + +ENDLOCAL