Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/2145#discussion_r68238504
--- Diff:
flink-core/src/main/java/org/apache/flink/metrics/reporter/JMXReporter.java ---
@@ -73,10 +86,61 @@ public JMXReporter() {
//
------------------------------------------------------------------------
@Override
- public void open(Configuration config) {}
+ public void open(Configuration config) {
+ this.jmxServer = startJmxServer(config);
+ }
+
+ private static JMXServer startJmxServer(Configuration config) {
+ JMXServer jmxServer;
+
+ String portRange = config.getString(KEY_METRICS_JMX_PORT,
"9010-9025");
+ String[] ports = portRange.split("-");
+
+ if (ports.length == 0 || ports.length > 2) {
+ throw new IllegalArgumentException("JMX port range was
configured incorrectly. " +
+ "Expected: <startPort>[-<endPort>] Configured:
" + portRange);
+ }
+
+ if (ports.length == 1) { //single port was configured
+ int port = Integer.parseInt(ports[0]);
+ jmxServer = new JMXServer(port);
+ try {
+ jmxServer.start();
+ } catch (IOException e) {
+ throw new RuntimeException("Could not start JMX
server on port " + port + ".");
+ }
+ return jmxServer;
+ } else { //port range was configured
+ int start = Integer.parseInt(ports[0]);
+ int end = Integer.parseInt(ports[1]);
+ while (true) {
+ try {
+ jmxServer = new JMXServer(start);
+ jmxServer.start();
+ LOG.info("Starting JMX on port " +
start + ".");
--- End diff --
Sure, but it might be interesting to see explicitly which ports were tried,
imho.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---