瀏覽代碼

HADOOP-3146. A DFSOutputStream.flush method is renamed as
DFSOutputStream.fsync. (dhruba)



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@644798 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur 17 年之前
父節點
當前提交
edc6ff9ceb

+ 3 - 0
CHANGES.txt

@@ -479,6 +479,9 @@ Trunk (unreleased changes)
     HADOOP-3089.  Streaming should accept stderr from task before
     first key arrives.  (Rick Cox via tomwhite)
 
+    HADOOP-3146. A DFSOutputStream.flush method is renamed as
+    DFSOutputStream.fsync.  (dhruba)
+
 Release 0.16.2 - 2008-04-02
 
   BUG FIXES

+ 1 - 2
src/java/org/apache/hadoop/dfs/DFSClient.java

@@ -2359,8 +2359,7 @@ class DFSClient implements FSConstants {
      * that data has been flushed to persistent store on the 
      * datanode. Block allocations are persisted on namenode.
      */
-    @Override
-    public synchronized void flush() throws IOException {
+    public synchronized void fsync() throws IOException {
       Packet savePacket = null;
       int position = 0;
       long saveOffset = 0;

+ 9 - 3
src/test/org/apache/hadoop/dfs/TestAbandonBlock.java

@@ -33,7 +33,13 @@ public class TestAbandonBlock extends junit.framework.TestCase {
   static final String FILE_NAME_PREFIX
       = "/" + TestAbandonBlock.class.getSimpleName() + "_"; 
 
-  public void testAbondanBlock() throws IOException {
+  private void flushFile(FSDataOutputStream stm) throws IOException {
+    DFSClient.DFSOutputStream dfstream = (DFSClient.DFSOutputStream)
+                                            (stm.getWrappedStream());
+    dfstream.fsync();
+  }
+
+  public void testAbandonBlock() throws IOException {
     MiniDFSCluster cluster = new MiniDFSCluster(CONF, 2, true, null);
     FileSystem fs = cluster.getFileSystem();
 
@@ -45,7 +51,7 @@ public class TestAbandonBlock extends junit.framework.TestCase {
       for(int i = 0; i < 1024; i++) {
         fout.write(123);
       }
-      fout.flush();
+      flushFile(fout);
   
       //try reading the block by someone
       DFSClient dfsclient = new DFSClient(CONF);
@@ -66,4 +72,4 @@ public class TestAbandonBlock extends junit.framework.TestCase {
       try{cluster.shutdown();} catch(Exception e) {}
     }
   }
-}
+}

+ 10 - 4
src/test/org/apache/hadoop/dfs/TestFileAppend.java

@@ -62,6 +62,12 @@ public class TestFileAppend extends TestCase {
     return stm;
   }
 
+  private void flushFile(FSDataOutputStream stm) throws IOException {
+    DFSClient.DFSOutputStream dfstream = (DFSClient.DFSOutputStream)
+                                            (stm.getWrappedStream());
+    dfstream.fsync();
+  }
+
   //
   // writes to file but does not close it
   //
@@ -226,14 +232,14 @@ public class TestFileAppend extends TestCase {
       // write to file
       int mid = fileSize/2;
       stm.write(fileContents, 0, mid);
-      stm.flush();
+      flushFile(stm);
       System.out.println("Wrote and Flushed first part of file.");
 
       // write the remainder of the file
       stm.write(fileContents, mid, fileSize - mid);
       System.out.println("Written second part of file");
-      stm.flush();
-      stm.flush(); // two consecutive flushes is being tested here.
+      flushFile(stm);
+      flushFile(stm); // two consecutive flushes is being tested here.
       System.out.println("Wrote and Flushed second part of file.");
 
       // verify that full blocks are sane
@@ -279,7 +285,7 @@ public class TestFileAppend extends TestCase {
       int start = 0;
       for (start = 0; (start + 29) < fileSize; ) {
         stm.write(fileContents, start, 29);
-        stm.flush();
+        flushFile(stm);
         start += 29;
       }
       stm.write(fileContents, start, fileSize-start);

+ 7 - 1
src/test/org/apache/hadoop/dfs/TestFileCreation.java

@@ -57,6 +57,12 @@ public class TestFileCreation extends TestCase {
     return stm;
   }
 
+  private void flushFile(FSDataOutputStream stm) throws IOException {
+    DFSClient.DFSOutputStream dfstream = (DFSClient.DFSOutputStream)
+                                            (stm.getWrappedStream());
+    dfstream.fsync();
+  }
+
   //
   // writes to file but does not close it
   //
@@ -377,7 +383,7 @@ public class TestFileCreation extends TestCase {
 
       // write two full blocks.
       writeFile(stm, numBlocks * blockSize);
-      stm.flush();
+      flushFile(stm);
 
       // create another new file.
       //