CN113810479B - Service coordination system and service coordination method - Google Patents

Service coordination system and service coordination method Download PDF

Info

Publication number
CN113810479B
CN113810479B CN202111017454.6A CN202111017454A CN113810479B CN 113810479 B CN113810479 B CN 113810479B CN 202111017454 A CN202111017454 A CN 202111017454A CN 113810479 B CN113810479 B CN 113810479B
Authority
CN
China
Prior art keywords
lock
service
request
condition
acquired
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.)
Active
Application number
CN202111017454.6A
Other languages
Chinese (zh)
Other versions
CN113810479A (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.)
Hillstone Networks Co Ltd
Original Assignee
Hillstone Networks 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 Hillstone Networks Co Ltd filed Critical Hillstone Networks Co Ltd
Priority to CN202111017454.6A priority Critical patent/CN113810479B/en
Publication of CN113810479A publication Critical patent/CN113810479A/en
Application granted granted Critical
Publication of CN113810479B publication Critical patent/CN113810479B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Hardware Redundancy (AREA)

Abstract

The application discloses a service coordination system and a service coordination method, wherein the system comprises a service coordination system of distributed application, and is used for providing a first lock and a second lock, wherein the first lock supports the preferential acquisition of services higher than a preset level, and the second lock supports the sequential acquisition of services of all levels; and the server is in communication connection with the service coordination system of the distributed application, and is used for requesting the first lock or the second lock from the service coordination system of the distributed application according to the service corresponding to the service request, and executing the service corresponding to the service request under the condition that the first lock and the second lock are acquired at the same time. The application solves the problem that the distributed lock in the related technology can not ensure the fairness of service access of the same level, but also ensure the differentiated execution among services of different levels.

Description

