Home > Articles > Programming > Java

Introduction to JMX

This chapter is from the book

2.5 JMX Overview

In its instrumentation and agent specification, the JMX architecture consists of four components (see Figure 2.4) that map to the management system components discussed earlier:

  1. Managed resources and management beans (MBeans) that expose the management interfaces that make up the instrumentation level.

  2. Agents, including MBeanServers and the monitoring, timing, relation, and class-loading services, that constitute the agent level.

  3. Adapters that translate between JMX capabilities and APIs, and between their respective management systems.

  4. Adapter tools that generate the files required by the management system through JMX APIs. Examples of these file types are Tivoli's AMS file,43 SNMP's MIB file,44 and CIM's MOF file.45

Figure 2.4Figure 2.4 JMX Architecture


Let's take a closer look at each of these elements.

2.5.1 JMX-Managed Resources

JMX-managed resources are instrumented with management beans (MBeans). You, the application developer, use MBeans to expose the management interface of the managed resource. The management interface of a resource consists of the attributes, operations, and notifications that are used to manage it.

2.5.2 MBeans

JMX specifies four types of MBeans: standard MBean, dynamic MBean, open MBean, and model MBean. Each MBean has metadata in MBeanInfo. MBeanInfo defines the attributes, operations, and notifications supported by the MBean.

2.5.2.1 Standard MBeans

A standard MBean can be any JavaBean or JavaBean-style program that has been registered with the MBeanServer. You, the application developer, define these MBeans and their management interfaces at development time. The only requirement is that your MBean class must implement a Java interface named classnameMBean that you must define for them. For example, an MBean class named CatalogManager would implement an interface called CatalogManagerMBean. This interface defines the management interface for the MBean. The interface might include all or just a subset of the methods in the actual MBean class.

When your MBean is registered with the MBeanServer, the MBeanServer will create an MBeanInfo metadata object for it by introspecting the classnameMBean interface. It will create attributes and operations in the MBean by looking for the JavaBean pattern. Each getAttributeName() method with a matching setAttributeName(attributeValue) method will create an attribute for the MBean. All other public methods will create operations for the MBean. The MBeanServer will use MBeanInfo to make sure only the attributes and operations you have exposed are invoked on your MBean.

Standard MBeans can be useful if your application already has management-oriented classes to support its own manager. You can simply register these instances with the MBeanServer after minor modifications to add "implements MBean." Chapter 3 explains standard MBeans thoroughly.

2.5.2.2 Dynamic MBeans

Dynamic MBeans allow your application or domain-specific manager to define or generate the management interface for your resource at runtime. This provides a simple way for you to wrap existing nonbean-style or even non-Java resources.

A dynamic MBean can be any Java class that implements the dynamic MBean interface. The dynamic MBean interface is similar to the CORBA Dynamic Invocation Interface (DII).46 The most important thing to remember about dynamic MBeans is that they must provide their own management interfaces during runtime by maintaining their own MBeanInfo objects. The MBeanServer requests MBeanInfo from your dynamic MBean whenever it needs that information. This means that a classnameMBean interface is not used by the MBeanServer to create an MBeanInfo object. Your dynamic MBean is also responsible for implementing and validating correct invocation of the interfaces it defines in MBeanInfo. The MBeanServer delegates invocations of getAttribute(), setAttribute(), and invoke() directly to your dynamic MBean. Your dynamic MBean satisfies the request and returns it to the MBeanServer.

You can develop dynamic MBean implementations for your applications directly, have them generated, or allow a management application developer to create them. You can also develop an MBean service that will instantiate or generate the dynamic MBeans.

The next two types of MBeans we will look at are standardized types of dynamic MBeans: open MBeans and model MBeans. However, the fact that JMX defines standard types of dynamic MBeans does not mean that you cannot write your own dynamic MBeans, nor does it in any way restrict how you implement them. See Chapter 3 for a more detailed discussion of diagnostic MBeans.

2.5.2.3 Open MBeans

Open MBeans are dynamic MBeans that are restricted to accepting and returning a limited number of data types. If you use open MBeans and these basic data types, you eliminate the need for class loading. Removing the need for class loading can make it easier for you to deploy the MBean and support a highly distributed system. However, it does not remove the need for your application or a management application to understand the semantics of the data to be passed or returned. The open Mbean data types that are allowed are

  • Primitive data types: int, boolean, float, double, and so on

  • Class wrappers for primitive data types: Integer, Boolean, Float, Double, String, and so on

  • Table: An array of rows of the same type

  • Composite: An object that can be decomposed into other open data types

Your open MBeans must return an OpenMBeanInfo object from the getMBeanInfo() method. OpenMBeanInfo extends MBeanInfo, adding some additional metadata that you may supply, such as legal values, and default values. The open MBean support is optional in JMX 1.0, and the classes are not available in the current Sun JMX 1.0 Reference Implementation. See Chapter 3 for an explanation of open MBeans.

2.5.2.4 Model MBeans

A model MBean is an extension of a dynamic MBean. However, where you must write all of a dynamic MBean, you don't have to implement the model MBean. A model MBean is more than a set of interfaces; it is a customizable, standardized, dynamic MBean implementation. An implementation class of a model MBean named RequiredModelMBean must come with the JMX agent. This model MBean instance is immediately useful because your application can instantiate and customize a RequiredModelMBean instance with its own management interface information. This reuse of an existing implementation drastically reduces the amount of code you need to write to achieve manageability, and it protects your resource from JVM version and JMX agent implementation variances. Using RequiredModelMBean instances can allow your managed resources to be installed in a range of JVMs, from embedded environments to enterprise environments, without affecting your instrumentation.

