|
@@ -20,8 +20,7 @@ package org.apache.hadoop.hdfs.server.namenode;
|
|
|
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY;
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
-import static org.junit.Assert.assertTrue;
|
|
|
+import static org.junit.Assert.*;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
@@ -142,4 +141,21 @@ public class TestFSNamesystem {
|
|
|
assertTrue("Replication queues weren't being populated after entering "
|
|
|
+ "safemode 2nd time", fsn.isPopulatingReplQueues());
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testFsLockFairness() throws IOException, InterruptedException{
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+
|
|
|
+ FSEditLog fsEditLog = Mockito.mock(FSEditLog.class);
|
|
|
+ FSImage fsImage = Mockito.mock(FSImage.class);
|
|
|
+ Mockito.when(fsImage.getEditLog()).thenReturn(fsEditLog);
|
|
|
+
|
|
|
+ conf.setBoolean("dfs.namenode.fslock.fair", true);
|
|
|
+ FSNamesystem fsNamesystem = new FSNamesystem(conf, fsImage);
|
|
|
+ assertTrue(fsNamesystem.getFsLockForTests().isFair());
|
|
|
+
|
|
|
+ conf.setBoolean("dfs.namenode.fslock.fair", false);
|
|
|
+ fsNamesystem = new FSNamesystem(conf, fsImage);
|
|
|
+ assertFalse(fsNamesystem.getFsLockForTests().isFair());
|
|
|
+ }
|
|
|
}
|