You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2015/08/24 18:45:08 UTC

[1/3] cassandra git commit: Speed up launch scripts on Windows

Repository: cassandra
Updated Branches:
  refs/heads/trunk 903a54d8a -> d200822e6


Speed up launch scripts on Windows

Patch by jmckenzie; reviewed by pthompson for CASSANDRA-9615


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2d477a4c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2d477a4c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2d477a4c

Branch: refs/heads/trunk
Commit: 2d477a4cc238ac1d7b7fe1f2086d01fb61d84cce
Parents: 941a5dd
Author: Joshua McKenzie <jm...@apache.org>
Authored: Mon Aug 24 12:44:00 2015 -0400
Committer: Joshua McKenzie <jm...@apache.org>
Committed: Mon Aug 24 12:44:00 2015 -0400

----------------------------------------------------------------------
 bin/cassandra.ps1      | 88 ++++++++-------------------------------------
 conf/cassandra-env.ps1 | 34 +++++++++---------
 2 files changed, 30 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d477a4c/bin/cassandra.ps1
----------------------------------------------------------------------
diff --git a/bin/cassandra.ps1 b/bin/cassandra.ps1
index b841841..5cc99aa 100644
--- a/bin/cassandra.ps1
+++ b/bin/cassandra.ps1
@@ -36,8 +36,6 @@ usage: cassandra.ps1 [-f] [-h] [-p pidfile] [-H dumpfile] [-D arg] [-E errorfile
 }
 
 #-----------------------------------------------------------------------------
-# Note: throughout these scripts we're replacing \ with /.  This allows clean
-# operation on both command-prompt and cygwin-based environments.
 Function Main
 {
     ValidateArguments
@@ -289,89 +287,28 @@ Function VerifyPortsAreAvailable
     #   native_transport_port
     #   rpc_port, which we'll match to rpc_address
     # and from env: JMX_PORT which we cache in our environment during SetCassandraEnvironment for this check
-    $toMatch = @("storage_port:","ssl_storage_port:","native_transport_port:","rpc_port")
+    $yamlRegex = "storage_port:|ssl_storage_port:|native_transport_port:|rpc_port"
     $yaml = Get-Content "$env:CASSANDRA_CONF\cassandra.yaml"
+    $portRegex = ":$env:JMX_PORT |"
 
-    $listenAddress = ""
-    $rpcAddress = ""
     foreach ($line in $yaml)
     {
-        if ($line -match "^listen_address:")
+        if ($line -match $yamlRegex)
         {
-            $args = $line -Split ": "
-            $listenAddress = $args[1] -replace " ", ""
+            $sa = $line.Split(":")
+            $portRegex = $portRegex + ":" + ($sa[1] -replace " ","") + " |"
         }
-        if ($line -match "^rpc_address:")
-        {
-            $args = $line -Split ": "
-            $rpcAddress = $args[1] -replace " ", ""
-        }
-    }
-    if ([string]::IsNullOrEmpty($listenAddress))
-    {
-        Write-Error "Failed to parse listen_address from cassandra.yaml to check open ports.  Aborting startup."
-        Exit
-    }
-    if ([string]::IsNullOrEmpty($rpcAddress))
-    {
-        Write-Error "Failed to parse rpc_address from cassandra.yaml to check open ports.  Aborting startup."
-        Exit
     }
+    $portRegex = $portRegex.Substring(0, $portRegex.Length - 2)
 
-    foreach ($line in $yaml)
-    {
-        foreach ($match in $toMatch)
-        {
-            if ($line -match "^$match")
-            {
-                if ($line.contains("rpc"))
-                {
-                    CheckPort $rpcAddress $line
-                }
-                else
-                {
-                    CheckPort $listenAddress $line
-                }
-            }
-        }
-    }
-    if ([string]::IsNullOrEmpty($env:JMX_PORT))
-    {
-        Write-Error "No JMX_PORT is set in environment.  Aborting startup."
-        Exit
-    }
-    CheckPort $listenAddress "jmx_port: $env:JMX_PORT"
-}
+    $netstat = netstat -an
 
-#-----------------------------------------------------------------------------
-Function CheckPort([string]$listenAddress, [string]$configLine)
-{
-    $split = $configLine -Split ":"
-    if ($split.Length -ne 2)
-    {
-        echo "Invalid cassandra.yaml config line parsed while checking for available ports:"
-        echo "$configLine"
-        echo "Aborting startup"
-        Exit
-    }
-    else
+    foreach ($line in $netstat)
     {
-        $port = $split[1] -replace " ", ""
-
-        # start an async connect to the ip/port combo, give it 25ms, and error out if it succeeded
-        $tcpobject = new-Object system.Net.Sockets.TcpClient
-        $connect = $tcpobject.BeginConnect($listenAddress, $port, $null, $null)
-        $wait = $connect.AsyncWaitHandle.WaitOne(25, $false)
-
-        if (!$wait)
-        {
-            # still trying to connect, if it's not serviced in 25ms we'll assume it's not open
-            $tcpobject.Close()
-        }
-        else
+        if ($line -match "TCP" -and $line -match $portRegex)
         {
-            $tcpobject.EndConnect($connect) | out-Null
-            echo "Cassandra port already in use ($configLine).  Aborting"
+            Write-Error "Found a port already in use. Aborting startup"
+            Write-Error $line
             Exit
         }
     }
@@ -391,6 +328,7 @@ Function ValidateArguments
     }
 }
 
