Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Java and the Furious (JMX)

Yeray Darias
November 18, 2016

The Java and the Furious (JMX)

Talk given at Codemotion 2016 in Madrid about how to measure (Java) code speed and health with JMX.

Yeray Darias

November 18, 2016
Tweet

More Decks by Yeray Darias

Other Decks in Programming

Transcript

  1. The JAVA and the FURIOUS Talk by Yeray Darias at

    Codemotion in Madrid on Friday, 18 November 2016
  2. • 35YO • BSc Computer Science • Agile evangelist •

    Cook • Science geek • Future space rocket builder • Sketchnoting practitioner Yeray Darias
  3. JMX manage Web Browser MBean Server MBean MBean MBean JVM

    Agent level Instrumentation level Services level
  4. JMX manage Web Browser MBean Server MBean MBean MBean JVM

    Agent level Instrumentation level Services level
  5. Implement the interface public class SystemStats implements SystemStatsMBean { public

    long getTotalWrites() { … } public void setTimeout(long timeout) { … } }
  6. Register MBean SystemStats systemStats = new SystemStats(metrics, configuration);
 
 MBeanServer

    beansServer = ManagementFactory.getPlatformMBeanServer(); 
 ObjectName beanName = new ObjectName(“…”); 
 beansServer.registerMBean( systemStats, beanName);
  7. Connect to the server JMXServiceURL url = new JMXServiceURL(…); JMXConnector

    connector = JMXConnectorFactory.connect(url); MBeanServerConnection serverConnection = connector.getMBeanServerConnection();
  8. Search the MBean ObjectName mbeanName = new ObjectName(…); SystemStatsMBean statsProxy

    = MBeanServerInvocationHandler.newProxyInstance( serverConnection, mbeanName, SystemStatsMBean.class, true);