Skip to content

Commit 673c9d5

Browse files
smengcljojochuang
authored andcommitted
HDFS-14686. HttpFS: HttpFSFileSystem#getErasureCodingPolicy always returns null (#1192) Contributed by Siyao Meng.
(cherry picked from commit 17e8cf5)
1 parent 3a0afcf commit 673c9d5

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,12 @@ static ContentSummary toContentSummary(final Map<?, ?> json) {
432432
final long length = ((Number) m.get("length")).longValue();
433433
final long fileCount = ((Number) m.get("fileCount")).longValue();
434434
final long directoryCount = ((Number) m.get("directoryCount")).longValue();
435+
final String ecPolicy = ((String) m.get("ecPolicy"));
435436
ContentSummary.Builder builder = new ContentSummary.Builder()
436437
.length(length)
437438
.fileCount(fileCount)
438-
.directoryCount(directoryCount);
439+
.directoryCount(directoryCount)
440+
.erasureCodingPolicy(ecPolicy);
439441
builder = buildQuotaUsage(builder, m, ContentSummary.Builder.class);
440442
return builder.build();
441443
}

hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public static FILE_TYPE getType(FileStatus fileStatus) {
193193

194194
public static final String CONTENT_SUMMARY_JSON = "ContentSummary";
195195
public static final String CONTENT_SUMMARY_DIRECTORY_COUNT_JSON = "directoryCount";
196+
public static final String CONTENT_SUMMARY_ECPOLICY_JSON = "ecPolicy";
196197
public static final String CONTENT_SUMMARY_FILE_COUNT_JSON = "fileCount";
197198
public static final String CONTENT_SUMMARY_LENGTH_JSON = "length";
198199

@@ -1140,7 +1141,8 @@ public ContentSummary getContentSummary(Path f) throws IOException {
11401141
ContentSummary.Builder builder = new ContentSummary.Builder()
11411142
.length((Long) json.get(CONTENT_SUMMARY_LENGTH_JSON))
11421143
.fileCount((Long) json.get(CONTENT_SUMMARY_FILE_COUNT_JSON))
1143-
.directoryCount((Long) json.get(CONTENT_SUMMARY_DIRECTORY_COUNT_JSON));
1144+
.directoryCount((Long) json.get(CONTENT_SUMMARY_DIRECTORY_COUNT_JSON))
1145+
.erasureCodingPolicy((String) json.get(CONTENT_SUMMARY_ECPOLICY_JSON));
11441146
builder = buildQuotaUsage(builder, json, ContentSummary.Builder.class);
11451147
return builder.build();
11461148
}

hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ private static Map contentSummaryToJSON(ContentSummary contentSummary) {
265265
Map json = new LinkedHashMap();
266266
json.put(HttpFSFileSystem.CONTENT_SUMMARY_DIRECTORY_COUNT_JSON,
267267
contentSummary.getDirectoryCount());
268+
json.put(HttpFSFileSystem.CONTENT_SUMMARY_ECPOLICY_JSON,
269+
contentSummary.getErasureCodingPolicy());
268270
json.put(HttpFSFileSystem.CONTENT_SUMMARY_FILE_COUNT_JSON,
269271
contentSummary.getFileCount());
270272
json.put(HttpFSFileSystem.CONTENT_SUMMARY_LENGTH_JSON,

hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,8 @@ private void testContentSummary() throws Exception {
682682
fs.close();
683683
assertEquals(hdfsContentSummary.getDirectoryCount(),
684684
httpContentSummary.getDirectoryCount());
685+
assertEquals(hdfsContentSummary.getErasureCodingPolicy(),
686+
httpContentSummary.getErasureCodingPolicy());
685687
assertEquals(hdfsContentSummary.getFileCount(),
686688
httpContentSummary.getFileCount());
687689
assertEquals(hdfsContentSummary.getLength(),

0 commit comments

Comments
 (0)