Github user tillrohrmann commented on a diff in the pull request: https://github.com/apache/flink/pull/2145#discussion_r68043825 --- Diff: flink-core/src/main/java/org/apache/flink/metrics/reporter/JMXReporter.java --- @@ -265,4 +329,72 @@ public Object getValue() { return gauge.getValue(); } } + + /** + * JMX Server implementation that JMX clients can connect to. + * + * Heavily based on j256 simplejmx project + * + * https://github.com/j256/simplejmx/blob/master/src/main/java/com/j256/simplejmx/server/JmxServer.java + */ + private static class JMXServer { + private int port; + private Registry rmiRegistry; + private JMXConnectorServer connector; + + public JMXServer(int port) { + this.port = port; + } + + public void start() throws IOException { + startRmiRegistry(); + startJmxService(); + } + + public void stop() throws IOException { + if (connector != null) { + try { + connector.stop(); + } finally { + connector = null; + } + } + if (rmiRegistry != null) { + try { + UnicastRemoteObject.unexportObject(rmiRegistry, true); + } catch (NoSuchObjectException e) { + throw new IOException("Could not unexport our RMI registry", e); + } finally { + rmiRegistry = null; + } + } + } + + private void startRmiRegistry() throws IOException { + if (rmiRegistry != null) { + return; + } + rmiRegistry = LocateRegistry.createRegistry(port); + } + + private void startJmxService() throws IOException { + if (connector != null) { + return; + } + String serverHost = "localhost"; + String registryHost = ""; + String serviceUrl = + "service:jmx:rmi://" + serverHost + ":" + port + "/jndi/rmi://" + registryHost + ":" + port + "/jmxrmi"; --- End diff -- Maybe we could try this out to know for sure.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---