Fix ray java worker metric test indentation (#9834)

This commit is contained in:
bermaker
2020-07-31 14:39:41 +08:00
committed by GitHub
parent a47121476f
commit 88e8714bcb
12 changed files with 55 additions and 51 deletions
@@ -17,7 +17,7 @@ public class Count extends Metric {
super(name, tags);
count = new DoubleAdder();
metricNativePointer = NativeMetric.registerCountNative(name, description, unit,
tags.keySet().stream().map(TagKey::getTagKey).collect(Collectors.toList()));
tags.keySet().stream().map(TagKey::getTagKey).collect(Collectors.toList()));
Preconditions.checkState(metricNativePointer != 0, "Count native pointer must not be 0.");
}
@@ -13,7 +13,7 @@ public class Gauge extends Metric {
public Gauge(String name, String description, String unit, Map<TagKey, String> tags) {
super(name, tags);
metricNativePointer = NativeMetric.registerGaugeNative(name, description, unit,
tags.keySet().stream().map(TagKey::getTagKey).collect(Collectors.toList()));
tags.keySet().stream().map(TagKey::getTagKey).collect(Collectors.toList()));
Preconditions.checkState(metricNativePointer != 0, "Gauge native pointer must not be 0.");
}
@@ -22,8 +22,8 @@ public class Histogram extends Metric {
Map<TagKey, String> tags) {
super(name, tags);
metricNativePointer = NativeMetric.registerHistogramNative(name, description, unit,
boundaries.stream().mapToDouble(Double::doubleValue).toArray(),
tags.keySet().stream().map(TagKey::getTagKey).collect(Collectors.toList()));
boundaries.stream().mapToDouble(Double::doubleValue).toArray(),
tags.keySet().stream().map(TagKey::getTagKey).collect(Collectors.toList()));
Preconditions.checkState(metricNativePointer != 0,
"Histogram native pointer must not be 0.");
histogramWindow = Collections.synchronizedList(new ArrayList<>());
@@ -32,6 +32,7 @@ public abstract class Metric {
// Sync metric with core worker stats for registry.
// Metric data will be flushed into stats view data inside core worker immediately after
// record is called.
/**
* Flush records to stats in last aggregator.
*/
@@ -51,19 +52,24 @@ public abstract class Metric {
/**
* Get the value to record and then reset.
*
* @return latest updating value.
*/
protected abstract double getAndReset();
/** Update gauge value without tags.
/**
* Update gauge value without tags.
* Update metric info for user.
*
* @param value latest value for updating
*/
public abstract void update(double value);
/** Update gauge value with dynamic tag values.
/**
* Update gauge value with dynamic tag values.
*
* @param value latest value for updating
* @param tags tag map
* @param tags tag map
*/
public void update(double value, Map<TagKey, String> tags) {
update(value);
@@ -39,10 +39,10 @@ public class MetricConfig {
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("timeIntervalMs", timeIntervalMs)
.add("threadPoolSize", threadPoolSize)
.add("shutdownWaitTimeMs", shutdownWaitTimeMs)
.toString();
.add("timeIntervalMs", timeIntervalMs)
.add("threadPoolSize", threadPoolSize)
.add("shutdownWaitTimeMs", shutdownWaitTimeMs)
.toString();
}
public static MetricConfigBuilder builder() {
@@ -32,8 +32,8 @@ public class MetricId {
}
MetricId metricId = (MetricId) o;
return type == metricId.type &&
Objects.equals(name, metricId.name) &&
Objects.equals(tags, metricId.tags);
Objects.equals(name, metricId.name) &&
Objects.equals(tags, metricId.tags);
}
@Override
@@ -44,10 +44,10 @@ public class MetricId {
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("type", type)
.add("name", name)
.add("tags", tags)
.toString();
.add("type", type)
.add("name", name)
.add("tags", tags)
.toString();
}
public MetricType getType() {
@@ -125,7 +125,7 @@ public class MetricRegistry {
return MetricType.HISTOGRAM;
}
throw new RuntimeException(
"Unknown metric type, the metric is " + metric.getClass().getSimpleName());
"Unknown metric type, the metric is " + metric.getClass().getSimpleName());
}
private MetricId genMetricIdByMetric(Metric metric) {
@@ -11,6 +11,6 @@ public enum MetricType {
SUM,
HISTOGRAM;
HISTOGRAM
}
@@ -26,6 +26,4 @@ class NativeMetric {
public static native void unregisterMetricNative(long gaugePtr);
}
@@ -17,7 +17,7 @@ public class Sum extends Metric {
public Sum(String name, String description, String unit, Map<TagKey, String> tags) {
super(name, tags);
metricNativePointer = NativeMetric.registerSumNative(name, description, unit,
tags.keySet().stream().map(TagKey::getTagKey).collect(Collectors.toList()));
tags.keySet().stream().map(TagKey::getTagKey).collect(Collectors.toList()));
Preconditions.checkState(metricNativePointer != 0, "Count native pointer must not be 0.");
this.sum = new DoubleAdder();
}
@@ -10,7 +10,7 @@ public class TagKey {
private String tagKey;
public TagKey(String key) {
tagKey = key;
tagKey = key;
NativeMetric.registerTagkeyNative(key);
}
@@ -38,7 +38,7 @@ public class TagKey {
@Override
public String toString() {
return "TagKey{" +
", tagKey='" + tagKey + '\'' +
'}';
", tagKey='" + tagKey + '\'' +
'}';
}
}