Successfully reported this slideshow.

JMX Training


Published on

This is a slide deck from JavaOne by Intertech.

Published in: Technology, Business
  • Be the first to comment

JMX Training

  1. 1. JMX & Your Systems Health<br />
  2. 2. A briefer history…(If its good enough for Hawking…)<br />JSR 3<br />Released in December of 2002<br />JSR 160 <br />Released in October of 2003<br />Added remote API for MBean Servers<br />
  3. 3. Terms<br />Manageable Resource<br />Any device, application, or entity that can be accessed or wrapped by Java.<br />MBean<br />Managed Bean – A Java class that implements elements of the JMX spec.<br />MBean Server<br />A Java class that manages a group of MBeans – the place you register your MBeans.<br />JMX Agent<br />A Java process that provides a set of services for managing MBeans – the container for the MBean server.<br />
  4. 4. Terms cont.<br />Protocol Adaptors<br />Provide a management view of the JMX agent through a given protocol, e.g. SNMP, HTTP<br />Connectors<br />Convey management operations transparently point-to-point over a specific protocol, e.g. RMI. <br />Notifications<br />Java objects published by MBeans and MBean servers to encapsulate events, alerts, or general information.<br />Instrumentation<br />The exposing of a manageable resource via an MBean.<br />
  5. 5. Architectural layers<br />Instrumentation<br />Allows for management of resources – your apps objects etc… via MBeans<br />Agent<br />Home of the MBean server, hosts all of your MBeans.<br />Manager<br />Provides the environment through which your MBeans talk to the outside world.<br />
  6. 6. Architectural layers<br />
  7. 7. Who’s using JMX?<br />Major App Server Vendors<br />JBoss<br />WebLogic<br />WebSphere<br />ESB Vendors<br />Sonic<br />IBM<br />JBI – Java Business Integration<br />JSR 208<br />
  8. 8. Why JMX – why them-us-me?<br />A cheap way to manage Java applications<br />Bonus – it’s now part of JSE 5<br />Will be supported by JEE 5<br />If need be you can interrogate the JVM<br />Short learning curve as compared to technologies like SNMP<br />If you know basic Java principles and patterns you are close to writing your own MBeans<br />Very component oriented <br />Even the MBean Server is a component – they’re all components!<br />
  9. 9. Why JMX – why them-us-me? (cont.)<br />Handy little features like<br />Alerts<br />Events<br />Statistics<br />Notification Model<br />Broadcasters<br />Listeners<br />
  10. 10. Why JMX – why them-us-me? (cont.)<br />Services<br />Timer MBeans<br />Monitor MBeans<br />Counter<br />Gauge<br />String<br />Relations<br />
  11. 11. When to ponder?<br />You can add JMX to a system anytime – but if you wait…<br />It’ll require some refactoring<br />Tends to not be woven into the fabric of the design<br />Kinda like adding on that mother-in-law addition to the house…<br />Best to do it early<br />Consider support needs in requirements gathering<br />What will you want to know as the system is running in production?<br />Design for it<br />Look at macro and micro picture<br />From components, tiers, and system perspectives<br />Can be an aid for unit and integration testing<br />
  12. 12.
  13. 13. Plumbing for better health<br />Instrumentation of key system resources<br />Business process controllers<br />Channels (queues)<br />Data Accessors<br />External interfaces<br />Notifications of<br />Threshold violations and near misses<br />Almost a violation but not quite!<br />Volumes<br />Throughput<br />
  14. 14. Where to look -<br />Tier interfaces<br />Delegates<br />Facades<br />System infrastructure –foundational classes e.g.<br />Exception handling – levels, counts<br />Logging – file sizes<br />Security – violation counts<br />System Interfaces<br />Gateways<br />Endpoints<br />
  15. 15.
  16. 16. What to look with<br />MBeans – helpful little buggers<br />Standard<br />Dynamic<br />Open<br />Model<br />Standard MBean<br />Quickest to implement<br />Most limited<br />Model MBean<br />Somewhat more complicated to work with<br />Offer the most flexibility<br />
  17. 17. So how does this relate to real systems?<br />
  18. 18. Where to look - revisited<br />Using the ‘real’ system on the previous slide, we’ll identify points of interest to instrument<br />Each of those cute little graphics represents a business component – a candidate for instrumentation…<br />What aspects of these subsystems do we care about once the app is in production?<br />Lets highlight and talk about some of them.<br />
  19. 19. Where to look - revisited (cont.)<br />E-commerce Website<br />Number of hits an hour<br />Average length of stay<br />Shopping cart<br />Number of active shopping cart instances in an hour<br />Average length of time taken to process an order<br />Check out<br />Average length of time to process credit purchases<br />Number credit purchases in a hour <br />Shipping <br />How many confirmed in an hour – reflects B2B integration point<br />
  20. 20. Why we’re looking<br />We want to understand the systems performance so we gather stats on -<br />Volumes of Units of Work (UOW) in subsystems<br />E.g. Hits on the website<br />The length of time that its takes to complete business processes<br />E.g. The time to complete a credit transaction<br />We want to know when we’re experiencing level of service issues so -<br />Send alerts when preset thresholds are <br />Exceeded - reactive<br />Reach a percentage of capacity - preventive<br />
  21. 21. How to look -<br />Gathering stats.<br />package com.ecommerce.systemhealth<br />public interface WebsiteMetricsMBean {<br /> public int getOrdersPerHour();<br />}<br />public class WebsiteMetrics implements WebsiteMetricsMBean {<br /> private int ordersPerHour;<br /> public void addToOrdersPerHour(int count){…}<br /> public int getOrdersPerHour() {…}<br />}<br />
  22. 22. How to look -<br />Sending alerts.<br />package com.ecommerce.systemhealth<br />public interface WebsiteAlertsMBean {<br /> public int areOrdersPerHourNearThreshold(int orders);<br />}<br />public class WebsiteAlerts extends NotificationBroadcasterSupport implements WebsiteAlertsMBean {<br /> public void areOrdersPerHourNearThreshold(int orders) {<br /> // check the new value against the threshold if exceeded<br /> sendNotification(notification);<br /> }<br />}<br />
  23. 23. Ways to watch – management tools<br />Part of the game<br />Sun’s JConsole<br />Open source<br />XMOJO<br />MX4J<br />Generous Licenses<br />MC4J<br />EJTools JMX Browser<br />Payware<br />Wil-Co Cockpit – provides graphical front components for JMX services in a designer view.<br />
  24. 24. Who to tell and how?<br />Staff in<br />Application support<br />Server support<br />Integration support – B2B partners<br />DBAs<br />Let them know via<br />Email <br />Pager<br />Monitoring control dashboards, e.g. Tivoli<br />
  25. 25. Some handy links<br /><br /><br /><br /><br />
  26. 26. Some books<br />JMX in Action -- by Benjamin G. Sullins <br />Java Management Extensions -- by J. Steven Perry <br />I have both of the above, the first seems to be the most comprehensive<br />Java and JMX: Building Manageable Systems -- by Heather Kreger<br />