[go: up one dir, main page]

CN119690489A - A Java-based dynamic code hot replacement system and method - Google Patents

A Java-based dynamic code hot replacement system and method Download PDF

Info

Publication number
CN119690489A
CN119690489A CN202411835580.6A CN202411835580A CN119690489A CN 119690489 A CN119690489 A CN 119690489A CN 202411835580 A CN202411835580 A CN 202411835580A CN 119690489 A CN119690489 A CN 119690489A
Authority
CN
China
Prior art keywords
module
code
unit
replacement
hot
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411835580.6A
Other languages
Chinese (zh)
Inventor
凌永志
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Hanshuo Zhirong Information Technology Co ltd
Original Assignee
Shanghai Hanshuo Zhirong Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Hanshuo Zhirong Information Technology Co ltd filed Critical Shanghai Hanshuo Zhirong Information Technology Co ltd
Priority to CN202411835580.6A priority Critical patent/CN119690489A/en
Publication of CN119690489A publication Critical patent/CN119690489A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a Java-based dynamic code hot replacement system and a Java-based dynamic code hot replacement method, wherein the system comprises a code management module, a hot replacement engine module, a CI/CD module and an error processing management module; the system comprises a code management module, a hot replacement engine module, a CI/CD module, an error processing management module and a user interface module, wherein the code management module is used for generating module metadata, the module metadata is used for guiding dependency analysis and conflict detection in a code replacement process, the hot replacement engine module is used for receiving module metadata, the hot replacement engine module is used for performing incremental replacement on codes, only replacing modified partial codes, realizing immediate effectiveness after the code replacement through deep integration with a JVM, the CI/CD module is used for managing continuous integration and continuous deployment processes of an application program, and the error processing management module is used for generating errors when the codes are subjected to incremental replacement and can automatically roll back to a previous version. The Java-based dynamic code hot replacing system and the Java-based dynamic code hot replacing method realize the support of JVM of different versions, and simultaneously ensure the stability of application performance and the simplification of development flow in the code replacing process.

Description

