JMX: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 80: Line 80:
</pre>
</pre>


The address is provided to a [https://docs.oracle.com/javase/8/docs/api/javax/management/remote/JMXConnectorFactory.html JMXConnectorFactory] instance, which creates the connection:
<pre>
JMXConnectorFactory.connect(address);
</pre>


<font color=red>
<font color=red>

Revision as of 02:43, 17 June 2017

External

Internal

Overview

Subjects

Specifications

Concepts

MXBean

An MXBean is a kind of MBean. For more details see

http://docs.oracle.com/javase/7/docs/api/javax/management/MXBean.html#mxbean-def

Open Type

http://docs.oracle.com/javase/7/docs/api/javax/management/openmbean/OpenType.html

The Platform MBean Server

The platform MBean server is an MBean server that is built into the JVM. It can be accessed and shared by all managed components that are running in that JVM. It can be retrieved with java.lang.management.ManagementFactory.getPlatformMBeanServer(). The platform MBean server was introduced in Java 5. javax.management.MBeanServerFactory can be used to create a different MBean server, or look up an already existing MBean server (that is not the platform server).

For a code example of how to look up the platform MBean server and how to register an arbitrary MBean to it, see

https://github.com/NovaOrdis/playground/blob/master/http/http-server/src/main/java/io/novaordis/playground/http/server/Main.java

Platform MXBeans

A platform managed object is an JMX MXBean deployed on a JVM's platform MBean server. Platform MXBeans expose monitoring and management capabilities for components of the Java platform. Platform MXBeans only use a set of basic data types, so a JMX management application and the platform MBeanServer can interoperate without requiring classes for MXBean specific data types. The data types being transmitted between the management client and the JMX server are open types and this allows interoperation across versions.

Common platform MXBeans:

Thread Monitoring and Management

ThreadMXBean Platform MBean

Memory Monitoring and Management

Memory Monitoring and Management Platform MBeans

O/S Level Runtime Metrics

OperatingSystemMXBean Platform MBean

Classloading Metrics

ClassLoadingMXBean Platform MBean

Other Monitoring and Management Components

Remote Access to a JMX Server

The JMX specification includes built-in support for accessing JMX servers remotely. Remote access details are described in the Section III of the specifications "JMX Remote API Specification".

An application that wishes to access a remote JMX server must create a session. The session allows for multiple, successive connections. The underlying mechanism that insures the client/server communication over the network is called a connector. A connector consists of a connector client and a connector server. The connector server is attached to the MBean server and listens for connection requests from clients. The connector client exposes essentially the same interface as the MBean server serviced by the connector. The connector client usually lives in a different JVM from the connector server, on a remote host. The connector client is connected to exactly one server. The connector client is represented by an object that implements JMXConnector.

The standard implementation required by the specification involves RMI (Remote Method Invocation). For an implementation to be spec-compliant, must expose an RMI-based remoting implementation. Optional protocols can be supported.

The JMX session does not have state on the server, each request is independent from the previous one.

The client obtains an object that implements MBeanServerConnection interface. The interface is similar to MBeanServer, which would be used if the client code was collocated with the MBean server in the same JVM. MBeanServerConnection is the parent of MBeanServer, which contains the same methods, with the exception of a small number of methods that only make sense for local access. This similarity allows to write client code that works identically when accessing a local server and a remote server. If the server operation throws an exception, the connector arranges for the client's invocation to get the same exception.

The connector server has an address used by the clients to establish connections to the server. The address is described by the JMXServiceURL class. Example:

service:jmx:jmxmp://example.com:9876

The address is provided to a JMXConnectorFactory instance, which creates the connection:

JMXConnectorFactory.connect(address);

  • Describe the specification basis.
  • Describe practical ways.
  • Mention novaordis-jmx.