Abnormal event processing system and method, storage medium and electronic equipment

By introducing Java agents into Java virtual machines, global perception and intelligent processing of Java exception events are realized, and the problem of lack of global exception perception and processing mechanism in the Java ecosystem is solved, and the reliability and stability of the system are improved.

CN119862058APending Publication Date: 2025-04-22BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411871425.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-22

AI Technical Summary

Technical Problem

The lack of global exception perception and processing mechanisms in the Java ecosystem leads to dispersed exception processing, which increases workload and reduces the maintenance of code. Especially when dealing with third-party dependencies, exceptions cannot be effectively caught and recorded, affecting the efficiency of troubleshooting.

Method used

By introducing Java agents into Java virtual machines, global awareness and intelligent processing of exception events are realized. The Java agent enables the ability of the Java virtual machine to generate exception events, catches exception events and calls callback functions, and passes exception events to the Java agent. The Java agent judges the severity of abnormal events based on filtering rules and sends key abnormal events to the monitoring platform and/or alarm platform.

Benefits of technology

It realizes global perception and intelligent processing of Java exception events, improves the reliability and stability of the system, enhances the real-time response capabilities to exception events, and solves the lack of Java global exception perception and processing strategies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119862058A_ABST
    Figure CN119862058A_ABST
Patent Text Reader

Abstract

The invention relates to an abnormal event processing system and method, a storage medium and electronic equipment. The system comprises a Java virtual machine and a Java agent, the Java agent is used for starting the ability of the Java virtual machine to generate an abnormal event, and the Java virtual machine is used for generating a corresponding abnormal event when a Java application generates an exception and captures the exception, calling a callback function of the Java agent and transmitting the abnormal event to the Java agent; and the Java agent is used for determining whether the abnormal event is a key abnormal event or not according to the filtering rule when the callback function is called, and sending the abnormal event to the monitoring platform and / or the alarm platform under the condition that the abnormal event is determined to be the key abnormal event. According to the method and the device, the technical problem that the Java exception event cannot be comprehensively monitored due to the lack of a Java global exception sensing and processing strategy at present is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a system, method, storage medium and electronic device for processing abnormal events. Background Art

[0002] In Java development, an exception event refers to an abnormal situation that occurs during the execution of a program, usually an error or an unexpected event. Exception events are key in troubleshooting, and developers often locate problems by viewing the exception information in the log. However, the current Java ecosystem lacks a global exception perception and handling mechanism, resulting in exception handling being scattered across various modules, mainly relying on developers to manually add logs or capture exceptions in the code. This approach not only increases the workload, but also leads to poor code maintainability, especially when dealing with third-party dependencies, which cannot effectively capture and record exceptions, thus affecting the efficiency of troubleshooting. Summary of the invention

[0003] The present application provides a system, method, storage medium and electronic device for processing abnormal events to solve the technical problem that there is currently a lack of a Java global abnormality perception and processing strategy, which leads to the inability to comprehensively monitor Java abnormal events.

[0004] In a first aspect, the present application provides a system for processing abnormal events, including a Java virtual machine and a Java agent: the Java agent is used to enable the ability of the Java virtual machine to generate abnormal events; the Java virtual machine is used to generate corresponding abnormal events when a Java application generates an exception and captures an exception, and call a callback function of the Java agent, and pass the abnormal event to the Java agent; the Java agent is used to determine whether the abnormal event is a critical abnormal event according to a filtering rule when the callback function is called, and if it is determined that the abnormal event is a critical abnormal event, send the abnormal event to a monitoring platform and / or an alarm platform.

[0005] As an optional example, the above-mentioned Java agent includes an exception perception enabling module: the above-mentioned exception perception enabling module is used to enable the ability of the above-mentioned Java virtual machine to generate exception events after the above-mentioned Java application is started, so that the above-mentioned Java virtual machine generates corresponding exception events when the above-mentioned Java application generates exceptions and captures exceptions, and calls the callback function of the above-mentioned Java agent, and at the same time passes the above-mentioned exception events to the above-mentioned Java agent, wherein the startup command of the above-mentioned Java application contains the absolute address of the library file of the above-mentioned exception perception enabling module, and when the above-mentioned Java application is started, the library file of the above-mentioned exception perception enabling module starts to be loaded.

[0006] As an optional example, the above-mentioned Java agent also includes an exception handling interface module and an exception handling module: the above-mentioned exception handling interface module is used to pass the above-mentioned exception event transmitted from the above-mentioned Java virtual machine to the above-mentioned exception handling module when the above-mentioned callback function is called; the above-mentioned exception handling module is used to determine whether the above-mentioned exception event is a critical exception event according to the above-mentioned filtering rules when receiving the above-mentioned exception event, and if the above-mentioned exception event is determined to be a critical exception event, send the above-mentioned exception event to the above-mentioned monitoring platform and / or the above-mentioned alarm platform.

