Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
kuszz committed Aug 6, 2024
1 parent 0fcf42c commit 4a22c8e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public class MetricsManager {
private final String[] defaultLabelValues;
private static final double[] QUANTILES = {0.50, 0.75, 0.90, 0.95, 0.99};
private static final double QUANTILE_ERROR = 0.01;
private static final String LABEL_SEPARATOR = ":";
private static final String NAME_SEPARATOR = "_";

public MetricsManager() {
this(null, Maps.newHashMap());
Expand All @@ -51,7 +49,7 @@ public MetricsManager(CollectorRegistry collectorRegistry, Map<String, String> d
} else {
this.collectorRegistry = collectorRegistry;
}
metricRegistry = new MetricRegistry();
this.metricRegistry = new MetricRegistry();
this.collectorRegistry.register(new DropwizardExports(metricRegistry));
this.defaultLabelNames = defaultLabels.keySet().toArray(new String[0]);
this.defaultLabelValues =
Expand All @@ -75,12 +73,10 @@ public Counter.Child addLabeledCounter(String name) {
return c.labels(this.defaultLabelValues);
}

@Deprecated
public Gauge addGauge(String name, String... labels) {
return addGauge(name, "Gauge " + name, labels);
}

@Deprecated
public Gauge addGauge(String name, String help, String[] labels) {
return Gauge.build().name(name).labelNames(labels).help(help).register(collectorRegistry);
}
Expand Down Expand Up @@ -111,7 +107,6 @@ protected T loadValue() {
}
}

@Deprecated
public Gauge.Child addLabeledGauge(String name) {
Gauge c = addGauge(name, this.defaultLabelNames);
return c.labels(this.defaultLabelValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ protected void initFlushEventExecutor() {
hadoopThreadPoolExecutor = createFlushEventExecutor(poolSize, "HadoopFlushEventThreadPool");
}
fallbackThreadPoolExecutor = createFlushEventExecutor(5, "FallBackFlushEventThreadPool");
ShuffleServerMetrics.getMetricsManager()
.registerGaugeIfAbsent(EVENT_QUEUE_SIZE, flushQueue::size);
ShuffleServerMetrics.registerGaugeIfAbsent(EVENT_QUEUE_SIZE, flushQueue::size);
startEventProcessor();
}

Expand Down
24 changes: 10 additions & 14 deletions server/src/main/java/org/apache/uniffle/server/ShuffleServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,16 @@ private void initialization() throws Exception {
new ShuffleTaskManager(
shuffleServerConf, shuffleFlushManager, shuffleBufferManager, storageManager);
shuffleTaskManager.start();
ShuffleServerMetrics.getMetricsManager()
.registerGaugeIfAbsent(
USED_DIRECT_MEMORY_SIZE_BY_NETTY, PlatformDependent::usedDirectMemory);
ShuffleServerMetrics.getMetricsManager()
.registerGaugeIfAbsent(
USED_DIRECT_MEMORY_SIZE_BY_GRPC_NETTY,
io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent::usedDirectMemory);
ShuffleServerMetrics.getMetricsManager()
.registerGaugeIfAbsent(
USED_DIRECT_MEMORY_SIZE,
() ->
PlatformDependent.usedDirectMemory()
+ io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent
.usedDirectMemory());
ShuffleServerMetrics.registerGaugeIfAbsent(
USED_DIRECT_MEMORY_SIZE_BY_NETTY, PlatformDependent::usedDirectMemory);
ShuffleServerMetrics.registerGaugeIfAbsent(
USED_DIRECT_MEMORY_SIZE_BY_GRPC_NETTY,
io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent::usedDirectMemory);
ShuffleServerMetrics.registerGaugeIfAbsent(
USED_DIRECT_MEMORY_SIZE,
() ->
PlatformDependent.usedDirectMemory()
+ io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent.usedDirectMemory());
setServer();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ private static void setUpMetrics(ShuffleServerConf serverConf) {
.register(metricsManager.getCollectorRegistry());
}

public static MetricsManager getMetricsManager() {
return metricsManager;
public static synchronized <T> void registerGaugeIfAbsent(
String name, com.codahale.metrics.Gauge<T> metric) {
metricsManager.registerGaugeIfAbsent(name, metric);
}
}

0 comments on commit 4a22c8e

Please sign in to comment.