diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/AbstractMetric.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/AbstractMetric.java index 6a11b875cd4..510cee073be 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/AbstractMetric.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/AbstractMetric.java @@ -84,9 +84,12 @@ public abstract class AbstractMetric implements MetricsInfo { } @Override public String toString() { - return Objects.toStringHelper(this) - .add("info", info) - .add("value", value()) - .toString(); + StringBuilder sb = new StringBuilder(32); + sb.append(this.getClass().getSimpleName()); + sb.append("{info="); + sb.append(info); + sb.append(", value="); + sb.append(value()); + return sb.append('}').toString(); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsTag.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsTag.java index e9e50a4acba..23ef0867dc6 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsTag.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsTag.java @@ -80,9 +80,12 @@ public class MetricsTag implements MetricsInfo { } @Override public String toString() { - return Objects.toStringHelper(this) - .add("info", info) - .add("value", value()) - .toString(); + StringBuilder sb = new StringBuilder(32); + sb.append(this.getClass().getSimpleName()); + sb.append("{info="); + sb.append(info); + sb.append(", value="); + sb.append(value()); + return sb.append('}').toString(); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/AbstractMetricsRecord.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/AbstractMetricsRecord.java index 3684c7ef5c3..cdcde144c3c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/AbstractMetricsRecord.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/AbstractMetricsRecord.java @@ -43,12 +43,18 @@ abstract class AbstractMetricsRecord implements MetricsRecord { } @Override public String toString() { - return Objects.toStringHelper(this) - .add("timestamp", timestamp()) - .add("name", name()) - .add("description", description()) - .add("tags", tags()) - .add("metrics", Iterables.toString(metrics())) - .toString(); + StringBuilder sb = new StringBuilder(32); + sb.append(this.getClass().getSimpleName()); + sb.append("{timestamp="); + sb.append(timestamp()); + sb.append(", name="); + sb.append(name()); + sb.append(", description="); + sb.append(description()); + sb.append(", tags="); + sb.append(tags()); + sb.append(", metrics="); + sb.append(Iterables.toString(metrics())); + return sb.append('}').toString(); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MsInfo.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MsInfo.java index 782f7557207..c66160f67c2 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MsInfo.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MsInfo.java @@ -18,8 +18,6 @@ package org.apache.hadoop.metrics2.impl; -import com.google.common.base.Objects; - import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.metrics2.MetricsInfo; @@ -48,8 +46,12 @@ public enum MsInfo implements MetricsInfo { } @Override public String toString() { - return Objects.toStringHelper(this) - .add("name", name()).add("description", desc) - .toString(); + StringBuilder sb = new StringBuilder(32); + sb.append(this.getClass().getSimpleName()); + sb.append("{name="); + sb.append(name()); + sb.append(", description="); + sb.append(desc); + return sb.append('}').toString(); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsInfoImpl.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsInfoImpl.java index dfb6c357a22..79bba1fe2f8 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsInfoImpl.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsInfoImpl.java @@ -55,8 +55,12 @@ class MetricsInfoImpl implements MetricsInfo { } @Override public String toString() { - return Objects.toStringHelper(this) - .add("name", name).add("description", description) - .toString(); + StringBuilder sb = new StringBuilder(32); + sb.append(this.getClass().getSimpleName()); + sb.append("{name="); + sb.append(name); + sb.append(", description="); + sb.append(description); + return sb.append('}').toString(); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsRegistry.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsRegistry.java index 1ef74f41c03..9c020c4f644 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsRegistry.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsRegistry.java @@ -22,7 +22,6 @@ import java.util.Collection; import java.util.Map; import com.google.common.collect.Maps; -import com.google.common.base.Objects; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -416,8 +415,14 @@ public class MetricsRegistry { } @Override public String toString() { - return Objects.toStringHelper(this) - .add("info", metricsInfo).add("tags", tags()).add("metrics", metrics()) - .toString(); + StringBuilder sb = new StringBuilder(32); + sb.append(this.getClass().getSimpleName()); + sb.append("{info="); + sb.append(metricsInfo); + sb.append(", tags="); + sb.append(tags()); + sb.append(", metrics="); + sb.append(metrics()); + return sb.append('}').toString(); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java index 55bb41720ed..e2b03f5cbff 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java @@ -18,8 +18,6 @@ package org.apache.hadoop.metrics2.source; -import com.google.common.base.Objects; - import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.metrics2.MetricsInfo; @@ -60,8 +58,12 @@ public enum JvmMetricsInfo implements MetricsInfo { @Override public String description() { return desc; } @Override public String toString() { - return Objects.toStringHelper(this) - .add("name", name()).add("description", desc) - .toString(); + StringBuilder sb = new StringBuilder(32); + sb.append(this.getClass().getSimpleName()); + sb.append("{name="); + sb.append(name()); + sb.append(", description="); + sb.append(desc); + return sb.append('}').toString(); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MetricsCache.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MetricsCache.java index efcb286fae2..9c7935b07db 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MetricsCache.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MetricsCache.java @@ -31,7 +31,6 @@ import org.apache.hadoop.metrics2.AbstractMetric; import org.apache.hadoop.metrics2.MetricsRecord; import org.apache.hadoop.metrics2.MetricsTag; -import com.google.common.base.Objects; import com.google.common.collect.Maps; /** @@ -127,9 +126,13 @@ public class MetricsCache { } @Override public String toString() { - return Objects.toStringHelper(this) - .add("tags", tags).add("metrics", metrics) - .toString(); + StringBuilder sb = new StringBuilder(32); + sb.append(this.getClass().getSimpleName()); + sb.append("{tags="); + sb.append(tags); + sb.append(", metrics="); + sb.append(metrics); + return sb.append('}').toString(); } }