[0007] As an optional example, the above-mentioned exception handling interface module includes an exception perception class: the callback method of the above-mentioned exception perception class is used to pass the above-mentioned exception event to the exception perception interface when being called, and at the same time call the implementation method of the above-mentioned exception perception interface, wherein the callback method of the above-mentioned exception perception class is the above-mentioned callback function, and before the above-mentioned Java virtual machine is started, the JAR package of the above-mentioned exception handling interface module is placed in the path of the boot class loader of the above-mentioned Java virtual machine, so that the exception perception class in the JAR package of the above-mentioned exception handling interface module is correctly loaded when the above-mentioned Java virtual machine is started; the implementation method of the above-mentioned exception perception interface is used to pass the above-mentioned exception event to the exception handling class of the above-mentioned exception handling module when being called, and at the same time call the processing method of the above-mentioned exception handling class, so that the processing method of the above-mentioned exception handling class processes the above-mentioned exception event.

[0008] As an optional example, the above-mentioned exception handling module includes the above-mentioned exception handling class: the processing method of the above-mentioned exception handling class is used to determine whether the above-mentioned exception event is a critical exception event according to the above-mentioned filtering rules when being called, and when the above-mentioned exception event is determined to be a critical exception event, the above-mentioned exception event is sent to the above-mentioned monitoring platform and / or the above-mentioned alarm platform; when the above-mentioned exception event is determined to be a non-critical exception event, the above-mentioned exception event is ignored, wherein, before the above-mentioned Java virtual machine is started, the JAR package of the above-mentioned exception handling module is placed in the path of the custom class loader of the above-mentioned Java virtual machine, so that the exception perception class in the JAR package of the above-mentioned exception handling module is correctly loaded when the above-mentioned Java virtual machine is started, so that the above-mentioned exception perception class is isolated from the above-mentioned Java application.

[0009] As an optional example, the processing method of the above-mentioned exception handling class is also used to determine the number of occurrences of the above-mentioned abnormal event before determining whether the above-mentioned abnormal event is a critical abnormal event according to the above-mentioned filtering rules, and ignore the above-mentioned abnormal event if it is determined that the above-mentioned number of occurrences is greater than the target threshold.

[0010] In a second aspect, the present application provides a method for handling abnormal events, which is applied to a system for handling abnormal events, including: enabling the ability of a Java virtual machine to generate abnormal events through a Java agent, so that the above-mentioned Java virtual machine generates corresponding abnormal events when an exception is generated and captured in a Java application; when the above-mentioned Java virtual machine generates the above-mentioned abnormal event, calling the callback function of the above-mentioned Java agent, and passing the above-mentioned abnormal event to the above-mentioned Java agent, so that the above-mentioned Java agent determines whether the above-mentioned abnormal event is a critical abnormal event according to a filtering rule, and when the above-mentioned abnormal event is determined to be a critical abnormal event, sending the above-mentioned abnormal event to a monitoring platform and / or an alarm platform.

[0011] In a third aspect, the present application provides a device for processing abnormal events, which is applied to a system for processing abnormal events, including: a first processing module, which is used to enable the Java virtual machine's ability to generate abnormal events through a Java agent, so that the above-mentioned Java virtual machine generates corresponding abnormal events when an exception is generated and captured in a Java application; a second processing module, which is used to call a callback function of the Java agent when the above-mentioned Java virtual machine generates the above-mentioned abnormal event, and at the same time pass the above-mentioned abnormal event to the above-mentioned Java agent, so that the above-mentioned Java agent determines whether the above-mentioned abnormal event is a critical abnormal event according to a filtering rule, and when the above-mentioned abnormal event is determined to be a critical abnormal event, sends the above-mentioned abnormal event to a monitoring platform and / or an alarm platform.

[0012] In a fourth aspect, the present application provides a storage medium storing a computer program, wherein the computer program executes the above-mentioned method for processing abnormal events when executed by a processor.

[0013] In a fifth aspect, the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-mentioned method for handling abnormal events through the computer program.

[0014] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:

[0015] The present application adopts a system including a Java virtual machine and a Java agent. The Java agent is used to enable the ability of the Java virtual machine to generate exception events; the Java virtual machine is used to generate corresponding exception events when a Java application generates an exception and captures an exception, and call the callback function of the Java agent, and pass the exception event to the Java agent; the Java agent is used to determine whether the exception event is a key exception event according to a filtering rule when the callback function is called, and send the exception event to a monitoring platform and / or an alarm platform when it is determined that the exception event is a key exception event. Since the Java agent is introduced into the Java virtual machine in the above system, global perception and intelligent processing of exception events can be achieved. When the Java virtual machine generates corresponding exception events when a Java application generates an exception and captures an exception and passes them to the Java agent, the Java agent will judge the severity of the exception event according to the filtering rules, and push the key exception event to the monitoring and alarm platform, thereby effectively improving the reliability and stability of the system and enhancing the real-time response capability to exception events, thereby solving the technical problem that there is currently a lack of a Java global exception perception and processing strategy, which makes it impossible to fully monitor Java exception events. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0019] Figure 1 is a schematic diagram of the structure of an optional abnormal event processing system according to an embodiment of the present application;

