Merge branch 'cassandra-2.1' into trunk

This commit is contained in:
Joshua McKenzie 2014-10-22 12:13:39 -05:00
commit 7dda131a5f
4 changed files with 103 additions and 57 deletions

View File

@ -30,6 +30,7 @@
2.1.2
* Fix installing as service on Windows (CASSANDRA-8115)
* Fix CREATE TABLE for CQL2 (CASSANDRA-8144)
* Avoid boxing in ColumnStats min/max trackers (CASSANDRA-8109)

View File

@ -51,7 +51,8 @@ echo Starting with legacy startup options
if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.service.CassandraDaemon
if NOT DEFINED JAVA_HOME goto :err
REM ***** JAVA options *****
REM -----------------------------------------------------------------------------
REM JVM Opts we'll use in legacy run or installation
set JAVA_OPTS=-ea^
-javaagent:"%CASSANDRA_HOME%\lib\jamm-0.2.6.jar"^
-Xms2G^
@ -71,7 +72,6 @@ set JAVA_OPTS=-ea^
-Djava.library.path=%CASSANDRA_HOME%\lib\sigar-bin
REM ***** CLASSPATH library setting *****
REM Ensure that any user defined CLASSPATH variables are not used on startup
set CLASSPATH="%CASSANDRA_HOME%\conf"
@ -83,31 +83,28 @@ goto okClasspath
set CLASSPATH=%CLASSPATH%;%1
goto :eof
REM -----------------------------------------------------------------------------
: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"
set CASSANDRA_PARAMS=-Dcassandra -Dcassandra-foreground=yes
set CASSANDRA_PARAMS=%CASSANDRA_PARAMS% "-Dcassandra.logdir=%CASSANDRA_HOME%\logs"
set CASSANDRA_PARAMS=%CASSANDRA_PARAMS% "-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
:runDaemon
echo Starting Cassandra Server
"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%"
goto finally
REM -----------------------------------------------------------------------------
:doInstallOperation
set SERVICE_JVM="cassandra"
rem location of Prunsrv
set PATH_PRUNSRV=%CASSANDRA_HOME%\bin\daemon\
set PR_LOGPATH=%PATH_PRUNSRV%
rem fix up java ops replace ' -' with ' ;-'
set JAVA_OPTS_DELM=%JAVA_OPTS: -=;-%
rem Allow prunsrv to be overridden
if "%PRUNSRV%" == "" set PRUNSRV=%PATH_PRUNSRV%prunsrv
@ -116,18 +113,37 @@ echo trying to delete service if it has been created already
rem quit if we're just going to uninstall
if /i "%ARG%" == "UNINSTALL" goto finally
echo.
echo Installing %SERVICE_JVM%. If you get registry warnings, re-run as an Administrator
"%PRUNSRV%" //IS//%SERVICE_JVM%
echo Setting the parameters for %SERVICE_JVM%
rem set PR_CLASSPATH=%CASSANDRA_CLASSPATH%
"%PRUNSRV%" //US//%SERVICE_JVM% ^
echo Setting startup parameters for %SERVICE_JVM%
set cmd="%PRUNSRV%" //US//%SERVICE_JVM% ^
--Jvm=auto --StdOutput auto --StdError auto ^
--Classpath=%CASSANDRA_CLASSPATH% ^
--StartMode=jvm --StartClass=%CASSANDRA_MAIN% --StartMethod=main ^
--StopMode=jvm --StopClass=%CASSANDRA_MAIN% --StopMethod=stop ^
++JvmOptions=%JAVA_OPTS_DELM% ++JvmOptions=-DCassandra ^
--PidFile pid.txt
--StopMode=jvm --StopClass=%CASSANDRA_MAIN% --StopMethod=stop
REM convert ' -' into ';-' so we can tokenize on semicolon as we may have spaces in folder names
set tempOptions=%JAVA_OPTS: -=;-%
REM Append the JAVA_OPTS, each with independent ++JvmOptions as delimited list fails for some options
:optStrip
for /F "tokens=1* delims=;" %%a in ("%tempOptions%") do (
set JVMOPTIONS=%JVMOPTIONS% ++JvmOptions=%%a
set tempOptions=%%b
)
if defined tempOptions goto :optStrip
REM do the same for CASSANDRA_PARAMS
set tempOptions=%CASSANDRA_PARAMS: -=;-%
:paramStrip
for /F "tokens=1* delims=;" %%a in ("%tempOptions%") do (
set JVMOPTIONS=%JVMOPTIONS% ++JvmOptions=%%a
set tempOptions=%%b
)
if defined tempOptions goto :paramStrip
%cmd% %JVMOPTIONS%
echo Installation of %SERVICE_JVM% is complete
goto finally
@ -136,6 +152,7 @@ goto finally
echo JAVA_HOME environment variable must be set!
pause
REM -----------------------------------------------------------------------------
:finally
ENDLOCAL

