SlideShare a Scribd company logo
1 of 24
Download to read offline
JMX 2.0
The forgotten source
Jaroslav Bachorik
Staff Software
Engineer
Datadog
> 2000
> JMX 1.0
> The first version, JMX 1.0
> It established the core concepts and >
architecture that include MBeans
(Managed Beans), the MBeanServer, and
various services for monitoring and
management
> 2004
> JMX 1.2
> This version brought enhancements to
ease the development of management and
monitoring solutions. It included
improvements in the MBean model and the
overall API
> 2004
> JMX in Java 5 SE
> JMX became part of the standard Java platform. This integration greatly increased its
adoption, as it became available in all standard Java distributions
> Minor improvements (generics) for Java 6 in 2006
> JMX APIs are at Java 6 level
> Naming convention based
> Minimal support for annotations
> Long term open issues and improvements
> Security concerns
> Performance
> Ease of use
> JMX Annotations
> JDK-8044507 (JEP)
> By yours truly
> Update the JMX APIs to allow using
annotations to register and use MBeans
> JEP created in 2014 then went dormant
> Builds on JSR 255
> more comprehensive JMX spec update
> created: 2004
> withdrawn: 2016
> never fully implemented
> JMX Rest Connector
> JDK-8171311 (JEP)
> Provide a lightweight REST connector
> default instead of aging RMI
> JEP created in 2016, closed 2018
> considered unnecessary due eg.
Jolokia
> JMX still works only via RMI OOTB
> Improved Key Management
> Non-public issue (sec related)
> Allow SSH-like experience
> no more fumbling with keystore and
certstore on client and server
> Not sure about its fate
> most probably cancelled as well
> JMX Annotations
> Simple service
> A simple service MXBean
> Custom description for service, attributes and operations
> Custom units for attributes and operations
> Notification support
> “Traditional” JMX
> Needs SimpleServiceMXBean interface
> Needs SimpleServiceMXBeanImpl implementation
> For custom descriptions
> Create custom MBeanInfo for the service
> Implement DynamicMBean with reflective operation/attribute access
> For notifications
> SimpleServiceMXBean extends NotificationEmitter
> SimpleServiceMXBeanImpl implements NotificationBroadcaster
> SimpleServiceMXBeanImpl delegates to NotificationBroadcasterSupport
> SimpleServiceMXBeanImpl provides MBeanNotificationInfos
> Lot of boilerplate!
> JMX Annotations
> Managed service
@ManagedService(
objectName="net.java.jmx:type=StandardService",
description="A simple service exposed as an MXBean",
service=Service.class,
tags = {
@Tag(name = "tag1", value = "val1"),
@Tag(name = "tag2", value = "val2")
}
)
public class SimpleService {
…
}
> JMX Annotations
> Managed service
@ManagedService(
objectName="net.java.jmx:type=StandardService",
description="A simple service exposed as an MXBean",
service=Service.class,
tags = {
@Tag(name = "tag1", value = "val1"),
@Tag(name = "tag2", value = "val2")
}
)
public class SimpleService {
…
}
Freeform service name
Included ObjectName
Included description
Custom service class
Freeform tags
> JMX Annotations
> Managed attributes
public class SimpleService {
// A write-only attribute measured in "ticks"
@ManagedAttribute(access = AttributeAccess.WRITE, units = "ticks")
int counter = 1;
// A read-only attribute being an array of strings
@ManagedAttribute(access = AttributeAccess.READ,
description = "ReadOnly Attribute")
String[] arr = new String[]{"sa", "ba", "ca"};
// Declare a read-write attribute ...
@ManagedAttribute(access = AttributeAccess.READWRITE,
tags = {
@Tag(name = "tag1", value = "val1"),
@Tag(name = "tag2", value = "val2")
}
)
private String label = "the label";
…
}
> JMX Annotations
> Managed attributes
public class SimpleService {
// A write-only attribute measured in "ticks"
@ManagedAttribute(access = AttributeAccess.WRITE, units = "ticks")
int counter = 1;
// A read-only attribute being an array of strings
@ManagedAttribute(access = AttributeAccess.READ,
description = "ReadOnly Attribute")
String[] arr = new String[]{"sa", "ba", "ca"};
// Declare a read-write attribute ...
@ManagedAttribute(access = AttributeAccess.READWRITE,
tags = {
@Tag(name = "tag1", value = "val1"),
@Tag(name = "tag2", value = "val2")
}
)
private String label = "the label";
…
}
Attribute access
Support for units
Included description
Freeform tags
Custom getters/setters
> JMX Annotations
> Managed operations
public class SimpleService {
// an operation modifying the 'counter' attribute
@ManagedOperation(impact = Impact.ACTION,
description = "Increases the associated counter by 1")
public int count() {
return ++counter;
}
// an operation declaring custom 'units' metadata for one of its parameters
@ManagedOperation
public void checkTime(@Parameter(units = "ms") long ts) {
System.err.println(new Date(ts));
}
…
}
> JMX Annotations
> Managed operations
public class SimpleService {
// an operation modifying the 'counter' attribute
@ManagedOperation(impact = Impact.ACTION,
description = "Increases the associated counter by 1")
public int count() {
return ++counter;
}
// an operation declaring custom 'units' metadata for one of its parameters
@ManagedOperation
public void checkTime(@ParameterInfo(units = "ms") long ts) {
System.err.println(new Date(ts));
}
…
}
Service impact
Included description
Metadata for parameters
Custom units
Freeform tags
> JMX Annotations
> Notifications
public class SimpleService {
@NotificationInfos({
@NotificationInfo(types = "test.mbean.label", description = "Label was set")
@NotificationInfo(types = "test.mbean.threshold", description = "Counter threshold reached")
})
private NotificationSender ns;
@ManagedAttribute
public void setLabel(String l) {
ns.sendNotification("test.mbean.label", "Label set", l);
label = l;
}
@ManagedOperation(impact = Impact.ACTION, description = "Increases the associated counter by 1")
public int count() {
if (counter >= 5) {
ns.sendNotification("test.mbean.threshold", "Threshold reached", counter);
}
return ++counter;
}
…
}
> JMX Annotations
> Notifications
public class SimpleService {
@NotificationInfos({
@NotificationInfo(types = "test.mbean.label", description = "Label was set")
@NotificationInfo(types = "test.mbean.threshold", description = "Counter threshold reached")
})
private NotificationSender ns;
@ManagedAttribute
public void setLabel(String l) {
ns.sendNotification("test.mbean.label", "Label set", l);
label = l;
}
@ManagedOperation(impact = Impact.ACTION, description = "Increases the associated counter by 1")
public int count() {
if (counter >= 5) {
ns.sendNotification("test.mbean.threshold", "Threshold reached", counter);
}
return ++counter;
}
…
}
Injected notification sender
Notification info types
Simple emitter
> JMX Annotations
> Custom registration handler
public class SimpleService {
// handle the registration/unregsitration of the MBean
@RegistrationHandler
public void onRegistration(RegistrationEvent re) {
switch(re.getKind()) {
case REGISTER: {
System.err.println("Registered " + re.getObjectName().getCanonicalName());
break;
}
case UNREGISTER: {
System.err.println("Unregistered " + re.getObjectName().getCanonicalName());
break;
}
}
}
…
}
> JMX Annotations
> Custom registration handler
public class SimpleService {
// handle the registration/unregsitration of the MBean
@RegistrationHandler
public void onRegistration(RegistrationEvent re) {
switch(re.getKind()) {
case REGISTER: {
System.err.println("Registered " + re.getObjectName().getCanonicalName());
break;
}
case UNREGISTER: {
System.err.println("Unregistered " + re.getObjectName().getCanonicalName());
break;
}
}
}
…
}
Simple registration listener
‘When-registered’ hook
‘When-unregistered’ hook
> JMX Annotations
> Where to get it?
GitHub!
> https://github.com/DataDog/openjdk-jdk/tree/jb/jmx_annotations
> https://github.com/DataDog/openjdk-jdk/pull/4
> JMX REST Connector
> Simple, self-contained implementation
> Base URL - http[s]://<host_name>:<port>/jmx/default
> auto-discovery capable - JDP, perf-counter, JCMD
> Endpoints
> <root>/mbeans
GET : list of all registered MBeans
> <root>/<mbean_name>
GET : get corresponding MBeanInfo
> <root>/<mbean_name>/<attribute_name>
GET : get the attribute value
> <root>/<mbean_name>/?attributes=a,b,c|all
GET : get values of multiple MBean attributes
> <root>/domains
GET : get all available domains
> <root>/?domain=default
GET : get default domain
> <root>/?domain=<domain_name>/mbeans
GET : list of all MBeans in the domain
> JMX REST Connector
> Advanced Query
> Use HTTP POST
> Query JSON
[
{
"name": "<mbean_name_1>",
"read"|"write"|"exec": "<param_name/exec_name>",
"arguments" : {
…
}
},{
"name": "<mbean_name_2>",
"read"|"write"|"exec": "<param_name/exec_name>",
"arguments" : {
…
}
},
]
> JMX REST Connector
> Advanced Query
> Use HTTP POST
> Query JSON
[
{
"name": "<mbean_name_1>",
"read"|"write"|"exec": "<param_name/exec_name>",
"arguments" : {
…
}
},{
"name": "<mbean_name_2>",
"read"|"write"|"exec": "<param_name/exec_name>",
"arguments" : {
…
}
},
]
Multiple queries per request
Query specification
Optional arguments
> JMX REST Connector
> Query Response
> Wrapped in
// success
{
"status": 200,
"request": {
original HTTP request
},
"response": {
result of above request
}
}
// error
{
"status": 4XX/5XX,
"request": {
original HTTP request
},
"error": "<error message>"
}
> JMX REST Connector
> Query Response Body
> Java->JSON auto-serialization for
- MXBeans
- OpenMBeans
- String, primitive values and arrays of them
- BigInteger, BigDecimal
- Date, ObjectName, CompositeData, TabularData
> JMX REST Connector
> Mostly working but abandoned
> Harsha Wardhana’s CR space
> https://cr.openjdk.org/~hb/8171311/webrev.01/
> might be up for adoption(?)
> Summary
> JMX feels outdated
> Labour intensive APIs
> Coupled with RMI
> Needs persistent connection and pull loop from client
> There are proposals to improve it
> Evolution rather than revolution
> Some parts almost fully functional
> Million Dollar Question
> Has JMX any future?
> Who is willing to invest?
It’s a wrap-up!
Thanks, Qs are welcome!
Jaroslav Bachorik
X:
@Bachorik
J
GH: jbachorik All images generated by Dall-E

