HDFS-4293. Fix TestSnapshot failure. Contributed by Jing Zhao.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2802@1419882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f4a723249e
commit
39d25fbac3
|
@ -81,3 +81,5 @@ Branch-2802 Snapshot (Unreleased)
|
||||||
|
|
||||||
HDFS-4175. Additional snapshot tests for more complicated directory
|
HDFS-4175. Additional snapshot tests for more complicated directory
|
||||||
structure and modifications. (Jing Zhao via suresh)
|
structure and modifications. (Jing Zhao via suresh)
|
||||||
|
|
||||||
|
HDFS-4293. Fix TestSnapshot failure. (Jing Zhao via suresh)
|
||||||
|
|
|
@ -2008,7 +2008,7 @@ public class FSDirectory implements Closeable {
|
||||||
((INodeDirectoryWithQuota)dirNode).setQuota(nsQuota, dsQuota);
|
((INodeDirectoryWithQuota)dirNode).setQuota(nsQuota, dsQuota);
|
||||||
if (!dirNode.isQuotaSet()) {
|
if (!dirNode.isQuotaSet()) {
|
||||||
// will not come here for root because root's nsQuota is always set
|
// will not come here for root because root's nsQuota is always set
|
||||||
INodeDirectory newNode = new INodeDirectory(dirNode);
|
INodeDirectory newNode = new INodeDirectory(dirNode, true);
|
||||||
INodeDirectory parent = (INodeDirectory)inodes[inodes.length-2];
|
INodeDirectory parent = (INodeDirectory)inodes[inodes.length-2];
|
||||||
dirNode = newNode;
|
dirNode = newNode;
|
||||||
parent.replaceChild(newNode);
|
parent.replaceChild(newNode);
|
||||||
|
|
|
@ -73,14 +73,16 @@ public class INodeDirectory extends INode {
|
||||||
super(name, permissions, null, mtime, 0L);
|
super(name, permissions, null, mtime, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** copy constructor
|
/**
|
||||||
*
|
* Copy constructor
|
||||||
* @param other
|
* @param other The INodeDirectory to be copied
|
||||||
|
* @param adopt Indicate whether or not need to set the parent field of child
|
||||||
|
* INodes to the new node
|
||||||
*/
|
*/
|
||||||
public INodeDirectory(INodeDirectory other) {
|
public INodeDirectory(INodeDirectory other, boolean adopt) {
|
||||||
super(other);
|
super(other);
|
||||||
this.children = other.children;
|
this.children = other.children;
|
||||||
if (this.children != null) {
|
if (adopt && this.children != null) {
|
||||||
for (INode child : children) {
|
for (INode child : children) {
|
||||||
child.parent = this;
|
child.parent = this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class INodeDirectoryWithQuota extends INodeDirectory {
|
||||||
*/
|
*/
|
||||||
protected INodeDirectoryWithQuota(long nsQuota, long dsQuota,
|
protected INodeDirectoryWithQuota(long nsQuota, long dsQuota,
|
||||||
INodeDirectory other) {
|
INodeDirectory other) {
|
||||||
super(other);
|
super(other, true);
|
||||||
INode.DirCounts counts = new INode.DirCounts();
|
INode.DirCounts counts = new INode.DirCounts();
|
||||||
other.spaceConsumedInTree(counts);
|
other.spaceConsumedInTree(counts);
|
||||||
this.nsCount = counts.getNsCount();
|
this.nsCount = counts.getNsCount();
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class SnapshotManager implements SnapshotStats {
|
||||||
+ "Please redo the operation after removing all the snapshots.");
|
+ "Please redo the operation after removing all the snapshots.");
|
||||||
}
|
}
|
||||||
|
|
||||||
final INodeDirectory d = new INodeDirectory(s);
|
final INodeDirectory d = new INodeDirectory(s, true);
|
||||||
fsdir.replaceINodeDirectory(path, s, d);
|
fsdir.replaceINodeDirectory(path, s, d);
|
||||||
snapshottables.remove(s);
|
snapshottables.remove(s);
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ public class SnapshotManager implements SnapshotStats {
|
||||||
*/
|
*/
|
||||||
private INodeDirectory processINodeDirectory(final INodeDirectory srcChild
|
private INodeDirectory processINodeDirectory(final INodeDirectory srcChild
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final INodeDirectory dstChild = new INodeDirectory(srcChild);
|
final INodeDirectory dstChild = new INodeDirectory(srcChild, false);
|
||||||
dstChild.setChildren(null);
|
dstChild.setChildren(null);
|
||||||
processRecursively(srcChild, dstChild);
|
processRecursively(srcChild, dstChild);
|
||||||
return dstChild;
|
return dstChild;
|
||||||
|
|
|
@ -220,7 +220,7 @@ public class TestINodeDirectoryWithSnapshot {
|
||||||
final int i = Diff.search(current, inode);
|
final int i = Diff.search(current, inode);
|
||||||
Assert.assertTrue(i >= 0);
|
Assert.assertTrue(i >= 0);
|
||||||
final INodeDirectory oldinode = (INodeDirectory)current.get(i);
|
final INodeDirectory oldinode = (INodeDirectory)current.get(i);
|
||||||
final INodeDirectory newinode = new INodeDirectory(oldinode);
|
final INodeDirectory newinode = new INodeDirectory(oldinode, true);
|
||||||
newinode.setModificationTime(oldinode.getModificationTime() + 1);
|
newinode.setModificationTime(oldinode.getModificationTime() + 1);
|
||||||
|
|
||||||
current.set(i, newinode);
|
current.set(i, newinode);
|
||||||
|
|
Loading…
Reference in New Issue