hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r823404 - in /hadoop/hbase/trunk/src: java/org/apache/hadoop/hbase/regionserver/HLog.java test/org/apache/hadoop/hbase/regionserver/TestHLog.java
Date Fri, 09 Oct 2009 04:36:31 GMT
Author: stack
Date: Fri Oct  9 04:36:30 2009
New Revision: 823404

URL: http://svn.apache.org/viewvc?rev=823404&view=rev
Log:
Update hbase trunk to latests on hadoop 0.21 branch so we can all test sync/append; add call
out to sync

Modified:
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HLog.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HLog.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HLog.java?rev=823404&r1=823403&r2=823404&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HLog.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HLog.java Fri Oct  9
04:36:30 2009
@@ -23,6 +23,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -123,6 +124,9 @@
    * Current log file.
    */
   SequenceFile.Writer writer;
+  // This is the above writer's output stream. Its private but we use reflection
+  // to expose it so we can call sync on it.
+  FSDataOutputStream writer_out;
 
   /*
    * Map of all log files but the current one. 
@@ -351,11 +355,29 @@
   protected SequenceFile.Writer createWriter(Path path,
     Class<? extends HLogKey> keyClass, Class<? extends KeyValue> valueClass)
   throws IOException {
-    return SequenceFile.createWriter(this.fs, this.conf, path, keyClass,
+    SequenceFile.Writer writer =
+      SequenceFile.createWriter(this.fs, this.conf, path, keyClass,
       valueClass, fs.getConf().getInt("io.file.buffer.size", 4096),
       fs.getDefaultReplication(), this.blocksize,
       SequenceFile.CompressionType.NONE, new DefaultCodec(), null,
       new Metadata());
+    // Get at the private FSDataOutputStream inside in SequenceFile so we can
+    // call sync on it.  Make it accessible.  Stash it aside for call up in
+    // the sync method above.
+    final Field fields[] = writer.getClass().getDeclaredFields();
+    final String fieldName = "out";
+    for (int i = 0; i < fields.length; ++i) {
+      if (fieldName.equals(fields[i].getName())) {
+        try {
+          fields[i].setAccessible(true);
+          this.writer_out = (FSDataOutputStream)fields[i].get(writer);
+          break;
+        } catch (IllegalAccessException ex) {
+          throw new IOException("Accessing " + fieldName, ex);
+        }
+      }
+    }
+    return writer;
   }
   
   /*
@@ -614,6 +636,7 @@
       }
     } else {
       this.writer.sync();
+      if (this.writer_out != null) this.writer_out.sync();
     }
     this.unflushedEntries.set(0);
   }

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java?rev=823404&r1=823403&r2=823404&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHLog.java Fri Oct
 9 04:36:30 2009
@@ -151,6 +151,7 @@
           timestamp, new byte[] { (byte)(i + '0') }));
       }
       log.append(regionName, tableName, cols, false, System.currentTimeMillis());
+      log.sync();
       long logSeqId = log.startCacheFlush();
       log.completeCacheFlush(regionName, tableName, logSeqId);
       log.close();
@@ -187,5 +188,4 @@
       }
     }
   }
-
 }
\ No newline at end of file



Mime
View raw message