HDFS-8444. Erasure Coding: fix cannot rename a zone dir (Contributed by Walter Su)

This commit is contained in:
Vinayakumar B 2015-06-02 16:41:19 +05:30
parent 9b54e66f3e
commit 2d847e7d62
3 changed files with 23 additions and 10 deletions

View File

@ -268,3 +268,6 @@
HDFS-8336. Expose some administrative erasure coding operations to HdfsAdmin HDFS-8336. Expose some administrative erasure coding operations to HdfsAdmin
(Uma Maheswara Rao G via vinayakumarb) (Uma Maheswara Rao G via vinayakumarb)
HDFS-8444. Erasure Coding: fix cannot rename a zone dir
(Walter Su via vinayakumarb)

View File

@ -153,8 +153,13 @@ XAttr createErasureCodingZone(String src, ECSchema schema, int cellSize)
void checkMoveValidity(INodesInPath srcIIP, INodesInPath dstIIP, String src) void checkMoveValidity(INodesInPath srcIIP, INodesInPath dstIIP, String src)
throws IOException { throws IOException {
assert dir.hasReadLock(); assert dir.hasReadLock();
final ECSchema srcSchema = getECSchema(srcIIP); final ErasureCodingZone srcZone = getECZone(srcIIP);
final ECSchema dstSchema = getECSchema(dstIIP); final ErasureCodingZone dstZone = getECZone(dstIIP);
if (srcZone != null && srcZone.getDir().equals(src) && dstZone == null) {
return;
}
final ECSchema srcSchema = (srcZone != null) ? srcZone.getSchema() : null;
final ECSchema dstSchema = (dstZone != null) ? dstZone.getSchema() : null;
if ((srcSchema != null && !srcSchema.equals(dstSchema)) || if ((srcSchema != null && !srcSchema.equals(dstSchema)) ||
(dstSchema != null && !dstSchema.equals(srcSchema))) { (dstSchema != null && !dstSchema.equals(srcSchema))) {
throw new IOException( throw new IOException(

View File

@ -119,15 +119,20 @@ public void testMoveValidity() throws IOException, InterruptedException {
final Path srcFile = new Path(srcECDir, "foo"); final Path srcFile = new Path(srcECDir, "foo");
fs.create(srcFile); fs.create(srcFile);
/* Verify that a file can be moved between 2 EC zones */ // Test move dir
try { // Move EC dir under non-EC dir
fs.rename(srcFile, dstECDir); final Path newDir = new Path("/srcEC_new");
} catch (IOException e) { fs.rename(srcECDir, newDir);
fail("A file should be able to move between 2 EC zones " + e); fs.rename(newDir, srcECDir); // move back
}
// Move the file back // Move EC dir under another EC dir
fs.rename(new Path(dstECDir, "foo"), srcECDir); fs.rename(srcECDir, dstECDir);
fs.rename(new Path("/dstEC/srcEC"), srcECDir); // move back
// Test move file
/* Verify that a file can be moved between 2 EC zones */
fs.rename(srcFile, dstECDir);
fs.rename(new Path(dstECDir, "foo"), srcECDir); // move back
/* Verify that a file cannot be moved from a non-EC dir to an EC zone */ /* Verify that a file cannot be moved from a non-EC dir to an EC zone */
final Path nonECDir = new Path("/nonEC"); final Path nonECDir = new Path("/nonEC");