diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index b81c4d946e..75dec90b85 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/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 diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPersistBlocks.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPersistBlocks.java index 497d29d738..5077a6dfdf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPersistBlocks.java +++ b/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 void testRestartDfs() throws Exception { // 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) {