[0020] Figure 2 It is a class diagram of an exception handling interface module of an optional abnormal event handling system according to an embodiment of the present application;

[0021] Figure 3is a structural diagram of an optional abnormal event processing system according to an embodiment of the present application;

[0022] Figure 4 is a flowchart of an optional method for handling abnormal events according to an embodiment of the present application;

[0023] Figure 5 is a schematic structural diagram of an optional abnormal event processing device according to an embodiment of the present application;

[0024] Figure 6 is a schematic diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0026] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0027] According to a first aspect of an embodiment of the present application, a system for processing abnormal events is provided. Optionally, as Figure 1 As shown, the above system includes a Java virtual machine 102 and a Java agent 104:

[0028] The Java agent 104 is used to enable the Java virtual machine 102 to generate abnormal events;

[0029] The Java virtual machine 102 is used to generate corresponding exception events when the Java application generates an exception or captures an exception, and to call the callback function of the Java agent, and to pass the exception event to the Java agent;

[0030] The Java agent 104 is used to determine whether the abnormal event is a critical abnormal event according to the filtering rules when the callback function is called, and send the abnormal event to the monitoring platform and / or the alarm platform if the abnormal event is determined to be a critical abnormal event.

[0031] Optionally, in this embodiment, through JVMTI (Java Virtual Machine Tool Interface), the JVM's exception notification capability is enabled and an exception callback is set when the service is started, and exception handling is performed in the exception callback method, such as delivering exception information to the monitoring and alarm system. JVMTI is a relatively low-level application programming interface that allows users to monitor and control the Java Virtual Machine (JVM). Through JVMTI, developers can freely write code in rich JVM information, perform customized parsing and operations, and implement some tools, such as: performance tuning, troubleshooting, thread analysis, code coverage analysis, runtime monitoring, etc.

[0032] Optionally, in this embodiment, the Java agent plays the role of a Java Agent, which is an agent program attached to the application when the Java virtual machine is started, and is loaded by specifying the "-javaagent" parameter. Exception events are caused by unhandled errors, system resource problems, programming logic problems, etc. in the Java application, which usually cause the program to terminate or fail to run normally. In order to improve the efficiency and accuracy of exception handling, the Java virtual machine collaborates with an external Java agent (also called a Java Agent), so that it can provide global perception, filtering, alarm and other processing functions when an exception occurs. When the Java virtual machine generates an exception and captures an exception in a Java application, a corresponding exception event will be generated, and a callback mechanism will be executed to pass the exception event to an external Java agent, i.e., a Java Agent. This process involves the following steps: the Java virtual machine monitors the exceptions generated and captured by the Java application, generates corresponding exception events when the Java application generates and captures an exception, and after generating the exception event, the Java virtual machine calls the preset callback function in the Java Agent and passes the exception event to it. The callback function is an interface provided by the Java Agent to handle these exception events. After receiving an abnormal event, the Java Agent will determine whether the abnormal event is a "critical abnormal event" based on the configured filtering rules. These rules may include: the type of abnormality, the frequency of abnormal occurrence, and the environment in which the abnormal event occurs. Through these filtering rules, the Java Agent can intelligently determine which abnormal events require special attention and processing. When the Java Agent confirms that an abnormal event is a "critical abnormal event" through the filtering rules, it will pass the abnormal event to the monitoring platform and / or the alarm platform. The monitoring platform will record the detailed information of the critical abnormal event (including the type of abnormality, stack information, time of occurrence, etc.) and display it on the monitoring dashboard for the convenience of system administrators to view. If the abnormal event has a high risk (for example, it may cause a service crash or system downtime), the alarm platform will trigger an alarm to notify the developer or operation and maintenance personnel to take timely measures to deal with it.

[0033] Optionally, in this embodiment, by introducing a Java Agent in a Java virtual machine, global perception and intelligent processing of abnormal events can be achieved. When the Java virtual machine generates an exception or captures an exception in a Java application, a corresponding abnormal event is generated and passed to the Java agent. The agent determines the severity of the abnormal event according to the filtering rules and pushes the key abnormal event to the monitoring and alarm platform, thereby effectively improving the reliability and stability of the system and enhancing the real-time response capability to abnormal events. The Java Agent solution is used for access, which is convenient and applicable to any Java service of any company.

[0034] As an optional example, the Java agent includes an exception awareness enablement module:

[0035] The exception perception enabling module is used to enable the Java virtual machine's ability to generate exception events after the Java application is started, so that the Java virtual machine generates corresponding exception events when the Java application generates exceptions and captures exceptions, calls the Java agent's callback function, and passes the exception events to the Java agent. The startup command of the Java application contains the absolute address of the library file of the exception perception enabling module. When the Java application is started, the library file of the exception perception enabling module begins to load.

