cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject cassandra git commit: Clean up IsWindows check, add hasProc check
Date Mon, 15 Dec 2014 17:35:24 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 f0767fdf4 -> 6d8862b00


Clean up IsWindows check, add hasProc check

Patch by Blake Eggleston; reviewed by jmckenzie for CASSANDRA-8452


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

Branch: refs/heads/cassandra-2.1
Commit: 6d8862b00ed60a24387beb642609c03fcee095e9
Parents: f0767fd
Author: Blake Eggleston <bdeggleston@gmail.com>
Authored: Mon Dec 15 11:10:17 2014 -0600
Committer: Joshua McKenzie <jmckenzie@apache.org>
Committed: Mon Dec 15 11:10:17 2014 -0600

----------------------------------------------------------------------
 .../apache/cassandra/io/sstable/SSTableRewriter.java   |  2 +-
 .../io/sstable/metadata/MetadataSerializer.java        |  2 +-
 .../org/apache/cassandra/service/CassandraDaemon.java  |  2 +-
 .../org/apache/cassandra/service/StorageService.java   |  4 ++--
 .../cassandra/utils/BackgroundActivityMonitor.java     |  4 ++--
 src/java/org/apache/cassandra/utils/FBUtilities.java   | 13 +++++++++++--
 6 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d8862b0/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
index f9d2fe4..cd9435d 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
@@ -156,7 +156,7 @@ public class SSTableRewriter
 
     private void maybeReopenEarly(DecoratedKey key)
     {
-        if (FBUtilities.isUnix() && writer.getFilePointer() - currentlyOpenedEarlyAt
> preemptiveOpenInterval)
+        if (!FBUtilities.isWindows() && writer.getFilePointer() - currentlyOpenedEarlyAt
> preemptiveOpenInterval)
         {
             if (isOffline)
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d8862b0/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java b/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java
index 7414208..0dcd981 100644
--- a/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java
+++ b/src/java/org/apache/cassandra/io/sstable/metadata/MetadataSerializer.java
@@ -154,7 +154,7 @@ public class MetadataSerializer implements IMetadataSerializer
             out.flush();
         }
         // we cant move a file on top of another file in windows:
-        if (!FBUtilities.isUnix())
+        if (FBUtilities.isWindows())
             FileUtils.delete(descriptor.filenameFor(Component.STATS));
         FileUtils.renameWithConfirm(tmpDescriptor.filenameFor(Component.STATS), descriptor.filenameFor(Component.STATS));
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d8862b0/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index 1c99348..c2b7b7d 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -430,7 +430,7 @@ public class CassandraDaemon
 
         // On windows, we need to stop the entire system as prunsrv doesn't have the jsvc
hooks
         // We rely on the shutdown hook to drain the node
-        if (!FBUtilities.isUnix())
+        if (FBUtilities.isWindows())
             System.exit(0);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d8862b0/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 332fbe5..36fe377 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -2534,7 +2534,7 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
         int cmd = nextRepairCommand.incrementAndGet();
         if (ranges.size() > 0)
         {
-            if (!FBUtilities.isUnix() && parallelismDegree != RepairParallelism.PARALLEL)
+            if (FBUtilities.isWindows() && parallelismDegree != RepairParallelism.PARALLEL)
             {
                 logger.warn("Snapshot-based repair is not yet supported on Windows.  Reverting
to parallel repair.");
                 parallelismDegree = RepairParallelism.PARALLEL;
@@ -2570,7 +2570,7 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
             return 0;
 
         int cmd = nextRepairCommand.incrementAndGet();
-        if (!FBUtilities.isUnix() && parallelismDegree != RepairParallelism.PARALLEL)
+        if (FBUtilities.isWindows() && parallelismDegree != RepairParallelism.PARALLEL)
         {
             logger.warn("Snapshot-based repair is not yet supported on Windows.  Reverting
to parallel repair.");
             parallelismDegree = RepairParallelism.PARALLEL;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d8862b0/src/java/org/apache/cassandra/utils/BackgroundActivityMonitor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/BackgroundActivityMonitor.java b/src/java/org/apache/cassandra/utils/BackgroundActivityMonitor.java
index 43113fc..1799d10 100644
--- a/src/java/org/apache/cassandra/utils/BackgroundActivityMonitor.java
+++ b/src/java/org/apache/cassandra/utils/BackgroundActivityMonitor.java
@@ -71,7 +71,7 @@ public class BackgroundActivityMonitor
         }
         catch (IOException ex)
         {
-            if (FBUtilities.isUnix())
+            if (FBUtilities.hasProcFS())
                 logger.warn("Couldn't open /proc/stats");
             statsFile = null;
         }
@@ -155,7 +155,7 @@ public class BackgroundActivityMonitor
             catch (IOException e)
             {
                 // ignore;
-                if (FBUtilities.isUnix())
+                if (FBUtilities.hasProcFS())
                     logger.warn("Couldn't read /proc/stats");
             }
             if (report == -1d)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d8862b0/src/java/org/apache/cassandra/utils/FBUtilities.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/FBUtilities.java b/src/java/org/apache/cassandra/utils/FBUtilities.java
index 01b7923..4c81b2a 100644
--- a/src/java/org/apache/cassandra/utils/FBUtilities.java
+++ b/src/java/org/apache/cassandra/utils/FBUtilities.java
@@ -72,6 +72,10 @@ public class FBUtilities
 
     private static final String OPERATING_SYSTEM = System.getProperty("os.name").toLowerCase();
 
+    private static final boolean IS_WINDOWS = OPERATING_SYSTEM.contains("windows");
+
+    private static final boolean HAS_PROCFS = !IS_WINDOWS && (new File(File.separator
+ "proc")).exists();
+
     private static volatile InetAddress localInetAddress;
     private static volatile InetAddress broadcastInetAddress;
 
@@ -676,9 +680,14 @@ public class FBUtilities
         return historyDir;
     }
 
-    public static boolean isUnix()
+    public static boolean isWindows()
+    {
+        return IS_WINDOWS;
+    }
+
+    public static boolean hasProcFS()
     {
-        return OPERATING_SYSTEM.contains("nix") || OPERATING_SYSTEM.contains("nux") || OPERATING_SYSTEM.contains("aix");
+        return HAS_PROCFS;
     }
 
     public static void updateWithShort(MessageDigest digest, int val)


Mime
View raw message