You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bi...@apache.org on 2013/06/06 19:46:38 UTC

svn commit: r1490379 - /accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/log/DfsLogger.java

Author: billie
Date: Thu Jun  6 17:46:38 2013
New Revision: 1490379

URL: http://svn.apache.org/r1490379
Log:
ACCUMULO-1486 handle absence of sync method

Modified:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/log/DfsLogger.java

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/log/DfsLogger.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/log/DfsLogger.java?rev=1490379&r1=1490378&r2=1490379&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/log/DfsLogger.java (original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/log/DfsLogger.java Thu Jun  6 17:46:38 2013
@@ -271,13 +271,21 @@ public class DfsLogger {
         logFile = fs.create(logPath, true, fs.getConf().getInt("io.file.buffer.size", 4096), replication, blockSize);
       
       try {
-        // sync: send data to datanodes
-        sync = logFile.getClass().getMethod("sync");
+        NoSuchMethodException e = null;
         try {
-          // hsych: send data to datanodes and sync the data to disk
+          // sync: send data to datanodes
+          sync = logFile.getClass().getMethod("sync");
+        } catch (NoSuchMethodException ex) {
+          e = ex;
+        }
+        try {
+          // hsync: send data to datanodes and sync the data to disk
           sync = logFile.getClass().getMethod("hsync");
+          e = null;
         } catch (NoSuchMethodException ex) {
         }
+        if (e != null)
+          throw new RuntimeException(e);
       } catch (Exception e) {
         throw new RuntimeException(e);
       }
@@ -314,13 +322,13 @@ public class DfsLogger {
       key.tserverSession = filename;
       key.filename = filename;
       write(key, EMPTY);
-      logFile.sync();
+      sync.invoke(logFile);
       log.debug("Got new write-ahead log: " + this);
-    } catch (IOException ex) {
+    } catch (Exception ex) {
       if (logFile != null)
         logFile.close();
       logFile = null;
-      throw ex;
+      throw new IOException(ex);
     }
     
     Thread t = new Daemon(new LogSyncingTask());
@@ -421,10 +429,10 @@ public class DfsLogger {
     key.tablet = tablet;
     try {
       write(key, EMPTY);
-      logFile.sync();
-    } catch (IOException ex) {
+      sync.invoke(logFile);
+    } catch (Exception ex) {
       log.error(ex);
-      throw ex;
+      throw new IOException(ex);
     }
   }