[0036] Optionally, in this embodiment, the Java agent includes an exception perception activation module, whose core task is to enable the Java virtual machine's function of generating exception events when the Java application is started, to ensure that the Java virtual machine can correctly generate corresponding exception events when the Java application generates exceptions and captures exceptions, and after the exception events are generated, pass the exception events to the Java agent for subsequent processing by calling a callback function. When the developer runs the Java application, the startup command of the Java application needs to contain the absolute path of the library file of the exception perception activation module. The "-agentpath: <path>The "" parameter causes the Java virtual machine to load the specified library file, which is a shared library written in C++ code. After loading the library file, the exception awareness enablement module uses the JVMTI interface provided by the Java virtual machine to enable the Java virtual machine's ability to generate exception events. By setting can_generate_exception_events=1, the Java virtual machine will start to generate corresponding exception events when Java applications generate exceptions and catch exceptions. When the Java virtual machine generates an exception event, it will notify the Java agent through the callback mechanism to pass the exception event. The callback function is provided by the Java agent to ensure that the exception event can be passed to the Java agent after it is generated and further processed.

[0037] Optionally, in this embodiment, the role of the exception perception activation module in the Java agent is crucial. It enables the exception event generation function of the Java virtual machine through the C++ library file, and passes the exception event to the Java agent through the callback mechanism, thereby realizing the global perception and intelligent processing of all exception events. This mechanism not only improves the stability and maintainability of the system, but also helps the development and operation and maintenance teams to quickly respond to potential risks through real-time monitoring and alarms, ensuring the high availability of the application.

[0038] As an optional example, the Java agent also includes an exception handling interface module and an exception handling module:

[0039] The exception handling interface module is used to pass the exception event passed from the Java virtual machine to the exception handling module when the callback function is called;

[0040] The exception handling module is used to determine whether the abnormal event is a key abnormal event according to the filtering rules when receiving the abnormal event, and send the abnormal event to the monitoring platform and / or the alarm platform if the abnormal event is determined to be a key abnormal event.

[0041] Optionally, in the present embodiment, the exception handling interface module and the exception handling module in the Java agent are key components for further processing abnormal events, and they work together to ensure that after the abnormal event is generated, the key abnormal event can be effectively judged, filtered and transmitted for further monitoring, alarm and processing. When the Java virtual machine generates an abnormal event and transmits the abnormal event to the Java agent through a callback mechanism, the role of the exception handling interface module is to receive these abnormal events and transmit them to the exception handling module. After the exception handling module receives the abnormal event from the exception handling interface module, it judges the abnormal event according to a preset filtering rule and filters out whether it is a key abnormal event. If the exception is considered to be a key exception, the exception handling module will send it to a monitoring platform or an alarm platform for further monitoring, analysis and response.

[0042] As an optional example, the exception handling interface module includes an exception perception class:

[0043] The callback method of the exception perception class is used to pass the exception event to the exception perception interface when called, and call the implementation method of the exception perception interface at the same time, wherein the callback method of the exception perception class is a callback function, and before the Java virtual machine is started, the JAR package of the exception handling interface module is placed in the path of the boot class loader of the Java virtual machine, so that the exception perception class in the JAR package of the exception handling interface module is correctly loaded when the Java virtual machine is started;

[0044] The implementation method of the exception perception interface is used to pass the exception event to the exception handling class of the exception handling module when called, and at the same time call the processing method of the exception handling class so that the processing method of the exception handling class processes the exception event.