More Related Content

Similar to JMX 2.0 - the Forgotten Source.pptx

Memcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMemcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My Sql
MySQLConference
 

Similar to JMX 2.0 - the Forgotten Source.pptx (20)

What You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSFWhat You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSF
 
Google Cloud Platform monitoring with Zabbix
Google Cloud Platform monitoring with ZabbixGoogle Cloud Platform monitoring with Zabbix
Google Cloud Platform monitoring with Zabbix
 
Library Project
Library ProjectLibrary Project
Library Project
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
Beyond simple benchmarks—a practical guide to optimizing code
Beyond simple benchmarks—a practical guide to optimizing code Beyond simple benchmarks—a practical guide to optimizing code
Beyond simple benchmarks—a practical guide to optimizing code
 
J boss
J bossJ boss
J boss
 
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
 
DrupalCafe4 Kiev Services
DrupalCafe4 Kiev ServicesDrupalCafe4 Kiev Services
DrupalCafe4 Kiev Services
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Memcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMemcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My Sql
 
Reactive Data System
Reactive Data SystemReactive Data System
Reactive Data System
 
Mysql
MysqlMysql
Mysql
 
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
 
Programming IoT Gateways in JavaScript with macchina.io
Programming IoT Gateways in JavaScript with macchina.ioProgramming IoT Gateways in JavaScript with macchina.io
Programming IoT Gateways in JavaScript with macchina.io
 
