HADOOP-14382 Remove usages of MoreObjects.toStringHelper.

Contributed by Andrew Wang
This commit is contained in:
Steve Loughran 2017-05-05 13:03:09 +01:00
parent 97c2e576c9
commit 4e6bbd049d
No known key found for this signature in database
GPG Key ID: 950CC3E032B79CA2
9 changed files with 66 additions and 54 deletions

View File

@ -18,13 +18,14 @@
package org.apache.hadoop.metrics2;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import static com.google.common.base.Preconditions.*;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import java.util.StringJoiner;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The immutable metric
*/
@ -84,10 +85,11 @@ public abstract class AbstractMetric implements MetricsInfo {
return Objects.hashCode(info, value());
}
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("info", info)
.add("value", value())
@Override
public String toString() {
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("info=" + info)
.add("value=" + value())
.toString();
}
}

View File

@ -18,13 +18,14 @@
package org.apache.hadoop.metrics2;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import static com.google.common.base.Preconditions.*;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import java.util.StringJoiner;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Immutable tag for metrics (for grouping on host/queue/username etc.)
*/
@ -81,9 +82,9 @@ public class MetricsTag implements MetricsInfo {
}
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("info", info)
.add("value", value())
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("info=" + info)
.add("value=" + value())
.toString();
}
}

View File

@ -18,12 +18,12 @@
package org.apache.hadoop.metrics2.impl;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
import org.apache.hadoop.metrics2.MetricsRecord;
import java.util.StringJoiner;
abstract class AbstractMetricsRecord implements MetricsRecord {
@Override public boolean equals(Object obj) {
@ -44,12 +44,12 @@ abstract class AbstractMetricsRecord implements MetricsRecord {
}
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("timestamp", timestamp())
.add("name", name())
.add("description", description())
.add("tags", tags())
.add("metrics", Iterables.toString(metrics()))
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("timestamp=" + timestamp())
.add("name=" + name())
.add("description=" + description())
.add("tags=" + tags())
.add("metrics=" + Iterables.toString(metrics()))
.toString();
}
}

View File

@ -18,11 +18,11 @@
package org.apache.hadoop.metrics2.impl;
import com.google.common.base.MoreObjects;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.metrics2.MetricsInfo;
import java.util.StringJoiner;
/**
* Metrics system related metrics info instances
*/
@ -48,8 +48,9 @@ public enum MsInfo implements MetricsInfo {
}
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("name", name()).add("description", desc)
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("name=" + name())
.add("description=" + desc)
.toString();
}
}

View File

@ -18,11 +18,13 @@
package org.apache.hadoop.metrics2.lib;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import static com.google.common.base.Preconditions.*;
import org.apache.hadoop.metrics2.MetricsInfo;
import java.util.StringJoiner;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Making implementing metric info a little easier
*/
@ -56,8 +58,9 @@ class MetricsInfoImpl implements MetricsInfo {
}
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("name", name).add("description", description)
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("name=" + name)
.add("description=" + description)
.toString();
}
}

View File

@ -18,20 +18,19 @@
package org.apache.hadoop.metrics2.lib;
import java.util.Collection;
import java.util.Map;
import com.google.common.collect.Maps;
import com.google.common.base.MoreObjects;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.metrics2.MetricsInfo;
import org.apache.hadoop.metrics2.MetricsException;
import org.apache.hadoop.metrics2.MetricsInfo;
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
import org.apache.hadoop.metrics2.MetricsTag;
import org.apache.hadoop.metrics2.impl.MsInfo;
import java.util.Collection;
import java.util.Map;
import java.util.StringJoiner;
/**
* An optional metrics registry class for creating and maintaining a
* collection of MetricsMutables, making writing metrics source easier.
@ -440,9 +439,12 @@ public class MetricsRegistry {
}
}
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("info", metricsInfo).add("tags", tags()).add("metrics", metrics())
@Override
public String toString() {
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("info=" + metricsInfo.toString())
.add("tags=" + tags())
.add("metrics=" + metrics())
.toString();
}

View File

@ -21,7 +21,7 @@ package org.apache.hadoop.metrics2.source;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.metrics2.MetricsInfo;
import com.google.common.base.MoreObjects;
import java.util.StringJoiner;
/**
* JVM and logging related metrics info instances
@ -60,8 +60,9 @@ public enum JvmMetricsInfo implements MetricsInfo {
@Override public String description() { return desc; }
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("name", name()).add("description", desc)
.toString();
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("name=" + name())
.add("description=" + desc)
.toString();
}
}

View File

@ -18,11 +18,7 @@
package org.apache.hadoop.metrics2.util;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Maps;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@ -31,8 +27,11 @@ import org.apache.hadoop.metrics2.AbstractMetric;
import org.apache.hadoop.metrics2.MetricsRecord;
import org.apache.hadoop.metrics2.MetricsTag;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.StringJoiner;
/**
* A metrics cache for sinks that don't support sparse updates.
@ -127,8 +126,9 @@ public class MetricsCache {
}
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("tags", tags).add("metrics", metrics)
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("tags=" + tags)
.add("metrics=" + metrics)
.toString();
}
}

View File

@ -18,7 +18,6 @@
package org.apache.hadoop.metrics2.impl;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import org.apache.commons.configuration2.SubsetConfiguration;
import org.apache.hadoop.metrics2.AbstractMetric;
@ -40,6 +39,7 @@ import org.slf4j.LoggerFactory;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringJoiner;
import java.util.concurrent.Future;
import static org.junit.Assert.assertEquals;
@ -74,8 +74,10 @@ public class TestKafkaMetrics {
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("name", name())
.add("description", desc).toString();
return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}")
.add("name=" + name())
.add("description=" + desc)
.toString();
}
}