[0045] Optionally, in this embodiment, if Figure 2 The class diagram of the exception handling interface module shown in FIG. 1 shows that the exception awareness class (ExceptionAware) is a key component for handling exception events. The callback method (aware) is called when an exception event is generated, passing the exception event to the exception awareness interface (IExceptionAware), and further handling the exception event by calling the implementation method of the interface (IExceptionAware#aware). Finally, the actual exception handling logic is completed by the exception handling class (ExceptionAwareFile). Through the design of the interface, developers can flexibly change the processing logic without modifying the main program. More importantly, through the design of the interface, the exception handling interface module is more concise, which can reduce the impact of the original Java application class loading after it is imported into the path of the boot class loader. The exception awareness interface (IExceptionAware) defines the specification of the exception awareness function (usually including a method for handling exceptions), and the specific exception handling logic is provided by the class that implements the interface (such as ExceptionAwareFile). Usually in an asynchronous or event-driven programming model, the callback function is used to execute the specified processing logic when an event occurs. Here, the callback method in the exception awareness class is the aware method, and the callback method is called when the Java virtual machine generates an exception event. The role of the exception perception interface module is to act as an intermediate layer, passing the generated exception events to the exception handling module through the interface to implement specific exception handling. The exception perception interface is an interface that defines standard methods in the exception perception process (such as aware(Exception e)). These methods do not contain specific implementation logic, but only provide interface specifications for passing exception events. The specific exception handling logic will be defined in the implementation class of the interface. The implementation class of the exception perception interface will implement all methods of the interface. When the callback method of the exception perception class is called, it will trigger the execution of the interface implementation method. The role of the interface implementation method is to receive exception events and further pass them to the exception handling class in the exception handling module. The exception handling of the exception handling module implements specific exception handling logic, such as logging, alarm triggering, and monitoring platform push.

[0046] Optionally, in this embodiment, to ensure that the exception handling interface module can be correctly loaded when the Java virtual machine is started, the JAR package of the exception handling interface module needs to be placed in the boot class loader path of the Java virtual machine. This is done to simplify the class isolation processing of this application and prevent the occurrence of ClassNotFoundException.

[0047] Optionally, in this embodiment, JVMTI is an interface provided by Java, which allows external tools or programs (such as Java Agent) to interact with the Java virtual machine. Through JVMTI, the Java Agent can set a callback function and perceive various abnormal events of the Java virtual machine. The VMInit event is an event triggered when the Java virtual machine is initialized. The VMInit event indicates that the Java virtual machine has been successfully initialized and can begin to accept the operation of the application. Therefore, the setting of the abnormal callback function needs to be completed at this time. When the VMInit event is triggered, the Java Agent will register a callback function to handle the abnormal events in the Java virtual machine. This is done by calling the callback method of the VMInit event, in which the abnormal callback function is set as the aware method of the abnormal perception class (ExceptionAware.class). Before the initialization of the Java virtual machine is completed, many internal components of the Java virtual machine have not been fully loaded and initialized. Therefore, the exception handling mechanism (including the setting of the callback function) can only take effect after the Java virtual machine is fully initialized. By placing the registration setting of the abnormal callback function in the callback of the VMInit event, it can be ensured that the callback function will only take effect when the Java virtual machine is fully ready. In this way, the problem that the abnormal events captured when the Java virtual machine is not fully initialized cannot be properly handled can be avoided.

[0048] Optionally, in the present embodiment, through the cooperation of the exception perception class and the exception perception interface, all abnormal events can be generated and processed in a centralized manner, avoiding scattered exception handling codes. Through interface implementation, developers can flexibly define various exception handling logics (such as log records, alarms, etc.), making the system more scalable and maintainable. Because the exception handling interface module is placed in the boot class loader, the Java virtual machine can load the relevant class when it starts, so that the abnormal event can be processed in the early stage of application startup. By modularizing the exception handling logic and decoupling it through the interface and callback mechanism, the exception handling module has better scalability and maintainability, and can replace or expand the processing logic as needed without affecting the normal operation of the business system.

[0049] As an optional example, the exception handling module includes the exception handling class:

[0050] The processing method of the exception handling class is used to determine whether the exception event is a critical exception event according to the filtering rules when it is called, and when the exception event is determined to be a critical exception event, send the exception event to the monitoring platform and / or the alarm platform; when the exception event is determined to be a non-critical exception event, ignore the exception event. Before the Java virtual machine is started, the JAR package of the exception handling module is placed in the path of the custom class loader of the Java virtual machine, so that the exception perception class in the JAR package of the exception handling module is correctly loaded when the Java virtual machine is started, so that the exception perception class is isolated from the Java application class.

[0051] Optionally, in this embodiment, the core task of the exception handling module is to filter and process the abnormal events generated from the Java virtual machine. It uses a series of filtering rules to determine whether the abnormal event is a critical abnormal event, and sends the abnormal event to the monitoring platform and / or the alarm platform according to the judgment result. For abnormal events that do not need to be concerned, the module will choose to ignore them, thereby reducing the burden on the system.

[0052] Optionally, in this embodiment, the exception handling class is a key component in the exception handling module, and its processing method is responsible for performing the following tasks: the exception handling class receives abnormal events through an interface, which are generated from a Java virtual machine and passed to the exception handling module through a callback mechanism. According to the filtering rules, the exception handling class will determine whether the abnormal event meets the criteria of a key abnormal event, and the filtering rules can be determined based on multiple factors such as the exception type, the exception stack, and the location where the abnormality occurs. If the abnormal event is determined to be a key abnormal event, the exception handling class will send it to a monitoring platform or an alarm platform for further visualization, alarm notification, and other operations to help developers respond and solve problems in a timely manner. For abnormal events that are determined to be non-critical, the exception handling class will choose to ignore them to avoid unnecessary resource consumption.

[0053] Optionally, in this embodiment, in this architecture, the JAR package (exception-aware-file.jar) of the exception handling module contains the core exception handling class (ExceptionAwareFile.class), and the JAR package is loaded by a custom class loader to achieve class isolation with the business Java virtual machine. The exception-aware-file.jar and the business Java application may contain classes with the same name, which will cause class loading conflicts and affect normal business operations. In order to avoid this situation, a custom class loader (such as UrlClassLoader) is used to load the exception-aware-file.jar to ensure that it uses a different class loading space from the Java application, thereby avoiding class conflicts. The custom class loader ensures that the classes in the exception-aware-file.jar (such as ExceptionAwareFile.class) are loaded into the Java virtual machine without conflicting with the classes in the business Java application. In this way, the exception-aware-file.jar can run independently of the business class loader and can load its own classes and other third-party libraries. Before the Java virtual machine is started, the JAR package of the exception handling module needs to be placed in the path of the custom class loader of the Java virtual machine. This ensures that the exception-aware class can be correctly loaded and initialized when the Java virtual machine is started.

[0054] Optionally, in this embodiment, the exception handling class is a core component in the exception handling module, which is responsible for determining whether the exception event is a key exception event according to the filtering rules after the exception event is generated, and processing it. The processing method includes delivering the key exception event to the monitoring platform and the alarm platform, thereby ensuring that the system exceptions are promptly paid attention to and processed. The exception perception and processing module can not only effectively capture and filter exceptions, but also flexibly support dynamic configuration and the introduction of third-party libraries, greatly improving the system's exception handling capabilities, and enhancing the robustness and monitorability of the system.

[0055] Optionally, in this embodiment, if Figure 3 The structure diagram of the exception event processing system shown in the figure, Java Agent includes three modules, namely, exception-aware-agent, exception-aware-api and exception-aware-file. The code of the exception-aware-agent module is written in C++, and the output is a library file. ".so" is a library file on the Linux platform, and ".dll" is a library file on the Windows platform. The code of the exception handling interface module is written in Java code, and the output is exception-aware-api.jar. The code of the exception handling module is also written in Java code, and the output is exception-aware-file.jar.

[0056] Abnormal callback process:

[0057] 1. The library file is loaded into the Java application through the startup command: When starting the Java application, by specifying the "-javaagent" parameter in the startup command, the Java virtual machine will load an external library file. The library file contains some agent code for setting the callback function for exception handling;

[0058] 2. Java application has an exception and calls the callback function in the library file: When an exception occurs during the running of a Java application, the Java virtual machine generates an exception event. At this time, the Java virtual machine calls the callback function set by the proxy (for example, the aware method in ExceptionAware.class);

[0059] 3. Call the implementation method of the exception perception interface: The callback function will pass the exception event to the class that implements the exception perception interface (such as IExceptionAware), and the implementation method of the interface is responsible for further processing these exceptions;

[0060] 4. The interface calls a specific processing class: In the implementation method of the interface, the exception event will be passed to a specific processing class (such as ExceptionAwareFile), which handles the exception event according to the defined rules, such as filtering unimportant exception events or delivering key exception events to the monitoring and alarm platform.

[0061] As an optional example, the processing method of the exception handling class is also used to determine the number of occurrences of the abnormal event before determining whether the abnormal event is a key abnormal event according to the filtering rules, and ignore the abnormal event when it is determined that the number of occurrences is greater than the target threshold.

[0062] Optionally, in this embodiment, in the exception handling module, the processing method of the exception handling class not only determines whether the abnormal event is a key abnormal event according to the filtering rules, but also includes tracking and processing the number of abnormal events. This additional step can help the system reduce meaningless alarms or monitoring information generated by repeated abnormal events, and improve the stability and monitoring efficiency of the system. In some cases, abnormal events may not necessarily need to be processed every time, especially when a certain abnormal event has occurred many times. This situation may not mean that a new problem has occurred in the system, but a known and tolerable abnormal event. In order to prevent excessive alarms or monitoring when a large number of abnormal events of the same type occur in a short period of time, the exception handling class will record and determine the number of occurrences of the abnormal event before filtering the abnormal event. Whenever the same type of abnormal event is captured, the system will count the abnormal event, and the same abnormal event can be identified based on the type of abnormal event, stack information or the location where the abnormal event occurs. Each time the same abnormal event occurs, the counter will increase. In order to avoid multiple occurrences of a single abnormal event (for example, a large number of instantaneous abnormal outputs), a time window (such as 1 minute, 5 minutes, etc.) can be set. If the number of occurrences of a certain type of abnormal event exceeds the preset threshold within the time window, the event is marked as "no further processing required". Once the number of occurrences of an abnormal event exceeds the preset target threshold, the event can be judged as a non-critical event and can be ignored.

[0063] Optionally, in this embodiment, the exception handling method not only works when determining whether an abnormal event is a critical abnormality, but can also filter abnormalities that occur too frequently according to the number of occurrences of the abnormal event before making a judgment. In this way, the system can effectively reduce meaningless alarms and monitoring information, and improve the operating efficiency and stability of the system.

[0064] According to a second aspect of an embodiment of the present application, a method for processing an abnormal event is provided, which is applied to a system for processing an abnormal event. Optionally, as follows: Figure 4 As shown, the above method includes:

[0065] S402, enabling the Java virtual machine to generate an exception event through a Java agent, so that the Java virtual machine generates a corresponding exception event when an exception is generated or captured by a Java application;

[0066] S404, when the Java virtual machine generates an exception event, the callback function of the Java agent is called, and the exception event is passed to the Java agent, so that the Java agent determines whether the exception event is a critical exception event according to the filtering rules, and if the exception event is determined to be a critical exception event, the exception event is sent to the monitoring platform and / or the alarm platform.

[0067] Optionally, in this embodiment, through JVMTI (Java Virtual Machine Tool Interface), the exception notification capability of the Java virtual machine is enabled and the exception callback is set when the service is started, and the exception handling is performed in the exception callback method, such as delivering the exception information to the monitoring and alarm system. JVMTI is a relatively low-level application programming interface that allows users to monitor and control the Java virtual machine (JVM). Through JVMTI, developers can freely write code in rich JVM information, perform customized parsing and operations, and implement some tools, such as: performance tuning, troubleshooting, thread analysis, code coverage analysis, runtime monitoring, etc.

[0068] Optionally, in this embodiment, the Java agent plays the role of a Java Agent, which is an agent program attached to the application when the Java virtual machine is started, and is loaded by specifying the "-javaagent" parameter. Exception events are caused by unhandled errors, system resource problems, programming logic problems, etc. in the Java application, which usually cause the program to terminate or fail to run normally. In order to improve the efficiency and accuracy of exception handling, the Java virtual machine cooperates with an external Java agent (also called a Java Agent), so that it can provide global perception, filtering, alarm and other processing functions when an exception occurs. When the Java virtual machine generates an exception and captures an exception in a Java application, a corresponding exception event will be generated, and a callback mechanism will be executed to pass the exception event to an external Java agent, i.e., a Java Agent. This process involves the following steps: the Java virtual machine monitors the exceptions generated and captured by the Java application, generates corresponding exception events when the Java application generates and captures an exception, and after generating the exception event, the Java virtual machine will call the callback function preset in the Java Agent and pass the exception event to it. The callback function is an interface provided by the Java Agent to handle these exception events. After receiving an abnormal event, the Java Agent will determine whether the abnormal event is a "critical abnormal event" based on the configured filtering rules. These rules may include: the type of abnormality, the frequency of abnormality, and the environment in which the abnormal event occurs. Through these filtering rules, the Java Agent can intelligently determine which abnormal events require special attention and processing. When the Java Agent confirms that an abnormal event is a "critical abnormal event" through the filtering rules, it will pass the abnormal event to the monitoring platform and / or the alarm platform. The monitoring platform will record the detailed information of the critical abnormal event (including the type of abnormality, stack information, time of occurrence, etc.) and display it on the monitoring dashboard for the system administrator to view. If the abnormal event has a high risk (for example, it may cause a service crash or system downtime), the alarm platform will trigger an alarm to notify the developer or operation and maintenance personnel to take timely measures to deal with it.

[0069] Optionally, in this embodiment, by introducing a Java Agent in a Java virtual machine, global perception and intelligent processing of abnormal events can be achieved. When the Java virtual machine generates an exception or captures an exception in a Java application, a corresponding abnormal event is generated and passed to the Java agent. The agent determines the severity of the abnormal event according to the filtering rules and pushes the key abnormal event to the monitoring and alarm platform, thereby effectively improving the reliability and stability of the system and enhancing the real-time response capability to abnormal events. The Java Agent solution is used for access, which is convenient and applicable to any Java service of any company.

[0070] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0071] For other examples of this embodiment, please refer to the examples and will not be repeated here.