Service coordination system and service coordination method
Technical Field
The application relates to the technical field of service coordination, in particular to a service coordination system and a service coordination method.
Background
With the rapid development of computer business, a server deployment system gradually evolves from a traditional single machine deployment system into a distributed cluster system, and as the distributed system comprises a plurality of threads and a plurality of processes and is distributed on different machines, concurrent control lock strategies in the single machine deployment system are invalid, and when the distributed systems synchronously access shared resources, the distributed locks are required to be used for control.
In order to solve the above-mentioned problem, a distributed lock based on redis (remote dictionary server, remote dictionary service) atomic command appears in the related art, but on one hand, a master-slave asynchronous copy strategy is adopted in a redis master-slave structure, which results in short-time transient inconsistency of master library and slave library data, and easily breaks the mutual exclusivity of the lock. On the other hand, when a plurality of services simultaneously preempt the lock, the service is completely random, and the fairness and the priority of locking cannot be ensured. On the other hand, after a certain service fails to lock, the service usually sleeps for a period of time and retries, when the lock holder holds the lock for a long time, other services have a large number of invalid retry operations, which causes the waste of system resources, and when the process of calling the lock crashes, certain service cannot release the lock resources in time, so that other services cannot normally operate.
Aiming at the problem that the distributed lock in the related technology can not ensure the fairness of service access of the same level and ensure the differentiated execution among services of different levels, no effective solution is proposed at present.
Disclosure of Invention
The application provides a service coordination system and a service coordination method, which are used for solving the problem that a distributed lock in the related technology cannot ensure the fairness of service access of the same level and ensure differentiated execution among services of different levels.
According to one aspect of the present application, a service coordination system is provided. The service coordination system includes: the service coordination system of the distributed application is used for providing a first lock and a second lock, wherein the first lock supports the preferential acquisition of the service higher than the preset level, and the second lock supports the sequential acquisition of the service of each level; the server is in communication connection with the service coordination system of the distributed application, and is used for requesting a first lock or a second lock from the service coordination system of the distributed application according to the service corresponding to the service request, and executing the service corresponding to the service request under the condition that the first lock and the second lock are acquired simultaneously, wherein the service corresponding to the service is a primary service, the first lock is requested to be acquired, the first lock is held after the first lock is acquired, the second lock is requested to be acquired under the condition that the service is a secondary service, the first lock is requested to be acquired after the second lock is acquired, and the second lock is released under the condition that the first lock fails to be acquired, and the primary service is higher in level than the secondary service.
Optionally, according to another aspect of the present application, there is provided a service coordination method, which is applied to the service coordination system, and the method includes: under the condition that the service corresponding to the current service request is primary service, requesting to acquire a first lock; requesting to acquire a second lock under the condition that the first lock is successfully acquired; and under the condition that the second lock is successfully acquired, releasing the first lock and executing the service corresponding to the current service request.
Optionally, in the case that the service corresponding to the current service request is the primary service, after the first lock is requested to be acquired, the method further includes: waiting for a service currently holding the first lock to release the first lock under the condition that the request for acquiring the first lock fails; the first lock is acquired in the event that the service currently holding the first lock releases the first lock.
Optionally, in case of successfully acquiring the first lock, after requesting to acquire the second lock, the method further comprises: waiting for a service holding the second lock to release the second lock under the condition that the request for acquiring the second lock fails; the second lock is acquired in the event that the service currently holding the second lock releases the second lock.
Optionally, in the case of successfully acquiring the second lock, releasing the first lock and executing the service corresponding to the service request, the method further includes: releasing the second lock when the service execution is completed; or releasing the second lock in case of failure of service execution.
Optionally, according to another aspect of the present application, there is provided another service coordination method, which is applied to the service coordination system, and the method includes: requesting to acquire a second lock under the condition that the service corresponding to the current service request is a second-level service; requesting to acquire the first lock under the condition that the second lock is successfully acquired; and under the condition that the first lock is successfully acquired, releasing the first lock, and executing the service corresponding to the current service request.
Optionally, in the case that the service corresponding to the current service request is a secondary service, after requesting to acquire the second lock, the method further includes: waiting for a service holding the second lock to release the second lock under the condition that the request for acquiring the second lock fails; the second lock is acquired in the event that the service currently holding the second lock releases the second lock.
Optionally, in case of successfully acquiring the second lock, after requesting to acquire the first lock, the method further comprises: releasing the second lock under the condition that the request for acquiring the first lock fails, and after the target service releases the second lock, requesting to acquire the second lock, wherein the target service is the primary service currently holding the primary lock under the condition that no non-executed secondary service exists before the current service request; in the case where there is an unexecuted secondary service before the current service request, the target service is the previously unexecuted secondary service of the current service.
Optionally, in the case of successfully acquiring the first lock, releasing the first lock and executing the service corresponding to the service request, the method further includes: releasing the second lock when the service execution is completed; or releasing the second lock in case of failure of service execution.
Optionally, releasing the first lock and executing the service corresponding to the service request includes: releasing the first lock before executing the service corresponding to the service request; or releasing the first lock in the process of executing the service corresponding to the service request; or releasing the first lock after executing the service corresponding to the service request.
According to another aspect of the embodiment of the present application, there is also provided a nonvolatile storage medium, the nonvolatile storage medium including a stored program, wherein when the program runs, the device in which the nonvolatile storage medium is controlled to execute a service coordination method.
According to another aspect of the embodiment of the present application, there is also provided an electronic device including a processor and a memory; the memory has stored therein computer readable instructions for execution by the processor, wherein the computer readable instructions when executed perform a service coordination method.
With the present application, a service coordination system is adopted, comprising: the service coordination system of the distributed application is used for providing a first lock and a second lock, wherein the first lock supports the preferential acquisition of the service higher than the preset level, and the second lock supports the sequential acquisition of the service of each level; the server is in communication connection with the service coordination system of the distributed application and is used for requesting a first lock or a second lock to the service coordination system of the distributed application according to the service corresponding to the service request, and executing the service corresponding to the service request under the condition that the first lock and the second lock are simultaneously acquired, wherein the service corresponding to the service is a primary service, the first lock is requested to be acquired, the first lock is held after the first lock is acquired, the second lock is requested to be acquired under the condition that the service is a secondary service, the first lock is requested to be acquired after the second lock is acquired, and the second lock is released under the condition that the first lock fails to be acquired, the problem that the distributed lock in the prior art cannot ensure the fairness of service access of the same level, and ensure the differentiated execution of service of different levels is solved, and the service of different levels is alternately locked by using the first lock and the second lock, so that the service of the same level is ensured to be executed in advance while the service of the same level is sequentially executed.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:
fig. 1 is a schematic diagram of a service system according to an embodiment of the present application.
Fig. 2 is a schematic diagram of a service coordination method according to an embodiment of the present application.
Fig. 3 is a schematic diagram of another service coordination method according to an embodiment of the present application.
Fig. 4 is a schematic flow chart of an alternative implementation according to an embodiment of the present application.
Fig. 5 is a schematic diagram of a service coordination device according to an embodiment of the present application.
Fig. 6 is a schematic diagram of another service coordination apparatus according to an embodiment of the present application.
Detailed Description
It should be noted that, without conflict, the embodiments of the present application and features of the embodiments may be combined with each other. The application will be described in detail below with reference to the drawings in connection with embodiments.
In order that those skilled in the art will better understand the present application, a technical solution in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the application herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In order to solve the problem that the distributed lock in the related technology cannot ensure the fairness of service access of the same level and ensure the differentiated execution among services of different levels, the related technology has the following steps:
the distributed locks based on zookeeper curator framework are used to control the process of accessing shared resources by the distributed system.
It should be noted that, the zookeeper is a distributed application system coordination service, and it is specified in the zookeeper that, at the same time, a plurality of clients cannot create the same node, and a distributed lock can be implemented by using this feature.
The specific implementation mode is that a temporary sequence node mechanism of a zookeeper is used, a service is successful in creating a temporary sequence node corresponding to a shared resource at the same time, and the service holds a distributed lock. The service with failed creation is automatically blocked, a temporary sequence node of the last sequence number is monitored through a latch mechanism, whether the sequence number of the temporary sequence node is minimum is judged every time the lock is acquired, the lock is acquired at the minimum, and the current node is deleted after execution is finished.
On the one hand, the zookeeper temporary node only exists in the session life cycle, and can be automatically destroyed when the session is finished, so that the distributed lock can be immediately released when the service is crashed. On the other hand, nodes generated by the zookeeper temporary sequence nodes are orderly, so that the service call can be ensured to be queued in sequence, and the fairness of the distributed lock can be ensured. In another aspect, the zookeeper adopts a latch mechanism, and when the node representing the lock resource is deleted, the latch mechanism can be triggered to unblock and reacquire the lock, repeated dormancy and repeated locking attempt are not needed, and the waste of the system resource is reduced, which is a great advantage of the zookeeper distributed lock compared with other distributed lock schemes.
However, this method also has the following disadvantages: when a plurality of services preempt the lock at the same time, the service with high priority cannot be distinguished, and the service with high priority cannot be executed preferentially.
Based on this, the present application is intended to provide a solution to the above technical problem, the details of which will be described in the following examples.
The embodiment of the disclosure provides a service coordination system. Fig. 1 is a schematic diagram of a service system according to an embodiment of the present application. As shown in fig. 1, the service system includes:
the service coordination system 101 of the distributed application is configured to provide a first lock and a second lock, where the first lock supports preferential acquisition of services higher than a preset level, and the second lock supports sequential acquisition of services of each level.
Specifically, the service coordination system 101 of the distributed application includes a first lock and a second lock, where the first lock is a priority mutex (priority mutex) lock, that is, a priority lock, configured to support priority acquisition of a high-level service, the preset-level service is a second-level service, the priority is lower, the service higher than the preset-level service is a high-level service, and the high-level service may preferentially acquire the first lock; the second lock is FairMutex (fair mutual exclusion) lock, namely public flat lock, which is used for ensuring that service calls are queued in sequence, so that fairness of the service calls can be ensured, and services of all levels are acquired in time sequence.
For example, when a high-level service and a low-level service coexist, a priority lock is acquired by the high-level service; when a high level service is created after a low level service, the fairness lock is acquired by the low level service created first.
The server 102 is in communication connection with the service coordination system of the distributed application, and is configured to request the service coordination system of the distributed application to acquire the first lock or the second lock according to the service corresponding to the generated service request, and execute the service corresponding to the service request when the first lock and the second lock are acquired simultaneously, where the service is a primary service, request to acquire the first lock first, and request to acquire the second lock after acquiring the first lock; and under the condition that the service is the secondary service, requesting to acquire the second lock, and after acquiring the second lock, requesting to acquire the first lock, wherein the level of the primary service is higher than that of the secondary service.
Specifically, the server 102 may be a plurality of servers, and the plurality of servers may issue a plurality of service execution request instructions respectively. The services corresponding to the service execution request instruction may be divided into a primary service and a secondary service, and the primary service has a higher priority than the secondary service, and the two services may be executed only when the first lock and the second lock are acquired at the same time.
It should be noted that, since the priorities of the two services are different, the order in which the two services acquire the two locks is different. For example, the primary service first requests to acquire a priority lock and requests to acquire a public lock after acquiring the priority lock; the secondary service first requests to acquire the public lock and requests to acquire the priority lock after acquiring the public lock.
The service coordination system provided by the embodiment of the application is used for providing a first lock and a second lock through the service coordination system 101 of the distributed application, wherein the first lock supports the preferential acquisition of the service higher than the preset level, and the second lock supports the sequential acquisition of the service of each level; the server 102 is in communication connection with the service coordination system of the distributed application, and is configured to request the first lock or the second lock to the service coordination system of the distributed application according to a service corresponding to the service request, and execute the service corresponding to the service request under the condition that the first lock and the second lock are acquired simultaneously, where the service corresponding to the service is a primary service, and requests to acquire the first lock and the second lock after the first lock is acquired, and requests to acquire the second lock under the condition that the service is a secondary service, and requests to acquire the first lock after the second lock is acquired, and releases the second lock under the condition that the first lock fails, so that the level of the primary service is higher than that of the secondary service, and the problem that the distributed lock in the related art cannot ensure fairness of service access of the same level, and ensure differentiated execution between services of different levels is solved.
The embodiment of the application also provides a service coordination method, which is applied to the service coordination system, and fig. 2 is a schematic diagram of the service coordination method according to the embodiment of the application, as shown in fig. 2: the method comprises the following steps:
in step S202, in the case that the service corresponding to the current service request is the primary service, the first lock is requested to be acquired.
In step S204, in the case of successfully acquiring the first lock, acquisition of the second lock is requested.
Step S206, releasing the first lock and executing the service corresponding to the current service request under the condition that the second lock is successfully acquired.
Specifically, the first lock is a priority lock for supporting the preferential acquisition of high-level services, and the second lock is a public lock for ensuring the sequential queuing of service calls and the sequential acquisition of all the levels of services. When the current service is one-level service, the service priority is high, so that the priority lock is requested to be acquired first, when the priority lock is not held by other services, the one-level service successfully acquires the priority lock and requests to acquire the public lock, when the public lock is not held by other services, the one-level service successfully acquires the public lock, at the moment, the one-level service acquires two locks simultaneously, and the service can be executed, and simultaneously releases the priority lock and provides the service for subsequent services.
According to the service coordination method provided by the embodiment of the application, under the condition that the service corresponding to the current service request is primary service, the first lock is requested to be acquired; requesting to acquire a second lock under the condition that the first lock is successfully acquired; and under the condition that the second lock is successfully acquired, releasing the first lock and executing the service corresponding to the current service request. Fairness and priority are controlled by using two distributed locks to lock in different orders. And the effect of additionally supporting a priority lock mechanism and ensuring that actions with high priority can be executed preferentially on the premise of ensuring fair execution is achieved.
Optionally, in the service coordination method provided by the embodiment of the present application, after requesting to acquire the first lock when the service corresponding to the current service request is the primary service, the method further includes: waiting for a service currently holding the first lock to release the first lock under the condition that the request for acquiring the first lock fails; the first lock is acquired in the event that the service currently holding the first lock releases the first lock.
Specifically, when other services are using the priority lock, the current primary service request fails to acquire the priority lock, the current service is blocked and waits, and the service with the priority lock releases the priority lock; when the service holding the priority lock releases the priority lock, the current primary service immediately acquires the priority lock and requests to acquire the public lock.
Optionally, in the service coordination method provided by the embodiment of the present application, after the second lock is requested to be acquired under the condition that the first lock is successfully acquired, the method further includes: waiting for a service holding the second lock to release the second lock under the condition that the request for acquiring the second lock fails; the second lock is acquired in the event that the service currently holding the second lock releases the second lock.
Specifically, when the current primary service successfully acquires the priority lock, but other services use the fair lock, the current primary service blocks and waits until the previous service gives up the fair lock because the priority lock cannot be acquired, the current primary service acquires the fair lock, and can start executing the current primary service, and simultaneously releases the priority lock and provides the priority lock for the subsequent service.
Optionally, in the service coordination method provided by the embodiment of the present application, after releasing the first lock and executing the service corresponding to the service request under the condition that the second lock is successfully acquired, the method further includes: releasing the second lock when the service execution is completed; or releasing the second lock in case of failure of service execution.
Specifically, after the current primary service is executed, the public lock is released to the next service; however, if an exception occurs and a crash occurs in the execution process when the current primary service is being executed, the fairness lock is released immediately, and other waiting service execution is not affected.
The embodiment of the application also provides another service coordination method, which is applied to the service coordination system, and fig. 3 is a schematic diagram of another service coordination method according to the embodiment of the application. As shown in fig. 3, the method includes:
in step S302, in the case that the service corresponding to the current service request is the second-level service, the second lock is requested to be acquired.
Step S304, in the case of successfully acquiring the second lock, requesting to acquire the first lock.
Step S306, releasing the first lock and executing the service corresponding to the current service request under the condition that the first lock is successfully acquired.
Specifically, the first lock is a priority lock for supporting the preferential acquisition of high-level services, and the second lock is a public lock for ensuring the sequential queuing of service calls and the sequential acquisition of all the levels of services. When the current service is the second-level service, the service priority is low, so that the public lock is requested to be acquired firstly, when the public lock is not held by other services, the current second-level service successfully acquires the public lock and requests to acquire the priority lock, when the priority lock is not held by other services, the current second-level service successfully acquires the priority lock, at the moment, the current second-level service acquires the two locks simultaneously, and the service can be executed, and meanwhile, the priority lock is released and is provided for the subsequent service.
According to the service coordination method provided by the embodiment of the application, the second lock is requested to be acquired under the condition that the service corresponding to the current service request is the second-level service; requesting to acquire the first lock under the condition that the second lock is successfully acquired; and under the condition that the first lock is successfully acquired, releasing the first lock, and executing the service corresponding to the current service request. Fairness and priority are controlled by using two distributed locks to lock in different orders. And the effect of additionally supporting a priority lock mechanism and ensuring that actions with high priority can be executed preferentially on the premise of ensuring fair execution is achieved.
Optionally, in the service coordination method provided by the embodiment of the present application, after requesting to acquire the second lock in the case that the service corresponding to the current service request is the second service, the method further includes: waiting for a service holding the second lock to release the second lock under the condition that the request for acquiring the second lock fails; the second lock is acquired in the event that the service currently holding the second lock releases the second lock.
Specifically, when the fair lock is held by other services, the current secondary service cannot acquire the fair lock, and starts to block waiting until the current secondary service acquires the fair lock after releasing the fair lock after the last service is executed.
Optionally, in the service coordination method provided by the embodiment of the present application, after requesting to acquire the first lock in the case of successfully acquiring the second lock, the method further includes: releasing the second lock under the condition that the request for acquiring the first lock fails, and after the target service releases the second lock, requesting to acquire the second lock, wherein the target service is the primary service currently holding the primary lock under the condition that no non-executed secondary service exists before the current service request; in the case where there is an unexecuted secondary service before the current service request, the target service is the previously unexecuted secondary service of the current service.
Specifically, after the current secondary service obtains the public lock, the current secondary service requests to obtain the priority lock, if other services hold the priority lock at the moment, the waiting is blocked, the priority lock still cannot be obtained within a certain time, that means that the current primary service holds the priority lock, the public lock is abandoned and the current secondary service moves to the rear of the primary service currently holding the priority lock, and the current primary service holding the priority lock is waited for trying again after execution of the current primary service holding the priority lock is completed.
For example, if the current secondary service requests to acquire a priority lock, at this time, other services hold the priority lock, the current service blocks waiting, at this time, the current secondary service may attempt to acquire the priority lock in 500 ms, and if the priority lock is not acquired in the time, the blocking times out, at this time, there is a case that the priority lock is held by the high-level service and waiting for acquisition of a fair lock to execute service call. The current secondary service cannot be invoked, releasing the public lock and moving to the primary service currently holding the priority lock, and waiting for the next round of retry.
If the second-level service which is not executed before the current second-level service, the second-level service is directly moved to the back of the first-level service which is currently provided with the priority lock, and the public lock is acquired again and the priority lock is requested to be acquired after the execution of the first-level service which is currently provided with the priority lock is completed; if the current secondary service is preceded by an unexecuted secondary service, moving to the back of the unexecuted secondary service, acquiring the public lock after the unexecuted secondary service releases the public lock, and requesting to acquire the priority lock.
Optionally, in the service coordination method provided by the embodiment of the present application, after releasing the first lock and executing the service corresponding to the service request under the condition that the first lock is successfully acquired, the method further includes: releasing the second lock when the service execution is completed; or releasing the second lock in case of failure of service execution.
Specifically, after the current secondary service is executed, the public lock is released for the next service to acquire; however, if an exception occurs and a crash occurs in the execution process when the current secondary service is being executed, the fair lock is released immediately, and the locking operation of other services waiting for the fair lock is not affected.
Optionally, releasing the first lock and executing the service corresponding to the service request includes: releasing the first lock before executing the service corresponding to the service request; or releasing the first lock in the process of executing the service corresponding to the service request; or releasing the first lock after executing the service corresponding to the service request.
It should be noted that, when the current service obtains two locks, the priority lock may be released whenever the current service obtains two locks, for example, before and during the service corresponding to the service request is executed, the subsequent primary service may start to obtain the priority lock; and releasing after executing the service corresponding to the service request, if the service which is the next service of the current service is the first-level service, acquiring the priority lock, then acquiring the public lock, executing the service, and if the service which is the second-level service, acquiring the priority lock, and then acquiring the public lock by the second-level service.
An alternative embodiment is provided below to further explain the present application in providing a service coordination method.
It should be noted that, in the application platform, the task will automatically issue a service request to the associated server when running. If multiple tasks use the same server, multiple tasks will be available at the same time and service requests will be issued to the server, where distributed locks are needed to control concurrency issues between multiple tasks. Meanwhile, if the user manually issues a service request to the server through the application platform, the manually issued service request, which is generally interacted with by the user, needs to be responded in time, and a result is returned in an expected time, so that advanced processing is needed.
Fig. 4 is a schematic diagram of a specific implementation flow of the alternative embodiment, where the first lock is a priority lock, the second lock is a public lock, the primary service is a service issued manually, no. 4, the secondary service is a service issued automatically, and No. 1, no. 2, and No. 3, and as shown in fig. 4, the method includes:
step S401 is: the distributed system generates 3 low-level services of service No. 1, service No. 2 and service No. 3, and the service No. 1 firstly acquires the fair lock and requests to acquire the priority lock according to the sequence of the services. Service number 1 begins executing service because no other service holds the priority lock.
Step S402 is: during service 1 execution, a high priority service 4 is written manually. Service No. 4 is a high-level service, and immediately applies for acquiring the priority lock, and since no other service occupies the priority lock, the priority lock is successfully acquired. And service number 4 also applies for obtaining the public lock, and the public lock is occupied by service number 1 at this time, and obtaining failure can only be waited.
Step S403 is: and when the service No. 1 is completed and the public lock is released, acquiring the public lock according to the service No. 2 in sequence. After service number 2 acquires the public lock, it applies to acquire the priority lock, but the priority lock is already held by service number 4. Service number 2 fails to acquire the priority lock and service cannot be performed, thus releasing the fair lock and re-queuing.
Step S404 is: and (3) acquiring the public lock according to the sequence. Service number 3 is the same as service number 2 in service level, and the acquisition of the priority lock fails, and the public lock is released and re-queued after number 2. And (4) acquiring the public lock according to the sequence. Service number 4 has now successfully acquired both locks, and can begin executing the service and releasing the priority lock.
Step S405 is: and the service No. 4 is completed, the fair lock is released, and the service No. 2 reacquires the fair lock and applies for acquiring the priority lock according to the sequence. At this point, since no primary service holds the priority lock, service No. 2 successfully acquires the priority lock, starts executing the service, and releases the priority lock. The subsequent service number 3 execution process is similar to the service number 2 execution process.
It should be noted that, in this scenario, if the distributed lock in the related art is used to control the manual and automatic service request issuing process to the server, the manual service request issuing needs to be queued after the automatic service request issuing actions, and waiting to be executed, and the time spent for each service request issuing action is unpredictable, which results in that the manual service request issuing is blocked for too long time, and finally, the result cannot be returned because of the timeout of the foreground and background interaction.
By using the service coordination method provided by the application, the priority of the manually issued service request can be improved, so that the manually issued service request is placed at the head of the queue, once the currently executed service is completed, the manually issued service is immediately executed, the efficiency of the manually issued service execution is improved, and the response time is reduced.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
The embodiment of the application also provides a service coordination device, and the service coordination device can be used for executing the service coordination method provided by the embodiment of the application. The following describes a service coordination device provided by the embodiment of the application.
Fig. 5 is a schematic diagram of a service coordination apparatus according to an embodiment of the present application. As shown in fig. 5: the device comprises: a first acquisition unit 501, a second acquisition unit 502, and a first execution unit 503.
Specifically, the first obtaining unit 501 is configured to request to obtain the first lock when the service corresponding to the current service request is the primary service.
A second obtaining unit 502, configured to request to obtain the second lock if the first lock is successfully obtained.
The first execution unit 503 is configured to execute a service corresponding to the current service request and release the first lock if the second lock is successfully acquired.
In the service coordination device provided by the embodiment of the present application, when a service corresponding to a current service request is a primary service, a first obtaining unit 501 requests to obtain a first lock; the second acquiring unit 502 requests to acquire the second lock if the first lock is successfully acquired; the first execution unit 503 executes the service corresponding to the current service request in the case of successfully acquiring the second lock. The distributed lock solves the problem that the distributed lock in the related technology cannot ensure the fairness of service access of the same level and ensure differentiated execution among services of different levels, and the first lock and the second lock are used for alternately locking the services of different levels, so that the effect that the service of a high level is ensured to be executed in advance while the sequential execution of the service of the same level is ensured is further achieved.
Optionally, in the service coordination device provided in the embodiment of the present application, the first obtaining unit 501 includes: the first acquisition module is used for waiting for the service currently holding the first lock to release the first lock under the condition that the acquisition of the first lock is requested to fail; and the second acquisition module acquires the first lock under the condition that the service currently holding the first lock releases the first lock.
Optionally, in the service coordination device provided in the embodiment of the present application, the second obtaining unit 502 includes: and the third acquisition module is used for waiting for the service holding the second lock to release the second lock when the request for acquiring the second lock fails after the second lock is successfully acquired. And the fourth acquisition module is used for acquiring the second lock under the condition that the service currently holding the second lock releases the second lock.
Optionally, in the service coordination device provided by the embodiment of the present application, the first execution unit 503 includes a first releasing module, configured to release the first lock when the second lock is successfully acquired; and the second releasing module is used for releasing the second lock after the service corresponding to the service request is executed or releasing the second lock under the condition that the service execution fails.
The service coordination device includes a processor and a memory, where the first acquiring unit 501, the second acquiring unit 502, the first executing unit 503, and the like are stored as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one, and the effect that the high-priority actions can be executed preferentially is ensured by additionally supporting a priority lock mechanism on the premise of ensuring fair execution by adjusting kernel parameters.
The embodiment of the application also provides another service coordination device, and it should be noted that the other service coordination device of the embodiment of the application can be used for executing the other service coordination method provided by the embodiment of the application. Another service coordination apparatus provided by the embodiment of the present application is described below.
Fig. 6 is a schematic diagram of another service coordination apparatus according to an embodiment of the present application. As shown in fig. 6: the device comprises: a third acquisition unit 601, a fourth acquisition unit 602, and a second execution unit 603.
Specifically, the third obtaining unit 601 is configured to request to obtain the second lock when the service corresponding to the current service request is a second-level service.
A fourth obtaining unit 602, configured to request to obtain the first lock if the second lock is successfully obtained.
The second execution unit 603 is configured to release the first lock and execute a service corresponding to the current service request if the first lock is successfully acquired.
In the service coordination device provided by the embodiment of the application, the third obtaining unit 601 requests to obtain the second lock under the condition that the service corresponding to the current service request is the second service; the fourth acquiring unit 602 requests to acquire the first lock if the second lock is successfully acquired; the second execution unit 603 releases the first lock and executes the service corresponding to the current service request if the first lock is successfully acquired. The distributed lock solves the problem that the distributed lock in the related technology cannot ensure the fairness of service access of the same level and ensure differentiated execution among services of different levels, and the first lock and the second lock are used for alternately locking the services of different levels, so that the effect that the service of a high level is ensured to be executed in advance while the sequential execution of the service of the same level is ensured is further achieved.
Optionally, in the service coordination apparatus provided in the embodiment of the present application, the third obtaining unit 601 includes: and the fifth acquisition module is used for waiting for the service holding the second lock to release the second lock under the condition that the acquisition of the second lock is failed. And a sixth acquisition module, configured to acquire the second lock when the service currently holding the second lock releases the second lock.
Optionally, in the service coordination device provided in the embodiment of the present application, the fourth obtaining unit 602 includes: and the third releasing module is used for releasing the second lock under the condition that the first lock acquisition request fails. A seventh obtaining module, configured to request to obtain the second lock after the target service releases the second lock, where the target service is a primary service that currently holds the primary lock if there is no non-executed secondary service before the current service request; in the case where there is an unexecuted secondary service before the current service request, the target service is the previously unexecuted secondary service of the current service.
Optionally, in the service coordination device provided by the embodiment of the present application, the second execution unit 603 includes a fourth release module, configured to release the first lock when the first lock is successfully acquired; and the fifth releasing module is used for releasing the second lock after the service corresponding to the service request is executed or releasing the second lock under the condition that the service execution fails.
The other service coordination apparatus includes a processor and a memory, where the third acquiring unit 601, the fourth acquiring unit 602, the second executing unit 603, and the like are stored as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one, and the effect that the high-priority actions can be executed preferentially is ensured by additionally supporting a priority lock mechanism on the premise of ensuring fair execution by adjusting kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
The embodiment of the application also provides a nonvolatile storage medium, which comprises a stored program, wherein the program controls equipment in which the nonvolatile storage medium is positioned to execute a service coordination method when running.
The embodiment of the application also provides an electronic device, which comprises a processor and a memory; the memory has stored therein computer readable instructions for execution by the processor, wherein the computer readable instructions when executed perform a service coordination method. The electronic device herein may be a server, a PC, a PAD, a mobile phone, etc.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and variations of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the application are to be included in the scope of the claims of the present application.