View File

@ -13,33 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
param (
[switch]$install,
[switch]$uninstall,
[switch]$help,
[switch]$v,
[switch]$s,
[switch]$f,
[string]$p,
[string]$H,
[string]$E
)
$pidfile = "pid.txt"
#-----------------------------------------------------------------------------
Function ValidateArguments
{
if ($install -and $uninstall)
{
exit
}
if ($help)
{
PrintUsage
}
}
#-----------------------------------------------------------------------------
Function PrintUsage
{
@ -92,10 +65,6 @@ Function Main
}
$pidfile = "$env:CASSANDRA_HOME\$pidfile"
$logdir = "$env:CASSANDRA_HOME/logs"
$storagedir = "$env:CASSANDRA_HOME/data"
$env:CASSANDRA_PARAMS = $env:CASSANDRA_PARAMS + " -Dcassandra.logdir=""$logdir"" -Dcassandra.storagedir=""$storagedir"""
# Other command line params
if ($H)
{
@ -176,23 +145,29 @@ Function HandleInstallation
echo "Setting launch parameters for [$SERVICE_JVM]"
Start-Sleep -s 2
# Change delim from " -" to ";-" in JVM_OPTS for prunsrv
$env:JVM_OPTS = $env:JVM_OPTS -replace " -", ";-"
$env:JVM_OPTS = $env:JVM_OPTS -replace " -", ";-"
# Strip off leading ; if it's there
$env:JVM_OPTS = $env:JVM_OPTS.TrimStart(";")
# Broken multi-line for convenience - glued back together in a bit
$args = @"
//US//$SERVICE_JVM
--Jvm=auto --StdOutput auto --StdError auto
--Classpath=$env:CLASSPATH
--StartMode=jvm --StartClass=$env:CASSANDRA_MAIN --StartMethod=main
--StopMode=jvm --StopClass=$env:CASSANDRA_MAIN --StopMethod=stop
++JvmOptions=$env:JVM_OPTS ++JvmOptions=-DCassandra
--PidFile "$pidfile"
"@
# Include cassandra params
$prunArgs = "$env:CASSANDRA_PARAMS $env:JVM_OPTS"
# Change to semicolon delim as we can't split on space due to potential spaces in directory names
$prunArgs = $prunArgs -replace " -", ";-"
# JvmOptions w/multiple semicolon delimited items isn't working correctly. storagedir and logdir were
# both being ignored / failing to parse on startup. See CASSANDRA-8115
$split_opts = $prunArgs.Split(";")
foreach ($arg in $split_opts)
{
$args += " ++JvmOptions=$arg"
}
$args = $args -replace [Environment]::NewLine, ""
$proc = Start-Process -FilePath "$env:PRUNSRV" -ArgumentList $args -PassThru -WindowStyle Hidden
@ -305,4 +280,52 @@ WARNING! Failed to write pidfile to $pidfile. stop-server.bat and
}
#-----------------------------------------------------------------------------
Function ValidateArguments
{
if ($install -and $uninstall)
{
echo "Cannot install and uninstall"
exit
}
if ($help)
{
PrintUsage
}
}
Function CheckEmptyParam($param)
{
if ([String]::IsNullOrEmpty($param))
{
echo "Invalid parameter: empty value"
PrintUsage
}
}
for ($i = 0; $i -lt $args.count; $i++)
{
Switch($args[$i])
{
"-install" { $install = $True }
"-uninstall" { $uninstall = $True }
"-help" { PrintUsage }
"-v" { $v = $True }
"-f" { $f = $True }
"-s" { $s = $True }
"-p" { $p = $args[++$i]; CheckEmptyParam($p) }
"-H" { $H = $args[++$i]; CheckEmptyParam($H) }
"-E" { $E = $args[++$i]; CheckEmptyParam($E) }
default
{
"Invalid argument: " + $args[$i];
if (-Not $args[$i].startsWith("-"))
{
echo "Note: All options require -"
}
exit
}
}
}
$pidfile = "pid.txt"
Main

View File

@ -269,6 +269,11 @@ Function SetCassandraEnvironment
SetCassandraHome
$env:CASSANDRA_CONF = "$env:CASSANDRA_HOME\conf"
$env:CASSANDRA_PARAMS="-Dcassandra -Dlogback.configurationFile=logback.xml"
$logdir = "$env:CASSANDRA_HOME\logs"
$storagedir = "$env:CASSANDRA_HOME\data"
$env:CASSANDRA_PARAMS = $env:CASSANDRA_PARAMS + " -Dcassandra.logdir=""$logdir"" -Dcassandra.storagedir=""$storagedir"""
SetCassandraMain
BuildClassPath