rionmonster commented on a change in pull request #15175:
URL: https://github.com/apache/flink/pull/15175#discussion_r593831319
##########
File path:
flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/PrometheusReporter.java
##########
@@ -50,30 +49,11 @@ int getPort() {
return port;
}
- @Override
- public void open(MetricConfig config) {
- super.open(config);
-
- String portsConfig = config.getString(ARG_PORT, DEFAULT_PORT);
- Iterator<Integer> ports = NetUtils.getPortRangeFromString(portsConfig);
-
- while (ports.hasNext()) {
- int port = ports.next();
- try {
- // internally accesses CollectorRegistry.defaultRegistry
- httpServer = new HTTPServer(port);
- this.port = port;
- log.info("Started PrometheusReporter HTTP server on port {}.",
port);
- break;
- } catch (IOException ioe) { // assume port conflict
- log.debug("Could not start PrometheusReporter HTTP server on
port {}.", port, ioe);
- }
- }
- if (httpServer == null) {
- throw new RuntimeException(
- "Could not start PrometheusReporter HTTP server on any
configured port. Ports: "
- + portsConfig);
- }
+ PrometheusReporter(
+ final int port,
+ @Nullable HTTPServer httpServer) {
+ this.httpServer = Preconditions.checkNotNull(httpServer);
Review comment:
Makes sense, although the `httpServer` is no longer passed in since we
pass in the ports iterator now. Done!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]