Claims (10)

1. A service orchestration system, comprising:
the service coordination system of the distributed application is used for providing a first lock and a second lock, wherein the first lock supports the preferential acquisition of the service with the higher than preset level, and the second lock supports the sequential acquisition of the service with each level;
and the server is in communication connection with the service coordination system of the distributed application, and is used for requesting the first lock or the second lock from the service coordination system of the distributed application according to the service corresponding to the service request, and executing the service corresponding to the service request under the condition that the first lock and the second lock are acquired simultaneously, wherein the first lock is requested to be acquired under the condition that the service corresponding to the service is primary service, the first lock is acquired, the second lock is acquired under the condition that the service is secondary service after the first lock is acquired, the second lock is requested to be acquired under the condition that the service is secondary service, the first lock is requested to be acquired after the second lock is acquired, and the second lock is released under the condition that the first lock fails to be acquired, wherein the primary service is higher in level than the secondary service.
2. A service coordination method, applied in the service coordination system of claim 1, comprising:
under the condition that the service corresponding to the current service request is primary service, requesting to acquire a first lock;
requesting to acquire a second lock if the first lock is successfully acquired;
and under the condition that the second lock is successfully acquired, releasing the first lock and executing the service corresponding to the current service request.
3. The method according to claim 2, wherein, in the case where the service corresponding to the current service request is a primary service, after requesting to acquire the first lock, the method further comprises:
waiting for a service currently holding the first lock to release the first lock under the condition that the request for acquiring the first lock fails;
and acquiring the first lock under the condition that the service currently holding the first lock releases the first lock.
4. The method of claim 2, wherein, in the event of a successful acquisition of the first lock, after requesting acquisition of a second lock, the method further comprises:
waiting for a last service holding the second lock to release the second lock under the condition that the request for acquiring the second lock fails;
And acquiring the second lock under the condition that the service currently holding the second lock releases the second lock.
5. The method of claim 2, wherein after releasing the first lock and executing the service corresponding to the service request in the case of successfully acquiring the second lock, the method further comprises:
releasing the second lock when the service is executed; or alternatively
And releasing the second lock in case of failure of the service execution.
6. A service coordination method, applied in the service coordination system of claim 1, comprising:
requesting to acquire a second lock under the condition that the service corresponding to the current service request is a second-level service;
requesting to acquire a first lock if the second lock is successfully acquired;
and under the condition that the first lock is successfully acquired, releasing the first lock and executing the service corresponding to the current service request.
7. The method of claim 6, wherein, in the case where the service corresponding to the current service request is a secondary service, after requesting to acquire the second lock, the method further comprises:
Waiting for a last service holding the second lock to release the second lock under the condition that the request for acquiring the second lock fails;
and acquiring the second lock under the condition that the service currently holding the second lock releases the second lock.
8. The method of claim 6, wherein upon requesting acquisition of the first lock in the event of successful acquisition of the second lock, the method further comprises:
releasing the second lock under the condition that the request for acquiring the first lock fails, and requesting to acquire the second lock after the target service releases the second lock, wherein the target service is a primary service currently holding a primary lock under the condition that no non-executed secondary service exists before the current service request; in the case that there is an unexecuted secondary service before the current service request, the target service is the previously unexecuted secondary service of the current service.
9. The method of claim 6, wherein upon the successfully acquiring the first lock, releasing the first lock and executing the service corresponding to the service request, the method further comprises:
Releasing the second lock when the service is executed; or alternatively
And releasing the second lock in case of failure of the service execution.
10. The method according to any one of claims 2 to 9, wherein releasing the first lock and executing the service corresponding to the service request comprises:
releasing the first lock before executing the service corresponding to the service request; or alternatively
Releasing the first lock in the process of executing the service corresponding to the service request; or alternatively
And releasing the first lock after executing the service corresponding to the service request.
CN202111017454.6A 2021-08-31 2021-08-31 Service coordination system and service coordination method Active CN113810479B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111017454.6A CN113810479B (en) 2021-08-31 2021-08-31 Service coordination system and service coordination method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111017454.6A CN113810479B (en) 2021-08-31 2021-08-31 Service coordination system and service coordination method

