HDFS-14683. WebHDFS: Add erasureCodingPolicy field to GETCONTENTSUMMARY response (#1189) Contributed by Siyao Meng.

This commit is contained in:
Siyao Meng 2019-08-01 17:14:07 -07:00 committed by Wei-Chiu Chuang
parent d086d058d8
commit 99bf1dc9eb
3 changed files with 23 additions and 0 deletions

View File

@ -354,6 +354,7 @@ public static String toJsonString(final ContentSummary contentsummary) {
m.put("length", contentsummary.getLength());
m.put("fileCount", contentsummary.getFileCount());
m.put("directoryCount", contentsummary.getDirectoryCount());
m.put("ecPolicy", contentsummary.getErasureCodingPolicy());
// For ContentSummary we don't need this since we already have
// separate count for file and directory.
m.putAll(toJsonMap(contentsummary, false));

View File

@ -761,6 +761,7 @@ Other File System Operations
"ContentSummary":
{
"directoryCount": 2,
"ecPolicy" : "RS-6-3-1024k",
"fileCount" : 1,
"length" : 24930,
"quota" : -1,

View File

@ -34,6 +34,7 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.XAttr;
import org.apache.hadoop.fs.XAttrCodec;
import org.apache.hadoop.fs.ContentSummary;
import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.AclStatus;
import org.apache.hadoop.fs.permission.FsPermission;
@ -256,6 +257,26 @@ public void testToJsonFromAclStatus() {
JsonUtil.toJsonString(aclStatusBuilder.build()));
}
@Test
public void testToJsonFromContentSummary() {
String jsonString =
"{\"ContentSummary\":{\"directoryCount\":33333,\"ecPolicy\":\"RS-6-3-1024k\",\"fileCount\":22222,\"length\":11111,\"quota\":44444,\"spaceConsumed\":55555,\"spaceQuota\":66666,\"typeQuota\":{}}}";
long length = 11111;
long fileCount = 22222;
long directoryCount = 33333;
long quota = 44444;
long spaceConsumed = 55555;
long spaceQuota = 66666;
String ecPolicy = "RS-6-3-1024k";
ContentSummary contentSummary = new ContentSummary.Builder().length(length).
fileCount(fileCount).directoryCount(directoryCount).quota(quota).
spaceConsumed(spaceConsumed).spaceQuota(spaceQuota).
erasureCodingPolicy(ecPolicy).build();
Assert.assertEquals(jsonString, JsonUtil.toJsonString(contentSummary));
}
@Test
public void testToJsonFromXAttrs() throws IOException {