Java-based dynamic code hot replacement system and method
Technical Field
The embodiment of the invention relates to the field of business processing, in particular to a Java-based dynamic code hot replacement system and a Java-based dynamic code hot replacement method.
Background
Along with the rapid progress of the software development industry, the improvement of development efficiency and the acceleration of debugging speed have become key indexes for evaluating the advantages and disadvantages of development environments. In the traditional Java development scenario, if a modification needs to be made to an running application, the conventional flow is to stop the application first, and then recompile and deploy the updated code. This is time consuming and can cause disruption of service, especially for those services requiring 24 hours/7 days of uninterrupted operation.
In recent years, various development tools and frameworks are proposed in the industry, and hot replacement functions are introduced, so as to realize partial or complete updating of codes without suspending execution of application programs.
The invention patent with application number of CN202010216486.8 and name of 'an automatic management method facing Java class hot update' discloses an automatic management method facing Java class hot update, which comprises two parts of class hot update execution and class hot update history inquiry, wherein the class hot update execution comprises the following steps of step 1, selecting a class to be subjected to hot update, identifying a class file path, converting the path into a software package path, returning the software package path for user confirmation, automatically modifying the path into a correct software package path by the user if the automatically identified path is wrong, executing step 2, otherwise directly executing step 2, clearing a compiling catalog, copying a class file to be replaced to the compiling catalog, automatically generating a catalog structure identical with the software package path, step 3, firstly searching whether a target process has a hot replacement log, if so, reading the log, determining a new sequence number for the class to be updated, setting the sequence number of the class to be updated to be 0, then modifying the class to be subjected to the hot update package path according to the sequence number, step 4, placing javac in the compiling catalog, writing the compiling command into the compiling catalog to be subjected to the target process, and carrying out the step 5, and inquiring the target process by the hot update catalog, and carrying out the step 1, and the step 1, the step 1 is carried out a hot update, and the step 1 is carried out a hot update-copy, and the target process is carried out by a hot-copy record, and a hot-copy record is searched, and searching the log file according to the pid, analyzing and presenting the history record in the log to the user. However, the above-described methods are relatively complex and inefficient in particular use.
To this end, there is a need to provide a Java-based dynamic code hot-swap system and method to solve the above-mentioned problems.
Disclosure of Invention
The embodiment of the application aims to provide a Java-based dynamic code hot replacing system and a Java-based dynamic code hot replacing method, which realize the support of JVM of different versions and ensure the stability of application performance and the simplification of development flow in the process of code replacement.
According to one aspect of the present invention, there is provided a Java-based dynamic code hot-swap system, which includes a code management module, a hot-swap engine module, a CI/CD module, and an error handling management module;
The code management module is used for generating module metadata, and the module metadata is used for guiding the dependency analysis and conflict detection in the code replacement process;
The hot replacement engine module receives the module metadata, and is used for performing incremental replacement on codes, replacing only modified partial codes, and realizing immediate effectiveness after code replacement through deep integration with the JVM;
the CI/CD module is used for managing the continuous integration and continuous deployment process of the application program, including automatic construction, test, packaging and deployment;
the error processing management module is used for generating errors when the codes are subjected to incremental replacement, and can automatically roll back to the previous version.
Preferably, the code management module comprises a code module management unit, a metadata generation unit, a dependency management unit and a version management unit;
The code module management unit is used for loading, unloading and updating the code module, and deploying the code module into the running environment when a new code version is detected;
The metadata generation unit is used for generating metadata describing the structure and the behavior of the code module management unit for the code module management unit, wherein the structure comprises classes, methods and attributes, and the behavior comprises an entry point and a callback mechanism;
The dependency management unit is used for automatically analyzing the dependency relationship of the module, transmitting the dependency relationship to the hot replacement engine module, and automatically updating the related dependency module by the hot replacement engine module according to the dependency relationship to ensure the consistency of the dependency relationship;
The version management unit is used for tracking different versions of codes, providing the capability of version rollback and supporting coexistence of parallel versions.
Preferably, the hot replacement engine module comprises a byte code operation library, a class loader management unit, an event monitoring unit and a notification mechanism unit;
the byte code operation library is used for reading, modifying and generating Java byte codes;
The class loader management unit is used for managing and coordinating the behavior of the class loader to ensure that the class with the new version can be loaded correctly and replace the old version, and is also used for processing class unloading so as to avoid memory leakage;
the event listening unit is configured to monitor class loading, unloading and other critical events that may affect the hot replacement process. The method can register a monitor, and when a specific event occurs, a corresponding callback function is called;
The notification mechanism unit is used for reporting information in the hot replacement process, wherein the information comprises successful update, error occurrence and rollback operation, and the information is realized by means of log record, mail transmission and instant messaging.
Preferably, the CI/CD module comprises a construction automation unit, an automation deployment unit and a dynamic code hot replacement unit;
The construction automation unit is used for automatically compiling source codes, running unit testing, integration testing and packaging to generate deployable workpieces, wherein the deployable workpieces comprise JAR files and WAR files;
The automatic deployment unit is used for managing the deployment process of the application program and comprises the steps of uploading a construction product to a target server, configuring environment variables and starting or restarting services;
the dynamic code hot replacing unit is used for carrying out code updating when the application program runs, and the code updating comprises class loader management, byte code operation, event monitoring and notification mechanisms.
Preferably, the error processing management module comprises an error detection unit, an error report notification unit and a rollback mechanism unit;
the error detection unit is used for monitoring the running state of the application program in real time, identifying and capturing the abnormality and the error, wherein the identifying and capturing the abnormality and the error comprises analysis of log files, capturing of abnormal stack tracking and monitoring of performance indexes;
The error report notification unit is used for generating a detailed error report when an abnormal situation is found, and sending out notification through various channels, wherein the error report comprises error description, occurrence time, influence range and preliminary diagnosis information, and the various channels comprise mail, instant message and log record;
The rollback mechanism unit is configured to restore the application program to a previous stable version when a serious error or a hot replacement failure is detected, where restoring the application program to the previous stable version includes unloading a new version class, reloading an old version class, and performing a cleanup operation, where the cleanup operation includes cleaning a cache and resetting a database connection.
Preferably, the system further comprises a log monitoring module for capturing, filtering and analyzing log information of the application program in real time, wherein the log information comprises a log file, a log level and keywords, and the log monitoring module is ELK Stack, splunk, graylog, log, 4J2 or SLF4J.
Preferably, the system further comprises an input interface module provided with a real unit, a Vue unit, an Echarts unit, a Material-UI unit, a CSS unit and an HTML unit;
the act unit is used for constructing a user interface and providing a declarative programming mode;
The Vue unit is used for constructing a user interface and providing a progressive JavaScript framework;
the Echarts unit is used for performing data visualization and providing chart types and configuration options;
The Material-UI unit is used for quickly constructing a user interface conforming to the Google MATERIAL DESIGN specification;
The CSS unit is used for defining and managing style rules;
the HTML unit is used to define the layout and content of the page, providing semantic tags.
Preferably, the automatically updating the related dependency module according to the dependency relationship specifically includes:
when the dependency relationship is a first dependency relationship, downloading a first application program package to update a related dependency module;
when the dependency relationship is a second dependency relationship, downloading a second application program package to update the related dependency module;
and storing the first dependency relationship and the second dependency relationship in a first tree structure and a second tree structure respectively.
Preferably, a signature file is added in the first application program package or the second application program package, a first hash algorithm is used for calculating the signature file, a second hash algorithm is used for calculating a hash value of the signature file, the hash value is mapped to the end-to-end hash ring virtual node, the first hash algorithm is a static hash algorithm, and the second hash algorithm is an elastic hash algorithm.
According to another aspect of the present invention, there is provided a Java-based dynamic code hot-swapping method, the method comprising:
Guiding the dependency parsing and conflict detection in the code replacement process;
Incremental replacement is carried out on codes, only modified partial codes are replaced, and the codes are immediately effective after replacement through deep integration with the JVM;
managing a continuous integration and continuous deployment process of an application program, including automated construction, testing, packaging, and deployment;
Errors occur when the code is incrementally replaced, enabling automatic rollback to the previous version.
The application discloses a Java-based dynamic code hot replacement system and a Java-based dynamic code hot replacement method, wherein the system comprises a code management module, a hot replacement engine module, a CI/CD module and an error processing management module, wherein the code management module is used for generating module metadata, the module metadata is used for guiding dependency analysis and conflict detection in a code replacement process, the hot replacement engine module is used for carrying out incremental replacement on codes, only replacing part of modified codes, realizing immediate effectiveness after the code replacement through deep integration with a JVM, and the CI/CD module is used for managing the continuous integration and continuous deployment process of an application program, including automatic construction, testing, packaging and deployment, and the error processing management module is used for generating errors when the codes are subjected to incremental replacement, automatically rolling back to previous versions, realizing support on different versions of the JVM, and simultaneously ensuring stability of application performance and simplification of development flow in the code replacement process;
Further, when the dependency relationship is a first dependency relationship, downloading a first application program package to update a related dependency module; when the dependency relationship is a second dependency relationship, downloading a second application program package to update related dependency modules, respectively storing the first dependency relationship and the second dependency relationship in a first tree structure and a second tree structure, and downloading the first application program package or the second application program package by using the first dependency relationship and the second dependency relationship, thereby improving the updating efficiency of the application program package;
Further, signature files are added in the first application program package or the second application program package, the signature files are calculated by using a first hash algorithm, hash values of the signature files are calculated by using a second hash algorithm, the hash values are mapped to end-to-end hash ring virtual nodes, the first hash algorithm is a static hash algorithm, the second hash algorithm is an elastic hash algorithm, and the signature files are checked by using the first hash algorithm and the second hash algorithm, so that safe updating of the first application program package or the second application program package is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the prior art, a brief description of the drawings is provided below, wherein it is apparent that the drawings in the following description are some, but not all, embodiments of the present invention. Other figures may be derived from these figures without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a block diagram of a Java-based dynamic code hot-swap system according to embodiments of the present invention;
fig. 2 is a flow diagram of a Java-based dynamic code hot-swapping method according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
The technical scheme of the invention is described in detail below by specific examples. The following embodiments may be combined with each other, and some embodiments may not be repeated for the same or similar concepts or processes.
According to the problems existing in the prior art, the embodiment of the invention provides a Java-based dynamic code hot replacing system and a Java-based dynamic code hot replacing method, which realize the support of JVM of different versions and simultaneously ensure the stability of application performance and the simplification of development flow in the code replacing process.
FIG. 1 is a schematic block diagram of a Java-based dynamic code hot-swap system according to an embodiment of the present invention, where, as shown in FIG. 1, the Java-based dynamic code hot-swap system provided in the embodiment of the present invention includes a code management module, a hot-swap engine module, a CI/CD module, and an error handling management module;
The code management module is used for generating module metadata, and the module metadata is used for guiding the dependency analysis and conflict detection in the code replacement process;
The hot replacement engine module receives the module metadata, and is used for performing incremental replacement on codes, replacing only modified partial codes, and realizing immediate effectiveness after code replacement through deep integration with the JVM;
the CI/CD module is used for managing the continuous integration and continuous deployment process of the application program, including automatic construction, test, packaging and deployment;
the error processing management module is used for generating errors when the codes are subjected to incremental replacement, and can automatically roll back to the previous version.
Preferably, the code management module comprises a code module management unit, a metadata generation unit, a dependency management unit and a version management unit;
The code module management unit is used for loading, unloading and updating the code module, and deploying the code module into the running environment when a new code version is detected;
The metadata generation unit is used for generating metadata describing the structure and the behavior of the code module management unit for the code module management unit, wherein the structure comprises classes, methods and attributes, and the behavior comprises an entry point and a callback mechanism;
The dependency management unit is used for automatically analyzing the dependency relationship of the module, transmitting the dependency relationship to the hot replacement engine module, and automatically updating the related dependency module by the hot replacement engine module according to the dependency relationship to ensure the consistency of the dependency relationship;
The version management unit is used for tracking different versions of codes, providing the capability of version rollback and supporting coexistence of parallel versions.
In specific implementation, the hot replacement engine module comprises a byte code operation library, a class loader management unit, an event monitoring unit and a notification mechanism unit;
the byte code operation library is used for reading, modifying and generating Java byte codes;
The class loader management unit is used for managing and coordinating the behavior of the class loader to ensure that the class with the new version can be loaded correctly and replace the old version, and is also used for processing class unloading so as to avoid memory leakage;
the event listening unit is configured to monitor class loading, unloading and other critical events that may affect the hot replacement process. The method can register a monitor, and when a specific event occurs, a corresponding callback function is called;
The notification mechanism unit is used for reporting information in the hot replacement process, wherein the information comprises successful update, error occurrence and rollback operation, and the information is realized by means of log record, mail transmission and instant messaging.
In a specific implementation, the CI/CD module comprises a construction automation unit, an automation deployment unit and a dynamic code hot replacement unit;
The construction automation unit is used for automatically compiling source codes, running unit testing, integration testing and packaging to generate deployable workpieces, wherein the deployable workpieces comprise JAR files and WAR files;
The automatic deployment unit is used for managing the deployment process of the application program and comprises the steps of uploading a construction product to a target server, configuring environment variables and starting or restarting services;
the dynamic code hot replacing unit is used for carrying out code updating when the application program runs, and the code updating comprises class loader management, byte code operation, event monitoring and notification mechanisms.
In specific implementation, the error processing management module comprises an error detection unit, an error report notification unit and a rollback mechanism unit;
the error detection unit is used for monitoring the running state of the application program in real time, identifying and capturing the abnormality and the error, wherein the identifying and capturing the abnormality and the error comprises analysis of log files, capturing of abnormal stack tracking and monitoring of performance indexes;
The error report notification unit is used for generating a detailed error report when an abnormal situation is found, and sending out notification through various channels, wherein the error report comprises error description, occurrence time, influence range and preliminary diagnosis information, and the various channels comprise mail, instant message and log record;
The rollback mechanism unit is configured to restore the application program to a previous stable version when a serious error or a hot replacement failure is detected, where restoring the application program to the previous stable version includes unloading a new version class, reloading an old version class, and performing a cleanup operation, where the cleanup operation includes cleaning a cache and resetting a database connection.
In a specific implementation, the system further comprises a log monitoring module, which is used for capturing, filtering and analyzing log information of the application program in real time, wherein the log information comprises a log file, a log level and a keyword, and the log monitoring module is ELK Stack, splunk, graylog, log J2 or SLF4J.
In a specific implementation, the system further comprises an input interface module, wherein the input interface module is provided with a real unit, a Vue unit, an Echarts unit, a Material-UI unit, a CSS unit and an HTML unit;
the act unit is used for constructing a user interface and providing a declarative programming mode;
The Vue unit is used for constructing a user interface and providing a progressive JavaScript framework;
the Echarts unit is used for performing data visualization and providing chart types and configuration options;
The Material-UI unit is used for quickly constructing a user interface conforming to the Google MATERIAL DESIGN specification;
The CSS unit is used for defining and managing style rules;
the HTML unit is used to define the layout and content of the page, providing semantic tags.
In a specific implementation, the automatic updating of the related dependency module according to the dependency relationship specifically includes:
when the dependency relationship is a first dependency relationship, downloading a first application program package to update a related dependency module;
when the dependency relationship is a second dependency relationship, downloading a second application program package to update the related dependency module;
and storing the first dependency relationship and the second dependency relationship in a first tree structure and a second tree structure respectively.
In specific implementation, a signature file is added in the first application program package or the second application program package, the signature file is calculated by using a first hash algorithm, a hash value of the signature file is calculated by using a second hash algorithm, the hash value is mapped to an end-to-end hash ring virtual node, the first hash algorithm is a static hash algorithm, and the second hash algorithm is an elastic hash algorithm.
Fig. 2 is a flow chart of a Java-based dynamic code hot replacing method according to an embodiment of the present invention, as shown in fig. 2, the method includes:
Step S201, guiding the dependency resolution and conflict detection in the code replacement process;
Step S202, performing incremental replacement on codes, replacing only part of modified codes, and realizing immediate effectiveness after the replacement of the codes through deep integration with the JVM;
Step 203, managing the continuous integration and continuous deployment process of the application program, including automatic construction, test, packaging and deployment;
step S204, when the code is subjected to incremental replacement, an error occurs, and the code can be automatically rolled back to the previous version.
The following specifically exemplifies the Java-based dynamic code hot-replacement method described above:
1. User request:
A user accesses the front-end interface of the system through a browser and loads pages containing React, vue, echarts, material-UI, CSS and HTML.
2. Initializing:
After the page loading is completed, the fact or Vue framework is initialized, and an initial user interface is rendered. The Material-UI component library is used to build interface elements, and the Echarts chart is rendered according to the initial data.
3. User interaction:
the user interacts with the interface such as clicking on a button, selecting an option, entering text, etc. The act or Vue component captures these events and updates the local state or sends requests to the backend as needed.
4. Data acquisition and updating:
The act or Vue component may initiate an API request if data needs to be obtained from the back-end. Upon receiving the response, the component updates the state and re-renders the relevant portion. For the Echarts chart, the data update triggers a redraw of the chart.
5. Error handling:
If an error occurs in the interaction process, the error detection unit captures the abnormality, the error report notification unit generates a detailed error report, and the log monitoring module records the related information. Friendly error cues can be displayed on the user interface.
6. Thermal replacement feedback:
When dynamic code hot replacement occurs, the front-end interface can receive update notifications through WebSocket or other real-time communication mechanisms. The exact or Vue component can be reloaded according to the new code version without refreshing the entire page. The echartists graph can be automatically updated according to new data sources.
7. Rollback and recovery:
The rollback mechanism unit may trigger a rollback operation if the hot replacement fails or a problem occurs. The front-end interface will receive the rollback notification and update the state and view accordingly, ensuring that the user always sees the latest stable version.
8. And (3) performance monitoring:
the log monitoring module not only monitors the back-end log, but also can collect front-end performance indexes such as loading time and response time. These data can help optimize front-end performance, ensuring a smooth user experience.
In summary, the system comprises a code management module, a hot replacement engine module, a CI/CD module and an error processing management module, wherein the code management module is used for generating module metadata, the module metadata is used for guiding the analysis of dependence and the detection of conflict in the process of replacing codes, the hot replacement engine module is used for carrying out incremental replacement on codes, only replacing modified partial codes, realizing immediate effectiveness after the replacement of codes through deep integration with JVM, the CI/CD module is used for managing the continuous integration and continuous deployment process of application programs, including automatic construction, test, packaging and deployment, and the error processing management module is used for carrying out errors when the codes are subjected to incremental replacement, automatically rolling back to the previous version, realizing the support of different versions of JVM, and simultaneously ensuring the stability of application performance and the simplification of development flow in the process of replacing codes;
Further, when the dependency relationship is a first dependency relationship, downloading a first application program package to update a related dependency module; when the dependency relationship is a second dependency relationship, downloading a second application program package to update related dependency modules, respectively storing the first dependency relationship and the second dependency relationship in a first tree structure and a second tree structure, and downloading the first application program package or the second application program package by using the first dependency relationship and the second dependency relationship, thereby improving the updating efficiency of the application program package;
Further, signature files are added in the first application program package or the second application program package, the signature files are calculated by using a first hash algorithm, hash values of the signature files are calculated by using a second hash algorithm, the hash values are mapped to end-to-end hash ring virtual nodes, the first hash algorithm is a static hash algorithm, the second hash algorithm is an elastic hash algorithm, and the signature files are checked by using the first hash algorithm and the second hash algorithm, so that safe updating of the first application program package or the second application program package is ensured.
It should be noted that the above embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the above embodiments, it should be understood by those skilled in the art that the technical solution described in the above embodiments may be modified or some or all of the technical features may be equivalently replaced, and these modifications or substitutions do not make the essence of the corresponding technical solution deviate from the scope of the technical solution of the embodiments of the present invention.

