This is my summary after reading JMX In Action. This article is the first In this series. It mainly introduces what JMX is and why JMX is used? And briefly describe the JMX architecture.
What is JMX?
First, let's take a look at Wikipedia's definition: JMX (Java Management Extensions, namely, Java Management extension) is a framework for Embedded Management functions such as applications, devices, and systems on the Java platform.
JMX supports flexible development of seamlessly integrated system, network, and service management applications across a series of heterogeneous operating system platforms, system architecture, and network transmission protocols.
As enterprise IT grows, the number of IT resources increases, and the distribution of IT resources becomes increasingly scattered. IT resources mainly include networks and applications. The main tool for managing network (hardware) is
Simple Network Management Protocol (SNMP), hardware vendors generally provide SNMP hooks in devices, but SNMP development is not easy and requires a specific language, it is not easy for JAVA developers.
Some enterprises do not consider runtime configuration and management issues when developing applications. Some enterprises directly develop management tools and interfaces in products. Some enterprises also directly use the application server or web server management tools.
Real-world IT resource management needs mainly include the following:
1. monitor the health of the platform and hardware. Hardware can use SNMP, and WEB servers and application servers can use their own management tools. The same is true for databases.
2. Configure resources at the application layer. For example, you can configure the number of applications displayed per page in the query results, the database connection pool, or the number of external requests.
3. Collect application statistics. Such as how many successful orders and how many failed orders.
4. Log Level: Change the log level. When a problem occurs, you can print debugging information by changing the log level to quickly locate the problem.
5. monitor the performance and load of the server, and notify critical events by email or sms. For example, the server load exceeds the preset threshold.
It is often very expensive and difficult to meet these requirements. administrators usually need to manage different services and hardware through different tools. If JMX is used, creating a management system that meets the above requirements will be cheaper, more flexible, and shorter.
Benefits of using JMX
1. Easy to use. It is especially difficult for a JAVA programmer to understand SNMP. And JMX is very easy for him.
2. Use existing technologies: existing management tools can be inserted into JMX. JMX provides many protocols (SNMP, HTTP) and transmission methods (such as RMI ), if the original applications and devices do not provide management capabilities, you can create a JMX agent to provide management capabilities.
3. modular. Create your management environment in a modular manner.
4. Warnings, events, and statistics.
JMX provides a notification system that makes full use of the object-oriented advantages. notifications provide a distributed JAVA object that encapsulates data and behavior. For example, if you send a server load notification, it also contains a mechanism that shows the importance of the load. To put it bluntly, there is a method in the object to determine the severity of the load.
5. Fast monitoring solution. Different developers only need to develop mbeans by themselves, instead of spending a lot of time on mutual collaboration. These mbeans are distributed on different hosts, however, you can use a management tool to manage all these applications.
Terms of JMX
1. Manageable resource)
It can be any application, device, or other entity that can be accessed and packaged by java. Resources managed by JMX MBean.
2. MBean (Managed Bean)
It is a java class that meets certain naming rules and inherits the JMX specifications and provides interfaces for managing and accessing resources. Expose interfaces through attributes and behaviors. There are three types: Standard, Dynamic, and Model MBeans.
3. MBean Server
Manage the JAVA classes of a group of mbeans. Is the core of the JMX management environment. Is the MBean registrar.
4. JMX Agent
JMX proxy is a java Process that provides a series of services for managing a group of mbeans. Is a container of MBean Server. It also provides some useful services: Creating MBean relationships, dynamic loading classes, simple monitoring services, and timer services. The Agent has a set of protocol adapters and connectors that allow external programs to connect to them.
5. Protocol adapters and connectors
Protocol adapters and connectors are objects in the JMX Agent. Expose the Agent to hypervisor and protocol. An Agent can have many adapters and connectors.
6. Management application
The user application that connects to the JMX Agent.
7. Notification
Notifications are java objects sent by Mbean or Mbean server. They encapsulate events, warnings, or other general information. Other mbeans or java objects can be registered as listeners to receive notifications.
8. Instrumentation (device-based)
Expose a resource management process with MBean.
JMX Architecture
The JMX architecture consists of three layers: Distributed layer, Agent layer, and Instrumentation layer, as shown in:
1,Distributed layer (Distributed layer)
The outermost layer of the JMX architecture is used to make the JMX Agent available to external programs. There are two types: one is to provide MBean visibility through different protocols (such as SNMP and HTTP.The other is to expose the Agent API to other distributed technologies such as RMI.
2. The agent layer)
MBean Server is the main component of MBean Server. It also includes four proxy services to make MBean management easier. They are: timer (timer), Monitoring Service, dynamic MBean loading, and MBean relationship service. The Agent and managed resources can be on the same host or remotely.
3. The instrumentation layer
This is the layer closest to the resource. It contains the MBean registered in the Agent.
4. Communications
In addition to the three layers in the architecture, JMX provides a notification mechanism similar to the JAVA event model. The notification mechanism is the final required component of the management system. The Agent and MBean can use the notification mechanism to send warnings or messages to the management application.
The above is the main content of the JMX architecture. The next article builds a HelloWorld JMX program.