A hot update method, device, computer storage medium and system
By monitoring the configuration information changes of Spring module and obtaining feature values, hot updates are realized when Spring module runs, solving the problem of high resource consumption in the existing technology, and real-time updates of local components are realized.
Patent Information
- Application Number
- CN202010763425.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-31
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2040-07-31
Smart Images

Figure CN114064094B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer software technology, and in particular to a hot update method, device, computer storage medium and system. Background Art
[0002] Currently, there are a large number of web applications in the Internet field. A web application is an application that can be accessed through the web. Here, web applications are generally written in Java language, so they are also called JavaWeb. With the contribution of the open source community, various JavaWeb writing technology solutions and development frameworks have emerged in an endless stream. Among them, the Spring framework can be regarded as the technical standard in the field of JavaWeb development.
[0003] The Spring framework can be used to manage various components. When the Spring framework reads the configuration information and starts, it means that these components have been loaded into memory. At this time, if some configuration information needs to be modified, it is usually necessary to refresh the Spring framework to reload the components into memory, so the resource consumption is large. Summary of the invention
[0004] The main purpose of this application is to propose a hot update method, device, computer storage medium and system, which can realize hot update of Spring module during runtime, so that the update of configuration files can be applied to Spring module in real time, reducing resource consumption in the hot update process.
[0005] To achieve the above purpose, the technical solution of this application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides a hot update method, the method comprising:
[0007] During the operation of the Spring module, monitor whether the configuration information corresponding to the Spring module changes;
[0008] When it is detected that the configuration information of the Spring module has changed, a change characteristic value corresponding to the changed configuration information is obtained;
[0009] Based on the changed configuration information and the corresponding changed characteristic values, the Spring module is hot updated.
[0010] In a second aspect, an embodiment of the present application provides a thermal update device, which includes a monitoring unit, an acquisition unit and an update unit; wherein:
[0011] The monitoring unit is configured to monitor whether the configuration information corresponding to the Spring module changes;
[0012] The acquisition unit is configured to acquire a change characteristic value corresponding to the changed configuration information when a change is detected in the configuration information of the Spring module;
[0013] The updating unit is configured to perform hot update on the Spring module based on the changed configuration information and the corresponding changed characteristic value.
[0014] In a third aspect, an embodiment of the present application provides a thermal update device, the thermal update device comprising: a memory and a processor; wherein:
[0015] The memory is used to store a computer program that can be run on the processor;
[0016] The processor is used to execute the steps of the method described in the first aspect when running the computer program.
[0017] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores a thermal update program, and when the thermal update program is executed by at least one processor, the steps of the method described in the first aspect are implemented.
[0018] In a fifth aspect, an embodiment of the present application provides a thermal update system, which includes at least the thermal update device as described in the second aspect or the third aspect.
[0019] The embodiments of the present application provide a hot update method, device, computer storage medium and system, the method comprising: during the operation of the Spring module, monitoring whether the configuration information corresponding to the Spring module changes; when it is monitored that the configuration information of the Spring module changes, obtaining the change characteristic value corresponding to the changed configuration information; based on the changed configuration information and the corresponding change characteristic value, hot updating the Spring module; in this way, by monitoring the configuration information corresponding to the Spring module, the change of its configuration information can be known in time; then the Spring module is hot updated using the changed configuration information, so that the local components can be updated without restarting the Spring module, thereby reducing the resource consumption during the update of the Spring module. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A schematic diagram of a hot update method provided in an embodiment of the present application;
[0021] Figure 2 A schematic diagram of another hot update method provided in an embodiment of the present application;
[0022] Figure 3A schematic diagram of a flow chart of another hot update method provided in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of a process flow of another hot update method provided in an embodiment of the present application;
[0024] Figure 5 A schematic diagram of the architecture of a hot update method provided in an embodiment of the present application;
[0025] Figure 6 A schematic diagram of a process flow of another hot update method provided in an embodiment of the present application;
[0026] Figure 7 A schematic diagram of the structure of a thermal update device provided in an embodiment of the present application;
[0027] Figure 8 A schematic diagram of the structure of another thermal update device provided in an embodiment of the present application;
[0028] Fig. 9 A schematic diagram of the hardware structure of a hot update device provided in an embodiment of the present application;
[0029] Fig.10 A schematic diagram of the structure of a thermal update system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] The technical solutions 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.
[0031] The Spring framework is the mainstream framework for developing Web applications. It was created to solve the complexity of enterprise application development. One of the main advantages of the Spring framework is its layered architecture, which allows users to choose different components to build Web applications. From the perspective of simplicity, testability, and loose coupling, any Java application can benefit from the Spring framework. For the Spring framework, there are several important modules:
[0032] Core container: The core container is the most basic and important component of the Spring framework. It is called the Spring module in this application (also called the Spring container in related technologies). It manages business components (Beans) through Inversion of Control (IoC), which means that the application is directly controlled by the Spring module rather than by the program code. Among them, Bean refers to the object managed by the Spring module. When the Spring module is loaded, the Spring module is initialized by reading the configuration information (which can be in the form of configuration files or annotations). At this time, a large number of Beans have been generated in the Spring module, and these Beans provide services.
[0033] Application context module: The core container enables Spring to complete the containerization process by generating a large number of beans, while the application context module makes it a framework. This module adds support for internationalization (I18N) messages, event propagation, and verification. In addition, this module provides many enterprise services, such as email, Java Naming and Directory Interface (JavaNaming and Directory Interface, JNDI) access, EJB (Enterprise JavaBean) component integration, remote and time scheduling services, and also includes support for template frameworks such as Velocity and FreeMarker integration.
[0034] Aspect Oriented Programming Module: The Spring Framework provides rich support for aspect-oriented programming in the Aspect Orient Programming (AOP) module. This module is the basis for implementing aspect programming in the Spring module. In order to ensure the interoperability of the Spring Framework with other AOP frameworks, the AOP support of the Spring Framework is based on the Application Programming Interface (API) defined by the AOP Alliance. The AOP Alliance is an open source project whose goal is to promote the use of AOP and interoperability between different AOP implementations by defining a set of common interfaces and components. The AOP module of the Spring Framework also introduces metadata programming into the Spring Framework. Using the metadata support of the Spring Framework, you can add annotations to the source code to indicate where and how the Spring Framework applies aspect functions.
[0035] JDBC abstraction and DAO module: Java Database Connectivity (JDBC) is an application program interface used in the Java language to regulate how client programs access databases; the Data Access Object (DAO) module is an object-oriented database connection interface that can provide code for operations such as adding, deleting, modifying, and querying data in the database. By using the JDBC abstraction and DAO module, the database code can be kept simple and problems caused by incorrect closure of database resources can be avoided. It provides a unified exception access layer on top of the error information of various databases, and it also uses Spring's AOP module to provide transaction management services for objects in Spring applications.
[0036] Object / relational mapping integration module: Spring framework provides an object / relational mapping integration (ORM) module for those who prefer to use object / relational mapping tools instead of directly using JDBC. It is worth noting that Spring does not design an independent ORM solution, but provides integration solutions for several mainstream ORM frameworks.
[0037] Web module: The Web module is built on the application context module and provides a context suitable for Web applications. In addition, this module also provides some support for specific services, such as implementing multiple requests for file uploads, and also provides integration between the Spring framework and other Web frameworks.
[0038] Model / View / Controller Framework: The Model / View / Controller (MVC) framework is a full-featured framework provided by the Spring Framework for building Web applications. Although the Spring Framework can be easily integrated with other MVC frameworks, such as Struts, the Spring Framework's MVC framework provides a complete separation of control logic and business objects using Spring modules. The MVC framework allows declarative binding of request parameters to business objects. In addition, the Spring Framework's MVC framework can also take advantage of any other Spring Framework services, such as internationalization information and validation.
[0039] Based on the structure of the Spring framework, when the application is initially loaded, it is necessary to read the configuration information (which can be in the form of configuration files or annotations) to complete the initialization of the Spring module. At this time, a large number of beans have been generated in the Spring module, and the instantiation objects of these beans provide specific services for the application. During operation, if some configuration parameters in the configuration information are modified, it is usually difficult for the Spring module to perceive it, so it is difficult to dynamically adjust these configuration parameters. Usually, the beans can only be changed through refresh operations. This process requires clearing all beans in the Spring module, and then re-reading the new configuration information to generate business components, resulting in excessive resource consumption.
[0040] Based on this, an embodiment of the present application provides a hot update method, which monitors whether the configuration information corresponding to the Spring module changes during the operation of the Spring module; when it is monitored that the configuration information of the Spring module changes, the change characteristic value corresponding to the changed configuration information is obtained; based on the changed configuration information and the corresponding change characteristic value, the Spring module is hot updated; in this way, by monitoring the configuration information corresponding to the Spring module, the change of its configuration information can be timely known, and then the Spring module can be hot updated using the changed configuration information, so that the update of local components can be achieved without restarting the Spring module, thereby reducing resource consumption during the update process of the Spring module.
[0041] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0042] In one embodiment provided in this application, see Figure 1 , which shows a schematic diagram of a hot update method provided in an embodiment of the present application. Figure 1 As shown, the method may include:
[0043] S101: During the operation of the Spring module, monitoring whether the configuration information corresponding to the Spring module changes;
[0044] It should be noted that the Spring module is equivalent to the core container in the Spring framework. When the Spring module is initialized, it will generate beans according to the configuration information and store them in memory for use. After initialization, the running Spring module no longer perceives the configuration information, so the modification of the configuration information by the developer / user at this time will not take effect on the Spring module. Therefore, to implement hot update of the Spring module, it is necessary to monitor the changes of the Spring configuration information first.
[0045] It should be noted that configuration information is equivalent to the blueprint for the Spring module to produce beans and inject relationships. It is the basis of the Spring module. Without configuration information, the Spring module will not be generated. For the Spring module, the implementation of configuration information is diverse, such as XML configuration files, JAVA configuration and annotation configuration.
[0046] It should be noted that for a distributed environment, configuration information is shared by multiple applications. There are many specific ways to implement sharing, such as the distributed configuration center (Disconf) and unified microservice configuration management (SpringCloudConfig).
[0047] It should also be noted that in actual applications, developers / users modify the configuration information of the Spring module in a continuous process, which means that a modification may last for 5 minutes or 10 minutes. At this time, if the server starts to obtain the changed configuration information and then performs a hot update as soon as it senses a slight change in the configuration information, it will obviously bring too much processing and unnecessary load to the machine.
[0048] Based on this, this problem can be solved from two perspectives, one is conditional restriction, and the other is time restriction. Specifically, under conditional restrictions, when the developer / user has finished modifying the configuration information, a predetermined signal will be triggered. The specific process can be that the processor automatically triggers the signal after recognizing the save operation after the developer / user has completed the modification, or it can be that the developer / user manually triggers the signal after the modification. When the module responsible for hot update receives this signal, it is considered that the configuration information has changed, and then the changed configuration information is obtained to start the hot update of the Spring module, thereby realizing the monitoring of whether the configuration information corresponding to the Spring module has changed; under the condition of time restrictions, the task of "monitoring configuration information" is essentially "detecting whether the configuration information has changed within a certain period of time". Of course, other forms can also be used to realize the process of monitoring changes in configuration information.
[0049] In some embodiments, before step S101, the method may further include:
[0050] Determine whether configuration data is stored in the preset storage area; wherein the configuration data includes configuration information corresponding to the Spring module and a characteristic value corresponding to the configuration information;
[0051] When configuration data is stored in the preset storage area, monitoring whether the configuration information corresponding to the Spring module changes;
[0052] When no configuration data is stored in the preset storage area, obtaining initial configuration information corresponding to the Spring module, performing characteristic value calculation on the initial configuration information, and determining an initial characteristic value corresponding to the initial configuration information;
[0053] The initial configuration information and the corresponding initial characteristic value are determined as configuration data, and the configuration data is stored in the preset storage area.
[0054] It should be noted that the hot update method provided in this embodiment can be implemented in a distributed environment, that is, the configuration information can be shared by multiple systems, and the preset storage area is a space for accessing configuration information that can be shared by multiple devices. The implementation method of the preset storage area can be a storage space provided by Disconf, SpringCloud Config or a database. Of course, the sharing function of the preset storage area is not a restrictive condition of the preset storage area. If it is applied to a non-distributed environment and the configuration information is only read by a single processor, then the preset storage area has no sharing function, and this method is also covered within the protection scope of this application.
[0055] In the preset storage area, configuration data consisting of configuration information and characteristic values corresponding to the configuration information are specifically stored. Among them, the characteristic values corresponding to the configuration information are obtained after processing the configuration information. In other words, when the configuration information of the Spring module is stored in the preset storage area, the configuration information needs to be calculated to obtain the corresponding characteristic value. The characteristic value can be one or more. Generally speaking, one Bean corresponds to one characteristic value.
[0056] It should also be noted that when the Spring module is started for the first time, the corresponding configuration data has not been stored in the preset storage area. It is necessary to obtain the initial configuration information corresponding to the Spring module and the initial characteristic value corresponding to the initial configuration information, store them in the preset storage area, and then monitor whether the configuration information corresponding to the Spring module has changed.
[0057] S102: when it is detected that the configuration information of the Spring module has changed, obtaining a change characteristic value corresponding to the changed configuration information;
[0058] It should be noted that for the Spring module, the granularity of the process of monitoring changes in configuration information cannot reach the level of each attribute in each Bean. In fact, the monitoring granularity is generally at the module level, and it is even difficult to reach the file level. Specifically, if the Spring module adopts the configuration form of XML configuration files, then a configuration file may record the specific configuration information of multiple beans. At this time, considering the issues of efficiency and processing volume, the configuration information can be monitored by monitoring whether the configuration file has changed. At this time, when a configuration file changes, it may be that only one Bean recorded in it has changed, or several Beans have changed; so for the changed configuration information, a quick method is still needed to further determine the changed Beans and the corresponding types of changes. This method is implemented through characteristic values.
[0059] Specifically, in some embodiments, the step S102 may specifically include:
[0060] Extract the attribute string in the changed configuration information;
[0061] Performing hash value calculation on the attribute string to obtain a hash value corresponding to the attribute string;
[0062] The hash value corresponding to the attribute character string is determined as the change characteristic value corresponding to the changed configuration information.
[0063] It should be noted that hash value is generally translated as hash, hash, or transliterated as hash, which is to transform an input of arbitrary length into an output of fixed length through a hash algorithm, and the output is the hash value. This conversion is a compression mapping, that is, the space of hash values is usually much smaller than the space of inputs, and different inputs may hash to the same output, so it is impossible to determine the unique input value from the hash value, but it can reflect the change of the input value. Simply put, it is a function that compresses a message of arbitrary length into a fixed-length message digest. By using the hash value of the Bean corresponding to the configuration information before and after the change, the changed Bean can be quickly determined, making the changed configuration information easier to retrieve and compare, greatly reducing the processing capacity of the machine.
[0064] In actual use, when the Spring module is first started, the attribute entries corresponding to a Bean in the configuration information can be extracted, and the field values corresponding to the Bean's identifier and class attributes can be directly stored (because the class determines the type of change), and then all the Bean's attribute entries can be extracted as an attribute string, a hash value is calculated for the attribute string, and the calculated hash value is used as an independent field of the attribute entry, and stored together in the preset storage area as configuration data. When the configuration information contains configuration information of multiple beans, each Bean will correspond to an identifier, a class attribute and a hash value, so the configuration information will correspond to multiple hash values. Afterwards, each time the changed configuration information is obtained, the attributes in the changed configuration information are also extracted and the hash value is calculated, and stored in the preset storage area together with the changed configuration information.
[0065] In this way, in the subsequent comparison process, by simply comparing the hash value in the configuration information in the preset storage area with the hash value in the changed configuration information, it is possible to determine whether the corresponding Bean has changed; specifically, if the two hash values are the same, the Bean has not changed; if the two hash values are different, the Bean must have changed, and the specific object corresponding to the Bean in the Spring module needs to be hot updated.
[0066] It should also be noted that for each Bean, there may be multiple attribute entries. For ease of processing, the embodiment of the present application extracts the strings of all attribute entries into one string to calculate the hash value. If the string of each attribute entry calculates the hash value separately, it is also covered within the protection scope of the embodiment of the present application.
[0067] S103: Based on the changed configuration information and the corresponding changed characteristic value, hot update the Spring module.
[0068] It should be noted that, based on the changed configuration information and the corresponding changed characteristic values, the Spring module can be hot-updated, and the specific hot-updating can be performed through the preset function of the Spring module.
[0069] Specifically, in some embodiments, step S103 may include:
[0070] Determining the changed configuration information and the corresponding changed characteristic value as changed configuration data, and storing the changed configuration data in the preset storage area;
[0071] Based on the configuration data in the preset storage area and the changed configuration data, the Spring module is hot updated.
[0072] It should be noted that, as mentioned above, the changed configuration data needs to be compared with the original configuration data before the change, so as to determine the specific Bean that has changed. Therefore, the changed configuration information and the corresponding characteristic values can be stored in a preset storage area containing the configuration data. By comparing the characteristic values, the specific Bean that has changed can be determined and then hot updated.
[0073] It should also be noted that after determining the changed Bean, the corresponding object in the Spring module can be obtained (the object is obtained by instantiating the Bean), and then the object is modified to complete the hot update of the Spring module. Here, the configuration data may represent the original configuration information when the Spring module is initialized, or it may represent the configuration information after the last modification.
[0074] It should also be noted that in the process of determining the changed configuration information and the corresponding changed characteristic values as the changed configuration data and storing them in the preset storage area, the configuration information can be streamlined, and the content that does not have much practical significance or is repeated can be deleted, and only the required content is retained, which can improve the storage efficiency of the preset storage area and reduce the processing volume.
[0075] Furthermore, in some embodiments, after step S103, the method may further include:
[0076] In the preset storage area, the configuration data is updated based on the changed configuration data.
[0077] It should be noted that after the Spring module is hot-updated, the configuration data needs to be updated based on the changed configuration data. That is, after the hot-update is completed, the changed configuration data overwrites the configuration data, and the changed configuration data is deleted. In this way, the preset storage area is still the same as before, and only one set of configuration data corresponding to the Spring module is stored.
[0078] This embodiment provides a hot update method, which monitors whether the configuration information corresponding to the Spring module changes during the operation of the Spring module; when it is monitored that the configuration information of the Spring module changes, obtains the change characteristic value corresponding to the changed configuration information; based on the changed configuration information and the corresponding change characteristic value, the Spring module is hot updated; in this way, by monitoring the configuration information corresponding to the Spring module, the change of its configuration information can be known in time; then the changed configuration information is used to hot update the Spring module, thereby realizing the update of local components without restarting the Spring module, reducing resource consumption during the update process of the Spring module.
[0079] In another embodiment provided in this application, see Figure 2 , which shows a flow chart of another hot update method provided in an embodiment of the present application, such as Figure 2 , the method may include:
[0080] S201: Determine a first object tag corresponding to a characteristic value in the configuration data and a second object tag corresponding to a changed characteristic value in the changed configuration data;
[0081] It should be noted that in this application, the configuration data and the modified configuration data will be uniformly stored in the preset storage area, that is, the hot update of the Spring module is performed according to the information in the preset storage area. The compilation principle of the Spring module is mainly to generate beans through configuration information, and then each bean instantiates a specific object, and then the specific object provides WEB services to users. In other words, the hot update of the Spring module is essentially the modification of the object, so if you want to perform a hot update of the Spring module, you need to first use the information in the preset storage area to determine the objects that have changed in the Spring module.
[0082] It should also be noted that each object in the Spring module has a unique object tag, which is an identity document (ID); as mentioned above, for each Bean, the specific storage information includes identification, class attributes and characteristic values, and the object tag is reflected as the Bean's identification in the configuration data. For the changed configuration data, its quantity and content are not equal to the original configuration data, so it is necessary to first determine the object tags (first object tag and second object tag) in the configuration data and the changed configuration data, and then compare the contents under the same object tag.
[0083] S202: Based on the first object tag and the second object tag, determine the object that has changed in the Spring module, and determine the update method corresponding to the changed object; wherein the update method includes a first update and a second update, the first update is used to indicate that the class information of the object has changed, and the second update is used to indicate that the attribute information of the object has changed;
[0084] It should be noted that after the object label is determined, for the same object label, the characteristic value in the changed configuration data corresponding to the object label is compared with the characteristic value of the original configuration data. When the two characteristic values are different, it can be determined that the object indicated by the object label has changed.
[0085] It should be noted that the characteristic value is calculated based on the attribute information of each Bean in order to uniquely identify the attribute information of the Bean. That is to say, the characteristic value and the string column of the attribute entry are one-to-one corresponding. If the value of any parameter in the attribute entry is modified, the characteristic value will change, and this can be used to determine whether the attribute value of the entry has changed.
[0086] It should be noted that for the Spring module, the information contained in the configuration information can be divided into two levels, namely class information and attribute information. Among them, class information is mainly used to indicate different beans, that is, different objects, and attribute information is used to indicate the specific attribute information of the object. On this basis, the hot update of the Spring module can be divided into two types. One is the change of attribute information, that is, the object in the Spring module is still the object created by the Spring module before, but some parameters of the object are overwritten, which is called the first update; the other is the change of class information. The Spring module needs to reload the class and regenerate the object, which is called the second update. Since the operation logic of these two replacements is different, it is necessary to first determine whether the object that needs to be modified is a class replacement or an attribute replacement. In actual use, a task may include the modification of multiple objects. Some objects only have attribute modifications, while some objects need to be reloaded. In this case, there are multiple loop judgments and loop updates.
[0087] It should be noted that in actual use, the class information can be specifically the field value of the object's class attribute. Specifically, for the object that has been determined to have changed, the field value of the object's class attribute is taken out and compared with the class field value of the changed object. If the field values of the class attribute are inconsistent, it means that the class referenced by the object to be updated has changed, that is, the update method of the object is the first update; if the field values of the class attribute are consistent, it means that the class referenced by the object has not changed, then the attribute information of the object has changed, that is, the update method of the object is the second update.
[0088] S203: Based on the determined update method, hot update the changed objects in the Spring module.
[0089] It should be noted that after determining the update method of each object, hot update is performed on the changed objects in the Spring module according to the update process corresponding to the update method.
[0090] Different update logics exist according to different update methods. Specifically, in some embodiments, after step S202, the method may further include:
[0091] When the update mode of the changed object is a first update, a first update event is issued; wherein the first update event includes an object tag of the changed object;
[0092] Accordingly, the step S203 may specifically include:
[0093] When the Spring module detects the first update event, it determines the first object to be updated based on the object tag of the changed object included in the first update event, generates an updated object based on the changed configuration data, and replaces the first object to be updated with the generated updated object;
[0094] It should be noted that the hot update of the Spring module in this embodiment is completed with the help of the preset function in the Spring module, that is to say, there is a preset function in the Spring framework specifically for generating or modifying objects according to configuration information, and the specific process of hot update can be completed through this preset function. However, the series of processes of monitoring the changes of configuration information, processing, storing, comparing and analyzing the configuration information in the aforementioned steps are controlled by a separate tool or module, so after determining the objects to be updated and the update method of the objects, it is necessary to notify the Spring module through a certain mechanism, and then the preset function in the Spring module can be updated. In this embodiment, an event monitoring mechanism is used to complete this process. That is to say, when it is determined that the object needs to be updated for the first time, the first update event is released, and when the Spring module monitors this update event, the preset function will be called to perform a specific update process. Here, the event monitoring mechanism of the Spring module can refer to the native monitoring mechanism of java. When the Spring module is started, the framework of the event monitoring mechanism is built, including event listener registration, event broadcaster initialization, etc.
[0095] It should also be noted that when the Spring module listens to the first update event, it will enter the class update logic, that is, use the object tag in the first update event to obtain the object to be updated, and replace the object to be updated with a new object generated by the changed configuration data.
[0096] Furthermore, in some embodiments, after step S202, the method may further include:
[0097] When the update mode of the changed object is a second update, a second update event is issued; wherein the second update event includes an object tag of the changed object;
[0098] Accordingly, the step S203 may include:
[0099] When the Spring module detects the second update event, it determines the second object to be updated based on the object tag of the changed object included in the second update event, and modifies the parameters of the second object to be updated based on the changed configuration data.
[0100] It should be noted that when the Spring module listens to the second update event, it will enter the logic of property update, that is, use the object tag in the second update event to get the object to be updated, and use the changed configuration data to modify the properties of the object to be updated.
[0101] This embodiment provides a hot update method, and elaborates on the specific implementation of the above embodiment. It can be seen that by monitoring the configuration information corresponding to the Spring module, the change of the configuration information can be timely known; then the Spring module is hot updated using the changed configuration information, so that the local component is updated without restarting the Spring module, and the resource consumption of the Spring module update process is reduced. .
[0102] In another embodiment provided in this application, see Figure 3 , which shows a flow chart of another hot update method provided in an embodiment of the present application, such as Figure 3 , the hot update method may further include:
[0103] S301: Start the timer and start timing;
[0104] It should be noted that, in this embodiment, the configuration information of the Spring module is implemented through an XML configuration file; that is, corresponding to one Spring module, there are one or more separate XML files, in which the configuration information of the Spring module is stored.
[0105] It should be noted that during the hot update process of the Spring module, the change of configuration information can be determined by a scheduled task. Specifically, the scheduled task is started after the Spring module is started, and the preset storage area is scanned at intervals. There are two situations here. The first is when it is loaded for the first time. At this time, there is no configuration data in the preset storage area. It is necessary to obtain the initial configuration data according to the initial configuration file and then store it in the preset storage area; the second is that there is configuration data stored in the preset storage area. At this time, the changed configuration information needs to be processed and stored in the preset storage area.
[0106] It should also be noted that scheduled tasks can be completed through timers. Timers can be written by themselves or use existing encapsulation tools, such as Quartz. Quartz is an open source project of the open source organization Open Symphony in the field of task scheduling, which is completely implemented based on the Java language. As an enterprise-level scheduled task scheduler, Quartz not only has powerful scheduling functions, but also supports various flexible application methods, and supports distributed and cluster capabilities at the same time. In a distributed environment, multiple threads performing read and write operations involve thread safety issues, so Quartz is used for control to prevent conflicts. Specifically, an application in the Spring module corresponds to a table, and the configuration of a Bean corresponds to a record in the table.
[0107] It should also be noted that the preset duration is the timing interval of the timer. For example, if the preset duration is 10 minutes, then during the life cycle of the Spring module, a judgment needs to be made and the corresponding steps need to be executed every 10 minutes.
[0108] S302: When the timing duration of the timer reaches a preset duration, determining whether configuration data is stored in a preset storage area;
[0109] It should be noted that, for scheduled tasks, depending on whether configuration data is stored in the preset storage area, there are two specific tasks, namely, the aforementioned "when configuration data is stored in the preset storage area, monitor whether the configuration information corresponding to the Spring module changes" and "when configuration data is not stored in the preset storage area, obtain the initial configuration information corresponding to the Spring module, perform eigenvalue calculation on the initial configuration information, and determine the initial eigenvalue corresponding to the initial configuration information".
[0110] It should be noted that in the first timed task, that is, when the Spring module is just started, there is no configuration data in the preset storage area, so it is necessary to obtain the configuration data. In this embodiment, the configuration information of the Spring module exists in the form of a configuration file, so it is necessary to obtain the initial configuration file of the Spring module at this time, and then parse it to obtain the initial configuration information.
[0111] It should also be noted that the process of parsing the configuration file to obtain configuration information can be performed using a packaged parsing tool, such as dom4j. dom4j is an application interface for Java XML configuration files, which is used to read and write XML files. It has excellent performance, powerful functions and is extremely easy to use. The work of parsing the configuration file is handed over to dom4j. When parsing the configuration file, dom4j parses a Bean tag (corresponding to a Spring object) into a table record. In general, it is the Bean ID (equivalent to the object tag), the class attribute is used as a separate field, and all the attributes of the Bean are extracted into a string as a separate table field. The attributes of the Bean are stored in the form of key-value pairs, and different key-value pairs are separated by semicolons. Among them, the original reason why the class attribute is used as a field alone is that it is used to indicate the update method of the object, and other attribute values do not affect the determination of the update method of the object. In other words, if the class attribute changes, the update method of the object is the aforementioned first update, and if the class attribute does not change, only other attributes change, the update method of the object is the aforementioned second update.
[0112] It should be noted that, in the embodiment of the present application, the preset storage area is managed by a MySQL database (a relational database), that is, all configuration information is stored in the same database to facilitate confirmation of modifications to the configuration information.
[0113] S303: When the timing duration of the timer reaches a preset duration and it is determined that the preset storage area stores configuration data, monitor whether the configuration file corresponding to the Spring module changes through a file monitor;
[0114] It should be noted that monitoring whether the configuration file corresponding to the Spring module has changed actually involves the perception of file changes, which requires a separate background thread to perceive the changes. This background thread can be written by yourself or a packaged Java tool such as WatchService, java common.io or jnotify can be used. At the same time, parsing the configuration file to obtain the changed configuration information can also be implemented using a packaged Java tool.
[0115] In this embodiment, WatchService is used as a file listener. WatchService is an efficient file monitor, and the file listener native to the operating system is used internally. Since WatchService uses a file listener native to the operating system, the principle is file monitoring based on signal transmission and reception. It can not only monitor the changes of all files on the system, but also this monitoring does not require traversal and comparison, so the efficiency is very high. In other words, WatchService is essentially a background thread that monitors the signals sent by file changes and makes corresponding processing. When the Spring module is loaded for the first time, the table is still empty. At this time, the configuration file is directly parsed for warehousing operations. After the first load, WatchService is used to monitor the changes of the file. If the file changes, the data in the table is updated.
[0116] It should also be noted that after the configuration data is stored in the database, the monitoring result of the file listener will be used to determine whether the configuration file corresponding to the Spring module has changed at each time node of the timer. In other words, after the file listener is turned on, the monitoring result of the file listener will be obtained every time the timer reaches a time node, and the configuration file corresponding to the Spring module will be determined based on the monitoring result, thereby realizing the monitoring of the configuration information.
[0117] S304: When it is monitored that the configuration file corresponding to the Spring module has changed, the configuration file is parsed to obtain the changed configuration information.
[0118] It should be noted that, since the present embodiment obtains the changed configuration information by changing the configuration file, the configuration file needs to be parsed after it changes to obtain the changed configuration information. As mentioned above, parsing the configuration file can also be performed using a packaged parsing component, such as dom4j.
[0119] This embodiment provides a hot update method and elaborates on the specific implementation of the aforementioned embodiment. It can be seen that by monitoring the configuration information corresponding to the Spring module, the changes in the configuration information can be timely known; then the Spring module is hot updated using the changed configuration information, thereby realizing the update of local components without restarting the Spring module, reducing resource consumption during the Spring module update process, and improving the flexibility of the Spring module update.
[0120] In yet another embodiment of the present application, see Figure 4 , which shows a flow chart of another hot update method provided in an embodiment of the present application, such as Figure 4 As shown, the method may include:
[0121] S401: The scheduled task starts;
[0122] It should be noted that the scheduled task starts after the Spring module is started, and scans the preset storage area at an interval frequency. The scheduled task can be performed by the packaged timer quartz.
[0123] S402: Determine whether there is a corresponding configuration table in the MySQL database;
[0124] For step S402, if the judgment result is no, execute step S403; if the judgment result is yes, execute step S404;
[0125] It should be noted that in each scheduled task, it is necessary to determine whether a configuration table is stored in the preset storage area, so as to determine the subsequent process. Generally speaking, a Spring module may correspond to multiple specific applications, and each application corresponds to a configuration table. In this embodiment, the preset storage area is specifically implemented through a MySQL database.
[0126] S403: Generate a corresponding configuration table, use dom4j to generate data to fill in the configuration table, generate a corresponding hash value, and record it in the MySQL database;
[0127] It should be noted that when there is no corresponding configuration table in the MySQL database, dom4j is needed to parse the original configuration file to generate the data of the configuration table, and calculate the hash value of the attribute string therein, which is stored in the MySQL database accordingly.
[0128] It should also be noted that the data that fills the configuration table may include multiple forms. For example, for an object, the filling data includes an object ID and a hash value (calculated from the attribute string); or for an object, the filling data includes an object ID, a class attribute value, and a hash value; or, for an object, the filling data includes an object ID, multiple specific attribute values, and a hash value. These can be flexibly set according to requirements. In this embodiment, the data that fills the configuration table are mainly object IDs, class attribute values, and hash values.
[0129] S404: Monitor file changes through WatchService;
[0130] It should be noted that WatchService is a file listener, which will continuously monitor file changes when it is turned on. For scheduled tasks, when the configuration table is stored in the MySQL database, it will periodically obtain the monitoring results of WatchService at each subsequent time node.
[0131] S405: Determine whether a file change is detected:
[0132] For step S405, if the judgment result is yes, then execute S405, if the judgment result is no, end;
[0133] It should be noted that if no file changes are detected, no other actions are required, the process ends, and the next start time of the scheduled task is waited for.
[0134] S406: Use dom4j to parse the configuration file and generate new configuration records into the MySQL database.
[0135] It should be noted that if the file is monitored to change, the configuration file needs to be parsed again to generate a new configuration record for storage comparison, so as to provide corresponding parameters for subsequent hot updates. At the same time, the process of generating a new configuration record also includes the calculation process of the hash value.
[0136] See also Figure 5 , which shows a schematic diagram of the architecture of a hot update method provided in an embodiment of the present application. Figure 5As shown, the architecture of the hot update method mainly includes Watchservice (file listener), MySQL database (preset storage area), Quartz job (timer) and multiple Applications (applications corresponding to Spring modules), where multiple Applications are created by the same Spring module. Among them, WatchService and Quartz job jointly realize the monitoring of configuration files corresponding to multiple Applications. When a modification is detected, the modified file is parsed to obtain the configuration information and stored in the MySQL database, and the Spring module performs hot updates based on the MySQL database.
[0137] This embodiment provides a hot update method and elaborates on the specific implementation of the aforementioned embodiment. It can be seen that by monitoring the configuration information corresponding to the Spring module, the changes in the configuration information can be timely known; then the Spring module is hot updated using the changed configuration information, thereby realizing the update of local components without restarting the Spring module, thereby reducing resource consumption during the Spring module update process.
[0138] In yet another embodiment of the present application, see Figure 6 , which shows a flow chart of another hot update method provided in an embodiment of the present application, such as Figure 6 As shown, the method may include:
[0139] S501: traverse the configuration table;
[0140] It should be noted that the scheduled task in the previous embodiment is responsible for loading the data of the configuration file into the database. At this point, a separate task is needed to perceive the changes in the data table and react this change to the Spring module in a timely manner. An event monitoring mechanism can be adopted here, that is, after the scheduled task updates the data of the configuration file to the database, a custom event is issued, and this event is perceived by a custom listener. After the listener is triggered, a table lookup is started in the database, and the configuration data (mainly class attribute values and hash values) of different objects are compared in turn according to the object ID. In other words, traversing the configuration table is to compare the original configuration data in the configuration table with the changed configuration data.
[0141] S502: Determine whether the class value of the object is consistent with the configuration item;
[0142] For step S502, if the judgment result is yes, execute S503, if the judgment result is no, execute S506;
[0143] It should be noted that for the Spring module, it is necessary to determine the object to be updated and the corresponding update method, so it is necessary to determine whether the class field value of the object has changed. If the class field value has changed, the class needs to be updated. If the class field value has not changed, the property needs to be updated. These two updates require different logics.
[0144] It should also be noted that, here, for each object, the class attribute value is judged first, and then the hash value is judged; of course, if the hash value is compared first, and then the class attribute value is compared, it is also possible.
[0145] S503: Determine whether the hash value of the object has changed;
[0146] Here, for step S503, if the judgment result is yes, then execute S504, if the judgment result is no, then execute S508;
[0147] It should be noted that when the class field value of an object is consistent with the configuration item, proving that the class information of the object has not changed, it is necessary to determine whether the other attribute values of the object are consistent based on the hash value, and then determine the attribute value that needs to be replaced;
[0148] S504: Publish attribute update event;
[0149] It should be noted that after the changed attribute is determined, an attribute update event is published; wherein the attribute update event and the corresponding monitoring mechanism are agreed and structured in advance. In addition, the attribute update event includes the update content and object ID of the object to be updated.
[0150] S505: Get the object in the Spring module, reset the properties, and execute S508;
[0151] It should be noted that when the Spring module listens to the property update event, it obtains the object through the object ID in the property update event and resets the properties.
[0152] S506: publishing class update event;
[0153] It should be noted that when the class field value of an object is inconsistent with the configuration item, it means that the class needs to be replaced and a class update event is published; similarly, the class update event includes the update content and object ID of the object to be updated.
[0154] S507: Load the class, generate a new object, destroy the old object, modify the class field value of the configuration record, and set the properties of the new object according to the configuration item;
[0155] It should be noted that when the class attribute of an object is modified, the object in the Spring module must be destroyed, the new class must be reloaded, the object must be generated, and the class attribute value must be modified in the configuration record.
[0156] S508: Overwrite the old hash value with the new hash value.
[0157] It should be noted that, in actual applications, S508 includes two situations. If the hash value of the object changes, the old hash value needs to be deleted and replaced by the new hash value. If the hash value does not change, the new and old hash values are the same, and overwriting can be understood as deleting the latter hash value.
[0158] This embodiment provides a hot update method and elaborates on the specific implementation of the aforementioned embodiment. It can be seen that by monitoring the corresponding configuration information of the Spring module, the changes in the configuration information can be timely known; then the Spring module is hot updated using the changed configuration information, thereby realizing the update of local components without restarting the Spring module, thereby reducing resource consumption during the Spring module update process.
[0159] In another embodiment of the present application, see Figure 7 , which shows a schematic diagram of the composition structure of a heat update device 60 provided in an embodiment of the present application. Figure 7 As shown, the thermal update device 60 may include a monitoring unit 601, an acquisition unit 602 and an update unit 603, wherein:
[0160] A monitoring unit 601 is configured to monitor whether the configuration information corresponding to the Spring module changes;
[0161] The acquisition unit 602 is configured to acquire a change characteristic value corresponding to the changed configuration information when it is detected that the configuration information of the Spring module has changed;
[0162] The updating unit 603 is configured to perform hot update on the Spring module based on the changed configuration information and the corresponding changed characteristic value.
[0163] In the above scheme, see Figure 8The hot update device 60 may also include a pre-storage unit 604, configured to determine whether configuration data is stored in a preset storage area; wherein the configuration data includes configuration information corresponding to the Spring module and a characteristic value corresponding to the configuration information; when configuration data is stored in the preset storage area, the step of monitoring whether the configuration information corresponding to the Spring module has changed is performed; accordingly, based on the changed configuration information and the corresponding changed characteristic value, the Spring module is hot updated, including: determining the changed configuration information and the corresponding changed characteristic value as the changed configuration data, and storing the changed configuration data in the preset storage area; based on the configuration data in the preset storage area and the changed configuration data, the Spring module is hot updated.
[0164] In the above scheme, the pre-storage unit 604 can also be configured to obtain the initial configuration information corresponding to the Spring module when no configuration data is stored in the preset storage area, perform eigenvalue calculation on the initial configuration information, and determine the initial eigenvalue corresponding to the initial configuration information; and the corresponding initial eigenvalue; determine the initial configuration information and the corresponding initial eigenvalue as configuration data, and store the configuration data in the preset storage area.
[0165] In the above scheme, the update unit 603 can also be configured to determine a first object tag corresponding to a characteristic value in the configuration data and a second object tag corresponding to a characteristic value in the changed configuration data; wherein the object tag is used to indicate different objects in the Spring module; based on the first object tag and the second object tag, determine the changed objects in the Spring module; determine the update method of the changed objects; wherein the update method includes a first update and a second update, the first update is used to indicate that the class information of the object has changed, and the second update is used to indicate that the attribute information of the object has changed; based on the determined update method, the changed objects in the Spring module are hot updated.
[0166] In the above scheme, see Figure 8 The hot update device 60 may further include a parameter unit 605 configured to update the configuration data in the preset storage area based on the changed configuration data.
[0167] In the above scheme, the acquisition unit 602 can also be configured to extract the attribute string in the changed configuration information; perform hash value calculation on the attribute string to obtain the hash value corresponding to the attribute string; and determine the hash value corresponding to the attribute string as the change feature value corresponding to the changed configuration information.
[0168] In the above scheme, the pre-storage unit 604 can also be configured to start a timer and start timing; when the timing duration of the timer reaches a preset duration, the step of determining whether configuration data is stored in the preset storage area is executed.
[0169] In the above scheme, when the timing duration of the timer reaches the preset duration and it is determined that the preset storage area stores configuration data, the monitoring unit 601 can also be configured to determine whether the configuration file corresponding to the Spring module has changed through a file listener; when it is detected that the configuration file corresponding to the Spring module has changed, the configuration file is parsed to obtain the changed configuration information, so as to implement the step of monitoring whether the configuration information corresponding to the Spring module has changed.
[0170] It can be understood that in this embodiment, a "unit" can be a part of a circuit, a part of a processor, a part of a program or software, etc., and of course it can also be a module, or it can be non-modular. Moreover, the components in this embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional module.
[0171] If the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0172] Therefore, this embodiment provides a computer storage medium, which stores a hot update program. When the hot update program is executed by at least one processor, the steps of the method described in any one of the above embodiments are implemented.
[0173] Based on the composition of the above-mentioned thermal update device 60 and the computer storage medium, see Fig. 9, which shows a specific hardware structure example of a hot update device 60 provided in an embodiment of the present application, which may include: a communication interface 701, a memory 702 and a processor 703; each component is coupled together through a bus system 704. It can be understood that the bus system 704 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 704 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, in Fig. 9 In FIG. 7 , various buses are labeled as bus system 704. Among them,
[0174] Communication interface 701, used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0175] A memory 702, used to store a computer program that can be run on the processor 703;
[0176] The processor 703 is configured to execute, when running the computer program:
[0177] During the operation of the Spring module, monitor whether the configuration information corresponding to the Spring module changes;
[0178] When it is detected that the configuration information of the Spring module has changed, a change characteristic value corresponding to the changed configuration information is obtained;
[0179] Based on the changed configuration information and the corresponding changed characteristic values, the Spring module is hot updated.
[0180] It can be understood that the memory 702 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DRRAM). The memory 702 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0181] The processor 703 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 703. The above processor 703 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (APPlication Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor are combined and executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 702, and the processor 703 reads the information in the memory 702 and completes the steps of the above method in combination with its hardware.
[0182] It is understood that the embodiments described in the present application can be implemented by hardware, software, firmware, middleware, microcode or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application or a combination thereof.
[0183] For software implementation, the technology described in this application can be implemented by a module (e.g., a procedure, a function, etc.) that performs the functions described in this application. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0184] Optionally, as another embodiment, the processor 703 is further configured to execute the steps of the method described in any one of the aforementioned embodiments when running the computer program.
[0185] Based on the composition and hardware structure of the above-mentioned hot update device 60, see Fig.10 , which shows a hot update system 80 provided in an embodiment of the present application, wherein the hot update system 80 includes at least a hot update device 60, which can timely obtain changes in configuration information by monitoring the corresponding configuration information of the Spring module; and then use the changed configuration information to hot update the Spring module, thereby realizing the update of local components without restarting the Spring module, thereby reducing resource consumption during the update process of the Spring module.
[0186] It should be noted that, in this application, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0187] 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.
[0188] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0189] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0190] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0191] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A hot update method, characterized in that: The method comprises: During the operation of the Spring module, it is determined whether configuration data is stored in the preset storage area; wherein the configuration data includes configuration information corresponding to the Spring module and a characteristic value corresponding to the configuration information; When configuration data is stored in the preset storage area, monitoring whether the configuration information corresponding to the Spring module changes; When it is detected that the configuration information of the Spring module has changed, a change characteristic value corresponding to the changed configuration information is obtained; Determining the changed configuration information and the corresponding changed characteristic value as changed configuration data, and storing the changed configuration data in the preset storage area; Determine a first object tag corresponding to the characteristic value in the configuration data and a second object tag corresponding to the changed characteristic value in the changed configuration data; Based on the first object tag and the second object tag, determine the object that has changed in the Spring module, and determine the update method corresponding to the changed object; wherein the update method includes a first update and a second update, the first update is used to indicate that the class information of the object has changed, and the second update is used to indicate that the attribute information of the object has changed; Based on the determined update mode, hot update is performed on the changed objects in the Spring module.
2. The hot update method according to claim 1, characterized in that: After determining whether the configuration data is stored in the preset storage area, the method further includes: When no configuration data is stored in the preset storage area, obtaining initial configuration information corresponding to the Spring module, performing characteristic value calculation on the initial configuration information, and determining an initial characteristic value corresponding to the initial configuration information; The initial configuration information and the corresponding initial characteristic value are determined as configuration data, and the configuration data is stored in the preset storage area.
3. The hot update method according to claim 1, characterized in that: After hot updating the Spring module based on the configuration data in the preset storage area and the changed configuration data, the method further includes: In the preset storage area, the configuration data in the preset storage area is updated based on the changed configuration data.
4. The hot update method according to claim 1, characterized in that: The obtaining the change characteristic value corresponding to the changed configuration information includes: Extract the attribute string in the changed configuration information; Performing hash value calculation on the attribute string to obtain a hash value corresponding to the attribute string; The hash value corresponding to the attribute character string is determined as the change characteristic value corresponding to the changed configuration information.
5. The hot update method according to any one of claims 1 or 2, characterized in that: Before monitoring whether the configuration information corresponding to the Spring module changes, the method further includes: Start the timer and count down; When the timing duration of the timer reaches the preset duration, the step of determining whether configuration data is stored in the preset storage area is executed.
6. The hot update method according to claim 5, characterized in that: When the timing duration of the timer reaches a preset duration and it is determined that the preset storage area stores configuration data, the method further includes: Monitor whether the configuration file corresponding to the Spring module changes through the file listener; When a change in the configuration file corresponding to the Spring module is detected, the configuration file is parsed to obtain the changed configuration information, so as to implement the step of monitoring whether the configuration information corresponding to the Spring module has changed.
7. A thermal update device, characterized in that: The hot update device includes a pre-storage unit, a monitoring unit, an acquisition unit and an update unit; wherein, A pre-storage unit is configured to determine whether configuration data is stored in a preset storage area during the operation of the Spring module; wherein the configuration data includes configuration information corresponding to the Spring module and a characteristic value corresponding to the configuration information; The monitoring unit is configured to monitor whether the configuration information corresponding to the Spring module changes; The acquisition unit is configured to acquire a change characteristic value corresponding to the changed configuration information when a change is detected in the configuration information of the Spring module; The update unit is configured to determine the changed configuration information and the corresponding changed characteristic value as the changed configuration data, and store the changed configuration data in the preset storage area; determine the first object tag corresponding to the characteristic value in the configuration data and the second object tag corresponding to the characteristic value in the changed configuration data; wherein the object tag is used to indicate different objects in the Spring module; based on the first object tag and the second object tag, determine the changed object in the Spring module; determine the update method of the changed object; wherein the update method includes a first update and a second update, the first update is used to indicate that the class information of the object has changed, and the second update is used to indicate that the attribute information of the object has changed; based on the determined update method, hot update the changed object in the Spring module.
8. A thermal update device, characterized in that: The thermal update device includes a memory and a processor; wherein, The memory is used to store a computer program that can be run on the processor; The processor is configured to execute the steps of the method according to any one of claims 1 to 6 when running the computer program.
9. A computer storage medium, characterized in that The computer storage medium stores a thermal update program, and when the thermal update program is executed by at least one processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A hot update system, characterized in that: The heat renewal system at least comprises the heat renewal device according to claim 7 or claim 8.
Citation Information
Patent Citations
Method and system for configuration information management of proprietary cloud
CN107479863A
Configuration application method, system and device and readable storage medium
CN109992297A