nsivabalan commented on code in PR #13851:
URL: https://github.com/apache/hudi/pull/13851#discussion_r2337997357
##########
hudi-common/src/main/java/org/apache/hudi/metrics/prometheus/PrometheusReporter.java:
##########
@@ -101,12 +148,86 @@ public void report() {
@Override
public void stop() {
- collectorRegistry.unregister(metricExports);
- HTTPServer httpServer = PORT_TO_SERVER.remove(serverPort);
- if (httpServer != null) {
- httpServer.stop();
+ if (stopped.get()) {
+ LOG.debug("PrometheusReporter.stop() called for port {} but already
stopped", serverPort);
+ return;
+ }
+
+ try {
+ synchronized (PrometheusReporter.class) {
+ stopped.set(true);
+ LOG.debug("PrometheusReporter.stop() called for port {}", serverPort);
+ unregisterMetricExports();
+ removeFromExportsTracking();
Review Comment:
I see we are calling below
```
PrometheusServerState serverState = PORT_TO_SERVER_STATE.get(serverPort);
```
in some of these methods.
why not call this at L 159, and pass the `PrometheusServerState` as an arg
to each of these methods.
not a blocking comment. but good to fix it
##########
hudi-common/src/main/java/org/apache/hudi/metrics/prometheus/PrometheusReporter.java:
##########
@@ -101,12 +148,86 @@ public void report() {
@Override
public void stop() {
- collectorRegistry.unregister(metricExports);
- HTTPServer httpServer = PORT_TO_SERVER.remove(serverPort);
- if (httpServer != null) {
- httpServer.stop();
+ if (stopped.get()) {
Review Comment:
minor.
if we really don't need the debug log at : 152, we could do
```
if(!stopped.getAndSet(true)){
.
.
.
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]