The MBeanServer functions as a factory and delegator for RequiredModelMBean instances. Because RequiredModelMBean instances are created and maintained by the JMX agent, the RequiredModelMBean class implementation can vary, depending on the needs of the environment and the JVM in which the JMX agent is installed. An application that requests the instantiation of a RequiredModelMBean object does not have to be aware of the implementation specifics of a RequiredModelMBean class. The RequiredModelMbean class is responsible for implementing and managing the implementation differences between JMX and JVM environments internally. These differences may include persistence, transactional behavior, caching, performance requirements, location transparency, and remotability.

Because the RequiredModelMBean model MBean implementation is provided by the JMX agent, your application does not have to implement RequiredModelMBean; it just needs to instantiate it, customize it, and use it. Your instrumentation code is consistent and minimal. Your application gains the benefit of support for and default policies concerning logging events, data persistence, data caching, and notification handling. Your application initializes its RequiredModelMBean's ModelMBeanInfo with its identity, management interface, and policy overrides.

You can add custom attributes to the model MBean during execution. Your application-specific information can be modified without interruption during runtime. The RequiredModelMBean instance then sets the behavior interface for the MBean and does any setup necessary for event logging and handling, data persistence and currency, and monitoring for your application's model MBean instance. The model MBean default behavior and simple APIs will satisfy the management needs of most applications, but they will also allow complex application management scenarios. More details on the model MBean are given in Chapter 4.

2.5.3 JMX Agents

Your managed resources will communicate data and events to management systems with their MBeans through the JMX agent. JMX agents consist of an MBeanServer and a set of service MBeans.

2.5.3.1 The MBeanServer

The MBeanServer runs in the JVM local to the managed resources' MBeans. The MBeanServer is a registry for MBeans. It is also a repository of the current set of MBean names and references, but it is not necessarily a repository for your MBeans. The MBeanServer provides a query service for the MBeans. Upon a query, it returns the names of the MBeans, not the references. Because only names are returned, all operations on all MBeans must go through the MBeanServer. The MBeanServer acts as a delegator to the MBeans, returning the results to the requester.

The MBeanServer can be a factory for any MBean, even those you create. You have the option of instantiating MBeans directly and then registering them, or having the MBeanServer return an instance of the MBean to your application. The MBeanServer should always be a factory for RequiredModelMBean instances. The MBeanServer also provides access to the metadata about the MBeans in the MBeanInfo instance. The metadata includes the attributes, operations, and notifications provided by the MBean. The MBeanServer provides notification registration and forwarding support to MBeans representing adapters, services, and resources. The MBeanServer is discussed thoroughly in Chapter 5.

2.5.3.2 Required Services

The JMX agent includes a set of required services: the monitoring service, the timer service, the relation service, and the MBean class loader. Services are MBeans registered with the MBeanServer that provide some generic functionality that can be used by MBeanServers, MBeans, and adapters. Additional management services can be added dynamically as service MBeans by applications or management systems, making the JMX agent flexible and extensible.

  • The monitoring service runs monitoring MBeans on a scheduled basis. It must support basic monitoring MBeans, including Gauge, Counter, StringMatch, and StateChange. Additional or specialized monitoring MBeans can also be developed and used.

  • The timer service executes an operation on a timed basis. It is used by the monitoring service.

  • The relation service supports relationship MBeans. Relationship MBeans contain the names of a set of MBeans that are related in some way. Some kinds of possible relationships include "contains" and "depends on."

  • The MLet (management applet) service is an MBean class-loading service that loads an MBean across a network when an MLET tag in an HTML page is encountered.

These services are covered in more detail in Chapter 7.

2.5.4 JMX Adapters

Adapters communicate between the JMX agent and their corresponding management systems. The adapter is responsible for translating from JMX MBean types to its manager's types and taking care of any remoteness issues. Because the adapter can be implemented to mimic the manager's supported agent technology, the management system may not even be aware that JMX is in the picture. Generally, there is at least one specific adapter for each management protocol or technology required to support different management systems.

Adapters are also MBeans, and they are registered with the MBeanServer. Given that this is the case, it is possible to find out all of the adapters that are currently registered with an MBeanServer. Because adapters are MBeans, they can register for JMX notifications from the MBeanServer or other MBeans. In this case the adapter would have to implement the NotificationListener interface, and it might provide a filter to limit the notifications it receives.

Because the MBeanServer returns only names of MBeans and not instances, adapters invoke methods on MBeans only through the MBeanServer. The type of MBean that represents the resource does not affect how the adapter invokes operations on the MBean. The type of MBean does affect how much data is available to the adapter in MBeanInfo. Adapters use the MBeanServer's interface directly. Adapters are responsible for "translating" JMX management information to their native representation of the management information, so JMX provides some hints on how to do that translation using ProtocolMap instances for attributes in model MBeans. Common, though nonstandard, adapters are RMI,47 HTTP,48 and SNMP.49 CIM and IIOP adapters are in the process of standardization. Adapters are discussed in depth in Chapter 5.

2.5.5 Adapter Tools

Adapter tools typically accompany a particular adapter for a particular management system. Adapter tools will interact with the MBeanServer to create any files to represent the available management data in the MBeans in a format that the management system can consume. For example, an SNMP adapter tool might create a MIB file from the available MBeanInfo instance. This MIB file would be used by an SNMP management system to represent the management data on its console.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020