rmahindra123 commented on code in PR #13851:
URL: https://github.com/apache/hudi/pull/13851#discussion_r2334475138
##########
hudi-common/src/main/java/org/apache/hudi/metrics/prometheus/PrometheusReporter.java:
##########
@@ -48,16 +50,47 @@ public class PrometheusReporter extends MetricsReporter {
private static final Pattern LABEL_PATTERN = Pattern.compile("\\s*,\\s*");
private static final Logger LOG =
LoggerFactory.getLogger(PrometheusReporter.class);
- private static final Map<Integer, CollectorRegistry>
PORT_TO_COLLECTOR_REGISTRY = new HashMap<>();
- private static final Map<Integer, HTTPServer> PORT_TO_SERVER = new
HashMap<>();
+ private static final Map<Integer, PrometheusServerState>
PORT_TO_SERVER_STATE = new ConcurrentHashMap<>();
+
+ private static class PrometheusServerState {
+ private final HTTPServer httpServer;
+ private final CollectorRegistry collectorRegistry;
+ private final AtomicInteger referenceCount;
+ private final Set<DropwizardExports> exports;
+
+ public PrometheusServerState(HTTPServer httpServer, CollectorRegistry
collectorRegistry) {
+ this.httpServer = httpServer;
+ this.collectorRegistry = collectorRegistry;
+ this.referenceCount = new AtomicInteger(0);
+ this.exports = ConcurrentHashMap.newKeySet();
+ }
+
+ public HTTPServer getHttpServer() {
+ return httpServer;
+ }
+
+ public CollectorRegistry getCollectorRegistry() {
+ return collectorRegistry;
+ }
+
+ public AtomicInteger getReferenceCount() {
+ return referenceCount;
+ }
+
+ public Set<DropwizardExports> getExports() {
+ return exports;
+ }
+ }
private final DropwizardExports metricExports;
private final CollectorRegistry collectorRegistry;
private final int serverPort;
+ private volatile boolean stopped = false;
Review Comment:
make it AtomicBoolean.
--
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]