struts
strutsstruts
struts
 
Rich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFXRich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFX
 
Migration to Extent Report 4
Migration to Extent Report 4Migration to Extent Report 4
Migration to Extent Report 4
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
What’s New in MariaDB Server 10.2
What’s New in MariaDB Server 10.2What’s New in MariaDB Server 10.2
What’s New in MariaDB Server 10.2
 
MariaDB training
MariaDB trainingMariaDB training
MariaDB training
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

JMX 2.0 - the Forgotten Source.pptx

  • 1. JMX 2.0 The forgotten source Jaroslav Bachorik Staff Software Engineer Datadog
  • 2. > 2000 > JMX 1.0 > The first version, JMX 1.0 > It established the core concepts and > architecture that include MBeans (Managed Beans), the MBeanServer, and various services for monitoring and management > 2004 > JMX 1.2 > This version brought enhancements to ease the development of management and monitoring solutions. It included improvements in the MBean model and the overall API > 2004 > JMX in Java 5 SE > JMX became part of the standard Java platform. This integration greatly increased its adoption, as it became available in all standard Java distributions > Minor improvements (generics) for Java 6 in 2006
  • 3. > JMX APIs are at Java 6 level > Naming convention based > Minimal support for annotations > Long term open issues and improvements > Security concerns > Performance > Ease of use
  • 4. > JMX Annotations > JDK-8044507 (JEP) > By yours truly > Update the JMX APIs to allow using annotations to register and use MBeans > JEP created in 2014 then went dormant > Builds on JSR 255 > more comprehensive JMX spec update > created: 2004 > withdrawn: 2016 > never fully implemented > JMX Rest Connector > JDK-8171311 (JEP) > Provide a lightweight REST connector > default instead of aging RMI > JEP created in 2016, closed 2018 > considered unnecessary due eg. Jolokia > JMX still works only via RMI OOTB > Improved Key Management > Non-public issue (sec related) > Allow SSH-like experience > no more fumbling with keystore and certstore on client and server > Not sure about its fate > most probably cancelled as well
  • 5. > JMX Annotations > Simple service > A simple service MXBean > Custom description for service, attributes and operations > Custom units for attributes and operations > Notification support > “Traditional” JMX > Needs SimpleServiceMXBean interface > Needs SimpleServiceMXBeanImpl implementation > For custom descriptions > Create custom MBeanInfo for the service > Implement DynamicMBean with reflective operation/attribute access > For notifications > SimpleServiceMXBean extends NotificationEmitter > SimpleServiceMXBeanImpl implements NotificationBroadcaster > SimpleServiceMXBeanImpl delegates to NotificationBroadcasterSupport > SimpleServiceMXBeanImpl provides MBeanNotificationInfos > Lot of boilerplate!
  • 6. > JMX Annotations > Managed service @ManagedService( objectName="net.java.jmx:type=StandardService", description="A simple service exposed as an MXBean", service=Service.class, tags = { @Tag(name = "tag1", value = "val1"), @Tag(name = "tag2", value = "val2") } ) public class SimpleService { … }
  • 7. > JMX Annotations > Managed service @ManagedService( objectName="net.java.jmx:type=StandardService", description="A simple service exposed as an MXBean", service=Service.class, tags = { @Tag(name = "tag1", value = "val1"), @Tag(name = "tag2", value = "val2") } ) public class SimpleService { … } Freeform service name Included ObjectName Included description Custom service class Freeform tags
  • 8. > JMX Annotations > Managed attributes public class SimpleService { // A write-only attribute measured in "ticks" @ManagedAttribute(access = AttributeAccess.WRITE, units = "ticks") int counter = 1; // A read-only attribute being an array of strings @ManagedAttribute(access = AttributeAccess.READ, description = "ReadOnly Attribute") String[] arr = new String[]{"sa", "ba", "ca"}; // Declare a read-write attribute ... @ManagedAttribute(access = AttributeAccess.READWRITE, tags = { @Tag(name = "tag1", value = "val1"), @Tag(name = "tag2", value = "val2") } ) private String label = "the label"; … }
  • 9. > JMX Annotations > Managed attributes public class SimpleService { // A write-only attribute measured in "ticks" @ManagedAttribute(access = AttributeAccess.WRITE, units = "ticks") int counter = 1; // A read-only attribute being an array of strings @ManagedAttribute(access = AttributeAccess.READ, description = "ReadOnly Attribute") String[] arr = new String[]{"sa", "ba", "ca"}; // Declare a read-write attribute ... @ManagedAttribute(access = AttributeAccess.READWRITE, tags = { @Tag(name = "tag1", value = "val1"), @Tag(name = "tag2", value = "val2") } ) private String label = "the label"; … } Attribute access Support for units Included description Freeform tags Custom getters/setters
  • 10. > JMX Annotations > Managed operations public class SimpleService { // an operation modifying the 'counter' attribute @ManagedOperation(impact = Impact.ACTION, description = "Increases the associated counter by 1") public int count() { return ++counter; } // an operation declaring custom 'units' metadata for one of its parameters @ManagedOperation public void checkTime(@Parameter(units = "ms") long ts) { System.err.println(new Date(ts)); } … }
  • 11. > JMX Annotations > Managed operations public class SimpleService { // an operation modifying the 'counter' attribute @ManagedOperation(impact = Impact.ACTION, description = "Increases the associated counter by 1") public int count() { return ++counter; } // an operation declaring custom 'units' metadata for one of its parameters @ManagedOperation public void checkTime(@ParameterInfo(units = "ms") long ts) { System.err.println(new Date(ts)); } … } Service impact Included description Metadata for parameters Custom units Freeform tags
  • 12. > JMX Annotations > Notifications public class SimpleService { @NotificationInfos({ @NotificationInfo(types = "test.mbean.label", description = "Label was set") @NotificationInfo(types = "test.mbean.threshold", description = "Counter threshold reached") }) private NotificationSender ns; @ManagedAttribute public void setLabel(String l) { ns.sendNotification("test.mbean.label", "Label set", l); label = l; } @ManagedOperation(impact = Impact.ACTION, description = "Increases the associated counter by 1") public int count() { if (counter >= 5) { ns.sendNotification("test.mbean.threshold", "Threshold reached", counter); } return ++counter; } … }
  • 13. > JMX Annotations > Notifications public class SimpleService { @NotificationInfos({ @NotificationInfo(types = "test.mbean.label", description = "Label was set") @NotificationInfo(types = "test.mbean.threshold", description = "Counter threshold reached") }) private NotificationSender ns; @ManagedAttribute public void setLabel(String l) { ns.sendNotification("test.mbean.label", "Label set", l); label = l; } @ManagedOperation(impact = Impact.ACTION, description = "Increases the associated counter by 1") public int count() { if (counter >= 5) { ns.sendNotification("test.mbean.threshold", "Threshold reached", counter); } return ++counter; } … } Injected notification sender Notification info types Simple emitter
  • 14. > JMX Annotations > Custom registration handler public class SimpleService { // handle the registration/unregsitration of the MBean @RegistrationHandler public void onRegistration(RegistrationEvent re) { switch(re.getKind()) { case REGISTER: { System.err.println("Registered " + re.getObjectName().getCanonicalName()); break; } case UNREGISTER: { System.err.println("Unregistered " + re.getObjectName().getCanonicalName()); break; } } } … }
  • 15. > JMX Annotations > Custom registration handler public class SimpleService { // handle the registration/unregsitration of the MBean @RegistrationHandler public void onRegistration(RegistrationEvent re) { switch(re.getKind()) { case REGISTER: { System.err.println("Registered " + re.getObjectName().getCanonicalName()); break; } case UNREGISTER: { System.err.println("Unregistered " + re.getObjectName().getCanonicalName()); break; } } } … } Simple registration listener ‘When-registered’ hook ‘When-unregistered’ hook
  • 16. > JMX Annotations > Where to get it? GitHub! > https://github.com/DataDog/openjdk-jdk/tree/jb/jmx_annotations > https://github.com/DataDog/openjdk-jdk/pull/4
  • 17. > JMX REST Connector > Simple, self-contained implementation > Base URL - http[s]://<host_name>:<port>/jmx/default > auto-discovery capable - JDP, perf-counter, JCMD > Endpoints > <root>/mbeans GET : list of all registered MBeans > <root>/<mbean_name> GET : get corresponding MBeanInfo > <root>/<mbean_name>/<attribute_name> GET : get the attribute value > <root>/<mbean_name>/?attributes=a,b,c|all GET : get values of multiple MBean attributes > <root>/domains GET : get all available domains > <root>/?domain=default GET : get default domain > <root>/?domain=<domain_name>/mbeans GET : list of all MBeans in the domain
  • 18. > JMX REST Connector > Advanced Query > Use HTTP POST > Query JSON [ { "name": "<mbean_name_1>", "read"|"write"|"exec": "<param_name/exec_name>", "arguments" : { … } },{ "name": "<mbean_name_2>", "read"|"write"|"exec": "<param_name/exec_name>", "arguments" : { … } }, ]
  • 19. > JMX REST Connector > Advanced Query > Use HTTP POST > Query JSON [ { "name": "<mbean_name_1>", "read"|"write"|"exec": "<param_name/exec_name>", "arguments" : { … } },{ "name": "<mbean_name_2>", "read"|"write"|"exec": "<param_name/exec_name>", "arguments" : { … } }, ] Multiple queries per request Query specification Optional arguments
  • 20. > JMX REST Connector > Query Response > Wrapped in // success { "status": 200, "request": { original HTTP request }, "response": { result of above request } } // error { "status": 4XX/5XX, "request": { original HTTP request }, "error": "<error message>" }
  • 21. > JMX REST Connector > Query Response Body > Java->JSON auto-serialization for - MXBeans - OpenMBeans - String, primitive values and arrays of them - BigInteger, BigDecimal - Date, ObjectName, CompositeData, TabularData
  • 22. > JMX REST Connector > Mostly working but abandoned > Harsha Wardhana’s CR space > https://cr.openjdk.org/~hb/8171311/webrev.01/ > might be up for adoption(?)
  • 23. > Summary > JMX feels outdated > Labour intensive APIs > Coupled with RMI > Needs persistent connection and pull loop from client > There are proposals to improve it > Evolution rather than revolution > Some parts almost fully functional > Million Dollar Question > Has JMX any future? > Who is willing to invest?
  • 24. It’s a wrap-up! Thanks, Qs are welcome! Jaroslav Bachorik X: @Bachorik J GH: jbachorik All images generated by Dall-E