From 7afddca9d50ae36ff58f9fbe671e37e830dd273c Mon Sep 17 00:00:00 2001 From: Weiwei Yang Date: Sat, 8 Jul 2017 10:06:58 +0800 Subject: [PATCH] HDFS-12037. Ozone: Improvement rest API output format for better looking. Contributed by Weiwei Yang. --- .../java/org/apache/hadoop/ozone/web/response/BucketInfo.java | 3 ++- .../java/org/apache/hadoop/ozone/web/response/KeyInfo.java | 3 ++- .../java/org/apache/hadoop/ozone/web/response/ListBuckets.java | 3 ++- .../java/org/apache/hadoop/ozone/web/response/ListKeys.java | 3 ++- .../java/org/apache/hadoop/ozone/web/response/ListVolumes.java | 3 ++- .../java/org/apache/hadoop/ozone/web/response/VolumeInfo.java | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/BucketInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/BucketInfo.java index 1e47c16152..53c71199df 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/BucketInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/BucketInfo.java @@ -56,7 +56,8 @@ public class BucketInfo implements Comparable { mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); mapper.addMixIn(Object.class, MixIn.class); - WRITER = mapper.writer(filters); + mapper.setFilterProvider(filters); + WRITER = mapper.writerWithDefaultPrettyPrinter(); } private String volumeName; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java index 69be5b9079..e5cfd21d17 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/KeyInfo.java @@ -54,7 +54,8 @@ public class KeyInfo implements Comparable { JsonAutoDetect.Visibility.ANY); mapper.addMixIn(Object.class, MixIn.class); - WRITER = mapper.writer(filters); + mapper.setFilterProvider(filters); + WRITER = mapper.writerWithDefaultPrettyPrinter(); } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListBuckets.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListBuckets.java index 3b0d32e6ca..bc4e65be0d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListBuckets.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListBuckets.java @@ -55,7 +55,8 @@ public class ListBuckets { JsonAutoDetect.Visibility.ANY); mapper.addMixIn(Object.class, MixIn.class); - WRITER = mapper.writer(filters); + mapper.setFilterProvider(filters); + WRITER = mapper.writerWithDefaultPrettyPrinter(); } private List buckets; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListKeys.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListKeys.java index fd76e4aecc..9dc77d2c23 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListKeys.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListKeys.java @@ -58,7 +58,8 @@ public class ListKeys { JsonAutoDetect.Visibility.ANY); mapper.addMixIn(Object.class, MixIn.class); - WRITER = mapper.writer(filters); + mapper.setFilterProvider(filters); + WRITER = mapper.writerWithDefaultPrettyPrinter(); } private String name; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListVolumes.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListVolumes.java index 797c0efb8f..b918349d49 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListVolumes.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/ListVolumes.java @@ -59,7 +59,8 @@ public class ListVolumes { JsonAutoDetect.Visibility.ANY); mapper.addMixIn(Object.class, MixIn.class); - WRITER = mapper.writer(filters); + mapper.setFilterProvider(filters); + WRITER = mapper.writerWithDefaultPrettyPrinter(); } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/VolumeInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/VolumeInfo.java index 8e6ec902de..112b27e541 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/VolumeInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/response/VolumeInfo.java @@ -58,7 +58,8 @@ public class VolumeInfo implements Comparable { JsonAutoDetect.Visibility.ANY); mapper.addMixIn(Object.class, MixIn.class); - WRITER = mapper.writer(filters); + mapper.setFilterProvider(filters); + WRITER = mapper.writerWithDefaultPrettyPrinter(); } /**