[0072] According to another aspect of the embodiment of the present application, a device for processing abnormal events is also provided, which is applied to a system for processing abnormal events, such as Figure 5 As shown, including:

[0073] The first processing module 502 is used to enable the Java virtual machine to generate an exception event through a Java agent, so that the Java virtual machine generates a corresponding exception event when the Java application generates an exception and captures an exception;

[0074] The second processing module 504 is used to call the callback function of the Java agent when the Java virtual machine generates the abnormal event, and pass the abnormal event to the Java agent, so that the Java agent determines whether the abnormal event is a critical abnormal event according to the filtering rules, and when the abnormal event is determined to be a critical abnormal event, sends the abnormal event to the monitoring platform and / or the alarm platform.

[0075] It should be noted that the first processing module 502 in this embodiment can be used to execute step S402 in the embodiment of the present application, and the second processing module 504 in this embodiment can be used to execute step S404 in the embodiment of the present application.

[0076] For other examples of this embodiment, please refer to the above examples and will not be repeated here.

[0077] Figure 6 is a schematic diagram of an optional electronic device according to an embodiment of the present application, such as Figure 6 As shown, it includes a processor 602, a communication interface 604, a memory 606 and a communication bus 608, wherein the processor 602, the communication interface 604 and the memory 606 communicate with each other through the communication bus 608, wherein,

