Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 af863d7d4 -> b7609903b


Warn on startup if swap file enabled on Windows

patch by Josh McKenzie; reviewed by Philip Thompson for CASSANDRA-7316


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

Branch: refs/heads/cassandra-2.1
Commit: b7609903b0046031c6a54f1ee93a785348472df1
Parents: af863d7
Author: Joshua McKenzie <[email protected]>
Authored: Mon Oct 6 15:13:10 2014 -0500
Committer: Joshua McKenzie <[email protected]>
Committed: Mon Oct 6 15:13:10 2014 -0500

----------------------------------------------------------------------
 conf/cassandra-env.ps1 | 73 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b7609903/conf/cassandra-env.ps1
----------------------------------------------------------------------
diff --git a/conf/cassandra-env.ps1 b/conf/cassandra-env.ps1
index 168f322..47f4fa3 100644
--- a/conf/cassandra-env.ps1
+++ b/conf/cassandra-env.ps1
@@ -54,6 +54,79 @@ Function BuildClassPath
 #-----------------------------------------------------------------------------
 Function CalculateHeapSizes
 {
+    # Check if swapping is enabled on the host and warn if so - reference 
CASSANDRA-7316
+
+    $osInfo = Get-WmiObject -class "Win32_computersystem"
+    $autoPage = $osInfo.AutomaticManagedPageFile
+
+    if ($autoPage)
+    {
+        echo 
"*---------------------------------------------------------------------*"
+        echo 
"*---------------------------------------------------------------------*"
+        echo ""
+        echo "    WARNING!  Automatic page file configuration detected."
+        echo "    It is recommended that you disable swap when running 
Cassandra"
+        echo "    for performance and stability reasons."
+        echo ""
+        echo 
"*---------------------------------------------------------------------*"
+        echo 
"*---------------------------------------------------------------------*"
+    }
+    else
+    {
+        $pageFileInfo = Get-WmiObject -class "Win32_PageFileSetting" 
-EnableAllPrivileges
+        $pageFileCount = $PageFileInfo.Count
+        if ($pageFileInfo)
+        {
+            $files = @()
+            $sizes = @()
+            $hasSizes = $FALSE
+
+            # PageFileCount isn't populated and obj comes back as single if 
there's only 1
+            if ([string]::IsNullOrEmpty($PageFileCount))
+            {
+                $PageFileCount = 1
+                $files += $PageFileInfo.Name
+                if ($PageFileInfo.MaximumSize -ne 0)
+                {
+                    $hasSizes = $TRUE
+                    $sizes += $PageFileInfo.MaximumSize
+                }
+            }
+            else
+            {
+                for ($i = 0; $i -le $PageFileCount; $i++)
+                {
+                    $files += $PageFileInfo[$i].Name
+                    if ($PageFileInfo[$i].MaximumSize -ne 0)
+                    {
+                        $hasSizes = $TRUE
+                        $sizes += $PageFileInfo[$i].MaximumSize
+                    }
+                }
+            }
+
+            echo 
"*---------------------------------------------------------------------*"
+            echo 
"*---------------------------------------------------------------------*"
+            echo ""
+            echo "    WARNING!  $PageFileCount swap file(s) detected"
+            for ($i = 0; $i -lt $PageFileCount; $i++)
+            {
+                $toPrint = "        Name: " + $files[$i]
+                if ($hasSizes)
+                {
+                    $toPrint = $toPrint + " Size: " + $sizes[$i]
+                    $toPrint = $toPrint -replace [Environment]::NewLine, ""
+                }
+                echo $toPrint
+            }
+            echo "    It is recommended that you disable swap when running 
Cassandra"
+            echo "    for performance and stability reasons."
+            echo ""
+            echo 
"*---------------------------------------------------------------------*"
+            echo 
"*---------------------------------------------------------------------*"
+        }
+    }
+
     # Validate that we need to run this function and that our config is good
     if ($env:MAX_HEAP_SIZE -and $env:HEAP_NEWSIZE)
     {

Reply via email to