Claims (10)

1.一种基于Java的动态代码热替换系统,其特征在于,所述系统包括代码管理模块、热替换引擎模块、CI/CD模块和错误处理管理模块;1. A Java-based dynamic code hot replacement system, characterized in that the system includes a code management module, a hot replacement engine module, a CI/CD module and an error handling management module; 所述代码管理模块用于生成模块元数据,所述模块元数据用于指导代码替换过程中的依赖解析和冲突检测;The code management module is used to generate module metadata, and the module metadata is used to guide dependency parsing and conflict detection during code replacement; 所述热替换引擎模块接收所述模块元数据,所述热替换引擎模块用于对代码进行增量式替换,只替换已修改的部分代码,通过与JVM的深度集成,实现代码替换后立即生效;The hot replacement engine module receives the module metadata, and the hot replacement engine module is used to incrementally replace the code, replacing only the modified part of the code, and realizing immediate effect after the code replacement through deep integration with the JVM; 所述CI/CD模块用于管理应用程序的持续集成和持续部署过程,包括自动化构建、测试、打包和部署;The CI/CD module is used to manage the continuous integration and continuous deployment process of applications, including automated building, testing, packaging, and deployment; 所述错误处理管理模块用于当所述代码进行增量式替换时发生错误,能够自动回滚到之前的版本。The error handling management module is used to automatically roll back to the previous version when an error occurs during the incremental replacement of the code. 2.根据权利要求1所述的基于Java的动态代码热替换系统,其特征在于,所述代码管理模块包括:代码模块管理单元、元数据生成单元、依赖管理单元和版本管理单元;2. According to the Java-based dynamic code hot replacement system of claim 1, the code management module comprises: a code module management unit, a metadata generation unit, a dependency management unit and a version management unit; 所述代码模块管理单元用于加载、卸载和更新代码模块,当检测到新的代码版本时,将其部署到运行环境中;The code module management unit is used to load, unload and update code modules, and when a new code version is detected, deploy it to the operating environment; 所述元数据生成单元用于为所述代码模块管理单元生成描述其结构和行为的元数据,所述结构包括类、方法以及属性,所述行为包括入口点以及回调机制;The metadata generation unit is used to generate metadata describing the structure and behavior of the code module management unit, wherein the structure includes classes, methods and properties, and the behavior includes entry points and callback mechanisms; 所述依赖管理单元用于自动解析模块的依赖关系,将所述依赖关系传递给所述热替换引擎模块,所述热替换引擎模块根据所述依赖关系自动更新相关的依赖模块,确保依赖关系的一致性;The dependency management unit is used to automatically parse the dependency relationship of the module, and pass the dependency relationship to the hot replacement engine module, and the hot replacement engine module automatically updates the related dependency modules according to the dependency relationship to ensure the consistency of the dependency relationship; 所述版本管理单元用于跟踪代码的不同版本,提供版本回滚的能力,支持并行版本的共存。The version management unit is used to track different versions of the code, provide version rollback capabilities, and support the coexistence of parallel versions. 3.根据权利要求1所述的基于Java的动态代码热替换系统,其特征在于,所述热替换引擎模块包括:字节码操作库、类加载器管理单元、事件监听单元和通知机制单元;3. The Java-based dynamic code hot replacement system according to claim 1, characterized in that the hot replacement engine module includes: a bytecode operation library, a class loader management unit, an event monitoring unit and a notification mechanism unit; 所述字节码操作库用于对Java字节码进行读取、修改和生成;The bytecode operation library is used to read, modify and generate Java bytecode; 所述类加载器管理单元用于管理和协调类加载器的行为,确保新版本的类能够被正确加载并替代旧版本,所述类加载器管理单元还用于处理类卸载,以避免内存泄漏;The class loader management unit is used to manage and coordinate the behavior of the class loader to ensure that the new version of the class can be correctly loaded and replace the old version. The class loader management unit is also used to handle class unloading to avoid memory leaks; 所述事件监听单元用于监控类加载、卸载以及其他可能影响热替换过程的关键事件。它可以注册监听器,当特定事件发生时,调用相应的回调函数;The event monitoring unit is used to monitor class loading, unloading and other key events that may affect the hot replacement process. It can register a listener and call the corresponding callback function when a specific event occurs; 所述通知机制单元用于报告热替换过程中的信息,所述信息包括成功更新、错误发生以及回滚操作,所述信息通过日志记录、邮件发送、即时消息的方式实现。The notification mechanism unit is used to report information during the hot replacement process, including successful updates, errors, and rollback operations. The information is recorded in logs, sent by email, or sent via instant messaging. 4.根据权利要求1所述的基于Java的动态代码热替换系统,其特征在于,所述CI/CD模块包括:构建自动化单元、自动化部署单元和动态代码热替换单元;4. The Java-based dynamic code hot replacement system according to claim 1, characterized in that the CI/CD module includes: a construction automation unit, an automated deployment unit and a dynamic code hot replacement unit; 所述构建自动化单元用于自动编译源代码、运行单元测试、集成测试以及打包生成可部署的工件,所述可部署的工件包括JAR文件以及WAR文件;The build automation unit is used to automatically compile source code, run unit tests, integration tests, and package to generate deployable artifacts, and the deployable artifacts include JAR files and WAR files; 所述自动化部署单元用于管理应用程序的部署过程,包括将构建产物上传到目标服务器、配置环境变量以及启动或重启服务;The automated deployment unit is used to manage the deployment process of the application, including uploading the build product to the target server, configuring environment variables, and starting or restarting the service; 所述动态代码热替换单元用于在应用程序运行时进行代码更新,所述代码更新包括类加载器管理、字节码操作、事件监听以及通知机制。The dynamic code hot replacement unit is used to update the code when the application is running, and the code update includes class loader management, bytecode operation, event monitoring and notification mechanism. 5.根据权利要求1所述的基于Java的动态代码热替换系统,其特征在于,所述错误处理管理模块包括:错误检测单元、错误报告通知单元和回滚机制单元;5. The Java-based dynamic code hot replacement system according to claim 1, characterized in that the error handling management module comprises: an error detection unit, an error reporting and notification unit, and a rollback mechanism unit; 所述错误检测单元用于实时监控应用程序的运行状态,识别捕获异常以及错误,所述识别捕获异常以及错误包括到对日志文件的分析、异常堆栈跟踪的捕捉、性能指标的监控;The error detection unit is used to monitor the running status of the application in real time, identify and capture exceptions and errors, and the identification and capture of exceptions and errors includes analysis of log files, capture of exception stack traces, and monitoring of performance indicators; 所述错误报告通知单元用于当发现异常情况时,生成详细的错误报告,并通过多种渠道发出通知,所述错误报告包括错误描述、发生时间、影响范围以及初步的诊断信息,所述多种渠道包括邮件、即时消息以及日志记录;The error report notification unit is used to generate a detailed error report when an abnormal situation is found, and send a notification through multiple channels, wherein the error report includes an error description, occurrence time, impact scope and preliminary diagnostic information, and the multiple channels include email, instant messaging and log records; 所述回滚机制单元用于当检测到严重错误或热替换失败时,将应用程序恢复到之前的稳定版本,所述将应用程序恢复到之前的稳定版本包括卸载新版本的类、重新加载旧版本的类以及执行清理操作,所述清理操作包括清除缓存以及重置数据库连接。The rollback mechanism unit is used to restore the application to a previous stable version when a serious error or hot replacement failure is detected. Restoring the application to the previous stable version includes unloading the new version class, reloading the old version class, and performing a cleanup operation. The cleanup operation includes clearing the cache and resetting the database connection. 6.根据权利要求1所述的基于Java的动态代码热替换系统,其特征在于,还包括日志监听模块,其用于实时捕获、过滤和分析应用程序的日志信息,所述日志信息包括日志文件、日志级别以及关键词,所述日志监听模块为ELK Stack、Splunk、Graylog、Log4j2或SLF4J。6. According to claim 1, the Java-based dynamic code hot replacement system is characterized in that it also includes a log monitoring module, which is used to capture, filter and analyze the log information of the application in real time, the log information includes log files, log levels and keywords, and the log monitoring module is ELK Stack, Splunk, Graylog, Log4j2 or SLF4J. 7.根据权利要求1所述的基于Java的动态代码热替换系统,其特征在于,还包括输入界面模块,其设置有React单元、Vue单元、Echarts单元、Material-UI单元、CSS单元和HTML单元;7. The Java-based dynamic code hot replacement system according to claim 1, characterized in that it also includes an input interface module, which is provided with a React unit, a Vue unit, an Echarts unit, a Material-UI unit, a CSS unit and an HTML unit; 所述React单元用于构建用户界面,提供声明式编程方式;The React unit is used to build a user interface and provides a declarative programming approach; 所述Vue单元用于构建用户界面,提供渐进式JavaScript框架;The Vue unit is used to build user interfaces, providing a progressive JavaScript framework; 所述Echarts单元用于进行数据可视化,提供图表类型以及配置选项;The Echarts unit is used for data visualization, providing chart types and configuration options; 所述Material-UI单元用于快速搭建遵循Google Material Design规范的用户界面;The Material-UI unit is used to quickly build a user interface that complies with the Google Material Design specification; 所述CSS单元用于定义和管理样式规则;The CSS unit is used to define and manage style rules; 所述HTML单元用于定义页面的布局和内容,提供语义化的标记。The HTML unit is used to define the layout and content of the page and provide semantic tags. 8.根据权利要求2所述的基于Java的动态代码热替换系统,其特征在于,根据所述依赖关系自动更新相关的依赖模块具体包括:8. The Java-based dynamic code hot replacement system according to claim 2, wherein automatically updating the related dependent modules according to the dependency relationship specifically comprises: 当所述依赖关系为第一依赖关系时,则下载第一应用程序包以更新相关的依赖模块;When the dependency relationship is the first dependency relationship, downloading the first application package to update the related dependency module; 当所述依赖关系为第二依赖关系时,则下载第二应用程序包以更新相关的依赖模块;When the dependency relationship is the second dependency relationship, downloading the second application package to update the related dependency module; 分别以第一树结构和第二树结构存储所述第一依赖关系和所述第二依赖关系。The first dependency relationship and the second dependency relationship are stored in a first tree structure and a second tree structure respectively. 9.根据权利要求8所述的基于Java的动态代码热替换系统,其特征在于,在所述第一应用程序包或所述第二应用程序包中添加签名文件,使用第一哈希算法计算所述签名文件,使用第二哈希算法计算所述签名文件的哈希值,将所述哈希值映射到首尾相连的哈希环虚拟节点上,所述第一哈希算法为静态哈希算法,所述第二哈希算法为弹性哈希算法。9. According to claim 8, the Java-based dynamic code hot replacement system is characterized in that a signature file is added to the first application package or the second application package, the signature file is calculated using a first hash algorithm, the hash value of the signature file is calculated using a second hash algorithm, and the hash value is mapped to a hash ring virtual node connected end to end, the first hash algorithm is a static hash algorithm, and the second hash algorithm is an elastic hash algorithm. 10.一种基于Java的动态代码热替换方法,其特征在于,所述方法包括:10. A Java-based dynamic code hot replacement method, characterized in that the method comprises: 指导代码替换过程中的依赖解析和冲突检测;Guide dependency resolution and conflict detection during code replacement; 对代码进行增量式替换,只替换已修改的部分代码,通过与JVM的深度集成,实现代码替换后立即生效;Incremental replacement of code, replacing only the modified part of the code. Through deep integration with JVM, code replacement takes effect immediately. 管理应用程序的持续集成和持续部署过程,包括自动化构建、测试、打包和部署;Manage the continuous integration and continuous deployment process of applications, including automated building, testing, packaging, and deployment; 当所述代码进行增量式替换时发生错误,能够自动回滚到之前的版本。When an error occurs during the incremental replacement of the code, it can automatically roll back to the previous version.
CN202411835580.6A 2024-12-13 2024-12-13 A Java-based dynamic code hot replacement system and method Pending CN119690489A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411835580.6A CN119690489A (en) 2024-12-13 2024-12-13 A Java-based dynamic code hot replacement system and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411835580.6A CN119690489A (en) 2024-12-13 2024-12-13 A Java-based dynamic code hot replacement system and method

