svn merge -c 1409311 FIXES: HDFS-4182. SecondaryNameNode leaks NameCache entries (bobby)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1409316 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8ca6059743
commit
d0a66f405f
|
@ -1726,6 +1726,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
|
||||
|
|
|
@ -59,6 +59,7 @@ import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
|||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
|
||||
import org.apache.hadoop.hdfs.util.ByteArray;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/*************************************************
|
||||
|
@ -173,6 +174,12 @@ public class FSDirectory implements Closeable {
|
|||
writeUnlock();
|
||||
}
|
||||
}
|
||||
|
||||
//This is for testing purposes only
|
||||
@VisibleForTesting
|
||||
boolean isReady() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
// exposed for unit tests
|
||||
protected void setReady(boolean flag) {
|
||||
|
@ -2003,9 +2010,16 @@ public class FSDirectory implements Closeable {
|
|||
* 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 @@ class NameCache<K> {
|
|||
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 @@ public class SecondaryNameNode implements Runnable {
|
|||
"just been downloaded");
|
||||
}
|
||||
dstImage.reloadFromImageFile(file, dstNamesystem);
|
||||
dstNamesystem.dir.imageLoadComplete();
|
||||
}
|
||||
|
||||
Checkpointer.rollForwardByApplyingLogs(manifest, dstImage, dstNamesystem);
|
||||
|
|
|
@ -58,6 +58,17 @@ public class TestNameCache {
|
|||
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