jongyoul commented on a change in pull request #3272: [ZEPPELIN-3422] Add JMX Support URL: https://github.com/apache/zeppelin/pull/3272#discussion_r243959951
########## File path: zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java ########## @@ -177,6 +183,51 @@ public void contextDestroyed(ServletContextEvent servletContextEvent) {} // Notebook server setupNotebookServer(webApp, conf, sharedServiceLocator); + // JMX Enable + Stream.of("ZEPPELIN_JMX_ENABLE") + .map(System::getenv) + .map(Boolean::parseBoolean) + .filter(Boolean::booleanValue) + .map(jmxEnabled -> "ZEPPELIN_JMX_PORT") + .map(System::getenv) + .map( + portString -> { + try { + return Integer.parseInt(portString); + } catch (Exception e) { + return null; + } + }) + .filter(Objects::nonNull) + .forEach( + port -> { + try { + MBeanContainer mbeanContainer = + new MBeanContainer(ManagementFactory.getPlatformMBeanServer()); + jettyWebServer.addEventListener(mbeanContainer); + jettyWebServer.addBean(mbeanContainer); + + JMXServiceURL jmxURL = + new JMXServiceURL( + String.format( + "service:jmx:rmi://0.0.0.0:%d/jndi/rmi://0.0.0.0:%d/jmxrmi", + port, port)); + ConnectorServer jmxServer = + new ConnectorServer(jmxURL, "org.eclipse.jetty.jmx:name=rmiconnectorserver"); + jettyWebServer.addBean(jmxServer); + + // Add JMX Beans + // TODO(jl): Need to investigate more about injection and jmx + jettyWebServer.addBean( + sharedServiceLocator.getService(InterpreterSettingManager.class)); + jettyWebServer.addBean(sharedServiceLocator.getService(NotebookServer.class)); + + LOG.info("JMX Enabled with port: {}", port); + } catch (Exception e) { + LOG.info("Error while setting JMX", e); Review comment: Make sense ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services