cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1030129 - in /cassandra/branches/cassandra-0.6: CHANGES.txt src/java/org/apache/cassandra/io/util/FileUtils.java src/java/org/apache/cassandra/utils/CLibrary.java src/java/org/apache/cassandra/utils/FBUtilities.java
Date Tue, 02 Nov 2010 17:18:43 GMT
Author: jbellis
Date: Tue Nov  2 17:18:34 2010
New Revision: 1030129

URL: http://svn.apache.org/viewvc?rev=1030129&view=rev
Log:
revert 1029959.  see CASSANDRA-1694

Modified:
    cassandra/branches/cassandra-0.6/CHANGES.txt
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/io/util/FileUtils.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/CLibrary.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java

Modified: cassandra/branches/cassandra-0.6/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=1030129&r1=1030128&r2=1030129&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.6/CHANGES.txt Tue Nov  2 17:18:34 2010
@@ -6,7 +6,6 @@ dev
  * initMetadata wasn't loading saved partitioner from disk (CASSANDRA-1638)
  * log tpstats when dropping messages (CASSANDRA-1660)
  * Avoid dropping messages off the client request path (CASSANDRA-1676)
- * fix jna errno reporting (CASSANDRA-1694)
  * add friendlier error for UnknownHostException on startup (CASSANDRA-1697)
 
 

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/io/util/FileUtils.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/io/util/FileUtils.java?rev=1030129&r1=1030128&r2=1030129&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/io/util/FileUtils.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/io/util/FileUtils.java
Tue Nov  2 17:18:34 2010
@@ -23,7 +23,6 @@ import java.text.DecimalFormat;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
 
-import com.sun.jna.LastErrorException;
 import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor;
 
 import org.apache.log4j.Logger;
@@ -203,21 +202,25 @@ public class FileUtils
      */
     public static void createHardLink(File sourceFile, File destinationFile) throws IOException
     {
+        int errno = Integer.MIN_VALUE;
         try
         {
             int result = CLibrary.link(sourceFile.getAbsolutePath(), destinationFile.getAbsolutePath());
-            assert result == 0; // success is always zero
+            if (result != 0)
+                errno = Native.getLastError();
         }
         catch (UnsatisfiedLinkError e)
         {
             createHardLinkWithExec(sourceFile, destinationFile);
+            return;
         }
-        catch (LastErrorException e)
+
+        if (errno != Integer.MIN_VALUE)
         {
             // there are 17 different error codes listed on the man page.  punt until/unless
we find which
             // ones actually turn up in practice.
-            throw new IOException(String.format("Unable to create hard link from %s to %s
(errno %d)",
-                                                sourceFile, destinationFile, CLibrary.errno(e)));
+            throw new IOException(String.format("Unable to create hard link from %s to %s
(errno %d)", 
+                                                sourceFile, destinationFile, errno));
         }
     }
 

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/CLibrary.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/CLibrary.java?rev=1030129&r1=1030128&r2=1030129&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/CLibrary.java (original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/CLibrary.java Tue
Nov  2 17:18:34 2010
@@ -21,7 +21,6 @@ package org.apache.cassandra.utils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.sun.jna.LastErrorException;
 import com.sun.jna.Native;
 
 public final class CLibrary
@@ -49,23 +48,10 @@ public final class CLibrary
         }
     }
 
-    public static native int mlockall(int flags) throws LastErrorException;
-    public static native int munlockall() throws LastErrorException;
+    public static native int mlockall(int flags);
+    public static native int munlockall();
 
-    public static native int link(String from, String to) throws LastErrorException;
-
-    public static int errno(LastErrorException e)
-    {
-        try
-        {
-            return e.getErrorCode();
-        }
-        catch (NoSuchMethodError x)
-        {
-            logger.warn("Obsolete version of JNA present; unable to read errno. Upgrade to
JNA 3.2.7 or later");
-            return 0;
-        }
-    }
+    public static native int link(String from, String to);
 
     private CLibrary() {}
 }

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1030129&r1=1030128&r2=1030129&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/utils/FBUtilities.java
Tue Nov  2 17:18:34 2010
@@ -37,7 +37,6 @@ import org.apache.log4j.Logger;
 
 import org.apache.commons.collections.iterators.CollatingIterator;
 
-import com.sun.jna.LastErrorException;
 import com.sun.jna.Native;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.DecoratedKey;
@@ -554,18 +553,22 @@ public class FBUtilities
 
     public static void tryMlockall()
     {
+        int errno = Integer.MIN_VALUE;
         try
         {
             int result = CLibrary.mlockall(CLibrary.MCL_CURRENT);
-            assert result == 0; // mlockall should always be zero on success
+            if (result != 0)
+                errno = Native.getLastError();
         }
         catch (UnsatisfiedLinkError e)
         {
             // this will have already been logged by CLibrary, no need to repeat it
+            return;
         }
-        catch (LastErrorException e)
+
+        if (errno != Integer.MIN_VALUE)
         {
-            if (CLibrary.errno(e) == CLibrary.ENOMEM && System.getProperty("os.name").toLowerCase().contains("linux"))
+            if (errno == CLibrary.ENOMEM && System.getProperty("os.name").toLowerCase().contains("linux"))
             {
                 logger_.warn("Unable to lock JVM memory (ENOMEM)."
                              + " This can result in part of the JVM being swapped out, especially
with mmapped I/O enabled."
@@ -574,7 +577,7 @@ public class FBUtilities
             else if (!System.getProperty("os.name").toLowerCase().contains("mac"))
             {
                 // OS X allows mlockall to be called, but always returns an error
-                logger_.warn("Unknown mlockall error " + CLibrary.errno(e));
+                logger_.warn("Unknown mlockall error " + errno);
             }
         }
     }



Mime
View raw message