CN111552474A - Processing method and device for executing distributed lock operation - Google Patents

Processing method and device for executing distributed lock operation Download PDF

Info

Publication number
CN111552474A
CN111552474A CN202010221900.4A CN202010221900A CN111552474A CN 111552474 A CN111552474 A CN 111552474A CN 202010221900 A CN202010221900 A CN 202010221900A CN 111552474 A CN111552474 A CN 111552474A
Authority
CN
China
Prior art keywords
configuration file
project
preset
distributed lock
annotation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010221900.4A
Other languages
Chinese (zh)
Other versions
CN111552474B (en
Inventor
宋瑞环
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Ping An Medical Health Technology Service Co Ltd
Original Assignee
Ping An Medical and Healthcare Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Medical and Healthcare Management Co Ltd filed Critical Ping An Medical and Healthcare Management Co Ltd
Priority to CN202010221900.4A priority Critical patent/CN111552474B/en
Publication of CN111552474A publication Critical patent/CN111552474A/en
Application granted granted Critical
Publication of CN111552474B publication Critical patent/CN111552474B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/45Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
    • G06F8/458Synchronisation, e.g. post-wait, barriers, locks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a processing method and a processing device for executing distributed lock operation, relates to the technical field of computers, and mainly aims to add a distributed lock in a code file in a section jump operation mode so as to solve the problem that a code is complicated and bloated because a technician manually adds the distributed lock in the development process, thereby reducing code redundancy and improving code maintenance efficiency. The method comprises the following steps: when a project object model file is operated, detecting whether a preset annotation mark exists or not; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file. The invention is applicable to processes that perform distributed lock operations.

Description

Processing method and device for executing distributed lock operation
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a processing method and an apparatus for executing a distributed lock operation.
Background
At present, when a cluster or a single machine is deployed, a distributed lock in a project is realized in a redis or database mode, and locks are manually acquired, processed in logic, released and released under abnormal conditions in a method body. However, in the process of implementing the code, much attention should be paid to the logic code, frequent lock acquisition and lock release can make the code cumbersome and bloated, and if the lock is forgotten to be released, the current thread can always occupy resources, and other threads cannot acquire the resources, so that the code cannot be continuously executed, and the execution efficiency is greatly reduced.
At present, in the prior art, through putting the relevant operations and the service logic processing of the lock into one system for operation, although the operation is intuitively clear and easy to understand, two problems exist after the coupling, on one hand, if the operation of the lock release is not executed in the code execution process, if the server is down at the moment, the program is interrupted, and the flexibility of the code is greatly reduced; on the other hand, distributed locks are possibly used in the current scenes of all systems, the implementation logics are basically similar, if each set of system writes one set of logic, the cost is increased, redundancy is caused, and the code maintenance efficiency is reduced.
Disclosure of Invention
In view of this, the present invention provides a processing method and an apparatus for executing distributed lock operations, and a main object of the present invention is to add a distributed lock in a code file through a cut plane jump operation manner, so as to solve the problem that technicians add the distributed lock manually in a development process, so that the code is cumbersome and bloated, thereby reducing code redundancy and improving code maintenance efficiency.
According to an aspect of the present invention, there is provided a processing method for executing a distributed lock operation, including:
when a project object model file is operated, detecting whether a preset annotation mark exists, wherein the preset annotation mark is used for marking a method needing to cut into a tangent plane, so that when the preset annotation mark is detected, the preset annotation mark jumps to a preset tangent plane;
if the preset annotation identification is detected, analyzing a configuration item configured in a project configuration file corresponding to the preset annotation identification, and judging whether the configuration item meets a preset distributed lock execution condition;
and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file, wherein the section is used for positioning the starter configured in the project configuration file to a connection point.
Optionally, the method further comprises:
pre-configuring an annotation identifier by utilizing attribute mark information, and configuring a tangent plane connected with the annotation identifier;
and configuring parameter information in the project configuration file, wherein the parameter information comprises configuration items, a starter, a preset annotation mark and a tangent plane.
Optionally, if the preset annotation identifier is detected, analyzing whether a configuration item configured in the project configuration file corresponding to the preset annotation identifier meets a preset distributed lock execution condition, including:
and correspondingly searching the project configuration file according to the analyzed preset annotation identification, and judging whether the configuration item parameter in the configuration file is a first preset threshold value.
If yes, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file, wherein the distributed lock operation comprises the following steps:
and if the configuration item parameter in the configuration file is a first preset threshold value, indicating that the current thread jumps to a section configured in the project configuration file, triggering a starter configured in the project configuration file, and executing locking and unlocking operations.
Further, if the parameter of the configuration item in the configuration file is a first preset threshold, the current thread is instructed to jump to a section configured in the project configuration file, a launcher configured in the project configuration file is triggered, and locking and unlocking operations are executed, including:
creating a spring section by adopting a section-oriented programming AOP technology, setting a code corresponding to the starter in the section, and establishing connection between the section and the annotation mark;
and when the configuration item parameter in the configuration file is a first preset threshold value, intercepting a section configured in the project configuration file, and executing distributed locking operation by triggering a starter configured in the project configuration file.
Further, the intercepting the section configured in the project configuration file includes:
and when the @ DistributedLock annotation identifier is detected, indicating the current thread to jump to a configured tangent plane in the project configuration file.
Optionally, before the instructing the current thread to jump to the configured section in the project profile and executing the distributed lock operation by triggering the initiator configured in the project profile, the method further includes:
and loading a redisson client and establishing connection between the client and a redis database.
Further, the method further comprises:
and if the configuration item parameter in the configuration file is a second preset threshold value, not jumping to a section configured in the project configuration file, and continuously detecting the preset annotation mark.
According to a second aspect of the present invention, there is provided a processing apparatus for performing a distributed lock operation, comprising:
the detection unit is used for detecting whether a preset annotation mark exists or not when the project object model file is operated;
the analysis unit is used for analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock or not if the preset annotation identification is detected;
and the triggering unit is used for indicating the current thread to jump to the section configured in the project configuration file if the condition is met, and executing the distributed lock operation by triggering the starter configured in the project configuration file.
The device further comprises:
the first configuration unit is used for presetting annotation identification by utilizing attribute marking information and setting a tangent plane connected with the annotation identification;
and the second configuration unit is used for configuring parameter information in the project configuration file, wherein the parameter information comprises configuration items, a starter, a preset annotation identifier and a tangent plane.
The analysis unit includes:
the searching module is used for correspondingly searching the project configuration file according to the analyzed preset annotation identification and judging whether the configuration item parameter in the configuration file is a first preset threshold value or not;
the triggering unit is further specifically configured to, if the configuration item parameter in the configuration file is a first preset threshold, instruct the current thread to jump to a section configured in the project configuration file, trigger a starter configured in the project configuration file, and perform locking and unlocking operations.
The trigger unit further includes:
the creating module is used for creating a spring section by adopting a section-oriented programming AOP technology and setting a code corresponding to the starter in the section;
and the intercepting module is used for intercepting the section configured in the project configuration file when the configuration item parameter in the configuration file is a first preset threshold value, and executing distributed locking operation by triggering a starter configured in the project configuration file.
The intercepting module is further specifically configured to instruct the current thread to jump to a tangent plane configured in the project configuration file when the @ distributedLock annotation identifier is detected.
The device further comprises:
and the loading unit is used for loading the redisson client and establishing the connection between the client and the redis database.
The judgment module is further specifically configured to, if the configuration item parameter in the configuration file is a second preset threshold, not skip to a section configured in the project configuration file, and continue to detect the preset annotation mark.
According to a third aspect of the present invention, there is provided a storage medium having at least one executable instruction stored therein, the executable instruction causing a processor to perform the steps of: when a project object model file is operated, detecting whether a preset annotation mark exists or not; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file.
According to a fourth aspect of the present invention, there is provided a computer device comprising a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus, and the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to perform the following steps: when a project object model file is operated, detecting whether a preset annotation mark exists or not; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file.
Compared with the prior art that the related operation and the business logic processing of the lock are put into one system for operation, the processing method and the processing device for executing the distributed lock operation detect whether the preset annotation identification exists or not when the project object model file is operated; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file. The distributed locks are added into the code files in a section jumping operation mode so as to decouple the logic realized by the distributed locks from the codes, and the method for adding the locks and releasing the locks is automatically loaded by the starter according to the configured annotations, so that the problem that the codes are complicated and bloated due to the fact that technicians manually add the distributed locks in the development process is solved, code redundancy is reduced, and code maintenance efficiency is improved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow chart of a processing method for executing a distributed lock operation according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram illustrating a processing apparatus for performing a distributed lock operation according to an embodiment of the present invention;
fig. 3 shows a physical structure diagram of a computer device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
As described in the background art, in the prior art, the related operations and the service logic processing of the lock are operated in one system, which is intuitive, clear and easy to understand, however, there are two problems after the coupling, on one hand, if the operation of releasing the lock is not executed yet in the process of executing the code, if the server goes down at this time, the program is interrupted, thereby greatly reducing the flexibility of the code; on the other hand, distributed locks are possibly used in the current scenes of all systems, the implementation logics are basically similar, if each set of system writes one set of logic, the cost is increased, redundancy is caused, and the code maintenance efficiency is reduced.
In order to solve the above problem, an embodiment of the present invention provides a processing method for executing a distributed lock operation, as shown in fig. 1, where the method includes:
101. and when the project object model file is operated, detecting whether a preset annotation mark exists or not.
Xml file for describing maven coordinates of the Project, the file for managing source code, configuration files, dependency relationships of the Project, and the like, is a configuration file at Project level. The preset annotation mark can be a custom annotation marked in advance through attribute information, and the preset annotation mark can be used for marking a method needing to cut into a tangent plane, so that when the preset annotation mark is detected, the preset annotation mark can jump to the preset tangent plane. Specifically, when a project object model file is operated, the file information is traversed, and the detected preset annotation identification is fed back.
102. And if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the preset distributed lock execution condition.
The project configuration file corresponding to the preset annotation identification may include a configuration file of a project management tool (Maven) or a project automation building tool (Gradle). The configuration item may specifically include spring distributed-lock enable, and the configuration item may be used to determine whether to trigger a corresponding initiator. Specifically, if the preset annotation identifier is detected, a corresponding project configuration file may be searched according to the preset annotation identifier, configuration item information configured in the project configuration file is analyzed, and it is determined whether a configuration item configured in the project configuration file meets a preset distributed lock execution condition, for example, it is determined that a state of the configuration item spring.
103. And if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file.
If the configuration items configured in the project configuration file corresponding to the preset annotation identifier meet the preset distributed lock execution condition, jumping to a section configured in the project configuration file, where the section may be configured in the configuration file in advance, and the section may be used to extract and position codes related to non-business logic to a specific connection point. The launcher may be pre-configured in a project configuration file. The performing distributed lock operations may include locking and unlocking operations.
Further, in order to better explain the process of the processing method for executing the distributed lock operation, as a refinement and an extension to the above embodiment, the embodiment of the present invention provides several alternative embodiments, but is not limited to this, and specifically as follows:
in an alternative embodiment of the present invention, the method may further comprise: pre-configuring an annotation identifier by utilizing attribute mark information, and configuring a tangent plane connected with the annotation identifier; and configuring parameter information in the project configuration file, wherein the parameter information comprises configuration items, a starter, a preset annotation mark and a tangent plane.
For the embodiment of the present invention, the pre-configuring the annotation identifier by using the attribute flag information specifically may include: defining lock-related attributes, such as presetting annotation identification by using attribute mark information such as key prefix-key prefix, key value, lock automatic release time-leaseTime and whether locking is blocked-isBlock, for example: the preset annotation flag may be set to @ DistributedLock (keyPrefix ═ app _ lock ═ key ═ userld ═ isBlock ═ false); the configuration items in the configuration files can automatically find the configuration items through the automatic configuration function of Spring when the Spring is started, the section class of the distributed lock is initialized into a Spring container according to whether the parameter of the Spring distributed-lock enabled configuration item is true, and the redisonson client is received as an entry parameter for subsequent judgment, wherein the Spring framework is an open source Java platform and can be used for providing comprehensive infrastructure for easily and quickly developing durable Java application programs; the configuring the launcher in the project configuration file may specifically include: when the starter is configured, only the corresponding configuration files which depend on the added Maven or Gradle need to be automatically configured through SpringBoot, and the SpringBoot is a framework for simplifying the Spring development and can be used for monitoring the Spring application development. The SpringBoot instantiates the classes and performs automatic configuration as follows: firstly, searching resources/META-INF/spring.factors in a dependent starter package when the SpringBoot is started; secondly, loading the AutoConfigure class according to spring. Finally, according to the condition of the @ Conditional annotation, automatic configuration is performed and the Bean is injected into the Context of the Spring Context.
In another alternative embodiment of the present invention, the step 102 may specifically include: and correspondingly searching the project configuration file according to the analyzed preset annotation identification, and judging whether the configuration item parameter in the configuration file is a first preset threshold value.
For the embodiment of the invention, when the project code file is executed, if the preset annotation identifier is detected, the project configuration file corresponding to the preset annotation identifier is correspondingly searched, whether the configuration item parameter in the configuration file is a first preset threshold value is judged, if the configuration item parameter is the first preset threshold value, the configuration file jumps to a preset section, the starter is triggered, and corresponding locking and unlocking operations are executed. The preset annotation mark can be a custom annotation based on java language, and is used for defining general attributes including lock name, prefix, automatic release time and the like, and the attributes of the distributed locks can be manually set without writing redundant codes, so that the codes can be greatly simplified. The specific steps may include: configuring keys of static stage prefixes and dynamic expressions of the keys, wherein the keys are specifically configured to be included by using single quotation marks of character strings; the time for automatically releasing the lock is configured, the time is taken as a second unit, the default time can be 60 seconds, and whether the lock is blocked or not is judged.
In yet another alternative embodiment of the present invention, the step 103 may specifically include: and if the configuration item parameter in the configuration file is a first preset threshold value, indicating that the current thread jumps to a section configured in the project configuration file, triggering a starter configured in the project configuration file, and executing locking and unlocking operations.
Wherein the first preset threshold may be true. Specifically, whether a parameter of a spring/distributed-lock/enable configuration item in the configuration is true is judged, if so, a section corresponding to the preset annotation identifier is called, a starter configured in the configuration file is triggered, and locking and unlocking operations are executed.
For the embodiment of the present invention, corresponding to the step 103, the method may further include: and if the configuration item parameter in the configuration file is a second preset threshold value, not jumping to a section configured in the project configuration file, and continuously detecting the preset annotation mark.
The second preset threshold may be false specifically. Specifically, it is determined whether a parameter of a spring distributed-lock enabled configuration item in an application properties configuration file of the project is false, if the parameter is false, the current code file is executed continuously without jumping to a section configured in the project configuration file, and the preset annotation identifier is detected.
In yet another alternative embodiment of the present invention, the step 103 may further include: creating a spring section by adopting a section-oriented programming AOP technology, and setting a code corresponding to the starter in the section; and when the configuration item parameter in the configuration file is a first preset threshold value, intercepting a section configured in the project configuration file, and executing distributed locking operation by triggering a starter configured in the project configuration file.
For the embodiment of the present invention, after it is determined that the configuration item satisfies the preset distributed lock execution condition, the spring AOP technology may be used to perform AOP interception on the method that detects the preset annotation identifier, and the execution method of the distributed lock is switched in through the preset tangent plane connection point. Specifically, the cut surface can be specified as a method for detecting the @ distributedLock annotation through a spring AOP cut surface technology, when the method is called, the cut surface is executed first, the relevant attributes defined by the preset annotation identification can be acquired in the cut surface, and then locking and unlocking operations are executed.
In yet another alternative embodiment of the present invention, the method may further comprise: and loading a redisson client and establishing connection between the client and a redis database.
For the embodiment of the invention, the precondition needs to be judged before the trigger of the initiator, including whether an initialized RedissonClient client exists in the spring container currently. Because the premise that the starter (starter) realizes distributed lock control is based on redisson, a redis server needs to be connected, namely a client connected with the redis is needed, the connected client is initialized, and when the code starts to run, the client is loaded, the connection with the redis is established, and important precondition is provided for subsequent operation. It should be noted that, for the embodiment of the present invention, after the redisson client is loaded, information such as a connection address, a port, and a password with a configuration attribute of redis may also be added to the configuration file, so as to establish the connection of the redis.
In practical applications, the configured Project files may be packaged into a distributed lock package, and the package may be imported into a Project Object Model (POM) file or a gradle file of the Project to be executed. And when the project is executed, if the preset annotation mark is detected, skipping to the tangent plane and executing the logic of the distributed lock, thereby achieving the purpose of controlling the distributed lock. For the distributed lock program package, because the package is already performed, when the project is executed, only the program package needs to be introduced, and the corresponding preset annotation identification needs to be detected. The program package can be based on the property that the software is used after being opened from a box, namely, a starter is packaged in advance, and the control logic of the distributed lock is realized by the starter, so that the code execution is separated from the control of the distributed lock, the code realization is simplified, and the reusability of the starter is improved.
Compared with the prior art that the related operation and the business logic processing of the lock are put into one system for operation, the method for processing the distributed lock detects whether the preset annotation mark exists or not when the project object model file is operated; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file. The distributed locks are added into the code files in a section jumping operation mode so as to decouple the logic realized by the distributed locks from the codes, and the method for adding the locks and releasing the locks is automatically loaded by the starter according to the configured annotations, so that the problem that the codes are complicated and bloated due to the fact that technicians manually add the distributed locks in the development process is solved, code redundancy is reduced, and code maintenance efficiency is improved.
Further, as a specific implementation of fig. 1, an embodiment of the present invention provides a processing apparatus for executing a distributed lock operation, and as shown in fig. 2, the apparatus includes: a detection unit 21, an analysis unit 22 and a trigger unit 23.
The detecting unit 21 may be configured to detect whether a preset annotation identifier exists when the project object model file is run;
the parsing unit 22 may be configured to, if the preset annotation identifier is detected, parse whether a configuration item configured in a project configuration file corresponding to the preset annotation identifier meets a preset distributed lock execution condition;
the triggering unit 23 may be configured to, if the condition is met, instruct the current thread to jump to the tangent plane configured in the project configuration file, and execute the distributed lock operation by triggering the initiator configured in the project configuration file.
For the embodiment of the present invention, the apparatus further includes:
the first configuration unit 24 may be configured to preset an annotation identifier by using the attribute flag information, and set a tangent plane connected to the annotation identifier;
the second configuration unit 25 may be configured to configure parameter information in the project configuration file, where the parameter information includes a configuration item, an initiator, a preset annotation identifier, and a section.
The analysis unit 22 includes:
the searching module 221 may be configured to correspondingly search the project configuration file according to the parsed preset annotation identifier, and determine whether a configuration item parameter in the configuration file is a first preset threshold;
the triggering unit 23 may be further specifically configured to, if the parameter of the configuration item in the configuration file is a first preset threshold, instruct the current thread to jump to a section configured in the project configuration file, trigger a starter configured in the project configuration file, and execute locking and unlocking operations;
the trigger unit 23 includes:
the creating module 231 may be configured to create a spring cut plane by using a cut plane-oriented programming AOP technique, and set a code corresponding to the initiator in the cut plane
The intercepting module 232 may be configured to intercept a section configured in the project configuration file when the configuration item parameter in the configuration file is a first preset threshold, and execute a distributed lock operation by triggering a launcher configured in the project configuration file.
The intercepting module 232 is further specifically configured to, when detecting the @ DistributedLock annotation identifier, instruct the current thread to jump to a tangent plane configured in the project configuration file.
For the embodiment of the present invention, the apparatus further includes:
the loading unit 26 may be configured to load a redisson client and establish a connection between the client and a redis database.
For the embodiment of the present invention, the search module 221 may be further configured to, if the parameter of the configuration item in the configuration file is a second preset threshold, not skip to the section configured in the project configuration file, and continue to detect the preset annotation identifier.
Compared with the prior art that the related operation and the business logic processing of the lock are put into one system for operation, the processing device for executing the distributed lock operation detects whether the preset annotation identification exists or not when the project object model file is operated; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file. The distributed locks are added into the code files in a section jumping operation mode so as to decouple the logic realized by the distributed locks from the codes, and the method for adding the locks and releasing the locks is automatically loaded by the starter according to the configured annotations, so that the problem that the codes are complicated and bloated due to the fact that technicians manually add the distributed locks in the development process is solved, code redundancy is reduced, and code maintenance efficiency is improved.
It should be noted that other corresponding descriptions of the functional modules involved in the processing apparatus for executing the distributed lock operation according to the embodiment of the present invention may refer to the corresponding description of the method shown in fig. 1, and are not described herein again.
Based on the method shown in fig. 1, correspondingly, an embodiment of the present invention further provides a storage medium, where at least one executable instruction is stored in the storage medium, and the executable instruction causes a processor to perform the following steps: when a project object model file is operated, detecting whether a preset annotation mark exists or not; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file.
Based on the above-mentioned embodiments of the method shown in fig. 1 and the apparatus shown in fig. 2, the embodiment of the present invention further provides a computer device, as shown in fig. 3, including a processor (processor)31, a communication Interface (communication Interface)32, a memory (memory)33, and a communication bus 34. Wherein: the processor 31, the communication interface 32, and the memory 33 communicate with each other via a communication bus 34. A communication interface 34 for communicating with network elements of other devices, such as clients or other servers. The processor 31 is configured to execute a program, and may specifically execute relevant steps in the above processing method embodiment for executing the distributed lock operation. In particular, the program may include program code comprising computer operating instructions. The processor 31 may be a central processing unit CPU or an Application specific integrated Circuit ASIC or one or more integrated circuits configured to implement an embodiment of the invention.
The terminal comprises one or more processors, which can be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs. And a memory 33 for storing a program. The memory 33 may comprise a high-speed RAM memory, and may further include a non-volatile memory (non-volatile memory), such as at least one disk memory. The program may specifically be adapted to cause the processor 31 to perform the following operations: when a project object model file is operated, detecting whether a preset annotation mark exists or not; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file.
By the technical scheme, whether the preset annotation identification exists can be detected when the project object model file is operated; if the preset annotation identification is detected, analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock; and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file. The distributed locks are added into the code files in a section jumping operation mode so as to decouple the logic realized by the distributed locks from the codes, and the method for adding the locks and releasing the locks is automatically loaded by the starter according to the configured annotations, so that the problem that the codes are complicated and bloated due to the fact that technicians manually add the distributed locks in the development process is solved, code redundancy is reduced, and code maintenance efficiency is improved.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It will be appreciated that the relevant features of the method and apparatus described above are referred to one another. In addition, "first", "second", and the like in the above embodiments are for distinguishing the embodiments, and do not represent merits of the embodiments.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the components in accordance with embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (10)

1. A processing method for performing a distributed lock operation, comprising:
when a project object model file is operated, detecting whether a preset annotation mark exists, wherein the preset annotation mark is used for marking a method needing to cut into a tangent plane, so that when the preset annotation mark is detected, the preset annotation mark jumps to a preset tangent plane;
if the preset annotation identification is detected, analyzing a configuration item configured in a project configuration file corresponding to the preset annotation identification, and judging whether the configuration item meets a preset distributed lock execution condition;
and if so, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file, wherein the section is used for positioning the starter configured in the project configuration file to a connection point.
2. The method of claim 1, wherein before detecting whether a pre-set annotation identification exists while running the project object model file, the method further comprises:
pre-configuring an annotation identifier by utilizing attribute mark information, and configuring a tangent plane connected with the annotation identifier;
and configuring parameter information in the project configuration file, wherein the parameter information comprises configuration items, a starter, a preset annotation mark and a tangent plane.
3. The method according to claim 1, wherein if the preset annotation identifier is detected, analyzing whether a configuration item configured in the project configuration file corresponding to the preset annotation identifier satisfies a preset distributed lock execution condition includes:
correspondingly searching the project configuration file according to the analyzed preset annotation identification, and judging whether the configuration item parameter in the configuration file is a first preset threshold value or not;
if yes, indicating the current thread to jump to a section configured in the project configuration file, and executing distributed lock operation by triggering a starter configured in the project configuration file, wherein the distributed lock operation comprises the following steps:
and if the configuration item parameter in the configuration file is a first preset threshold value, indicating that the current thread jumps to a section configured in the project configuration file, triggering a starter configured in the project configuration file, and executing locking and unlocking operations.
4. The method according to claim 3, wherein the instructing the current thread to jump to the section configured in the project profile and trigger the initiator configured in the project profile to perform the locking and unlocking operations if the parameter of the configuration item in the configuration file is a first preset threshold comprises:
creating a spring section by adopting a section-oriented programming AOP technology, setting a code corresponding to the starter in the section, and establishing connection between the section and the annotation mark;
and when the configuration item parameter in the configuration file is a first preset threshold value, intercepting a section configured in the project configuration file, and executing distributed locking operation by triggering a starter configured in the project configuration file.
5. The method of claim 4, wherein intercepting the configured section in the project profile comprises:
and when the @ DistributedLock annotation identifier is detected, indicating the current thread to jump to a configured tangent plane in the project configuration file.
6. The method of claim 1, wherein the instructing the current thread to jump into the configured section in the project profile further comprises, before triggering a launcher configured in the project profile to perform a distributed lock operation:
and loading a redisson client and establishing connection between the client and a redis database.
7. The method of claim 3, further comprising:
and if the configuration item parameter in the configuration file is a second preset threshold value, not jumping to a section configured in the project configuration file, and continuously detecting the preset annotation mark.
8. A processing apparatus that performs distributed lock operations, comprising:
the detection unit is used for detecting whether a preset annotation mark exists or not when the project object model file is operated;
the analysis unit is used for analyzing whether the configuration items configured in the project configuration file corresponding to the preset annotation identification meet the execution condition of the preset distributed lock or not if the preset annotation identification is detected;
and the triggering unit is used for indicating the current thread to jump to the section configured in the project configuration file if the condition is met, and executing the distributed lock operation by triggering the starter configured in the project configuration file.
9. A storage medium having a computer program stored thereon, the storage medium having at least one executable instruction stored therein, the executable instruction causing a processor to perform operations corresponding to the processing method of performing a distributed lock operation of any one of claims 1-7.
10. A computer device comprising a processor, a memory, a communication interface and a communication bus through which the processor, the memory and the communication interface communicate with each other, the memory being for storing at least one executable instruction that causes the processor to perform an operation corresponding to the process of performing a distributed lock operation as claimed in any one of claims 1 to 7.
CN202010221900.4A 2020-03-26 2020-03-26 Processing method and device for executing distributed lock operation Active CN111552474B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010221900.4A CN111552474B (en) 2020-03-26 2020-03-26 Processing method and device for executing distributed lock operation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010221900.4A CN111552474B (en) 2020-03-26 2020-03-26 Processing method and device for executing distributed lock operation

Publications (2)

Publication Number Publication Date
CN111552474A true CN111552474A (en) 2020-08-18
CN111552474B CN111552474B (en) 2022-03-18

Family

ID=72000060

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010221900.4A Active CN111552474B (en) 2020-03-26 2020-03-26 Processing method and device for executing distributed lock operation

Country Status (1)

Country Link
CN (1) CN111552474B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113407553A (en) * 2021-05-14 2021-09-17 重庆锐云科技有限公司 Method, system, equipment and storage medium for realizing distributed lock

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007068530A1 (en) * 2005-12-13 2007-06-21 Thomson Licensing Method and apparatus for protecting a data set
CN106412123A (en) * 2016-11-28 2017-02-15 上海斐讯数据通信技术有限公司 Distributed terminal equipment information processing method and system of cloud access controller
CN108874552A (en) * 2018-06-28 2018-11-23 杭州云英网络科技有限公司 Distributed lock executes method, apparatus and system, application server and storage medium
CN109257259A (en) * 2018-11-30 2019-01-22 广东美的制冷设备有限公司 Scene inter-linked controlling method, device and household appliance
CN109495528A (en) * 2017-09-12 2019-03-19 阿里巴巴集团控股有限公司 Distributed lock ownership dispatching method and device
CN110795128A (en) * 2019-10-30 2020-02-14 上海米哈游天命科技有限公司 Program bug fixing method and device, storage medium and server

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007068530A1 (en) * 2005-12-13 2007-06-21 Thomson Licensing Method and apparatus for protecting a data set
CN106412123A (en) * 2016-11-28 2017-02-15 上海斐讯数据通信技术有限公司 Distributed terminal equipment information processing method and system of cloud access controller
CN109495528A (en) * 2017-09-12 2019-03-19 阿里巴巴集团控股有限公司 Distributed lock ownership dispatching method and device
CN108874552A (en) * 2018-06-28 2018-11-23 杭州云英网络科技有限公司 Distributed lock executes method, apparatus and system, application server and storage medium
CN109257259A (en) * 2018-11-30 2019-01-22 广东美的制冷设备有限公司 Scene inter-linked controlling method, device and household appliance
CN110795128A (en) * 2019-10-30 2020-02-14 上海米哈游天命科技有限公司 Program bug fixing method and device, storage medium and server

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113407553A (en) * 2021-05-14 2021-09-17 重庆锐云科技有限公司 Method, system, equipment and storage medium for realizing distributed lock
CN113407553B (en) * 2021-05-14 2023-05-05 重庆锐云科技有限公司 Method, system, equipment and storage medium for realizing distributed lock

Also Published As

Publication number Publication date
CN111552474B (en) 2022-03-18

Similar Documents

Publication Publication Date Title
US8627289B2 (en) Detecting configuration problems in an eclipse-based software application
CN106156186B (en) Data model management device, server and data processing method
US7451435B2 (en) Self-describing artifacts and application abstractions
US8584101B2 (en) Apparatus and method for automatically analyzing program for detecting malicious codes triggered under specific event/context
US8424090B2 (en) Apparatus and method for detecting obfuscated malicious web page
CN106874180B (en) Detection system and method thereof
US20160142437A1 (en) Method and system for preventing injection-type attacks in a web based operating system
KR101854975B1 (en) Method and system for extending function of package file
US10169005B2 (en) Consolidating and reusing portal information
WO2021022713A1 (en) Distributed module update method, device, and storage medium
CN114077741B (en) Software supply chain safety detection method and device, electronic equipment and storage medium
WO2017041499A1 (en) Software upgrade method and system, and computer-readable storage medium
US20130151736A1 (en) Device configuration with cached pre-assembled driver state
CN112579461A (en) Assertion processing method, system and storage medium
CN113835713A (en) Source code package downloading method and device, computer equipment and storage medium
CN111552474B (en) Processing method and device for executing distributed lock operation
US10019344B1 (en) Computer implemented system and method and computer program product for a test framework for orchestration workflows
CN112100620B (en) Code security detection method, apparatus, device and readable storage medium
US8762953B2 (en) Exception-based error handling in an array-based language
US9246987B2 (en) Service registry for web services
CN110781081B (en) Mobile application callback forced triggering method, system and storage medium
CN111352631A (en) Interface compatibility detection method and device
US20050210462A1 (en) Systems and method for the incremental deployment of Enterprise Java Beans
CN106293897B (en) Automatic scheduling system of subassembly
KR20180048518A (en) Method and system for extending function of package file

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20220524

Address after: 518000 China Aviation Center 2901, No. 1018, Huafu Road, Huahang community, Huaqiang North Street, Futian District, Shenzhen, Guangdong Province

Patentee after: Shenzhen Ping An medical and Health Technology Service Co.,Ltd.

Address before: Room 12G, Area H, 666 Beijing East Road, Huangpu District, Shanghai 200001

Patentee before: PING AN MEDICAL AND HEALTHCARE MANAGEMENT Co.,Ltd.