[0078] Memory 606, used to store computer programs;

[0079] The processor 602 is used to implement the following steps when executing the computer program stored in the memory 606:

[0080] Enable the Java virtual machine's ability to generate exception events through the Java agent, so that the Java virtual machine generates corresponding exception events when the Java application generates an exception or catches an exception;

[0081] When the Java virtual machine generates an exception event, the callback function of the Java agent is called, and the exception event is passed to the Java agent so that the Java agent determines whether the exception event is a critical exception event based on the filtering rules, and if the exception event is determined to be a critical exception event, the exception event is sent to the monitoring platform and / or alarm platform.

[0082] Optionally, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 The communication interface is used for communication between the above electronic device and other devices.

[0083] The memory may include RAM, or may include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0084] As an example, the memory 606 may include but is not limited to the first processing module 502 and the second processing module 504 in the abnormal event processing device. In addition, it may also include but is not limited to other module units in the abnormal event processing device, which will not be repeated in this example.

[0085] The above-mentioned processor can be a general-purpose processor, which can include but not be limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0086] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0087] It can be understood by those skilled in the art that Figure 6 The structure shown is for illustration only. The device for implementing the above-mentioned abnormal event processing method may be a terminal device, which may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 6 The structure of the electronic device is not limited. For example, the electronic device may also include Figure 6 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 6 Different configurations shown.