Publications (2)

Publication Number Publication Date
CN113810479A CN113810479A (en) 2021-12-17
CN113810479B true CN113810479B (en) 2023-11-07

Family

ID=78894508

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111017454.6A Active CN113810479B (en) 2021-08-31 2021-08-31 Service coordination system and service coordination method

Country Status (1)

Country Link
CN (1) CN113810479B (en)

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5333319A (en) * 1992-03-02 1994-07-26 International Business Machines Corporation Virtual storage data processor with enhanced dispatching priority allocation of CPU resources
EP0655682A1 (en) * 1993-11-26 1995-05-31 Siemens Aktiengesellschaft Multitasking arithmetic unit
CN101753608A (en) * 2008-12-09 2010-06-23 中国移动通信集团公司 Dispatching method and system of distributed system
CN103019859A (en) * 2012-12-05 2013-04-03 北京普泽天玑数据技术有限公司 Method and system for calling service request
CN103559088A (en) * 2012-05-21 2014-02-05 辉达公司 Resource management subsystem that maintains fairness and order
CN103870330A (en) * 2014-03-03 2014-06-18 大唐移动通信设备有限公司 Task dispatching method and device based on DSP (digital signal processing)
CN105703941A (en) * 2015-12-31 2016-06-22 山石网科通信技术有限公司 Method and device for processing configuration transaction
CN105897613A (en) * 2015-12-08 2016-08-24 乐视云计算有限公司 Level-limit-free QoS realizing method and level-limit-free QoS system
CN106708608A (en) * 2015-11-16 2017-05-24 阿里巴巴集团控股有限公司 Distributed lock service method and acquisition method, and corresponding device
CN109491801A (en) * 2018-09-27 2019-03-19 平安科技(深圳)有限公司 Micro services access scheduling method, apparatus, medium and electronic equipment
CN109753364A (en) * 2018-12-28 2019-05-14 北京明朝万达科技股份有限公司 A kind of implementation method, equipment and the medium of network-based distributed lock
CN110457129A (en) * 2019-07-19 2019-11-15 深圳联友科技有限公司 A kind of priority lock method for pre-emptively and system based on zookeeper
CN110677465A (en) * 2019-09-09 2020-01-10 北京信安世纪科技股份有限公司 Control method and device of distributed lock
CN112527489A (en) * 2020-12-22 2021-03-19 税友软件集团股份有限公司 Task scheduling method, device and equipment and computer readable storage medium
CN112965829A (en) * 2021-02-22 2021-06-15 电子科技大学 Method for using lock protocol under parallel task grouping scheduling

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5333319A (en) * 1992-03-02 1994-07-26 International Business Machines Corporation Virtual storage data processor with enhanced dispatching priority allocation of CPU resources
EP0655682A1 (en) * 1993-11-26 1995-05-31 Siemens Aktiengesellschaft Multitasking arithmetic unit
CN101753608A (en) * 2008-12-09 2010-06-23 中国移动通信集团公司 Dispatching method and system of distributed system
CN103559088A (en) * 2012-05-21 2014-02-05 辉达公司 Resource management subsystem that maintains fairness and order
CN103019859A (en) * 2012-12-05 2013-04-03 北京普泽天玑数据技术有限公司 Method and system for calling service request
CN103870330A (en) * 2014-03-03 2014-06-18 大唐移动通信设备有限公司 Task dispatching method and device based on DSP (digital signal processing)
CN106708608A (en) * 2015-11-16 2017-05-24 阿里巴巴集团控股有限公司 Distributed lock service method and acquisition method, and corresponding device
CN105897613A (en) * 2015-12-08 2016-08-24 乐视云计算有限公司 Level-limit-free QoS realizing method and level-limit-free QoS system
CN105703941A (en) * 2015-12-31 2016-06-22 山石网科通信技术有限公司 Method and device for processing configuration transaction
CN109491801A (en) * 2018-09-27 2019-03-19 平安科技(深圳)有限公司 Micro services access scheduling method, apparatus, medium and electronic equipment
CN109753364A (en) * 2018-12-28 2019-05-14 北京明朝万达科技股份有限公司 A kind of implementation method, equipment and the medium of network-based distributed lock
CN110457129A (en) * 2019-07-19 2019-11-15 深圳联友科技有限公司 A kind of priority lock method for pre-emptively and system based on zookeeper
CN110677465A (en) * 2019-09-09 2020-01-10 北京信安世纪科技股份有限公司 Control method and device of distributed lock
CN112527489A (en) * 2020-12-22 2021-03-19 税友软件集团股份有限公司 Task scheduling method, device and equipment and computer readable storage medium
CN112965829A (en) * 2021-02-22 2021-06-15 电子科技大学 Method for using lock protocol under parallel task grouping scheduling