+#-----------------------------------------------------------------------------
 Function CheckEmptyParam($param)
 {
     if ([String]::IsNullOrEmpty($param))
@@ -400,6 +338,8 @@ Function CheckEmptyParam($param)
     }
 }
 
+#-----------------------------------------------------------------------------
+# Populate arguments
 for ($i = 0; $i -lt $args.count; $i++)
 {
     # Skip JVM args

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d477a4c/conf/cassandra-env.ps1
----------------------------------------------------------------------
diff --git a/conf/cassandra-env.ps1 b/conf/cassandra-env.ps1
index ad2392e..f6cd6bc 100644
--- a/conf/cassandra-env.ps1
+++ b/conf/cassandra-env.ps1
@@ -241,13 +241,28 @@ Function ParseJVMInfo
     $pinfo.RedirectStandardError = $true
     $pinfo.RedirectStandardOutput = $true
     $pinfo.UseShellExecute = $false
-    $pinfo.Arguments = "-version"
+    $pinfo.Arguments = "-d64 -version"
     $p = New-Object System.Diagnostics.Process
     $p.StartInfo = $pinfo
     $p.Start() | Out-Null
     $p.WaitForExit()
     $stderr = $p.StandardError.ReadToEnd()
 
+    $env:JVM_ARCH = "64-bit"
+
+    if ($stderr.Contains("Error"))
+    {
+        # 32-bit JVM. re-run w/out -d64
+        echo "Failed 64-bit check. Re-running to get version from 32-bit"
+        $pinfo.Arguments = "-version"
+        $p = New-Object System.Diagnostics.Process
+        $p.StartInfo = $pinfo
+        $p.Start() | Out-Null
+        $p.WaitForExit()
+        $stderr = $p.StandardError.ReadToEnd()
+        $env:JVM_ARCH = "32-bit"
+    }
+
     $sa = $stderr.Split("""")
     $env:JVM_VERSION = $sa[1]
 
@@ -266,23 +281,6 @@ Function ParseJVMInfo
 
     $pa = $sa[1].Split("_")
     $env:JVM_PATCH_VERSION=$pa[1]
-
-    # get 64-bit vs. 32-bit
-    $pinfo.Arguments = "-d64 -version"
-    $pArch = New-Object System.Diagnostics.Process
-    $p.StartInfo = $pinfo
-    $p.Start() | Out-Null
-    $p.WaitForExit()
-    $stderr = $p.StandardError.ReadToEnd()
-
-    if ($stderr.Contains("Error"))
-    {
-        $env:JVM_ARCH = "32-bit"
-    }
-    else
-    {
-        $env:JVM_ARCH = "64-bit"
-    }
 }
 
 #-----------------------------------------------------------------------------


[3/3] cassandra git commit: Merge branch 'cassandra-3.0' into trunk

Posted by jm...@apache.org.
Merge branch 'cassandra-3.0' into trunk


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

Branch: refs/heads/trunk
Commit: d200822e68a92f5e42c8c9327d678c7026b9bbb2
Parents: 903a54d a3d9e6c
Author: Joshua McKenzie <jm...@apache.org>
Authored: Mon Aug 24 12:44:48 2015 -0400
Committer: Joshua McKenzie <jm...@apache.org>
Committed: Mon Aug 24 12:44:48 2015 -0400

----------------------------------------------------------------------
 bin/cassandra.ps1      | 88 ++++++++-------------------------------------
 conf/cassandra-env.ps1 | 34 +++++++++---------
 2 files changed, 30 insertions(+), 92 deletions(-)
----------------------------------------------------------------------



[2/3] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0

Posted by jm...@apache.org.
Merge branch 'cassandra-2.2' into cassandra-3.0


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

Branch: refs/heads/trunk
Commit: a3d9e6c479e62c1641173d9c6a2af2212b1a961d
Parents: 7ad1da5 2d477a4
Author: Joshua McKenzie <jm...@apache.org>
Authored: Mon Aug 24 12:44:34 2015 -0400
Committer: Joshua McKenzie <jm...@apache.org>
Committed: Mon Aug 24 12:44:34 2015 -0400

----------------------------------------------------------------------
 bin/cassandra.ps1      | 88 ++++++++-------------------------------------
 conf/cassandra-env.ps1 | 34 +++++++++---------
 2 files changed, 30 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3d9e6c4/conf/cassandra-env.ps1
----------------------------------------------------------------------