HADOOP-14891. Remove references to Guava Objects.toStringHelper. Contributed by Jonathan Eagles

(cherry picked from commit 0aac5af6e1)
This commit is contained in:
Jason Lowe 2017-09-26 10:08:06 -05:00
parent f794adde3b
commit 86e092029d
8 changed files with 64 additions and 36 deletions

View File

@ -84,9 +84,12 @@ public abstract class AbstractMetric implements MetricsInfo {
} }
@Override public String toString() { @Override public String toString() {
return Objects.toStringHelper(this) StringBuilder sb = new StringBuilder(32);
.add("info", info) sb.append(this.getClass().getSimpleName());
.add("value", value()) sb.append("{info=");
.toString(); sb.append(info);
sb.append(", value=");
sb.append(value());
return sb.append('}').toString();
} }
} }

View File

@ -80,9 +80,12 @@ public class MetricsTag implements MetricsInfo {
} }
@Override public String toString() { @Override public String toString() {
return Objects.toStringHelper(this) StringBuilder sb = new StringBuilder(32);
.add("info", info) sb.append(this.getClass().getSimpleName());
.add("value", value()) sb.append("{info=");
.toString(); sb.append(info);
sb.append(", value=");
sb.append(value());
return sb.append('}').toString();
} }
} }

View File

@ -43,12 +43,18 @@ abstract class AbstractMetricsRecord implements MetricsRecord {
} }
@Override public String toString() { @Override public String toString() {
return Objects.toStringHelper(this) StringBuilder sb = new StringBuilder(32);
.add("timestamp", timestamp()) sb.append(this.getClass().getSimpleName());
.add("name", name()) sb.append("{timestamp=");
.add("description", description()) sb.append(timestamp());
.add("tags", tags()) sb.append(", name=");
.add("metrics", Iterables.toString(metrics())) sb.append(name());
.toString(); sb.append(", description=");
sb.append(description());
sb.append(", tags=");
sb.append(tags());
sb.append(", metrics=");
sb.append(Iterables.toString(metrics()));
return sb.append('}').toString();
} }
} }

View File

@ -18,8 +18,6 @@
package org.apache.hadoop.metrics2.impl; package org.apache.hadoop.metrics2.impl;
import com.google.common.base.Objects;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.metrics2.MetricsInfo; import org.apache.hadoop.metrics2.MetricsInfo;
@ -48,8 +46,12 @@ public enum MsInfo implements MetricsInfo {
} }
@Override public String toString() { @Override public String toString() {
return Objects.toStringHelper(this) StringBuilder sb = new StringBuilder(32);
.add("name", name()).add("description", desc) sb.append(this.getClass().getSimpleName());
.toString(); sb.append("{name=");
sb.append(name());
sb.append(", description=");
sb.append(desc);
return sb.append('}').toString();
} }
} }

View File

@ -55,8 +55,12 @@ class MetricsInfoImpl implements MetricsInfo {
} }
@Override public String toString() { @Override public String toString() {
return Objects.toStringHelper(this) StringBuilder sb = new StringBuilder(32);
.add("name", name).add("description", description) sb.append(this.getClass().getSimpleName());
.toString(); sb.append("{name=");
sb.append(name);
sb.append(", description=");
sb.append(description);
return sb.append('}').toString();
} }
} }

View File

@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.Map; import java.util.Map;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.base.Objects;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
@ -416,8 +415,14 @@ public class MetricsRegistry {
} }
@Override public String toString() { @Override public String toString() {
return Objects.toStringHelper(this) StringBuilder sb = new StringBuilder(32);
.add("info", metricsInfo).add("tags", tags()).add("metrics", metrics()) sb.append(this.getClass().getSimpleName());
.toString(); sb.append("{info=");
sb.append(metricsInfo);
sb.append(", tags=");
sb.append(tags());
sb.append(", metrics=");
sb.append(metrics());
return sb.append('}').toString();
} }
} }

View File

@ -18,8 +18,6 @@
package org.apache.hadoop.metrics2.source; package org.apache.hadoop.metrics2.source;
import com.google.common.base.Objects;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.metrics2.MetricsInfo; import org.apache.hadoop.metrics2.MetricsInfo;
@ -60,8 +58,12 @@ public enum JvmMetricsInfo implements MetricsInfo {
@Override public String description() { return desc; } @Override public String description() { return desc; }
@Override public String toString() { @Override public String toString() {
return Objects.toStringHelper(this) StringBuilder sb = new StringBuilder(32);
.add("name", name()).add("description", desc) sb.append(this.getClass().getSimpleName());
.toString(); sb.append("{name=");
sb.append(name());
sb.append(", description=");
sb.append(desc);
return sb.append('}').toString();
} }
} }

View File

@ -31,7 +31,6 @@ import org.apache.hadoop.metrics2.AbstractMetric;
import org.apache.hadoop.metrics2.MetricsRecord; import org.apache.hadoop.metrics2.MetricsRecord;
import org.apache.hadoop.metrics2.MetricsTag; import org.apache.hadoop.metrics2.MetricsTag;
import com.google.common.base.Objects;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
/** /**
@ -127,9 +126,13 @@ public class MetricsCache {
} }
@Override public String toString() { @Override public String toString() {
return Objects.toStringHelper(this) StringBuilder sb = new StringBuilder(32);
.add("tags", tags).add("metrics", metrics) sb.append(this.getClass().getSimpleName());
.toString(); sb.append("{tags=");
sb.append(tags);
sb.append(", metrics=");
sb.append(metrics);
return sb.append('}').toString();
} }
} }