HDFS-13786. EC: Display erasure coding policy for sub-directories is not working. Contributed by Ayush Saxena.

This commit is contained in:
Vinayakumar B 2018-08-08 07:47:10 +05:30
parent 7862f1523f
commit 2b0f977241
2 changed files with 16 additions and 0 deletions

View File

@ -191,6 +191,8 @@ public String getErasureCodingPolicyName(INode inode) {
.getEnabledPolicyByName(ecPolicyName) .getEnabledPolicyByName(ecPolicyName)
.getName(); .getName();
} }
} else if (inode.getParent() != null) {
return getErasureCodingPolicyName(inode.getParent());
} }
} catch (IOException ioe) { } catch (IOException ioe) {
LOG.warn("Encountered error getting ec policy for " LOG.warn("Encountered error getting ec policy for "

View File

@ -19,6 +19,7 @@
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.ContentSummary;
import org.apache.hadoop.fs.CreateFlag; import org.apache.hadoop.fs.CreateFlag;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
@ -153,6 +154,19 @@ public void testReplicatedFileUnderECDir() throws IOException {
assertNotNull(files[1].getErasureCodingPolicy()); assertNotNull(files[1].getErasureCodingPolicy());
} }
@Test
public void testContentSummaryOfECSubdir() throws IOException {
final Path testDir = new Path("/ec");
fs.mkdir(testDir, FsPermission.getDirDefault());
fs.setErasureCodingPolicy(testDir, ecPolicy.getName());
final Path fPath = new Path("ec/file");
fs.create(fPath).close();
final Path subdir = new Path("/ec/sub");
fs.mkdir(subdir, FsPermission.getDirDefault());
ContentSummary contentSummary = fs.getContentSummary(subdir);
assertEquals(ecPolicy.getName(),contentSummary.getErasureCodingPolicy());
}
@Test @Test
public void testBasicSetECPolicy() public void testBasicSetECPolicy()
throws IOException, InterruptedException { throws IOException, InterruptedException {