Also Published As

Publication number Publication date
CN113810479A (en) 2021-12-17

Similar Documents

Publication Publication Date Title
US9501319B2 (en) Method and apparatus for scheduling blocking tasks
CN106406983B (en) Task scheduling method and device in cluster
US6622155B1 (en) Distributed monitor concurrency control
CN108429631B (en) Method and device for instantiating network service
US9778962B2 (en) Method for minimizing lock contention among threads when tasks are distributed in multithreaded system and apparatus using the same
WO2020177564A1 (en) Vnf life cycle management method and apparatus
CN105700939A (en) Method and system for multi-thread synchronization in distributed system
TW201447766A (en) Systems and methods of using a hypervisor with guest operating systems and virtual processors
EP4057139A1 (en) Pod deployment method and device
CN107479981B (en) Processing method and device for realizing synchronous call based on asynchronous call
CN111431970B (en) Resource allocation method, device, equipment and storage medium based on micro-service architecture
CN110971700A (en) Method and device for realizing distributed lock
CN109831394B (en) Data processing method, terminal and computer storage medium
CN109376020B (en) Data processing method, device and storage medium under multi-block chain interaction concurrence
CN113590320A (en) Resource processing method, device, equipment and medium for distributed batch task scheduling
CN113918336A (en) FreeRTOS task running method and device based on multi-core CPU
CN113810479B (en) Service coordination system and service coordination method
US9274819B2 (en) Performing garbage collection using a virtual thread in operating system without kernel thread support
CN110888726A (en) Multitask concurrent processing method and system
CN116185589A (en) Scheduling right acquisition method, equipment, system and storage medium
US20220350666A1 (en) Resource allocation method, device and audio-visual playback terminal
CN112749020A (en) Microkernel optimization method of Internet of things operating system
CN108255820B (en) Method and device for data storage in distributed system and electronic equipment
CN110618794A (en) Method and system for accessing NandFlash by SSD firmware
CN117742979B (en) Distributed lock method oriented to space-time data processing and electronic equipment

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