Publications (1)

Publication Number Publication Date
CN119690489A true CN119690489A (en) 2025-03-25

Family

ID=95044498

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411835580.6A Pending CN119690489A (en) 2024-12-13 2024-12-13 A Java-based dynamic code hot replacement system and method

Country Status (1)

Country Link
CN (1) CN119690489A (en)

Similar Documents

Publication Publication Date Title
Tomassi et al. Bugswarm: Mining and continuously growing a dataset of reproducible failures and fixes
US12353319B2 (en) Scalable execution tracing for large program codebases
EP3769223B1 (en) Unified test automation system
US9740594B2 (en) Automated debug trace specification
CN110554965B (en) Automated fuzz testing method, related equipment and computer readable storage medium
US7698691B2 (en) Server application state
US20100185590A1 (en) Autonomic information management system (ims) mainframe database pointer error diagnostic data extraction
US9588872B2 (en) Discovery of code paths
CN112099880A (en) Scenario-driven application reduction method and system
Dai et al. Dscope: Detecting real-world data corruption hang bugs in cloud server systems
CN112506923B (en) Method, device and electronic device for determining link of method call corresponding to business
CN111352631A (en) Interface compatibility detection method and device
Nguyen et al. An empirical study of exception handling bugs and fixes
CN119690489A (en) A Java-based dynamic code hot replacement system and method
CN111367796A (en) Application program debugging method and device
CN119862167B (en) File operation tracking method and device, computer equipment and storage medium
WO2020194000A1 (en) Method of detecting and removing defects
CN119357161B (en) Pre-data construction method, device, storage medium and program product
CN107632934B (en) Function copying method and device in C-sharp
Ross et al. Exception monitoring for the Flask Monitoring Dashboard
嶋利 et al. Study on Cost-Effective Debugging Methods under
Jin Understanding and Detecting Software Upgrade Failures in Distributed Systems
CN119829407A (en) Program debugging method and device
CN119149403A (en) Application program testing method, device, equipment, storage medium and program product
CN118916076A (en) Version injection method, version injection device, electronic equipment, storage medium and product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination