Quellcode durchsuchen

HDFS-3630 Modify TestPersistBlocks to use both flush and hflush (sanjay)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1360991 13f79535-47bb-0310-9956-ffa450edef68
Sanjay Radia vor 13 Jahren
Ursprung
Commit
6a59f08a15

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -107,6 +107,8 @@ Trunk (unreleased changes)
     HDFS-3190. Simple refactors in existing NN code to assist
     QuorumJournalManager extension. (todd)
 
+    HDFS-3630 Modify TestPersistBlocks to use both flush and hflush  (sanjay)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 22 - 4
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPersistBlocks.java

@@ -72,10 +72,25 @@ public class TestPersistBlocks {
     rand.nextBytes(DATA_BEFORE_RESTART);
     rand.nextBytes(DATA_AFTER_RESTART);
   }
+ 
+  /** check if DFS remains in proper condition after a restart 
+   **/
+  @Test  
+  public void TestRestartDfsWithFlush() throws Exception {
+    testRestartDfs(true);
+  }
   
-  /** check if DFS remains in proper condition after a restart */
-  @Test
-  public void testRestartDfs() throws Exception {
+  
+  /** check if DFS remains in proper condition after a restart 
+   **/
+  public void TestRestartDfsWithSync() throws Exception {
+    testRestartDfs(false);
+  }
+  
+  /** check if DFS remains in proper condition after a restart
+   * @param useFlush - if true then flush is used instead of sync (ie hflush)
+   */
+  void testRestartDfs(boolean useFlush) throws Exception {
     final Configuration conf = new HdfsConfiguration();
     // Turn off persistent IPC, so that the DFSClient can survive NN restart
     conf.setInt(
@@ -92,7 +107,10 @@ public class TestPersistBlocks {
       // Creating a file with 4096 blockSize to write multiple blocks
       stream = fs.create(FILE_PATH, true, BLOCK_SIZE, (short) 1, BLOCK_SIZE);
       stream.write(DATA_BEFORE_RESTART);
-      stream.hflush();
+      if (useFlush)
+        stream.flush();
+      else 
+        stream.hflush();
       
       // Wait for at least a few blocks to get through
       while (len <= BLOCK_SIZE) {