|
@@ -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) {
|