DAO layer downgrading method and device
By using DAO methods with specific annotations in the application system and using an independent downgrade engine to downgrade according to the configuration file, the problem of the lack of downgrade scheme of the DAO layer in the existing technology is solved, and efficient and flexible DAO layer downgrade is achieved. Improve the execution efficiency of the application system and the reusability of the downgrade solution.
Patent Information
- Application Number
- CN202110142943.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-02
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2041-02-02
AI Technical Summary
The lack of a downgrade scheme for the DAO layer in the prior art leads to a collapse of the DAO layer when facing huge traffic, and the downgrade mechanism is coupled with the application system code, affecting efficiency and reusability.
By presetting a DAO method with specific annotations in the application system, an independent downgrade engine is used to perform downgrade processing based on the policies in the downgrade configuration file, including determining the target method, obtaining the current downgrade policy, judging the downgrade conditions, and performing downgrade processing.
It realizes flexible downgrading of the DAO layer, improves the execution efficiency of the application system, has the reusability and real-time adjustment capabilities of the downgrade solution, and can meet diversified business needs.
Smart Images

Figure CN113778980B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a DAO layer degradation method and device. Background Art
[0002] In the field of computer technology, a downgrade mechanism is generally used to deal with the situation where the server cannot support a large number of requests in a short period of time. In the current downgrade mechanism, downgrade is mainly performed on the business service layer close to the user, and there is no downgrade solution for the DAO (Data Access Object) layer acting on the database. However, in actual applications, the DAO layer also has the problem of crashing due to being unable to support huge traffic (i.e., traffic). Moreover, in the current downgrade mechanism, the application system code is often coupled with the downgrade solution code, which affects the efficiency of business execution and makes the downgrade solution difficult to adjust and not reusable. In addition, the current downgrade mechanism is generally executed at the application system level or service level, and it is impossible to perform customized flexible downgrades for specific methods within the application system. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a DAO layer degradation method and device, which can achieve decoupling from the application system and a degradation mechanism for any method of the DAO layer in the application system.
[0004] To achieve the above objective, according to one aspect of the present invention, a DAO layer degradation method is provided.
[0005] The DAO layer downgrade method of an embodiment of the present invention includes: when an application system processes an external request, a DAO method in the application system that is annotated with a preset specific annotation is determined as a target method; wherein the definition of the specific annotation includes a downgrade policy identifier corresponding to the target method; based on the downgrade policy identifier corresponding to the target method, the current downgrade policy of the target method is obtained from a preset downgrade configuration file corresponding to the application system; wherein the current downgrade policy includes a downgrade condition and a downgrade ratio; when it is determined that the external request meets the downgrade condition in the current downgrade policy, the external request is downgraded according to the downgrade ratio in the current downgrade policy.
[0006] Optionally, the method of obtaining the current downgrade policy of the target method from a preset downgrade configuration file corresponding to the application system based on the downgrade policy identifier corresponding to the target method includes: obtaining a downgrade policy set corresponding to the target method from the downgrade configuration file based on the downgrade policy identifier corresponding to the target method; wherein the downgrade policy set includes multiple downgrade policies corresponding to the target method, each of the multiple downgrade policies matches a load state of the application system; obtaining the current load state of the application system, and determining the downgrade policy in the downgrade policy set that matches the current load state as the current downgrade policy of the target method.
[0007] Optionally, the downgrade condition is a Boolean expression based on the IP address, user identifier and / or request source corresponding to the external request; and, determining whether the external request satisfies the downgrade condition in the current downgrade policy includes: calculating the Boolean expression based on the parameters of the external request; when the calculation result is true, determining that the external request satisfies the downgrade condition in the current downgrade policy.
[0008] Optionally, the downgrading processing of the external request according to the downgrade ratio in the current downgrade strategy includes: converting the user identifier carried in the external request into a hash value between 0 and 1; when the hash value is less than the downgrade ratio, returning default data to respond to the external request; when the hash value is not less than the downgrade ratio, executing the target method to respond to the external request.
[0009] Optionally, the method further includes: before the application system processes an external request, pulling the downgrade configuration file corresponding to the application system from the configuration server to the storage space where the application system is located; wherein the downgrade configuration file in the configuration server is issued, updated or deleted by the remote server.
[0010] Optionally, the DAO methods include: adding, deleting, updating and querying, and the load status of the application system includes: light load, full load and overload.
[0011] To achieve the above objective, according to another aspect of the present invention, a DAO layer degradation device is provided.
[0012] The DAO layer downgrading device of an embodiment of the present invention may include: a positioning unit, used to: when an application system processes an external request, determine the DAO method annotated by a preset specific annotation in the application system as a target method; wherein the definition of the specific annotation includes a downgrade policy identifier corresponding to the target method; a current downgrade policy acquisition unit, used to: based on the downgrade policy identifier corresponding to the target method, acquire the current downgrade policy of the target method from a preset downgrade configuration file corresponding to the application system; wherein the current downgrade policy includes a downgrade condition and a downgrade ratio; a downgrade processing unit, used to: when it is determined that the external request meets the downgrade condition in the current downgrade policy, downgrade the external request according to the downgrade ratio in the current downgrade policy.
[0013] Optionally, the current downgrade strategy acquisition unit may be further used to: acquire a downgrade strategy set corresponding to the target method from the downgrade configuration file based on the downgrade strategy identifier corresponding to the target method; wherein the downgrade strategy set includes multiple downgrade strategies corresponding to the target method, and each of the multiple downgrade strategies matches a load state of the application system; acquire the current load state of the application system, and determine the downgrade strategy in the downgrade strategy set that matches the current load state as the current downgrade strategy of the target method.
[0014] To achieve the above objective, according to another aspect of the present invention, an electronic device is provided.
[0015] An electronic device of the present invention includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the DAO layer degradation method provided by the present invention.
[0016] To achieve the above objective, according to yet another aspect of the present invention, a computer-readable storage medium is provided.
[0017] A computer-readable storage medium of the present invention stores a computer program, which, when executed by a processor, implements the DAO layer degradation method provided by the present invention.
[0018] According to the technical solution of the present invention, the embodiments of the above invention have the following advantages or beneficial effects:
[0019] When the application system processes an external request, the downgrade engine independent of the application system determines the DAO method marked with a preset specific annotation in the application system as the target method that needs to perform downgrade judgment. Thereafter, the current downgrade strategy of the target method is obtained from the downgrade configuration file corresponding to the application system according to the downgrade strategy identifier in the specific annotation definition and the current load status of the application system, and when it is determined that the external request meets the downgrade conditions in the current downgrade strategy, the target method is downgraded according to the downgrade ratio in the current downgrade strategy. Among them, the above-mentioned downgrade configuration file can be sent from the remote server to the configuration server, and then pulled from the configuration server to the local by the downgrade engine. The staff can update the downgrade strategy in the downgrade configuration file in real time on the remote server. Through the above settings, the downgrade mechanism based on the downgrade engine can be decoupled from the application system, thereby improving the execution efficiency of the application system and realizing the reusability and real-time adjustment of the downgrade plan; at the same time, a flexible downgrade plan is formed for any application system and any DAO layer method in the application system, which helps to meet diverse business needs.
[0020] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0022] Figure 1 It is a schematic diagram of the main steps of the DAO layer degradation method in an embodiment of the present invention;
[0023] Figure 2 It is a schematic diagram of specific execution steps of the DAO layer degradation method in an embodiment of the present invention;
[0024] Figure 3 It is a schematic diagram of components of a DAO layer degradation device in an embodiment of the present invention;
[0025] Figure 4 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
[0026] Figure 5 It is a schematic diagram of the structure of an electronic device used to implement the DAO layer degradation method in an embodiment of the present invention. DETAILED DESCRIPTION
[0027] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0028] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.
[0029] Figure 1 Schematic diagram of main steps of the DAO layer degradation method according to an embodiment of the present invention.
[0030] like Figure 1 As shown, the DAO layer degradation method of the embodiment of the present invention can be specifically performed according to the following steps:
[0031] Step S101: when the application system processes an external request, a DAO method in the application system marked with a preset specific annotation is determined as a target method; wherein the definition of the specific annotation includes a degradation strategy identifier corresponding to the target method.
[0032] In an embodiment of the present invention, a downgrade engine for performing downgrade processing is pre-set, and the downgrade engine is a downgrade framework independent of each application system, and is completely decoupled from the code of each application system. The DAO layer downgrade method of the embodiment of the present invention is executed by the downgrade engine. In actual applications, the downgrade engine can be deployed on a different server from the application system, or it can be deployed on the same server to improve operating efficiency. In this step, the application system can be an application or service system related to the business, and the external request is generally a user request sent by the client.
[0033] In order to call the downgrade framework to perform downgrade processing when the application system code is executed, it is necessary to embed points in the application system code in advance. It can be understood that in the field of computer technology, embedding points refers to using AOP (Aspect Oriented Programming) technology to enhance the methods (also called functions) in the code, so as to execute the preset logic first before the method is executed.
[0034] Specifically, a specific annotation may be used to mark the DAO method in the application system code that needs to be downgraded, and the specific annotation is associated with the downgrade engine. When the application system code is executed, if a specific annotation is found, the method marked with the specific annotation is used as the target method (i.e., the DAO method that needs to be downgraded), and the downgrade engine is called to execute this step and subsequent steps S102 and S103. The above-mentioned DAO method may include methods such as adding, deleting, updating, and querying the DAO layer read interface and write interface.
[0035] As a preferred solution, the above specific annotations are custom annotations. In programming languages such as JAVA, annotations are special modifiers applied to class, method, parameter, variable, constructor or package declarations, and are a tool for describing metadata. Custom annotations are annotations written by developers using meta-annotations in addition to the system's built-in annotations. In specific applications, the system provides the following four meta-annotations:
[0036] @Documented – used to determine whether the defined annotation will be included in the Java documentation;
[0037] @Retention – An annotation used to determine when a definition is used;
[0038] @Target – used to determine where the annotation is used;
[0039] @Inherited – An annotation used to determine whether subclasses are allowed to inherit the definition.
[0040] It should be noted that the above annotations are completely different from comments. Generally, comments are used to inform developers of the logic, description, characteristics, etc. of the code, and can be written arbitrarily without restrictions; during compilation, comments will be completely ignored by the compiler. Annotations are used to mark elements such as classes, methods, parameters, variables, constructors, or packages to inform the JAVA virtual machine of the metadata of these elements. They generally start with "@" and have strict restrictions on location, syntax, and content. If there are any errors, an exception will be displayed during the compilation process.
[0041] Generally, the definition code of the above-mentioned specific annotation may include a downgrade policy identifier corresponding to the target method, and the downgrade policy identifier corresponds one-to-one to the downgrade policy set in the downgrade configuration file corresponding to the application system. The downgrade policy set in the above-mentioned downgrade configuration file can be uniquely determined through the downgrade policy identifier.
[0042] Preferably, a one-to-one downgrade configuration file can be written in advance for each application system, and the downgrade configuration file includes a downgrade strategy set corresponding to each target method in the corresponding application system, and the downgrade strategy set is composed of multiple downgrade strategies corresponding to the corresponding target method, and each of the multiple downgrade strategies matches a load state of the application system. In one embodiment, the load state may include light load, full load, and overload. Exemplarily, light load can mean that the current load is less than 80% of the maximum request processing capacity of the application system, full load can mean that the current load is between 80% and 100% of the maximum request processing capacity of the application system, and overload can mean that the current load is equal to or greater than the maximum request processing capacity of the application system.
[0043] In specific applications, each downgrade strategy may include downgrade conditions and downgrade ratios. The downgrade conditions are used to determine whether to perform downgrade processing, and the downgrade ratio can determine the proportion of requests to be restricted. Preferably, the downgrade condition can be a Boolean expression based on parameters such as the IP address, user identifier and / or request source corresponding to the external request. When performing the downgrade judgment, the downgrade engine can calculate the Boolean expression as the downgrade condition based on the relevant parameters of the external request, and perform the downgrade when the calculation result is true, and do not perform the downgrade and execute the target method normally when the calculation result is false.
[0044] The following table shows the downgrade strategy set corresponding to a target method in a downgrade configuration file in a certain application system:
[0045]
[0046] It can be seen that the downgrade policy identification of the downgrade policy set is XXXXX (only for example, in actual application, the identification is generally a hash value, and the downgrade policy set can be determined from the downgrade configuration file through the identification), including three downgrade policies. Among them, the first downgrade policy matches the light load state, the downgrade condition is "entry = XX" (whether the request source is XX), and the downgrade ratio is 20%; the second downgrade policy matches the full load state, the downgrade condition is "IP = 192.168.1.1" (whether the IP address in the request is 192.168.1.1, only for example), and the downgrade ratio is 50%; the third downgrade policy matches the overload state, the downgrade condition is "USERID = TOM" (whether the user ID in the request is TOM), and the downgrade ratio is 80%. It should be noted that the above is only an example, and the hash value of the corresponding parameter is often used in actual application to formulate the downgrade policy.
[0047] In specific applications, the above-mentioned downgrade configuration file can be configured by the staff in real time on the remote server and sent to the configuration server for storing the downgrade configuration files of each application system. When the server where the application system is located is started, the downgrade engine deployed by the server will pull the downgrade configuration file corresponding to the application system in the server from the configuration server to the local for subsequent use. After the staff updates the downgrade configuration file in the configuration server, the downgrade engine can determine whether the corresponding downgrade configuration file is updated by comparing the version number, and pull the latest downgrade configuration file to the local when it is determined to be updated. It can be understood that in addition to issuing and updating the downgrade configuration file, the staff can also remotely delete the downgrade configuration file.
[0048] Step S102: according to the downgrade strategy identifier corresponding to the target method, the current downgrade strategy of the target method is obtained from a preset downgrade configuration file corresponding to the application system.
[0049] In this step, the downgrade engine obtains the current downgrade strategy of the target method corresponding to the current load state of the application system from the downgrade configuration file corresponding to the application system pre-stored locally according to the downgrade strategy identifier included in the specific annotation definition code (that is, the downgrade strategy identifier corresponding to the target method).
[0050] Specifically, the downgrade engine first obtains the downgrade policy set corresponding to the target method from the above-mentioned downgrade configuration file according to the downgrade policy identifier corresponding to the target method; thereafter, the downgrade engine obtains the current load state of the application system, and determines the downgrade policy in the downgrade policy set that matches the current load state as the current downgrade policy of the target method. It can be understood that the above current downgrade policy is the downgrade policy that corresponds to all the target method and the current load state of the application system, and the subsequent downgrade processing can be performed based on the current downgrade policy.
[0051] Step S103: when it is determined that the external request meets the downgrade condition in the current downgrade policy, downgrade the external request according to the downgrade ratio in the current downgrade policy.
[0052] In this step, the downgrade engine first determines whether the external request meets the downgrade conditions in the current downgrade policy. Specifically, the downgrade engine can calculate the Boolean expression as the downgrade condition based on the relevant parameters such as the IP address, user identifier, and request source of the external request, and when the calculation result is true, it is determined that the external request meets the downgrade conditions in the current downgrade policy, and downgrades the external request according to the downgrade ratio in the current downgrade policy; when the calculation result is false, it is determined that the external request does not meet the downgrade conditions in the current downgrade policy, then the downgrade is not performed and the target method is executed normally.
[0053] Exemplarily, the downgrade process can be performed based on parameters such as IP address and user ID. Taking user ID as an example, the corresponding downgrade process steps are as follows: first, the user ID carried in the external request is converted into a hash value between 0 and 1, and then the hash value is compared with the downgrade ratio in the current downgrade strategy: when the hash value is less than the downgrade ratio, the default data is returned to respond to the external request; when the hash value is not less than the downgrade ratio, the target method is executed to respond to the external request. The default data can be the normal call data returned last time or a null value.
[0054] After the above settings, the downgrade mechanism can be implemented for any method of the DAO layer in any application system. The staff can configure downgrade strategies for different application systems according to business needs. For example, the downgrade is not performed at all for important application systems (no tracking is required or tracking is performed but the downgrade strategy is not configured), and the downgrade is performed for relatively unimportant application systems. The staff can also configure downgrade strategies for different DAO methods according to business needs. For example, some DAO methods such as query are downgraded (no tracking is required or tracking is performed but the downgrade strategy is not configured), and other DAO methods such as update are not downgraded. The staff can also update the downgrade strategy in real time according to emergencies. For example, when a hacker is found, a downgrade strategy is formulated based on his IP address. After the updated downgrade strategy is sent to the configuration server, it is pulled by the downgrade engine and immediately executed by the application system. It can be seen that the above scheme realizes the complete decoupling of the downgrade engine and the application system.
[0055] Figure 2 Schematic diagram of specific execution steps of the DAO layer degradation method in an embodiment of the present invention. Figure 2 As shown, in step S201, the application system receives an external request. In step S202, the downgrade engine locates the target method using a specific annotation in the application system code. In step S203, the downgrade engine obtains the downgrade policy set in the downgrade policy file according to the downgrade policy identifier in the specific annotation definition. In step S204, the downgrade engine determines the current downgrade policy of the target method from the downgrade policy set according to the current load status of the application system. In step S205, the downgrade engine determines whether the external request meets the downgrade condition: if so, execute step S206 to perform downgrade processing, otherwise execute step S207 without implementing downgrade and execute the target method normally.
[0056] In the technical solution of the embodiment of the present invention, when the application system processes an external request, the downgrade engine independent of the application system determines the DAO method marked by the preset specific annotation in the application system as the target method that needs to perform downgrade judgment, and then obtains the current downgrade strategy of the target method from the downgrade configuration file corresponding to the application system according to the downgrade strategy identifier in the specific annotation definition and the current load state of the application system, and performs downgrade on the target method according to the downgrade ratio in the current downgrade strategy when it is judged that the external request meets the downgrade condition in the current downgrade strategy. Among them, the above-mentioned downgrade configuration file can be sent from the remote server to the configuration server, and then pulled from the configuration server to the local by the downgrade engine, and the staff can update the downgrade strategy in the downgrade configuration file in real time on the remote server. Through the above settings, the downgrade mechanism based on the downgrade engine can be decoupled from the application system, thereby improving the execution efficiency of the application system, realizing the reusability and real-time adjustment of the downgrade scheme; at the same time, a flexible downgrade scheme is formed for any application system and any DAO layer method in the application system, which helps to meet diverse business needs.
[0057] It should be noted that, for the convenience of description, the aforementioned method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the present invention is not limited by the described action sequence, and some steps can actually be performed in other sequences or simultaneously. In addition, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily necessary to implement the present invention.
[0058] In order to better implement the above-mentioned solution of the embodiment of the present invention, relevant devices for implementing the above-mentioned solution are also provided below.
[0059] See also Figure 3 As shown, the DAO layer degradation device 300 provided in the embodiment of the present invention may include: a positioning unit 301 , a current degradation strategy acquisition unit 302 , and a degradation processing unit 303 .
[0060] Among them, the positioning unit 301 can be used to: when the application system processes an external request, determine the DAO method annotated by a preset specific annotation in the application system as the target method; wherein the definition of the specific annotation includes a downgrade policy identifier corresponding to the target method; the current downgrade policy acquisition unit 302 can be used to: based on the downgrade policy identifier corresponding to the target method, obtain the current downgrade policy of the target method from a preset downgrade configuration file corresponding to the application system; wherein the current downgrade policy includes a downgrade condition and a downgrade ratio; the downgrade processing unit 303 can be used to: when it is determined that the external request meets the downgrade condition in the current downgrade policy, downgrade the external request according to the downgrade ratio in the current downgrade policy.
[0061] In an embodiment of the present invention, the current downgrade strategy acquisition unit 302 can be further used to: obtain a downgrade strategy set corresponding to the target method from the downgrade configuration file based on the downgrade strategy identifier corresponding to the target method; wherein the downgrade strategy set includes multiple downgrade strategies corresponding to the target method, and each of the multiple downgrade strategies matches a load state of the application system; obtain the current load state of the application system, and determine the downgrade strategy in the downgrade strategy set that matches the current load state as the current downgrade strategy of the target method.
[0062] As a preferred scheme, the downgrade condition is a Boolean expression based on the IP address, user identifier and / or request source corresponding to the external request; and the downgrade processing unit 303 can be further used to: calculate the Boolean expression according to the parameters of the external request; when the calculation result is true, determine that the external request satisfies the downgrade condition in the current downgrade strategy.
[0063] Preferably, the downgrade processing unit 303 can be further used to: convert the user identifier carried in the external request into a hash value between 0 and 1; when the hash value is less than the downgrade ratio, return default data to respond to the external request; when the hash value is not less than the downgrade ratio, execute the target method to respond to the external request.
[0064] In actual applications, the device 300 may further include a configuration pulling unit, which is used to: before the application system processes an external request, pull the downgrade configuration file corresponding to the application system from the configuration server to the storage space where the application system is located; wherein the downgrade configuration file in the configuration server is issued, updated or deleted by the remote server.
[0065] In addition, in the embodiment of the present invention, the DAO method includes: adding, deleting, updating and querying, and the load status of the application system includes: light load, full load and overload.
[0066] In the technical solution of the embodiment of the present invention, when the application system processes an external request, the downgrade engine independent of the application system determines the DAO method marked by the preset specific annotation in the application system as the target method that needs to perform downgrade judgment, and then obtains the current downgrade strategy of the target method from the downgrade configuration file corresponding to the application system according to the downgrade strategy identifier in the specific annotation definition and the current load state of the application system, and performs downgrade on the target method according to the downgrade ratio in the current downgrade strategy when it is judged that the external request meets the downgrade condition in the current downgrade strategy. Among them, the above-mentioned downgrade configuration file can be sent from the remote server to the configuration server, and then pulled from the configuration server to the local by the downgrade engine, and the staff can update the downgrade strategy in the downgrade configuration file in real time on the remote server. Through the above settings, the downgrade mechanism based on the downgrade engine can be decoupled from the application system, thereby improving the execution efficiency of the application system, realizing the reusability and real-time adjustment of the downgrade scheme; at the same time, a flexible downgrade scheme is formed for any application system and any DAO layer method in the application system, which helps to meet diverse business needs.
[0067] Figure 4 An exemplary system architecture 400 to which the DAO layer degradation method or DAO layer degradation apparatus according to the embodiment of the present invention can be applied is shown.
[0068] like Figure 4 As shown, the system architecture 400 may include terminal devices 401, 402, 403, a network 404 and a server 405 (this architecture is only an example, and the components included in the specific architecture may be adjusted according to the specific application). The network 404 is used to provide a medium for a communication link between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0069] The user can use the terminal devices 401, 402, 403 to interact with the server 405 through the network 404 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 401, 402, 403, such as a downgrade processing application (only as an example).
[0070] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0071] The server 405 may be a server that provides various services, such as a background server that supports the downgrade processing application operated by the user using the terminal devices 401, 402, 403 (only as an example). The server 405 may process the received downgrade judgment request, etc., and feed back the processing result (such as whether to downgrade - only as an example) to the terminal devices 401, 402, 403.
[0072] It should be noted that the DAO layer degradation method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the DAO layer degradation device is generally disposed in the server 405 .
[0073] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0074] The present invention also provides an electronic device. The electronic device of an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the DAO layer degradation method provided by the present invention.
[0075] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of an electronic device suitable for implementing an embodiment of the present invention. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0076] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the computer system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0077] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed so that a computer program read therefrom is installed into the storage section 508 as needed.
[0078] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, the embodiments of the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the main step diagram. In the above embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit 501, the above functions defined in the system of the present invention are executed.
[0079] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0080] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0081] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes a positioning unit, a current downgrade strategy acquisition unit and a downgrade processing unit. The names of these units do not constitute a limitation on the units themselves in some cases, for example, the positioning unit may also be described as "a unit that provides a target method to the current downgrade strategy acquisition unit".
[0082] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by the device, the steps executed by the device include: when the application system processes an external request, the DAO method annotated by a preset specific annotation in the application system is determined as the target method; wherein the definition of the specific annotation includes a downgrade strategy identifier corresponding to the target method; according to the downgrade strategy identifier corresponding to the target method, the current downgrade strategy of the target method is obtained from the preset downgrade configuration file corresponding to the application system; wherein the current downgrade strategy includes downgrade conditions and downgrade ratios; when it is determined that the external request meets the downgrade conditions in the current downgrade strategy, the external request is downgraded according to the downgrade ratio in the current downgrade strategy.
[0083] In the technical solution of the embodiment of the present invention, when the application system processes an external request, the downgrade engine independent of the application system determines the DAO method marked by the preset specific annotation in the application system as the target method that needs to perform downgrade judgment, and then obtains the current downgrade strategy of the target method from the downgrade configuration file corresponding to the application system according to the downgrade strategy identifier in the specific annotation definition and the current load state of the application system, and performs downgrade on the target method according to the downgrade ratio in the current downgrade strategy when it is judged that the external request meets the downgrade condition in the current downgrade strategy. Among them, the above-mentioned downgrade configuration file can be sent from the remote server to the configuration server, and then pulled from the configuration server to the local by the downgrade engine, and the staff can update the downgrade strategy in the downgrade configuration file in real time on the remote server. Through the above settings, the downgrade mechanism based on the downgrade engine can be decoupled from the application system, thereby improving the execution efficiency of the application system, realizing the reusability and real-time adjustment of the downgrade scheme; at the same time, a flexible downgrade scheme is formed for any application system and any DAO layer method in the application system, which helps to meet diverse business needs.
[0084] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A DAO layer downgrade method, characterized in that: The method is performed by a downgrade engine independent of the application system; the method comprises: When the application system processes an external request, a DAO method in the application system marked with a preset specific annotation is determined as a target method; wherein the definition of the specific annotation includes a degradation strategy identifier corresponding to the target method; According to the downgrade strategy identifier corresponding to the target method, the current downgrade strategy of the target method is obtained from a preset downgrade configuration file corresponding to the application system; wherein the current downgrade strategy includes a downgrade condition and a downgrade ratio; When it is determined that the external request satisfies the downgrade condition in the current downgrade policy, downgrade processing is performed on the external request according to the downgrade ratio in the current downgrade policy.
2. The DAO layer downgrade method according to claim 1, characterized in that: The step of obtaining the current downgrade strategy of the target method from a preset downgrade configuration file corresponding to the application system according to the downgrade strategy identifier corresponding to the target method includes: According to the downgrade strategy identifier corresponding to the target method, a downgrade strategy set corresponding to the target method is obtained from the downgrade configuration file; wherein the downgrade strategy set includes multiple downgrade strategies corresponding to the target method, and each of the multiple downgrade strategies matches a load state of the application system; The current load state of the application system is obtained, and a downgrade strategy in the downgrade strategy set that matches the current load state is determined as the current downgrade strategy of the target method.
3. The DAO layer downgrading method according to claim 2, characterized in that: The downgrade condition is a Boolean expression based on the IP address, user identifier and / or request source corresponding to the external request; And, determining whether the external request satisfies the downgrade condition in the current downgrade strategy includes: Calculating the Boolean expression according to the parameters of the external request; When the calculation result is true, it is determined that the external request satisfies the downgrade condition in the current downgrade policy.
4. The DAO layer downgrading method according to claim 1, characterized in that: The downgrading the external request according to the downgrading ratio in the current downgrading strategy includes: Convert the user ID carried in the external request into a hash value between 0 and 1; When the hash value is less than the degradation ratio, returning default data to respond to the external request; When the hash value is not less than the degradation ratio, the target method is executed to respond to the external request.
5. The DAO layer downgrading method according to claim 1, characterized in that: The method further comprises: Before the application system processes an external request, the downgrade configuration file corresponding to the application system is pre-pulled from the configuration server to the storage space where the application system is located; wherein the downgrade configuration file in the configuration server is issued, updated or deleted by the remote server.
6. The DAO layer downgrading method according to claim 2 or 3, characterized in that: The DAO methods include: adding, deleting, updating and querying, and the load status of the application system includes: light load, full load and overload.
7. A DAO layer degradation device, characterized in that: The device is arranged in a downgrade engine independent of the application system; the device comprises: The positioning unit is used to: when the application system processes an external request, determine the DAO method in the application system that is annotated with a preset specific annotation as the target method; wherein the definition of the specific annotation includes a degradation strategy identifier corresponding to the target method; The current downgrade strategy acquisition unit is used to: acquire the current downgrade strategy of the target method from the preset downgrade configuration file corresponding to the application system according to the downgrade strategy identifier corresponding to the target method; wherein the current downgrade strategy includes downgrade conditions and downgrade ratios; The downgrade processing unit is used to: when it is determined that the external request meets the downgrade condition in the current downgrade strategy, perform downgrade processing on the external request according to the downgrade ratio in the current downgrade strategy.
8. The DAO layer degradation device according to claim 7, characterized in that: The current downgrade strategy acquisition unit is further used for: According to the downgrade policy identifier corresponding to the target method, a downgrade policy set corresponding to the target method is obtained from the downgrade configuration file; wherein the downgrade policy set includes multiple downgrade policies corresponding to the target method, and each of the multiple downgrade policies matches a load state of the application system; the current load state of the application system is obtained, and the downgrade policy in the downgrade policy set that matches the current load state is determined as the current downgrade policy of the target method.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Sensinel-based service fusion, degradation, and current limiting system
CN111475382A
Systems and methods for overload protection for real-time computing engines
US20190121676A1