HDFS-15276. Concat on INodeRefernce fails with illegal state exception. Contributed by hemanthboyina

This commit is contained in:
Mingliang Liu 2020-04-22 13:31:02 -07:00
parent 52ea5a0227
commit 03ff1d3bd8
No known key found for this signature in database
GPG Key ID: BC2FB8C6908A0C16
2 changed files with 35 additions and 1 deletions

View File

@ -526,7 +526,7 @@ public class INodeDirectory extends INodeWithAdditionalFields
}
final INode removed = children.remove(i);
Preconditions.checkState(removed == child);
Preconditions.checkState(removed.equals(child));
return true;
}

View File

@ -1283,4 +1283,38 @@ public class TestFileTruncate {
cluster.waitActive();
}
}
/**
* Test concat on file which is a reference.
*/
@Test
public void testConcatOnInodeRefernce() throws IOException {
String dir = "/testConcat";
Path trgDir = new Path(dir);
fs.mkdirs(new Path(dir), FsPermission.getDirDefault());
// Create a target file
Path trg = new Path(dir, "file");
DFSTestUtil.createFile(fs, trg, 512, (short) 2, 0);
String dir2 = "/dir2";
Path srcDir = new Path(dir2);
// create a source file
fs.mkdirs(srcDir);
fs.allowSnapshot(srcDir);
Path src = new Path(srcDir, "file1");
DFSTestUtil.createFile(fs, src, 512, (short) 2, 0);
// make the file as an Inode reference and delete the reference
fs.createSnapshot(srcDir, "s1");
fs.rename(src, trgDir);
fs.deleteSnapshot(srcDir, "s1");
Path[] srcs = new Path[1];
srcs[0] = new Path(dir, "file1");
assertEquals(2, fs.getContentSummary(new Path(dir)).getFileCount());
// perform concat
fs.concat(trg, srcs);
assertEquals(1, fs.getContentSummary(new Path(dir)).getFileCount());
}
}