tillrohrmann commented on a change in pull request #8373:
[FLINK-11922][metrics] Support MetricReporter factories
URL: https://github.com/apache/flink/pull/8373#discussion_r282393246
##########
File path:
flink-metrics/flink-metrics-jmx/src/main/java/org/apache/flink/metrics/jmx/JMXReporter.java
##########
@@ -86,33 +88,24 @@ public String filterCharacters(String input) {
private final Map<Metric, ObjectName> registeredMetrics;
/** The server to which JMX clients connect to. Allows for better
control over port usage. */
- private JMXServer jmxServer;
+ @Nullable
+ private final JMXServer jmxServer;
- public JMXReporter() {
+ JMXReporter(final Optional<String> portsConfig) {
this.mBeanServer = ManagementFactory.getPlatformMBeanServer();
this.registeredMetrics = new HashMap<>();
- }
-
- //
------------------------------------------------------------------------
- // life cycle
- //
------------------------------------------------------------------------
- @Override
- public void open(MetricConfig config) {
- String portsConfig = config.getString(ARG_PORT, null);
+ if (portsConfig.isPresent()) {
Review comment:
I would suggest to use `portsConfig.ifPresent(Consumer<String>)`.
----------------------------------------------------------------
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]
With regards,
Apache Git Services