[0088] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.

[0089] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps in the above-mentioned method for processing abnormal events when executed by a processor.

[0090] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0091] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0092] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.

[0093] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0094] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0095] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0096] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0097] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.< / path>

Claims

1. A system for processing abnormal events, characterized in that: Including Java virtual machine and Java agent: The Java agent is used to enable the Java virtual machine to generate an abnormal event capability; The Java virtual machine is used to generate a corresponding exception event when a Java application generates an exception or captures an exception, and to call a callback function of the Java agent, and to pass the exception event to the Java agent; The Java agent is used to determine whether the abnormal event is a critical abnormal event according to the filtering rules when the callback function is called, and send the abnormal event to the monitoring platform and / or the alarm platform if it is determined that the abnormal event is a critical abnormal event.

2. The system according to claim 1, characterized in that The Java agent includes an exception perception activation module: The exception perception enabling module is used to enable the Java virtual machine's ability to generate exception events after the Java application is started, so that the Java virtual machine generates corresponding exception events when the Java application generates exceptions and captures exceptions, calls the callback function of the Java agent, and passes the exception events to the Java agent. The startup command of the Java application contains the absolute address of the library file of the exception perception enabling module. When the Java application is started, the library file of the exception perception enabling module begins to be loaded.

3. The system according to claim 1, characterized in that The Java agent also includes an exception handling interface module and an exception handling module: The exception handling interface module is used to pass the exception event transmitted from the Java virtual machine to the exception handling module when the callback function is called; The exception handling module is used to determine whether the abnormal event is a key abnormal event according to the filtering rule when receiving the abnormal event, and send the abnormal event to the monitoring platform and / or the alarm platform if it is determined that the abnormal event is a key abnormal event.

4. The system according to claim 3, characterized in that The exception handling interface module includes an exception perception class: The callback method of the exception perception class is used to pass the exception event to the exception perception interface when called, and call the implementation method of the exception perception interface at the same time, wherein the callback method of the exception perception class is the callback function, and before the Java virtual machine is started, the JAR package of the exception handling interface module is placed in the path of the boot class loader of the Java virtual machine, so that the exception perception class in the JAR package of the exception handling interface module is correctly loaded when the Java virtual machine is started; The implementation method of the exception perception interface is used to pass the exception event to the exception handling class of the exception handling module when called, and at the same time call the processing method of the exception handling class so that the processing method of the exception handling class processes the exception event.

5. The system according to claim 4, characterized in that The exception handling module includes the exception handling class: The processing method of the exception handling class is used to determine whether the exception event is a critical exception event according to the filtering rules when it is called, and when the exception event is determined to be a critical exception event, send the exception event to the monitoring platform and / or the alarm platform; when the exception event is determined to be a non-critical exception event, ignore the exception event, wherein, before the Java virtual machine is started, the JAR package of the exception handling module is placed in the path of the custom class loader of the Java virtual machine, so that the exception perception class in the JAR package of the exception handling module is correctly loaded when the Java virtual machine is started, so that the exception perception class is isolated from the Java application.

6. The system according to claim 4, characterized in that The processing method of the exception handling class is also used to determine the number of occurrences of the abnormal event before determining whether the abnormal event is a key abnormal event according to the filtering rule, and ignore the abnormal event when it is determined that the number of occurrences is greater than a target threshold.

7. A method for handling abnormal events, characterized in that: The system used for handling abnormal events includes: Enable the Java virtual machine's ability to generate exception events through the Java agent, so that the Java virtual machine generates corresponding exception events when the Java application generates an exception and captures an exception; When the Java virtual machine generates the abnormal event, the callback function of the Java agent is called, and the abnormal event is passed to the Java agent, so that the Java agent determines whether the abnormal event is a critical abnormal event according to the filtering rules, and when it is determined that the abnormal event is a critical abnormal event, the abnormal event is sent to the monitoring platform and / or the alarm platform.

8. A device for processing abnormal events, characterized in that: The system used for handling abnormal events includes: A first processing module is used to enable the Java virtual machine to generate an exception event through a Java agent, so that the Java virtual machine generates a corresponding exception event when an exception is generated or captured in a Java application; The second processing module is used to call the callback function of the Java agent when the Java virtual machine generates the abnormal event, and pass the abnormal event to the Java agent, so that the Java agent determines whether the abnormal event is a critical abnormal event according to the filtering rules, and when it is determined that the abnormal event is a critical abnormal event, sends the abnormal event to the monitoring platform and / or the alarm platform.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method described in claim 7 is performed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method of claim 7 through the computer program.