merge -c 1525624 FIXES: HDFS-5239. Allow FSNamesystem lock fairness to be configurable (daryn)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1525625 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9e56f8c7ab
commit
15f857c59c
|
@ -50,6 +50,8 @@ Release 2.3.0 - UNRELEASED
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
|
HDFS-5239. Allow FSNamesystem lock fairness to be configurable (daryn)
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
HDFS-5034. Remove debug prints from GetFileLinkInfo (Andrew Wang via Colin
|
HDFS-5034. Remove debug prints from GetFileLinkInfo (Andrew Wang via Colin
|
||||||
Patrick McCabe)
|
Patrick McCabe)
|
||||||
|
|
|
@ -420,7 +420,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
private final long accessTimePrecision;
|
private final long accessTimePrecision;
|
||||||
|
|
||||||
/** Lock to protect FSNamesystem. */
|
/** Lock to protect FSNamesystem. */
|
||||||
private ReentrantReadWriteLock fsLock = new ReentrantReadWriteLock(true);
|
private ReentrantReadWriteLock fsLock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used when this NN is in standby state to read from the shared edit log.
|
* Used when this NN is in standby state to read from the shared edit log.
|
||||||
|
@ -595,6 +595,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
*/
|
*/
|
||||||
FSNamesystem(Configuration conf, FSImage fsImage, boolean ignoreRetryCache)
|
FSNamesystem(Configuration conf, FSImage fsImage, boolean ignoreRetryCache)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
boolean fair = conf.getBoolean("dfs.namenode.fslock.fair", true);
|
||||||
|
LOG.info("fsLock is fair:" + fair);
|
||||||
|
fsLock = new ReentrantReadWriteLock(fair);
|
||||||
try {
|
try {
|
||||||
resourceRecheckInterval = conf.getLong(
|
resourceRecheckInterval = conf.getLong(
|
||||||
DFS_NAMENODE_RESOURCE_CHECK_INTERVAL_KEY,
|
DFS_NAMENODE_RESOURCE_CHECK_INTERVAL_KEY,
|
||||||
|
|
|
@ -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_EDITS_DIR_KEY;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_NAME_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.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -142,4 +141,21 @@ public class TestFSNamesystem {
|
||||||
assertTrue("Replication queues weren't being populated after entering "
|
assertTrue("Replication queues weren't being populated after entering "
|
||||||
+ "safemode 2nd time", fsn.isPopulatingReplQueues());
|
+ "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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue