HDFS-4182. SecondaryNameNode leaks NameCache entries (bobby)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1409311 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9b9edd9b47
commit
59e4199d84
@ -2006,6 +2006,8 @@ Release 0.23.5 - UNRELEASED
|
||||
HDFS-4172. namenode does not URI-encode parameters when building URI for
|
||||
datanode request (Derek Dagit via bobby)
|
||||
|
||||
HDFS-4182. SecondaryNameNode leaks NameCache entries (bobby)
|
||||
|
||||
Release 0.23.4 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
@ -61,6 +61,7 @@
|
||||
import org.apache.hadoop.hdfs.server.namenode.INodeDirectory.INodesInPath;
|
||||
import org.apache.hadoop.hdfs.util.ByteArray;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/*************************************************
|
||||
@ -176,6 +177,12 @@ void setReady() {
|
||||
}
|
||||
}
|
||||
|
||||
//This is for testing purposes only
|
||||
@VisibleForTesting
|
||||
boolean isReady() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
// exposed for unit tests
|
||||
protected void setReady(boolean flag) {
|
||||
ready = flag;
|
||||
@ -1981,9 +1988,16 @@ private boolean unprotectedSetTimes(String src, INode inode, long mtime,
|
||||
* Reset the entire namespace tree.
|
||||
*/
|
||||
void reset() {
|
||||
rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
|
||||
getFSNamesystem().createFsOwnerPermissions(new FsPermission((short)0755)),
|
||||
Integer.MAX_VALUE, -1);
|
||||
writeLock();
|
||||
try {
|
||||
setReady(false);
|
||||
rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
|
||||
getFSNamesystem().createFsOwnerPermissions(new FsPermission((short)0755)),
|
||||
Integer.MAX_VALUE, -1);
|
||||
nameCache.reset();
|
||||
} finally {
|
||||
writeUnlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,4 +152,14 @@ private void promote(final K name) {
|
||||
cache.put(name, name);
|
||||
lookups += useThreshold;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
initialized = false;
|
||||
cache.clear();
|
||||
if (transientMap == null) {
|
||||
transientMap = new HashMap<K, UseCount>();
|
||||
} else {
|
||||
transientMap.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -886,6 +886,7 @@ static void doMerge(
|
||||
"just been downloaded");
|
||||
}
|
||||
dstImage.reloadFromImageFile(file, dstNamesystem);
|
||||
dstNamesystem.dir.imageLoadComplete();
|
||||
}
|
||||
|
||||
Checkpointer.rollForwardByApplyingLogs(manifest, dstImage, dstNamesystem);
|
||||
|
@ -81,7 +81,6 @@ public void setUp() throws Exception {
|
||||
|
||||
DFSTestUtil.createFile(hdfs, file5, 1024, REPLICATION, seed);
|
||||
hdfs.mkdirs(sub2);
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
@ -130,6 +129,16 @@ public void testDumpTree() throws Exception {
|
||||
Assert.assertTrue(diff.contains(file4.getName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReset() throws Exception {
|
||||
fsdir.reset();
|
||||
Assert.assertFalse(fsdir.isReady());
|
||||
final INodeDirectory root = (INodeDirectory) fsdir.getINode("/");
|
||||
Assert.assertNull(root.getChildren());
|
||||
fsdir.imageLoadComplete();
|
||||
Assert.assertTrue(fsdir.isReady());
|
||||
}
|
||||
|
||||
static void checkClassName(String line) {
|
||||
int i = line.lastIndexOf('(');
|
||||
int j = line.lastIndexOf('@');
|
||||
|
@ -58,6 +58,17 @@ public void testDictionary() throws Exception {
|
||||
for (String s : notMatching) {
|
||||
verifyNameReuse(cache, s, false);
|
||||
}
|
||||
|
||||
cache.reset();
|
||||
cache.initialized();
|
||||
|
||||
for (String s : matching) {
|
||||
verifyNameReuse(cache, s, false);
|
||||
}
|
||||
|
||||
for (String s : notMatching) {
|
||||
verifyNameReuse(cache, s, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyNameReuse(NameCache<String> cache, String s, boolean reused) {
|
||||
|
Loading…
Reference in New Issue
Block a user