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
|
HDFS-4172. namenode does not URI-encode parameters when building URI for
|
||||||
datanode request (Derek Dagit via bobby)
|
datanode request (Derek Dagit via bobby)
|
||||||
|
|
||||||
|
HDFS-4182. SecondaryNameNode leaks NameCache entries (bobby)
|
||||||
|
|
||||||
Release 0.23.4 - UNRELEASED
|
Release 0.23.4 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -61,6 +61,7 @@ import org.apache.hadoop.hdfs.server.namenode.INode.BlocksMapUpdateInfo;
|
|||||||
import org.apache.hadoop.hdfs.server.namenode.INodeDirectory.INodesInPath;
|
import org.apache.hadoop.hdfs.server.namenode.INodeDirectory.INodesInPath;
|
||||||
import org.apache.hadoop.hdfs.util.ByteArray;
|
import org.apache.hadoop.hdfs.util.ByteArray;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
/*************************************************
|
/*************************************************
|
||||||
@ -175,6 +176,12 @@ public class FSDirectory implements Closeable {
|
|||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This is for testing purposes only
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean isReady() {
|
||||||
|
return ready;
|
||||||
|
}
|
||||||
|
|
||||||
// exposed for unit tests
|
// exposed for unit tests
|
||||||
protected void setReady(boolean flag) {
|
protected void setReady(boolean flag) {
|
||||||
@ -1981,9 +1988,16 @@ public class FSDirectory implements Closeable {
|
|||||||
* Reset the entire namespace tree.
|
* Reset the entire namespace tree.
|
||||||
*/
|
*/
|
||||||
void reset() {
|
void reset() {
|
||||||
rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME,
|
writeLock();
|
||||||
getFSNamesystem().createFsOwnerPermissions(new FsPermission((short)0755)),
|
try {
|
||||||
Integer.MAX_VALUE, -1);
|
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 @@ class NameCache<K> {
|
|||||||
cache.put(name, name);
|
cache.put(name, name);
|
||||||
lookups += useThreshold;
|
lookups += useThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
initialized = false;
|
||||||
|
cache.clear();
|
||||||
|
if (transientMap == null) {
|
||||||
|
transientMap = new HashMap<K, UseCount>();
|
||||||
|
} else {
|
||||||
|
transientMap.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -886,6 +886,7 @@ public class SecondaryNameNode implements Runnable {
|
|||||||
"just been downloaded");
|
"just been downloaded");
|
||||||
}
|
}
|
||||||
dstImage.reloadFromImageFile(file, dstNamesystem);
|
dstImage.reloadFromImageFile(file, dstNamesystem);
|
||||||
|
dstNamesystem.dir.imageLoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
Checkpointer.rollForwardByApplyingLogs(manifest, dstImage, dstNamesystem);
|
Checkpointer.rollForwardByApplyingLogs(manifest, dstImage, dstNamesystem);
|
||||||
|
@ -81,7 +81,6 @@ public class TestFSDirectory {
|
|||||||
|
|
||||||
DFSTestUtil.createFile(hdfs, file5, 1024, REPLICATION, seed);
|
DFSTestUtil.createFile(hdfs, file5, 1024, REPLICATION, seed);
|
||||||
hdfs.mkdirs(sub2);
|
hdfs.mkdirs(sub2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -130,6 +129,16 @@ public class TestFSDirectory {
|
|||||||
Assert.assertTrue(diff.contains(file4.getName()));
|
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) {
|
static void checkClassName(String line) {
|
||||||
int i = line.lastIndexOf('(');
|
int i = line.lastIndexOf('(');
|
||||||
int j = line.lastIndexOf('@');
|
int j = line.lastIndexOf('@');
|
||||||
|
@ -58,6 +58,17 @@ public class TestNameCache {
|
|||||||
for (String s : notMatching) {
|
for (String s : notMatching) {
|
||||||
verifyNameReuse(cache, s, false);
|
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) {
|
private void verifyNameReuse(NameCache<String> cache, String s, boolean reused) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user