WO2014029323A1 - 一种并行业务处理方法、设备及系统 - Google Patents

一种并行业务处理方法、设备及系统 Download PDF

Info

Publication number
WO2014029323A1
WO2014029323A1 PCT/CN2013/081864 CN2013081864W WO2014029323A1 WO 2014029323 A1 WO2014029323 A1 WO 2014029323A1 CN 2013081864 W CN2013081864 W CN 2013081864W WO 2014029323 A1 WO2014029323 A1 WO 2014029323A1
Authority
WO
WIPO (PCT)
Prior art keywords
service
request
locking
server
locked
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.)
Ceased
Application number
PCT/CN2013/081864
Other languages
English (en)
French (fr)
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Publication of WO2014029323A1 publication Critical patent/WO2014029323A1/zh
Priority to US14/621,474 priority Critical patent/US10310913B2/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a parallel service processing method, device, and system. Background of the invention
  • a typical Internet system model is divided into three layers, namely the interface layer, the business layer, and the data layer.
  • the interface layer is used to forward the caller's request to the business layer, to isolate the caller and the business system;
  • the business layer is used to process the caller's request according to a certain logic flow, and usually returns the processing result;
  • the data layer is used to store the business layer.
  • the result is processed for use on the next call.
  • the business layer processes the request according to a specific execution sequence, and the data is read from the data layer or the intermediate processing result is written to the data layer during processing.
  • An execution sequence is a number of logical processing steps required to process a request.
  • Synchronization schemes for current interprocess communication include pipelines, FIFO (First Input First Output) named pipes, shared memory, message queues, and semaphores.
  • FIFO First Input First Output
  • existing interprocesses The synchronization scheme for communication is to handle the synchronization requirements between multiple processes deployed on the same server, and cannot handle the process synchronization requirements across cities, across IDCs, and across servers.
  • the object of the present invention is to provide a method, a device and a system for implementing parallel service layer service synchronization, which are used to solve the logic confusion caused by executing the same service request on a parallel service layer deployed across cities, across IDCs or across servers. Inconsistent with the data, to ensure the accuracy of business processing results.
  • An embodiment of the present invention provides a parallel service processing method, where the method includes: after receiving a lock request sent by a service server, the synchronization lock server determines whether the service request requested to be locked is locked, if the service request is not If the lock is locked, the service request is locked, and a lock success response is returned to the service server; if the service request is locked, a lock failure response is returned to the service server.
  • the embodiment of the present invention further provides a parallel service processing method, where the method includes: the service server sends a lock request to the synchronization lock server to lock the service request, so that the synchronization lock server determines the service requested to be locked. Whether the request has been locked, when it is determined that the service request is not locked, the service request is locked, and a locking success response is returned to the service server, when it is determined that the service request has been locked, Returning a lock failure response to the business server;
  • the service server receives the lock failure response, temporarily abandon the service processing of the service request, and again serve the synchronization lock according to a preset number of times and/or frequency.
  • the server sends a lock request.
  • An embodiment of the present invention further provides a synchronization lock server, where the synchronization lock server includes:
  • a receiving module configured to receive a lock request sent by the service server
  • a processing module configured to: after the receiving module receives the locking request, determine whether the service request requested to be locked is locked, and when the service request is not locked, lock the service request, and Returning a lock success response to the service server by the sending module; when the service request is locked, the sending module returns a lock failure response to the service server.
  • the embodiment of the present invention further provides a service server, where the service server includes: a sending module, configured to send a lock request to the synchronization lock server to lock the service request, so that the synchronization lock server determines the requested lock Whether the service request has been locked, and when it is determined that the service request is not locked, the synchronization lock server locks the service request, and returns a lock success response to the service server; When the request is locked, the synchronization lock server returns a lock failure response to the service server;
  • a processing module configured to: when the receiving module receives the locking success response, perform service processing according to the service request; and, when the receiving module receives the locking failure response, temporarily abandon the service processing of the service request, and The lock request is sent to the sync lock server again through the sending module according to a preset number of times and/or frequency.
  • the embodiment of the present invention further provides a parallel service processing system, where the system includes: the synchronization lock server and the service server.
  • the synchronization lock server determines that the requested service request is not locked, and locks the service request, and returns a lock success response, so that After receiving the successful response, the server performs corresponding service processing; otherwise, returns a lock failure response to the service server.
  • FIG. 1 is a schematic structural diagram of a distributed service processing system according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a parallel service processing flow according to an embodiment of the present invention
  • FIG. 3 is still another parallel service processing flow according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of a synchronization lock server according to an embodiment of the present invention
  • FIG. 5 is a schematic structural diagram of a service server according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of another synchronization lock server according to an embodiment of the present invention
  • FIG. 7 is a schematic structural diagram of another service server according to an embodiment of the present invention. Mode for carrying out the invention
  • the parallel service provided by the embodiment of the present invention is applicable to the application scenario in which the parallel service is deployed on the cross-city, the cross-IDC, or the cross-server, and the parallel service layer is processed by the multiple parallel service layers, and the service processing logic is confused and the data is inconsistent.
  • the processing scheme locks the service request of one business layer at a time, and then performs business processing to ensure the accuracy of the business processing result.
  • the parallel service processing method provided by the embodiment of the present invention is applied to a service processing system including a synchronization lock server and a data center, where the service processing system may include multiple data centers, and the multiple data centers form a distributed architecture;
  • the service processing system may also include only one data center, and the data center includes multiple service servers, and each service server forms a distributed architecture.
  • the embodiment of the present invention is described in detail by taking a distributed service processing system including a synchronization lock server and at least two service servers as an example.
  • the distributed service processing system includes: a synchronization lock server 11 and a data center 12, and may further include a database for storing service processing results, and the data center 12 may include a plurality of interface machines 121 and a plurality of service servers 122.
  • Each interface machine 121 forms a parallel service processing layer with each service server 122 for parallel processing of services.
  • the synchronization lock server 11 is configured to lock the corresponding service request according to the lock request sent by the service server 122, and unlock the corresponding service request according to the unlock request sent by the service server 122;
  • the service server 122 is configured to the synchronization lock server. 11 sending a lock request and an unlock request, and after the service request is locked, performing corresponding service processing according to the service request;
  • the interface machine 121 is configured to receive the service request sent by the client 13, and send the service request to the corresponding Business server 122.
  • Step 201 the service server 122 sends a lock request to the synchronization lock server 11 to lock the service request.
  • the client 13 sends a service request to the interface device 121, and after receiving the service request, the interface device 121 sends the service request to each service server 122.
  • the service server 122 After receiving the service request sent by the interface device 121, the service server 122 does not directly execute the corresponding service logic, but sends the service request to the synchronization lock server 11 to request the service request. Lock.
  • Step 202 The synchronization lock server 11 receives the lock request, and determines whether the service request has been locked. If the lock is already applied, step 203 is performed; otherwise, step 204 is performed.
  • Step 203 The synchronization lock server 11 returns a lock failure response to the service server 122.
  • the synchronization lock server 11 determines that the service request has been locked after receiving the lock request, it returns a lock failure response to the service server 122, so that the service server 122 temporarily gives up the service request. Conduct business processing.
  • the service server 122 After receiving the lock failure response, the service server 122 does not perform corresponding service processing.
  • the service server 122 may send a lock request to the synchronization lock server 11 again according to a preset number of times and/or frequency to ensure the service server 122. The chances of handling this business request are greater. The number of times the resending request is sent again and/or the sending frequency is related to the application scenario and the service processing time.
  • Step 204 The synchronization lock server 11 locks the service request, and returns a lock success response to the service server 122, so that the service server 122 performs service processing according to the service request. After the locking is successful, the service request can only be processed by the service server that sends the lock request, and the other service servers cannot perform the service processing.
  • Step 205 After receiving the locking success response, the service server 122 performs corresponding service processing, and stores the service processing result in the database.
  • the service server 122 performs corresponding service processing, and stores the service processing result in the database.
  • other business servers cannot handle business. This prevents the confusion of business processing logic and data inconsistency in the prior art.
  • Step 206 After completing the service processing, the service server 122 sends an unlock request to the synchronization lock server 11. Step 207, the synchronization lock server 11 unlocks the service request.
  • the synchronization lock server 11 unlocks the service request, and the unlock request is sent by the service server 122 after completing the service processing.
  • the synchronization lock server 11 determines that the service request is in an unlocked state, the service request is locked, and a lock success response is returned to the corresponding service server 122, but the server 122 does not receive the service. The lock is successfully responded. At this time, the service request is already in the locked state, but the service server 122 cannot perform corresponding service processing, and if the other service server 122 sends a lock request to the synchronization lock server 11 to lock the service request. Since the service request is still in the locked state, the synchronization lock server 11 returns a lock failure response, thereby causing the service request to be locked forever.
  • the locking time of the service request may be limited by setting a timer on the synchronization lock server 11 (the timer duration of the timer is the lock time expiration period).
  • the timer duration of the timer is greater than or equal to the processing time of the service server 122 processing the service request.
  • a parallel service processing flow that is abnormally unlocked includes the following steps:
  • Step 301 the service server 122 sends a lock request to the synchronization lock server 11 to lock the service request.
  • Step 302 The synchronization lock server 11 receives the lock request, and determines whether the service request has been locked. If the lock is already applied, step 303 is performed; otherwise, step 304 is performed. Step 303, the synchronization lock server 11 returns a lock failure response to the service server 122.
  • Step 304 The synchronization lock server 11 locks the service request, starts a timer, and returns a lock success response to the service server 122.
  • Step 305 When the timer duration of the timer arrives, the synchronization lock server 11 unlocks the service request.
  • the operation of unlocking the service request is a new operation.
  • the timer is used to monitor the lock duration of the service request, and when the condition is satisfied, the lock status of the service request is changed, so that the synchronization lock server 11 can only judge the lock status of the service request each time the lock request is received.
  • the processing efficiency of the synchronization lock server 11 is improved without considering the locking time, and the service processing capability of the system can be significantly improved for the case where multiple lock requests are received in a short time.
  • the lock success response sent by the synchronization lock server 11 cannot be sent to the service server 122, and the service server 122 cannot perform corresponding service processing, but the actual service is The request is already in a locked state, causing the service request to be locked forever; or, when the unlock request sent by the service server 122 cannot reach the sync lock server 11, the service request is also permanently locked.
  • the embodiment of the present invention uses a timer to limit the expiration date of the lock time, and when the expiration date of the lock time expires, the service request is forcibly unlocked, which can effectively prevent the service request from being locked forever, and ensure the smooth business process. get on.
  • the synchronization lock server determines whether the requested service request is locked (step 202), and performs a lock processing (step 204) or an unlock processing (step 207) on the service request. This can be done in the following ways:
  • the lock data list includes the service identifier and the lock start time of the corresponding service request, and the service identifier may be the service type identifier or the user identifier according to the application scenario.
  • the synchronization lock server 11 may extract the service identifier from the lock request and lock the corresponding service request according to the service identifier.
  • the synchronization lock server 11 may select a HASH algorithm or a full direct mapping algorithm to perform operation on the service identifier according to different application scenarios.
  • the HASH algorithm may be used to calculate the service identifier.
  • the lock process may be: The synchronization lock server 11 hashes the service identifier, and the lock is requested according to the hash result index. The service identifier, and sets the lock start time corresponding to the indexed service identifier to the receiving time of receiving the lock request.
  • the unlocking process may be: The synchronization lock server 11 performs a hash operation on the service identifier, indexes the service identifier requested to be unlocked according to the hash result, and clears the indexed service identifier and the corresponding lock start time.
  • the process of determining whether the service request requested to be locked is locked may be: the synchronization lock server 11 performs a hash operation on the service identifier, and indexes the service identifier requested to be locked in the table 1 according to the hash result, if the index To the service identifier and the corresponding lock start time, it is determined that the requested service request is locked, otherwise, the service request for the lock request is determined to be unlocked.
  • a full direct mapping algorithm can be used.
  • the locking process may be: The synchronization lock server 11 performs the operation on the service identifier according to the full-quantity direct mapping algorithm, indexes the service identifier requested to be locked according to the operation result, and associates the indexed service identifier.
  • the lock start time is set to receive the receive time of the lock request.
  • the unlocking process may be: the synchronization lock server 11 performs the operation on the service identifier according to the full direct mapping algorithm, indexes the service identifier requested to be unlocked according to the operation result, and sets the lock start time corresponding to the indexed service identifier to The initial value; correspondingly, the process of determining whether the requested service request is locked is: The synchronization lock server 11 performs the operation on the service identifier according to the full direct mapping algorithm, and according to the operation result, the index is requested to be unlocked according to the operation result.
  • the service identifier if the index is to the service identifier, and the corresponding lock start time is not the initial value, it is determined that the requested service request is locked; if the service identifier is not indexed and the corresponding lock start time (first time) After receiving the lock request of the service or indexing to the service identifier, and the corresponding lock start time is an initial value (the service request is unlocked), it is determined that the requested service request is unlocked.
  • step 204 is performed; Query whether the service request whose service identifier is ID2 is locked, and query a lock record, and the lock time in the lock record is 0 (in this embodiment, the initial value of the lock start time is 0, A person skilled in the art may know that the initial value of the lock start time may be arbitrarily set.
  • step 204 is performed; if the service request with the service identifier ID1 is queried in Table 1, is The lock is applied, and a lock record is queried, and the lock time in the lock record is not 0. If it is determined that the service request has been locked, step 203 is performed.
  • the lock start time corresponding to the indexed service identifier may be set when the service identifier that is requested to be unlocked is indexed according to the hash result during the unlocking process. Is the initial value.
  • judge the requested addition in the process of locking the service request of the lock, when indexing the requested service identifier in the index according to the hash result, if the index is to the service identifier, and the corresponding lock start time is not the initial value, then the judgment may be made.
  • the requested service request is locked; if the service identifier and the corresponding lock start time (the lock request for the service is received for the first time) or the index to the service identifier is not indexed, and the corresponding lock start time is The initial value (the service request is unlocked) can determine that the requested service request is unlocked.
  • the service identifier of the index and the corresponding lock start time may be cleared when the service identifier requested to be unlocked is indexed according to the operation result.
  • the service identifier requested to be locked is indexed in Table 1, if the index is to the service identifier and the corresponding lock start time, it is determined The service request requested to be locked is locked. Otherwise, it is judged that the requested service request is unlocked.
  • the lock of the service request may also be recorded on the sync lock server 11
  • the state is unlocked, and it is determined whether the service request has been locked according to the locked/unlocked state of the service request.
  • a lock data list (Table 2) for recording the correspondence between the service identifier and the service request status may be established in the sync lock server 11, and the service request status includes a lock status and an unlock status.
  • the synchronization lock server 11 can extract the service identifier from the lock request, and operate and index the service identifier to record the service request status corresponding to the service identifier.
  • the ID2 0 synchronization lock server 11 locks the corresponding service request according to the service identifier, and specifically: the synchronization lock server 11 performs a hash operation on the service identifier, and indexes the service identifier that is requested to be locked according to the hash result, and Set the service request status corresponding to the indexed service identifier to the lock status. For example, in Table 2, set the service identifier service request status value to 1.
  • the synchronization lock server 11 unlocks the corresponding service request according to the service identifier, which may be: the synchronization lock server 11 performs a hash operation on the service identifier, indexes the service identifier requested to be unlocked according to the hash result, and clears the index to The service identifier and the corresponding service request status; or, the service request status corresponding to the indexed service identifier is set to an unlocked state, for example, the service request status value is set to 0.
  • the synchronization lock server 11 determines whether the corresponding service request is locked according to the service identifier, and specifically: the synchronization lock server 11 performs a hash operation on the service identifier, and indexes the service identifier requested to be locked according to the hash result. Indexing to the service identifier and the corresponding service request status, for example, indexing the service request status value corresponding to the service identifier
  • the requested service request is locked. If the service identifier and the corresponding service request status are not indexed, it is determined that the requested service request is unlocked. Or if the service request status value corresponding to the service identifier is an unlocked state, for example, 0, it is determined that the requested service request is unlocked.
  • the synchronization lock server 11 can also implement locking, unlocking, and judging the status of the service request by the full direct mapping algorithm according to the service identifier.
  • the locking process may be: the synchronization lock server 11 performs the operation on the service identifier according to the full direct mapping algorithm, and indexes the service identifier requested to be locked according to the operation result.
  • the service request status corresponding to the indexed service identifier is set to a locked state, for example, the service request status value is set to 1.
  • the unlocking process may be: the synchronization lock server 11 performs the operation according to the service identifier on the service identifier of the service request that is requested to be unlocked according to the full direct mapping algorithm, and indexes the service identifier requested to be unlocked according to the operation result, and indexes with the index
  • the service request status corresponding to the service identifier is set to the unlock state, for example, the service request status value is set to 0. Or, clear the index to the service identifier and the corresponding service request status.
  • the process of determining whether the corresponding service request has been locked according to the service identifier may be: the synchronization lock server 11 performs the operation on the service identifier according to the full direct mapping algorithm, and indexes the service identifier requested to be locked according to the operation result, if the index If the service request status value is 1 and the service request status value corresponding to the service identifier is 1, the service request that is requested to be locked is determined to be locked; otherwise, if the index is to the service identifier and the service request status value corresponding to the service identifier is 0, Then, it is judged that the service request requested to be locked is unlocked. Alternatively, if the service identifier and the corresponding service request status are not indexed, it is determined that the requested service request is unlocked.
  • the embodiment of the present invention sets a lock/unlock mechanism for a parallel service request, so that in a distributed service processing system including at least two service servers, for one service request, it is ensured that only one service layer requests a lock at a time, and the solution is solved.
  • a distributed service processing system including at least two service servers, for one service request, it is ensured that only one service layer requests a lock at a time, and the solution is solved.
  • the embodiment of the present invention further provides a synchronization lock server.
  • the synchronization lock server includes: a receiving module 41, a processing module 42, and a sending module 43.
  • the receiving module 41 is configured to receive a lock request sent by the service server.
  • the processing module 42 is configured to determine, after the receiving module 41 receives the locking request, the requested addition. Whether the service request of the lock is locked, when the service request is not locked, the service request is locked, and the locking success response is returned to the service server by the sending module 43; when the service request is locked, the The sending module 43 returns a lock failure response to the service server.
  • the processing module 42 is further configured to: after the service request is locked, start a timer, and unlock the service request that is requested to be unlocked when the timer duration expires; the timer duration is greater than or equal to the service server processing the service request. Processing time.
  • the receiving module 41 is further configured to receive an unlock request sent by the service server, where the unlock request is sent by the service server after completing the service processing.
  • the processing module 42 is further configured to: after the receiving module 41 receives the unlock request sent by the service server, unlock the service request that is requested to be unlocked.
  • the processing module 42 includes a decision sub-module 421 and a lock/unlock sub-module 422.
  • the lock/unlock sub-module 422 is configured to extract the service identifier from the lock request received by the receiving module 41, and when the judgment sub-module 421 determines that the service request for the lock request is not locked, according to the service identifier The service request is locked; and the service identifier is extracted from the unlock request received by the receiving module, and the corresponding service request is unlocked according to the service identifier.
  • the determining sub-module 421 is configured to extract the service identifier from the lock request received by the receiving module 41, and determine whether the corresponding service request is locked according to the service identifier.
  • the locking/unlocking sub-module 422 is specifically configured to perform a hash operation on the service identifier when the determining sub-module 421 determines that the service request is not locked, and index the requested service identifier according to the hash result. And setting a lock start time corresponding to the indexed service identifier to a receiving time of receiving the lock request; and, when the receiving module 41 receives the unlock request sent by the service server, performing hash operation on the service identifier, according to the hash
  • the result indexes the service identifier requested to be unlocked, and clears the indexed service identifier and the corresponding lock Start time; or, set the lock start time corresponding to the indexed service ID to the initial value.
  • the determining sub-module 421 is specifically configured to perform a hash operation on the service identifier, and according to the hash result index, the service identifier requested to be locked, if the index to the service identifier and the corresponding lock start time, determine the service request for the lock request. It is locked, otherwise, it determines that the requested service request is unlocked. Or indexing to the service identifier, and the corresponding lock start time is not the initial value, then determining that the requested service request is locked, otherwise, indexing to the service identifier and the corresponding lock start time is an initial value (the service) If the request is unlocked, it can be judged that the requested service request is unlocked.
  • the locking/unlocking sub-module 422 is specifically configured to: when the determining sub-module 421 determines that the service request is not locked, perform operation on the service identifier according to the full-quantity direct mapping algorithm, and perform the locking according to the operation result index.
  • the algorithm performs an operation, indexes the service identifier requested to be unlocked according to the operation result, and sets a lock start time corresponding to the indexed service identifier to an initial value; or, clears the indexed service identifier and the corresponding lock start time.
  • the determining module 421 is specifically configured to perform operation on the service identifier according to the full-quantity direct mapping algorithm, and index the service identifier that is requested to be locked according to the operation result. If the index is to the service identifier, and the corresponding locking start time is not an initial value, the determining unit The service request requesting the lock is locked. Otherwise, it is judged that the requested service request is unlocked.
  • the locking/unlocking sub-module 421 is specifically configured to: when the determining sub-module 421 determines that the service request is not locked, performs a hash operation on the service identifier, and indexes the requested service identifier according to the hash result index.
  • the service server sends the When the request is unlocked, the service identifier of the service request that is requested to be unlocked is hashed, the service identifier that is requested to be unlocked is indexed according to the hash result, and the service identifier and the corresponding service request status of the index are cleared; or, The service request status corresponding to the service identifier is set to the unlock state, for example, the service request status value is set to 0.
  • the determining sub-module 421 is specifically configured to perform a hash operation on the service identifier, and according to the hash result index, the service identifier that is requested to be locked, if the index is to the service identifier and the corresponding service request status, determine that the service request requested to be locked is Has been locked, otherwise, it is judged that the requested service request is unlocked. Or, if the service identifier is indexed to the service identifier and the service request status value corresponding to the service identifier is an unlocked state, for example, 0, the service request for the requested lock is determined to be unlocked.
  • the locking/unlocking sub-module 421 is specifically configured to: when the determining sub-module 421 determines that the service request is not locked, perform operation on the service identifier according to the full-quantity direct mapping algorithm, and perform the locking according to the operation result index.
  • the service identifier, and the service request status corresponding to the indexed service identifier is set to a locked state; and when the receiving module 41 receives the unlock request sent by the service server, the service identifier of the service request that is requested to be unlocked is directly
  • the mapping algorithm performs an operation, and indexes the service identifier requested to be unlocked according to the operation result, and sets the service request status corresponding to the indexed service identifier to an unlocked state. Or, clear the index to the service identifier and the corresponding service request status.
  • the determining sub-module 421 is specifically configured to perform the operation on the service identifier according to the full-quantity direct mapping algorithm, and index the service identifier that is requested to be locked according to the operation result, and if the index is to the service identifier and the service request status value corresponding to the service identifier is a locked state, For example, if it is 1, it is determined that the requested service request is locked. Otherwise, if the index is to the service identifier and the service request status value corresponding to the service identifier is an unlocked state, for example, 0, the requested lock is determined. Business requests are unlocked. Alternatively, if the service identifier and the corresponding service request status are not indexed, it is determined that the requested service request is unlocked. Based on the same concept, the embodiment of the present invention further provides a service server. As shown in FIG. 5, the service server includes: a sending module 51, a processing module 52, and a receiving module 53.
  • the sending module 51 is configured to send, to the synchronization lock server, a lock request for locking the service request, so that the synchronization lock server determines whether the requested service request is locked, and determines that the service request is not added.
  • the lock is locked, the service request is locked, and a lock success response is returned to the service server; when it is determined that the service request has been locked, a lock failure response is returned to the service server.
  • the processing module 52 is configured to perform service processing according to the service request when the receiving module 53 receives the locking success response; and, when the receiving module 53 receives the locking failure response, temporarily abandon the service processing for the service request, and according to the pre- The set number and/or frequency is again sent by the sending module 51 to the sync lock server for a lock request.
  • the sending module 51 is further configured to send an unlock request to the synchronization lock server after the processing module 52 completes the service processing, so that the synchronization lock server unlocks the service request.
  • the embodiment of the present invention further provides a parallel service processing system.
  • the parallel service processing system includes: a synchronization lock server and at least two service servers.
  • the modules in the apparatus in the embodiments may be distributed in the apparatus of the embodiment according to the description of the embodiments, or may be correspondingly changed in one or more apparatuses different from the embodiment.
  • the modules of the above embodiments may be combined into one module, or may be further split into multiple sub-modules.
  • the present invention can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is a better implementation. the way.
  • the technical solution of the present invention which is essential or contributes to the prior art, can be produced by software.
  • the computer software product is stored in a storage medium, and includes a plurality of instructions for causing a terminal device (which may be a mobile phone, a personal computer, a server, or a network device, etc.) to perform the embodiments of the present invention.
  • FIG. 6 is a schematic structural diagram of still another synchronization lock server according to an embodiment of the present invention.
  • the sync lock server includes: a memory 61 and a processor 62 in communication with the memory 61.
  • the memory 61 stores a receive command 611, a process command 612, and a send command 613 that are executable by the processor 62.
  • the receiving instruction 611 is used to indicate that the locking request sent by the service server is received.
  • the processing instruction 612 is configured to: after the receiving module receives the locking request, determine whether the service request requested to be locked is locked, and when the service request is not locked, lock the service request, And indicating that the lock success response is returned to the service server by sending the command 613; when the service request has been locked, indicating that the lock failure response is returned to the service server by sending the command 613.
  • processing instruction 612 is further configured to: after the locking of the service request is started, start a timer, and unlock the service request that is requested to be unlocked when the timer duration expires;
  • the timer duration of the timer is greater than or equal to the processing time of the service server processing the service request.
  • the receiving instruction 611 is further configured to instruct the receiving service server to send an unlocking request, where the unlocking request is sent by the service server after completing the service processing.
  • the processing instruction 612 is further configured to: after performing the receiving the instruction 611 to receive the unlocking request sent by the service server, unlocking the requested unlocked service request.
  • the processing instruction 612 can include a lock/unlock sub-command 6121 and a judgment sub-command 6122.
  • the memory 61 is further configured to store a service identifier and A list of locked data that corresponds to the correspondence of the start time.
  • the lock/unlock sub-command 6121 may be specifically configured to indicate that the service identifier is extracted from the lock request received by executing the receive instruction 611, and the service request requesting the lock is not determined by the execution judgment sub-command 6122.
  • the lock is performed, the corresponding service request is locked according to the service identifier; and the service identifier is extracted from the unlock request received by executing the receiving instruction 611, and the service request is unlocked according to the corresponding service identifier.
  • the determining sub-command 6122 is configured to instruct to extract a service identifier from the lock request received by executing the receiving instruction 611, and determine whether the corresponding service request is locked according to the service identifier.
  • the lock/unlock sub-command 6121 is specifically configured to indicate that when the service request is not locked by executing the determining sub-command 6122, the service identifier is calculated according to a setting algorithm. And indexing, by the operation result, the service identifier that is requested to be locked, and setting a lock start time corresponding to the indexed service identifier to a receiving time for receiving the lock request; and receiving the service by executing the receiving instruction 611
  • the service identifier is calculated according to the setting algorithm, and the service identifier requested to be unlocked is indexed according to the operation result, and the indexed service identifier and the corresponding locking start time are cleared.
  • the determining sub-command 6122 is specifically configured to indicate that the service identifier is operated according to the setting algorithm, and the service identifier that is requested to be locked according to the operation result index, if the index is to the service identifier and the corresponding lock start time, the judgment The service request requesting the lock is locked. Otherwise, it is judged that the requested service request is unlocked.
  • the memory 61 is further configured to store a lock data list for recording a correspondence between the service identifier and the service request status.
  • the lock/unlock sub-command 6121 is specifically configured to indicate that when the service request is not locked by executing the determining sub-command 6122, the service identifier is set according to the setting.
  • the algorithm performs an operation, indexes the service identifier requested to be locked according to the operation result, and sets a lock start time corresponding to the indexed service identifier to a receiving time for receiving the lock request; and, by executing the receiving instruction 611, when receiving the unlocking request sent by the service server, performing operation on the service identifier according to the setting algorithm, indexing the service identifier requested to be unlocked according to the operation result, and setting a lock start time corresponding to the indexed service identifier to Initial value.
  • the determining sub-command 6122 is specifically configured to indicate that the service identifier is operated according to the setting algorithm, and according to the operation result index, the service identifier that is requested to be locked, if the index is to the service identifier, and the corresponding locking start time is not initial.
  • the value determines that the requested service request is locked, otherwise, it determines that the requested service request is unlocked.
  • the lock/unlock sub-command 6121 is specifically configured to indicate that when the service request is not locked by executing the determining sub-command 6122, the service identifier is operated according to a setting algorithm. And indexing, by the operation result, the service identifier that is requested to be locked, and setting the service request status corresponding to the indexed service identifier to a locked state; and receiving the unlock request sent by the service server by executing the receiving instruction 611,
  • the service identifier is calculated according to the setting algorithm, and the service identifier requested to be unlocked is indexed according to the operation result, and the indexed service identifier and the corresponding service request state are cleared.
  • the determining sub-command 6122 is specifically configured to indicate that the service identifier is operated according to the setting algorithm, and the service identifier that is requested to be locked is indexed according to the operation result index, and if the index is to the service identifier and the corresponding service request state, the request is determined.
  • the locked service request is locked, otherwise, it is judged that the requested service request is unlocked.
  • the lock/unlock sub-command 6121 is specifically configured to indicate that when the service request is not locked by the execution of the judgment sub-command 6122, the service identifier is operated according to the setting algorithm, and the request is added according to the operation result index.
  • the service identifier of the lock, and the service request status corresponding to the indexed service identifier is set to the lock state;
  • the receiving instruction 611 When receiving the unlocking request sent by the service server, the receiving instruction 611 performs an operation on the service identifier of the service request that is requested to be unlocked according to the setting algorithm, and indexes the service identifier requested to be unlocked according to the operation result, and corresponds to the indexed service identifier.
  • the business request status is set to the unlocked state.
  • the determining sub-command 6122 is specifically configured to indicate that the service identifier is operated according to the setting algorithm, and the service identifier that is requested to be locked according to the operation result index, if the index is to the service identifier and the service request status value corresponding to the service identifier is a locked state, For example, if it is 1, it is determined that the requested service request is locked. Otherwise, if the index is to the service identifier and the service request status value corresponding to the service identifier is an unlocked state, for example, 0, the requested lock is determined. Business requests are unlocked.
  • FIG. 7 is a schematic structural diagram of still another service server according to an embodiment of the present invention.
  • the service lock server includes: a memory 71 and a command 711, a processing instruction 712, and a receive command 713 with the memory 71.
  • the sending instruction 711 is configured to send a locking request to the synchronization lock server to lock the service request, so that the synchronization lock server determines whether the service request requested to be locked is locked, and determines that the service request is not When the lock is locked, the service request is locked, and a lock success response is returned to the service server; when it is determined that the service request has been locked, a lock failure response is returned to the server.
  • the processing instruction 712 is configured to indicate that the service processing is performed according to the service request when receiving the locking success response by executing the receiving instruction 713; and, when receiving the locking failure response by executing the receiving instruction 713, temporarily giving up the The service request performs service processing, and transmits a lock request to the synchronization lock server again by executing the sending instruction 711 according to a preset number of times and/or frequencies.
  • the sending instruction 711 is further configured to: after completing the service processing by executing the processing instruction 712, send an unlock request to the synchronization lock server, so that the synchronization lock server is configured to The business request is unlocked.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Lock And Its Accessories (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Computer And Data Communications (AREA)

Description

一种并行业务处理方法、 设备及系统 本申请要求于 2012 年 08 月 24 日提交中国专利局、 申请号为 201210303495.6、 发明名称为"一种并行业务处理方法、 设备及系统"的 中国专利申请的优先权, 其全部内容通过引用结合在本申请中。 技术领域
本发明涉及通信技术领域, 特别是涉及一种并行业务处理方法、 设 备及系统。 发明背景
典型的互联网系统模型分为三层结构, 即接口层、业务层和数据层。 接口层用于将调用者的请求转发给业务层, 隔离调用者和业务系统; 业 务层用于按照一定的逻辑流程处理调用者的请求, 通常要返回处理结 果; 数据层用于存储业务层的处理结果, 供下次调用时使用。 业务层按 照特定的执行序列处理请求, 且处理过程中会从数据层读取数据或将中 间处理结果写入数据层。 执行序列是指, 处理一个请求需要的多个逻辑 处理步骤。
根据互联网的特点, 往往需要在多个城市、 同一城市的不同 IDC ( Internet Data Center, Internet数据中心)或者同一 IDC的不同服务器 部署并行业务层, 这时如果同一个业务请求同时出现在多个并行的业务 层, 必然会交叉执行同一逻辑执行序列, 并由此产生逻辑混乱和数据不 一致的问题。 因此, 需要一种同步机制, 使得同一个业务请求的执行序 列能够在多个业务层间同步执行。
当前进程间通信的同步方案有管道、 FIFO ( First Input First Output ) 命名管道、 共享内存、 消息队列、 以及信号量等。 然而, 现有的进程间 通信的同步方案都是处理部署在同一台服务器上的多个进程间的同步 需求, 无法处理跨城市、 跨 IDC和跨服务器间的进程同步需求。
因此, 亟需一种并行业务处理方案用以解决上述问题。 发明内容
本发明的目的在于提供一种并行业务层业务同步的实现方法、 设备 及系统, 用以解决在跨城市、跨 IDC或跨服务器上部署的并行业务层上 执行同一个业务请求带来的逻辑混乱和数据不一致的问题, 保证业务处 理结果的准确性。
为此, 本发明实施例采用如下技术方案:
本发明实施例提供一种并行业务处理方法, 所述方法包括: 同步锁服务器接收到业务服务器发送的加锁请求后, 判断所请求 加锁的业务请求是否已加锁, 若所述业务请求未加锁, 则对所述业务 请求进行加锁, 并向所述业务服务器返回加锁成功响应; 若所述业务 请求已加锁, 则向所述业务服务器返回加锁失败响应。
本发明实施例还提供一种并行业务处理方法, 所述方法包括: 业务服务器向同步锁服务器发送对业务请求进行加锁的加锁请 求, 以使所述同步锁服务器判断所请求加锁的业务请求是否已加锁, 在判断所述业务请求未加锁时, 则对所述业务请求进行加锁, 并向所 述业务服务器返回加锁成功响应, 在判断所述业务请求已加锁时, 向 所述业务服务器返回加锁失败响应;
若所述业务服务器接收到加锁成功响应, 则根据所述业务请求进 行业务处理;
若所述业务服务器接收到加锁失败响应, 则暂时放弃对所述业务 请求进行业务处理, 并按照预设的次数和 /或频率再次向所述同步锁服 务器发送加锁请求。
本发明实施例还提供一种同步锁服务器, 所述同步锁服务器包 括:
接收模块, 用于接收业务服务器发送的加锁请求;
处理模块, 用于在所述接收模块接收到加锁请求后, 判断所请求 加锁的业务请求是否已加锁, 当所述业务请求未加锁时, 对所述业务 请求进行加锁, 并通过发送模块向所述业务服务器返回加锁成功响 应; 当所述业务请求已加锁时, 通过发送模块向所述业务服务器返回 加锁失败响应。
本发明实施例还提供一种业务服务器, 所述业务服务器包括: 发送模块, 用于向同步锁服务器发送对业务请求进行加锁的加锁 请求, 以使所述同步锁服务器判断所请求加锁的业务请求是否已加 锁, 在判断所述业务请求未加锁时, 所述同步锁服务器对所述业务请 求进行加锁, 并向所述业务服务器返回加锁成功响应; 在判断所述业 务请求已加锁时, 所述同步锁服务器向所述业务服务器返回加锁失败 响应;
处理模块, 用于在接收模块接收到加锁成功响应时, 根据所述业 务请求进行业务处理; 以及, 在接收模块接收到加锁失败响应时, 暂 时放弃对所述业务请求进行业务处理, 并按照预设的次数和 /或频率再 次通过所述发送模块向所述同步锁服务器发送加锁请求。
本发明实施例还提供一种并行业务处理系统, 所述系统包括: 所述 同步锁服务器以及所述业务服务器。
与现有技术相比, 本发明的实施例具有如下优点:
本发明实施例通过同步锁服务器根据加锁请求, 在判断所请求的业 务请求未加锁时, 对该业务请求进行加锁, 并返回加锁成功响应, 以使 业务 务器在接收到加锁成功响应后进行相应的业务处理; 否则, 向业 务服务器返回加锁失败响应。 通过对并行业务请求设置加锁 /解锁机制, 使得在包括至少两个业务服务器的分布式业务处理系统中, 针对一个业 务请求, 保证每次只有一个业务层请求加锁成功, 解决了在跨城市、 跨
IDC或跨服务器上部署并行业务, 当执行同一个业务请求时, 业务处理 逻辑混乱以及数据不一致的问题, 保证了业务处理结果的准确性。 附图简要说明
图 1为本发明实施例提供的分布式业务处理系统架构示意图; 图 2为本发明实施例提供的一种并行业务处理流程示意图; 图 3为本发明实施例提供的又一种并行业务处理流程示意图; 图 4为本发明实施例提供的同步锁服务器的结构示意图;
图 5为本发明实施例提供的业务服务器的结构示意图;
图 6为本发明实施例提供的又一种同步锁服务器的结构示意图; 图 7为本发明实施例提供的又一种业务服务器的结构示意图。 实施本发明的方式
针对在跨城市、跨 IDC或跨服务器上部署并行业务的应用场景, 多 个并行业务层同时处理同一个业务请求, 引起的业务处理逻辑混乱以及 数据不一致的问题, 本发明实施例提供的并行业务处理方案, 每次对一 个业务层的业务请求进行加锁, 之后进行业务处理, 保证业务处理结果 的准确性。
下面将结合本发明中的附图, 对本发明中的技术方案进行清楚、 完 整的描述, 显然, 所描述的实施例是本发明的一部分实施例, 而不是全 部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有做出 创造性劳动的前提下所获得的所有其他实施例, 都属于本发明保护的范 围。
本发明实施例提供的并行业务处理方法, 应用于包括同步锁服务 器和数据中心的业务处理系统, 该业务处理系统可以包括多个数据中 心, 所述多个数据中心形成分布式架构; 或者, 该业务处理系统也可以 只包括一个数据中心, 该数据中心内包括多个业务服务器, 各业务服 务器形成分布式架构。 本发明实施例以包括同步锁服务器和至少两个 业务服务器的分布式业务处理系统为例进行详细说明。 如图 1所示, 分 布式业务处理系统包括: 同步锁服务器 11和数据中心 12, 还可以包括 用于存储业务处理结果的数据库, 数据中心 12可以包括多个接口机 121 和多个业务服务器 122, 各接口机 121与各业务服务器 122形成并行的 业务处理层, 用于并行处理业务。 同步锁服务器 11 用于根据业务服务 器 122发送的加锁请求对相应的业务请求进行加锁, 以及根据业务服务 器 122发送的解锁请求对相应的业务请求进行解锁; 业务服务器 122用 于向同步锁服务器 11 发送加锁请求和解锁请求, 并在业务请求被加锁 后, 根据该业务请求进行相应的业务处理; 接口机 121用于接收客户端 13发送的业务请求, 并将业务请求发送给相应的业务服务器 122。
以下以图 1所示的分布式业务处理系统架构为例, 结合图 2详细说 明并行业务处理流程, 如图所示, 该流程包括:
步骤 201 , —业务服务器 122向同步锁服务器 11发送对业务请求进 行加锁的加锁请求。
具体的, 客户端 13向接口机 121发送业务请求, 接口机 121接收 到该业务请求后, 将该业务请求发送给各业务服务器 122。 业务服务器 122接收到接口机 121 发送的业务请求后, 不直接执行相应的业务逻 辑, 而是将该业务请求发送给同步锁服务器 11 , 请求对该业务请求加 锁。
步骤 202, 同步锁服务器 11接收加锁请求, 并判断该业务请求是否 已加锁, 若已加锁, 则执行步骤 203, 否则, 执行步骤 204。
步骤 203, 同步锁服务器 11向所述业务服务器 122返回加锁失败响 应。
具体的, 若同步锁服务器 11 在接收到加锁请求后, 判断该业务请 求已加锁, 则向所述业务服务器 122返回加锁失败响应, 以使所述业务 服务器 122暂时放弃对该业务请求进行业务处理。
所述业务服务器 122接收到加锁失败响应后, 不会进行相应的业务 处理。 优选的, 所述业务服务器 122在接收到同步锁服务器 11发送的 加锁失败响应后, 可以按照预设的次数和 /或频率再次向同步锁服务器 11发送加锁请求, 以确保本业务服务器 122处理该业务请求的机会更大 一些。 其中, 再次发送加锁请求的次数和 /或发送频率与应用场景以及 业务处理时间相关。
步骤 204, 同步锁服务器 11对该业务请求进行加锁, 并向所述业务 服务器 122返回加锁成功响应, 以使所述业务服务器 122根据该业务请 求进行业务处理。 其中, 加锁成功后, 对应该业务请求便只能由发送所 述加锁请求的业务服务器进行业务处理, 而其它业务服务器则不能进行 业务处理了。
步骤 205, 所述业务服务器 122在接收到加锁成功响应后, 进行相 应的业务处理, 并将业务处理结果存储于数据库当中。 此外, 其它的业 务服务器便不能进行业务处理了。 这就防止了现有技术中业务处理逻辑 混乱以及数据不一致的问题的发生。
步骤 206, 所述业务服务器 122在完成业务处理后, 向同步锁服务 器 11发送解锁请求。 步骤 207, 同步锁服务器 11对该业务请求进行解锁。
具体的, 同步锁服务器 11 在接收到对该业务请求进行解锁的解锁 请求后, 对该业务请求解锁, 该解锁请求是所述业务服务器 122在完成 业务处理后所发送的。
在并行业务处理过程中, 有两种情况会造成业务请求的同步锁被 永远锁住:
1、 若同步锁服务器 11判断该业务请求处于未加锁状态, 则对该业 务请求加锁, 并向相应的业务服务器 122返回加锁成功响应, 但是该业 务 务器 122并未收到该加锁成功响应, 此时, 该业务请求已处于加锁 状态, 但是该业务服务器 122无法进行相应的业务处理, 若其他业务服 务器 122向同步锁服务器 11发送对该业务请求进行加锁的加锁请求, 由于该业务请求仍处于加锁状态, 因此, 同步锁服务器 11 会返回加锁 失败响应, 由此导致该业务请求被永远锁住。
2、 若同步锁服务器 11 对业务请求加锁之后, 未收到业务服务器 122发送的解锁请求, 这样也会导致该业务请求被永远锁住。
因此, 为了避免业务请求的同步锁被永远锁住, 可以通过在同步 锁服务器 11 上设置定时器 (定时器的计时时长即为加锁时间有效期 限) , 来限制业务请求的加锁时长, 该定时器的计时时长大于等于业务 服务器 122处理业务请求的处理时间。
如图 3所示, 为本发明另一实施例提供的非正常解锁的并行业务处 理流程, 该流程包括以下步骤:
步骤 301 , —业务服务器 122向同步锁服务器 11发送对业务请求进 行加锁的加锁请求。
步骤 302, 同步锁服务器 11接收加锁请求, 并判断该业务请求是否 已加锁, 若已加锁, 则执行步骤 303, 否则, 执行步骤 304。 步骤 303, 同步锁服务器 11向所述业务服务器 122返回加锁失败响 应。
步骤 304, 同步锁服务器 11对业务请求进行加锁, 启动定时器, 并 向所述业务服务器 122返回加锁成功响应。
步骤 305, 当定时器的计时时长到达时, 同步锁服务器 11对该业务 请求进行解锁。
在本实施例中, 步骤 304中的启动定时器操作, 以及步骤 305的在 定时器的计时时长到达时, 对业务请求进行解锁的操作为新增操作。 利用定时器监控业务请求的加锁时长, 并在条件满足时改变业务请求的 加锁状态, 使得同步锁服务器 11 在每次接收到加锁请求时, 可以仅判 断该业务请求的加锁状态, 而不用考虑加锁时长, 提高了同步锁服务器 11的处理效率, 对于在短时间内接收到多次加锁请求的情况, 可以明显 提高系统的业务处理能力。
当同步锁服务器 11与业务服务器 122之间发生通信故障或者其他 故障时, 同步锁服务器 11 发送的加锁成功响应无法送达业务服务器 122, 业务服务器 122无法进行相应的业务处理, 而实际该业务请求已 处于加锁状态, 导致该业务请求被永远锁死; 或者, 当业务服务器 122 发送的解锁请求无法到达同步锁服务器 11 时, 也会导致业务请求被永 远锁死。 本发明实施例利用定时器限定加锁时间的有效期限, 在加锁 时间的有效期限到期时, 对业务请求进行强制解锁, 能够有效避免业 务请求被永远锁死的情况, 确保业务流程的顺利进行。
在本发明的上述实施例中, 同步锁服务器判断所请求加锁的业务 请求是否加锁的处理(步骤 202 ) 、 以及对业务请求进行加锁处理(步 骤 204 )或解锁处理(步骤 207 ) , 可以通过以下方式实现:
在同步锁服务器 11中建立用于记录业务标识与加锁开始时间的对 应关系的加锁数据列表, 该加锁数据列表如表 1所示:
表 1
Figure imgf000011_0001
加锁数据列表包括业务标识及对应的业务请求的加锁开始时间, 才艮据应用场景的不同, 业务标识可以为业务类型标识或者用户标识。
优选的, 同步锁服务器 11 可以从加锁请求中提取业务标识, 并根 据所述业务标识对相应的业务请求进行加锁。优选的, 同步锁服务器 11 可以根据应用场景的不同, 选择 HASH 算法或者全量直接映射算法对 业务标识进行运算。
在业务标识分布较为分散的情形下, 可以使用 HASH 算法对业务 标识进行计算, 例如, 加锁过程可以为: 同步锁服务器 11 对业务标识 进行哈希运算, 根据哈希结果索引所请求加锁的业务标识, 并将索引 到的业务标识对应的加锁开始时间设置为接收加锁请求的接收时间。 相 应的, 解锁过程可以是: 同步锁服务器 11 对业务标识进行哈希运算, 根据哈希结果索引所请求解锁的业务标识, 并清除索引到的业务标识及 对应的加锁开始时间。 相应的, 判断所请求加锁的业务请求是否加锁的 过程可以为: 同步锁服务器 11 对业务标识进行哈希运算, 根据哈希结 果在表 1中索引所请求加锁的业务标识, 若索引到业务标识以及对应的 加锁开始时间, 则判断所请求加锁的业务请求为已加锁, 否则, 判断 所请求加锁的业务请求为未加锁。
在业务标识分布较为集中的情形下, 可以使用全量直接映射算法 对业务标识进行计算, 例如, 加锁过程可以为: 同步锁服务器 11 对业 务标识按照全量直接映射算法进行运算, 根据运算结果索引所请求加 锁的业务标识, 并将索引到的业务标识对应的加锁开始时间设置为接 收加锁请求的接收时间。 相应的, 解锁过程可以是: 同步锁服务器 11 对业务标识按照全量直接映射算法进行运算, 根据运算结果索引所请 求解锁的业务标识, 并将与索引到的业务标识对应的加锁开始时间设置 为初始值; 相应的, 判断所请求加锁的业务请求是否已加锁的过程可 以为: 同步锁服务器 11 对业务标识按照全量直接映射算法进行运算, 并根据运算结果在表 1中索引所请求解锁的业务标识, 若索引到业务标 识, 且对应的加锁开始时间非初始值, 则判断所请求加锁的业务请求为 已加锁; 若未索引到业务标识以及对应的加锁开始时间 (首次接收到该 业务的加锁请求)或者索引到业务标识, 且对应的加锁开始时间为初始 值(该业务请求已解锁) , 则判断所请求加锁的业务请求为未加锁。
例如, 若在表 1中查询业务标识为 ID3的业务请求是否已加锁, 且 未查询到相关记录, 则可以判断出该业务请求是首次请求加锁, 则执 行步骤 204; 若在表 1中查询业务标识为 ID2的业务请求是否已加锁, 且查询到一条加锁记录, 且该条加锁记录中的加锁时间为 0 (在本实施 例中, 加锁开始时间初始值为 0, 本领域技术人员可知, 加锁开始时间 初始值可以任意设定) , 可以判断出该业务请求曾经加锁后又解锁, 则 执行步骤 204; 若在表 1 中查询业务标识为 ID1 的业务请求是否已加 锁, 查询到一条加锁记录, 且该条加锁记录中的加锁时间不为 0, 可以 判断出该业务请求已加锁, 则执行步骤 203。
上述方法中, 在使用 HASH算法对业务标识进行计算时, 也可在解 锁过程中, 在根据哈希结果索引所请求解锁的业务标识时, 将与索引到 的业务标识对应的加锁开始时间设置为初始值。 相应地, 判断所请求加 锁的业务请求是否加锁的过程中, 在根据哈希结果在表 1中索引所请求 加锁的业务标识时, 若索引到业务标识, 且对应的加锁开始时间非初始 值, 则可判断所请求加锁的业务请求为已加锁; 若未索引到业务标识以 及对应的加锁开始时间 (首次接收到该业务的加锁请求)或者索引到业 务标识, 且对应的加锁开始时间为初始值(该业务请求已解锁) , 则可 判断所请求加锁的业务请求为未加锁。
同理, 在使用全量直接映射算法对业务标识进行计算时, 也可在解 锁过程中, 在根据运算结果索引所请求解锁的业务标识时, 清除索引到 的业务标识及对应的加锁开始时间。 相应的, 判断所请求加锁的业务请 求是否加锁的过程中, 根据运算结果在表 1中索引所请求加锁的业务标 识时, 若索引到业务标识以及对应的加锁开始时间, 则判断所请求加 锁的业务请求为已加锁, 否则, 判断所请求加锁的业务请求为未加 锁。
除了记录加锁开始时间, 并通过判断加锁开始时间判断业务请求 是否处于加锁状态之外, 在本发明的另一实施例中, 也可以在同步锁 服务器 11上记录业务请求的加锁 /解锁状态, 并根据业务请求的加锁 /解 锁状态判断该业务请求是否已加锁。 在本实施例中, 可在同步锁服务 器 11 中建立用于记录业务标识与业务请求状态的对应关系的加锁数据 列表(表 2 ) , 业务请求状态包括加锁状态和解锁状态。 同步锁服务器 11 可以从加锁请求中提取业务标识, 并对业务标识进行运算并进行索 引, 从而记录业务标识对应的业务请求状态。
表 2
Figure imgf000013_0001
ID4 1
ID2 0 同步锁服务器 11 根据所述业务标识对相应的业务请求进行加锁, 具体可以为: 同步锁服务器 11 对业务标识进行哈希运算, 根据哈希结 果索引所请求加锁的业务标识, 并将索引到的业务标识对应的业务请 求状态设置为加锁状态, 例如, 在表 2中, 将业务标识业务请求状态值 设置为 1。
相应的, 同步锁服务器 11 根据业务标识对相应的业务请求进行解 锁, 具体可以为: 同步锁服务器 11 对业务标识进行哈希运算, 根据哈 希结果索引所请求解锁的业务标识, 并清除索引到的业务标识及对应的 业务请求状态; 或者, 将与索引到的业务标识对应的业务请求状态设置 为解锁状态, 例如, 将业务请求状态值设置为 0。
相应的, 同步锁服务器 11 根据业务标识判断相应的业务请求是否 已加锁, 具体可以为: 同步锁服务器 11 对业务标识进行哈希运算, 根 据哈希结果索引所请求加锁的业务标识, 若索引到业务标识以及对应 的业务请求状态, 例如, 索引到该业务标识对应的业务请求状态值为
1 , 则判断所请求加锁的业务请求为已加锁; 若未索引到该业务标识以 及对应的业务请求状态, 则判断所请求加锁的业务请求为未加锁。 或 者, 若索引到业务标识且该业务标识对应的业务请求状态值为解锁状 态, 例如为 0, 则判断所请求加锁的业务请求为未加锁。
同步锁服务器 11 还可以根据业务标识, 通过全量直接映射算法实 现加锁、 解锁以及判断业务请求状态。
具体的, 加锁过程可以为: 同步锁服务器 11 对业务标识按照全量 直接映射算法进行运算, 根据运算结果索引所请求加锁的业务标识, 并将索引到的业务标识对应的业务请求状态设置为加锁状态, 例如, 将业务请求状态值设置为 1。
相应的, 解锁过程可以为: 同步锁服务器 11 根据业务标识对所请 求解锁的业务请求的业务标识按照全量直接映射算法进行运算, 根据 运算结果索引所请求解锁的业务标识, 并将与索引到的业务标识对应的 业务请求状态设置为解锁状态, 例如, 将业务请求状态值设置为 0。 或 者, 清除索引到的业务标识及对应的业务请求状态。
相应的, 根据业务标识判断相应的业务请求是否已加锁的过程可 以为: 同步锁服务器 11 对业务标识按照全量直接映射算法进行运算, 并根据运算结果索引所请求加锁的业务标识, 若索引到业务标识且该 业务标识对应的业务请求状态值为 1 , 则判断所请求加锁的业务请求为 已加锁; 否则, 若索引到业务标识且该业务标识对应的业务请求状态 值为 0, 则判断所请求加锁的业务请求为未加锁。 或者, 若未索引到该 业务标识以及对应的业务请求状态, 则判断所请求加锁的业务请求为 未加锁。
本发明实施例通过对并行业务请求设置加锁 /解锁机制, 使得在包 括至少两个业务服务器的分布式业务处理系统中, 针对一个业务请 求, 保证每次只有一个业务层请求加锁成功, 解决了在跨城市、 跨 IDC 或跨服务器上部署并行业务, 当执行同一个业务请求时, 业务处理逻 辑混乱以及数据不一致的问题, 保证了业务处理结果的准确性。 基于相同的构思, 本发明实施例还提供一种同步锁服务器, 如图 4 所示, 同步锁服务器包括: 接收模块 41、 处理模块 42和发送模块 43。
其中, 接收模块 41用于接收业务服务器发送的加锁请求。
处理模块 42用于在接收模块 41接收到加锁请求后, 判断所请求加 锁的业务请求是否已加锁, 当业务请求未加锁时, 对业务请求进行加 锁, 并通过发送模块 43 向所述业务服务器返回加锁成功响应; 当该业 务请求已加锁时, 通过发送模块 43 向所述业务服务器返回加锁失败响 应。
处理模块 42还用于在对业务请求进行加锁之后, 启动定时器, 并 在定时器计时时长到达时, 对所请求解锁的业务请求进行解锁; 定时 器的计时时长大于等于业务服务器处理业务请求的处理时间。
接收模块 41 还用于接收业务服务器发送的解锁请求, 解锁请求是 业务服务器在完成业务处理后发送的。
处理模块 42还用于在接收模块 41接收到业务服务器发送的解锁请 求后, 对所请求解锁的业务请求进行解锁。
处理模块 42包括判断子模块 421和加锁 /解锁子模块 422。
加锁 /解锁子模块 422用于从接收模块 41接收到的加锁请求中提取 业务标识, 并在判断子模块 421判断请求加锁的业务请求未加锁时, 根 据所述业务标识对相应的业务请求进行加锁; 以及从接收模块接收到的 解锁请求中提取业务标识, 并根据业务标识对相应的业务请求进行解 锁。
判断子模块 421用于从接收模块 41接收到的加锁请求中提取业务 标识, 并根据业务标识判断相应的业务请求是否加锁。
在一个实施方式中, 加锁 /解锁子模块 422 具体用于在判断子模块 421 判断业务请求未加锁时, 对业务标识进行哈希运算, 根据哈希结果 索引所请求加锁的业务标识, 并将索引到的业务标识对应的加锁开始 时间设置为接收加锁请求的接收时间; 以及, 在接收模块 41 接收到业 务服务器发送的解锁请求时, 对业务标识进行哈希运算, 根据哈希结 果索引所请求解锁的业务标识, 并清除索引到的业务标识及对应的加锁 开始时间; 或者, 将与索引到的业务标识对应的加锁开始时间设置为初 始值。
判断子模块 421具体用于对业务标识进行哈希运算, 根据哈希结果 索引所请求加锁的业务标识, 若索引到业务标识以及对应的加锁开始 时间, 则判断所请求加锁的业务请求为已加锁, 否则, 判断所请求加 锁的业务请求为未加锁。 或者索引到业务标识, 且对应的加锁开始时间 非初始值, 则判断所请求加锁的业务请求为已加锁, 否则, 索引到业务 标识且对应的加锁开始时间为初始值(该业务请求已解锁) , 则可判断 所请求加锁的业务请求为未加锁。
在又一个实施方式中, 加锁 /解锁子模块 422 具体用于在判断子模 块 421判断业务请求未加锁时, 对业务标识按照全量直接映射算法进行 运算, 根据运算结果索引所请求加锁的业务标识, 并将与索引到的业 务标识对应的加锁开始时间设置为接收加锁请求的接收时间; 以及, 在接收模块 41 接收到业务服务器发送的解锁请求时, 对业务标识按照 全量直接映射算法进行运算, 根据运算结果索引所请求解锁的业务标 识,并将与索引到的业务标识对应的加锁开始时间设置为初始值;或者, 清除索引到的业务标识及对应的加锁开始时间。
判断模块 421 具体用于对业务标识按照全量直接映射算法进行运 算, 并根据运算结果索引所请求加锁的业务标识, 若索引到业务标识, 且对应的加锁开始时间非初始值, 则判断所请求加锁的业务请求为已 加锁, 否则, 判断所请求加锁的业务请求为未加锁。
在又一个实施方式中, 加锁 /解锁子模块 421 具体用于在判断子模 块 421判断业务请求未加锁时, 对业务标识进行哈希运算, 根据哈希结 果索引所请求加锁的业务标识, 并将索引到的业务标识对应的业务请 求状态设置为加锁状态; 以及在接收模块 41 接收到业务服务器发送的 解锁请求时, 对所请求解锁的业务请求的业务标识进行哈希运算, 根 据哈希结果索引所请求解锁的业务标识, 并清除索引到的业务标识及对 应的业务请求状态; 或者, 将与索引到的业务标识对应的业务请求状态 设置为解锁状态, 例如, 将业务请求状态值设置为 0。
判断子模块 421具体用于对业务标识进行哈希运算, 根据哈希结果 索引所请求加锁的业务标识, 若索引到业务标识以及对应的业务请求 状态, 则判断所请求加锁的业务请求为已加锁, 否则, 则判断所请求 加锁的业务请求为未加锁。 或者, 若索引到业务标识且该业务标识对应 的业务请求状态值为解锁状态, 例如为 0, 则判断所请求加锁的业务请 求为未加锁。
在又一个实施方式中,加锁 /解锁子模块 421具体用于在判断子模块 421 判断业务请求未加锁时, 对业务标识按照全量直接映射算法进行运 算, 根据运算结果索引所请求加锁的业务标识, 并将与索引到的业务 标识对应的业务请求状态设置为加锁状态; 以及在接收模块 41 接收到 业务服务器发送的解锁请求时, 对所请求解锁的业务请求的业务标识 按照全量直接映射算法进行运算, 根据运算结果索引所请求解锁的业 务标识, 并将与索引到的业务标识对应的业务请求状态设置为解锁状 态。 或者, 清除索引到的业务标识及对应的业务请求状态。
判断子模块 421具体用于对业务标识按照全量直接映射算法进行运 算, 根据运算结果索引所请求加锁的业务标识, 若索引到业务标识且 该业务标识对应的业务请求状态值为加锁状态, 例如为 1 , 则判断所请 求加锁的业务请求为已加锁, 否则, 若索引到业务标识且该业务标识 对应的业务请求状态值为解锁状态, 例如为 0, 则判断所请求加锁的业 务请求为未加锁。 或者, 若未索引到该业务标识以及对应的业务请求状 态, 则判断所请求加锁的业务请求为未加锁。 基于相同的构思, 本发明实施例还提供一种业务服务器, 如图 5所 示, 业务服务器包括: 发送模块 51、 处理模块 52和接收模块 53。
其中, 发送模块 51 用于向同步锁服务器发送对业务请求进行加锁 的加锁请求, 以使所述同步锁服务器判断所请求加锁的业务请求是否 加锁, 在判断所述业务请求未加锁时, 则对所述业务请求进行加锁, 并向所述业务服务器返回加锁成功响应; 在判断所述业务请求已加锁 时, 向所述业务服务器返回加锁失败响应。
处理模块 52用于在接收模块 53接收到加锁成功响应时, 根据业务 请求进行业务处理; 以及, 在接收模块 53接收到加锁失败响应时, 暂 时放弃对业务请求进行业务处理, 并按照预设的次数和 /或频率再次通 过发送模块 51向同步锁服务器发送加锁请求。
发送模块 51还用于在处理模块 52完成所述业务处理后, 向同步锁 服务器发送解锁请求, 以使同步锁服务器对所述业务请求进行解锁。
基于相同的构思, 本发明实施例还提供一种并行业务处理系统, 如 图 1所示, 并行业务处理系统包括: 同步锁服务器以及至少两个业务服 务器。 本领域技术人员可以理解实施例中的装置中的模块可以按照实施 例描述进行分布于实施例的装置中, 也可以进行相应变化位于不同于本 实施例的一个或多个装置中。 上述实施例的模块可以合并为一个模块, 也可以进一步拆分成多个子模块。
通过以上的实施方式的描述, 本领域的技术人员可以清楚地了解到 本发明可借助软件加必需的通用硬件平台的方式来实现, 当然也可以通 过硬件, 但很多情况下前者是更佳的实施方式。 基于这样的理解, 本发 明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产 品的形式体现出来, 该计算机软件产品存储在一个存储介质中, 包括若 干指令用以使得一台终端设备(可以是手机, 个人计算机, 服务器, 或 者网络设备等)执行本发明各个实施例所述的方法。
例如, 图 6为本发明实施例提供的又一种同步锁服务器的结构示意 图。 如图 6所示, 该同步锁服务器包括: 存储器 61 以及与所述存储器 61进行通信的处理器 62。 其中, 存储器 61存储有可由所述处理器 62 执行的接收指令 611、 处理指令 612和发送指令 613。
其中, 接收指令 611用于指示接收业务服务器发送的加锁请求。 处理指令 612用于指示在所述接收模块接收到加锁请求后, 判断所 请求加锁的业务请求是否已加锁, 当所述业务请求未加锁时, 对所述 业务请求进行加锁, 并指示通过发送指令 613向所述业务服务器返回加 锁成功响应; 当所述业务请求已加锁时, 指示通过发送指令 613向所述 业务服务器返回加锁失败响应。
进一步地, 所述处理指令 612还用于指示在对所述业务请求进行加 锁之后, 启动定时器, 并在所述定时器计时时长到达时, 对所请求解 锁的业务请求进行解锁; 所述定时器的计时时长大于等于业务服务器 处理所述业务请求的处理时间。
在一个实施方式中, 所述接收指令 611还用于指示接收业务服务器 发送的解锁请求, 所述解锁请求是业务服务器在完成业务处理后发送 的。
所述处理指令 612还用于指示在执行所述接收指令 611接收到业务 服务器发送的解锁请求后, 对所请求解锁的业务请求进行解锁。
具体地, 所述处理指令 612可包括加锁 /解锁子指令 6121和判断子 指令 6122。
在一个实施方式中, 存储器 61 中还用于存储用于记录业务标识与 加锁开始时间的对应关系的加锁数据列表。
此时, 加锁 /解锁子指令 6121可具体用于指示从通过执行所述接收 指令 611接收到的加锁请求中提取业务标识, 并在通过执行判断子指令 6122判断请求加锁的业务请求未加锁时,根据所述业务标识对相应的业 务请求进行加锁; 以及从通过执行所述接收指令 611接收到的解锁请求 中提取业务标识, 并根据相应的业务标识对所述业务请求进行解锁。
所述判断子指令 6122用于指示从通过执行所述接收指令 611接收 到的加锁请求中提取业务标识, 并根据所述业务标识判断相应的业务请 求是否加锁。
在一个实施方式中, 所述加锁 /解锁子指令 6121具体用于指示在通 过执行所述判断子指令 6122 判断所述业务请求未加锁时, 对所述业务 标识按照设定算法进行运算, 根据运算结果索引所请求加锁的业务标 识, 并将索引到的业务标识对应的加锁开始时间设置为接收所述加锁 请求的接收时间; 以及, 在通过执行所述接收指令 611接收到业务服务 器发送的解锁请求时, 对所述业务标识按照所述设定算法进行运算, 根据运算结果索引所请求解锁的业务标识, 并清除索引到的业务标识及 对应的加锁开始时间。
判断子指令 6122具体用于指示对所述业务标识按照所述设定算法 进行运算, 根据运算结果索引所请求加锁的业务标识, 若索引到业务 标识以及对应的加锁开始时间, 则判断所请求加锁的业务请求为已加 锁, 否则, 判断所请求加锁的业务请求为未加锁。
在又一个实施方式中, 存储器 61 中还用于存储用于记录业务标识 与业务请求状态的对应关系的加锁数据列表。
此时, 所述加锁 /解锁子指令 6121具体用于指示在通过执行所述判 断子指令 6122判断所述业务请求未加锁时, 对所述业务标识按照设定 算法进行运算, 根据运算结果索引所请求加锁的业务标识, 并将索引 到的业务标识对应的加锁开始时间设置为接收所述加锁请求的接收时 间; 以及, 在通过执行所述接收指令 611接收到业务服务器发送的解锁 请求时, 对所述业务标识按照设定算法进行运算, 根据运算结果索引 所请求解锁的业务标识, 并将与索引到的业务标识对应的加锁开始时间 设置为初始值。
所述判断子指令 6122具体用于指示对所述业务标识按照设定算法 进行运算, 并根据运算结果索引所请求加锁的业务标识, 若索引到业 务标识, 且对应的加锁开始时间非初始值, 则判断所请求加锁的业务请 求为已加锁, 否则, 判断所请求加锁的业务请求为未加锁。
在又一个实施方式中, 所述加锁 /解锁子指令 6121具体用于指示在 通过执行所述判断子指令 6122判断所述业务请求未加锁时, 对所述业 务标识按照设定算法进行运算, 根据运算结果索引所请求加锁的业务 标识, 并将索引到的业务标识对应的业务请求状态设置为加锁状态; 以及在通过执行所述接收指令 611 接收到业务服务器发送的解锁请求 时, 对所述业务标识按照设定算法进行运算, 根据运算结果索引所请 求解锁的业务标识, 并清除索引到的业务标识及对应的业务请求状态。
所述判断子指令 6122具体用于指示对所述业务标识按照设定算法 进行运算, 根据运算结果索引所请求加锁的业务标识, 若索引到业务 标识以及对应的业务请求状态, 则判断所请求加锁的业务请求为已加 锁, 否则, 则判断所请求加锁的业务请求为未加锁。
在又一个实施方式中, 加锁 /解锁子指令 6121具体用于指示在通过 执行判断子指令 6122判断业务请求未加锁时, 对业务标识按照设定算 法进行运算, 根据运算结果索引所请求加锁的业务标识, 并将与索引 到的业务标识对应的业务请求状态设置为加锁状态; 以及在通过执行 接收指令 611接收到业务服务器发送的解锁请求时, 对所请求解锁的业 务请求的业务标识按照设定算法进行运算, 根据运算结果索引所请求 解锁的业务标识, 并将与索引到的业务标识对应的业务请求状态设置为 解锁状态。
判断子指令 6122 具体用于指示对业务标识按照设定算法进行运 算, 根据运算结果索引所请求加锁的业务标识, 若索引到业务标识且 该业务标识对应的业务请求状态值为加锁状态, 例如为 1 , 则判断所请 求加锁的业务请求为已加锁, 否则, 若索引到业务标识且该业务标识 对应的业务请求状态值为解锁状态, 例如为 0, 则判断所请求加锁的业 务请求为未加锁。
图 6所示实施例中,所述设定算法为哈希运算或全量直接映射算法。 图 7为本发明实施例提供的又一种业务服务器的结构示意图。 如图 7所示, 该业务锁服务器包括: 存储器 71以及与所述存储器 71进行通 指令 711、 处理指令 712和接收指令 713。
其中, 发送指令 711用于指示向同步锁服务器发送对业务请求进行 加锁的加锁请求, 以使所述同步锁服务器判断所请求加锁的业务请求 是否加锁, 在判断所述业务请求未加锁时, 则对所述业务请求进行加 锁, 并向所述业务服务器返回加锁成功响应; 在判断所述业务请求已 加锁时, 向所述业务 务器返回加锁失败响应。
处理指令 712用于指示在通过执行接收指令 713接收到加锁成功响 应时, 根据所述业务请求进行业务处理; 以及, 在通过执行接收指令 713接收到加锁失败响应时, 暂时放弃对所述业务请求进行业务处理, 并按照预设的次数和 /或频率再次通过执行所述发送指令 711 向所述同 步锁服务器发送加锁请求。 在一个实施方式中, 所述发送指令 711还用于指示在通过执行所述 处理指令 712完成所述业务处理后,向所述同步锁服务器发送解锁请求, 以使所述同步锁服务器对所述业务请求进行解锁。
以上所述仅是本发明的优选实施方式, 应当指出, 对于本技术领域 的普通技术人员来说, 在不脱离本发明原理的前提下, 还可以做出若干 改进和润饰, 这些改进和润饰也应视本发明的保护范围。

Claims

权利要求书
1、 一种并行业务处理方法, 其特征在于, 所述方法包括: 同步锁服务器接收到业务服务器发送的加锁请求后, 判断所请求 加锁的业务请求是否已加锁, 若所述业务请求未加锁, 则对所述业务 请求进行加锁, 并向所述业务服务器返回加锁成功响应; 若所述业务 请求已加锁, 则向所述业务服务器返回加锁失败响应。
2、 如权利要求 1 所述的方法, 其特征在于, 所述对所述业务请求 进行加锁之后, 所述方法还包括:
所述同步锁服务器启动定时器; 所述定时器的计时时长大于等于 所述业务服务器处理所述业务请求的处理时间;
当所述定时器的计时时长到达时, 所述同步锁服务器对所述业务 请求进行解锁。
3、 如权利要求 1 所述的方法, 其特征在于, 所述方法还包括: 所 述同步锁服务器在接收到所述业务服务器完成业务处理后所发送的解 锁请求后, 对所述业务请求进行解锁。
4、 如权利要求 1-3任一项所述的方法, 其特征在于, 所述同步锁服 务器对所述业务请求进行加锁包括: 所述同步锁服务器从接收到的加锁 请求中提取业务标识, 并根据所述业务标识对相应的业务请求进行加 锁;
所述同步锁服务器对所述业务请求进行解锁包括: 所述同步锁服务 器从接收到的解锁请求中提取业务标识, 并根据所述业务标识对相应的 业务请求进行解锁;
所述判断所请求加锁的业务请求是否已加锁包括: 所述同步锁服务 器从接收到的加锁请求中提取业务标识, 并根据所述业务标识判断相应 的业务请求是否已加锁。
5、 如权利要求 4所述的方法, 其特征在于, 所述同步锁服务器根 据所述业务标识对相应的业务请求进行加锁包括: 所述同步锁服务器 对所述业务标识按照设定算法进行运算, 根据运算结果索引所请求加 锁的业务标识, 并将索引到的业务标识对应的加锁开始时间设置为接 收所述加锁请求的接收时间;
所述同步锁服务器根据所述业务标识对相应的业务请求进行解锁 包括: 所述同步锁服务器对所述业务标识按照所述设定算法进行运 算, 根据运算结果索引所请求解锁的业务标识, 并清除索引到的业务标 识及对应的加锁开始时间, 或者将与索引到的业务标识对应的加锁开始 时间设置为初始值;
所述根据所述业务标识判断相应的业务请求是否已加锁包括: 所 述同步锁服务器对所述业务标识按照所述设定算法进行运算, 根据运 算结果索引所请求加锁的业务标识, 若索引到业务标识以及对应的加 锁开始时间, 则判断所请求加锁的业务请求为已加锁, 否则, 判断所 请求加锁的业务请求为未加锁; 或者若索引到业务标识, 且对应的加锁 开始时间非初始值, 则判断所请求加锁的业务请求为已加锁, 否则, 判断所请求加锁的业务请求为未加锁。
6、 如权利要求 4所述的方法, 其特征在于, 所述同步锁服务器根 据所述业务标识对相应的业务请求进行加锁包括: 所述同步锁服务器 对所述业务标识按照设定算法进行运算, 根据运算结果索引所请求加 锁的业务标识, 并将索引到的业务标识对应的业务请求状态设置为加 锁状态;
所述同步锁服务器根据所述业务标识对相应的业务请求进行解锁 包括: 所述同步锁服务器对所述业务标识按照所述设定算法进行运 算, 根据运算结果索引所请求解锁的业务标识, 并清除索引到的业务标 识及对应的业务请求状态, 或者将与索引到的业务标识对应的业务请求 状态设置为解锁状态;
所述根据所述业务标识判断相应的业务请求是否已加锁包括: 所 述同步锁服务器对所述业务标识按照所述设定算法进行运算, 根据运 算结果索引所请求加锁的业务标识, 若索引到业务标识以及对应的业 务请求状态, 则判断所请求加锁的业务请求为已加锁, 否则, 则判断 所请求加锁的业务请求为未加锁; 或者, 若索引到业务标识且该业务标 识对应的业务请求状态值为加锁状态, 则判断所请求加锁的业务请求为 已加锁, 否则, 若索引到业务标识且该业务标识对应的业务请求状态 值为解锁状态, 则判断所请求加锁的业务请求为未加锁。
7、 如权利要求 5或 6所述的方法, 其特征在于, 所述设定算法为 哈希运算或全量直接映射算法。
8、 一种并行业务处理方法, 其特征在于, 所述方法包括: 业务服务器向同步锁服务器发送对业务请求进行加锁的加锁请求, 以使所述同步锁服务器判断所请求加锁的业务请求是否已加锁, 在判断 所述业务请求未加锁时, 则对所述业务请求进行加锁, 并向所述业务服 务器返回加锁成功响应, 在判断所述业务请求已加锁时, 向所述业务服 务器返回加锁失败响应;
若所述业务服务器接收到加锁成功响应, 则根据所述业务请求进 行业务处理;
若所述业务服务器接收到加锁失败响应, 则暂时放弃对所述业务 请求进行业务处理, 并按照预设的次数和 /或频率再次向所述同步锁服 务器发送加锁请求。
9、 如权利要求 8 所述的方法, 其特征在于, 所述根据所述业务请 求进行业务处理之后, 所述方法还包括:
所述业务服务器在完成所述业务处理后, 向所述同步锁服务器发送 解锁请求, 以使所述同步锁服务器对所述业务请求进行解锁。
10、 一种同步锁服务器, 其特征在于, 所述同步锁服务器包括: 接收模块, 用于接收业务服务器发送的加锁请求;
处理模块, 用于在所述接收模块接收到加锁请求后, 判断所请求 加锁的业务请求是否已加锁, 当所述业务请求未加锁时, 对所述业务 请求进行加锁, 并通过发送模块向所述业务服务器返回加锁成功响 应; 当所述业务请求已加锁时, 通过发送模块向所述业务服务器返回 加锁失败响应。
11、 如权利要求 10 所述的同步锁服务器, 其特征在于, 所述处理 模块还用于, 在对所述业务请求进行加锁之后, 启动定时器, 并在所 述定时器计时时长到达时, 对所请求解锁的业务请求进行解锁; 所述 定时器的计时时长大于等于业务服务器处理所述业务请求的处理时 间。
12、 如权利要求 10所述的同步锁服务器, 其特征在于,
所述接收模块还用于, 接收所述业务服务器发送的解锁请求, 所述 解锁请求是所述业务服务器在完成业务处理后发送的;
所述处理模块还用于, 在所述接收模块接收到所述业务服务器发送 的解锁请求后, 对所请求解锁的业务请求进行解锁。
13、 如权利要求 10-12任一项所述的同步锁服务器, 其特征在于, 所述处理模块包括加锁 /解锁子模块和判断子模块;
所述加锁 /解锁子模块用于, 从所述接收模块接收到的所述加锁请 求中提取业务标识, 并根据所述业务标识对相应的业务请求进行加锁; 以及从所述接收模块接收到的所述解锁请求中提取业务标识, 并根据相 应的业务标识对所述业务请求进行解锁;
所述判断子模块用于, 从所述接收模块接收到的所述加锁请求中 提取业务标识, 并根据所述业务标识判断相应的业务请求是否已加锁。
14、 如权利要求 13所述的同步锁服务器, 其特征在于,
所述加锁 /解锁子模块具体用于, 在所述判断子模块判断所述业务 请求未加锁时, 对所述业务标识按照设定算法进行运算, 根据运算结 果索引所请求加锁的业务标识, 并将索引到的业务标识对应的加锁开 始时间设置为接收所述加锁请求的接收时间; 以及, 在所述接收模块 接收到业务服务器发送的解锁请求时, 对所述业务标识按照所述设定 算法进行运算, 根据运算结果索引所请求解锁的业务标识, 并清除索引 到的业务标识及对应的加锁开始时间, 或者将与索引到的业务标识对应 的加锁开始时间设置为初始值;
所述判断子模块具体用于, 对所述业务标识按照所述设定算法进 行运算, 根据运算结果索引所请求加锁的业务标识, 若索引到业务标 识以及对应的加锁开始时间, 则判断所请求加锁的业务请求为已加 锁, 否则, 判断所请求加锁的业务请求为未加锁; 或者若索引到业务标 识, 且对应的加锁开始时间非初始值, 则判断所请求加锁的业务请求为 已加锁, 否则, 判断所请求加锁的业务请求为未加锁。
15、 如权利要求 13所述的同步锁服务器, 其特征在于,
所述加锁 /解锁子模块具体用于, 在所述判断子模块判断所述业务 请求未加锁时, 对所述业务标识按照设定算法进行运算, 根据运算结 果索引所请求加锁的业务标识, 并将索引到的业务标识对应的业务请 求状态设置为加锁状态; 以及在所述接收模块接收到业务服务器发送 的解锁请求时, 对所述业务标识按照所述设定算法进行运算, 根据运 算结果索引所请求解锁的业务标识, 并清除索引到的业务标识及对应的 业务请求状态, 或者将与索引到的业务标识对应的业务请求状态设置为 解锁状态;
所述判断子模块具体用于, 对所述业务标识按照所述设定算法进行 运算, 根据运算结果索引所请求加锁的业务标识, 若索引到业务标识 以及对应的业务请求状态, 则判断所请求加锁的业务请求为已加锁, 否则, 则判断所请求加锁的业务请求为未加锁; 或者, 若索引到业务标 识且该业务标识对应的业务请求状态值为加锁状态, 则判断所请求加锁 的业务请求为已加锁, 否则, 若索引到业务标识且该业务标识对应的 业务请求状态值为解锁状态, 则判断所请求加锁的业务请求为未加锁。
16、 如权利要求 14或 15所述的同步锁服务器, 其特征在于, 所述 设定算法为哈希运算或全量直接映射算法。
17、 一种业务服务器, 其特征在于, 所述业务服务器包括: 发送模块, 用于向同步锁服务器发送对业务请求进行加锁的加锁 请求, 以使所述同步锁服务器判断所请求加锁的业务请求是否已加 锁, 在判断所述业务请求未加锁时, 所述同步锁服务器对所述业务请 求进行加锁, 并向所述业务服务器返回加锁成功响应; 在判断所述业 务请求已加锁时, 所述同步锁服务器向所述业务服务器返回加锁失败 响应;
处理模块, 用于在接收模块接收到加锁成功响应时, 根据所述业 务请求进行业务处理; 以及, 在接收模块接收到加锁失败响应时, 放 弃对所述业务请求进行业务处理, 并按照预设的次数和 /或频率再次通 过所述发送模块向所述同步锁服务器发送加锁请求。
18、 如权利要求 17 所述的业务服务器, 其特征在于, 所述发送模 块还用于, 在所述处理模块完成所述业务处理后, 向所述同步锁服务器 发送解锁请求, 以使所述同步锁服务器对所述业务请求进行解锁。
19、 一种并行业务处理系统, 其特征在于, 所述系统包括: 如权利 要求 10-16任一项所述的同步锁服务器,以及至少两个如权利要求 17-18 任一项所述的业务服务器。
PCT/CN2013/081864 2012-08-24 2013-08-20 一种并行业务处理方法、设备及系统 Ceased WO2014029323A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US14/621,474 US10310913B2 (en) 2012-08-24 2015-02-13 Method, device and system for processing parallel services

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210303495.6 2012-08-24
CN201210303495.6A CN103634347B (zh) 2012-08-24 2012-08-24 一种并行业务处理方法、设备及系统

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/621,474 Continuation US10310913B2 (en) 2012-08-24 2015-02-13 Method, device and system for processing parallel services

Publications (1)

Publication Number Publication Date
WO2014029323A1 true WO2014029323A1 (zh) 2014-02-27

Family

ID=50149447

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/081864 Ceased WO2014029323A1 (zh) 2012-08-24 2013-08-20 一种并行业务处理方法、设备及系统

Country Status (3)

Country Link
US (1) US10310913B2 (zh)
CN (1) CN103634347B (zh)
WO (1) WO2014029323A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116647600A (zh) * 2023-05-30 2023-08-25 中国银行股份有限公司 业务处理方法、装置、设备及可读存储介质

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105447023B (zh) * 2014-08-25 2019-02-05 阿里巴巴集团控股有限公司 业务标识生成方法和装置
CN105550052B (zh) * 2015-12-28 2019-09-27 东软集团股份有限公司 分布式锁实现方法和装置
CA2960982C (en) 2015-12-30 2021-02-16 Huawei Technologies Co., Ltd. Method for processing acquire lock request and server
CN107656815A (zh) * 2016-07-26 2018-02-02 北京京东尚科信息技术有限公司 用于控制分布式锁的方法和装置
CN107783843B (zh) * 2016-08-31 2021-08-06 中国移动通信有限公司研究院 一种云数据的处理方法及装置
CN107818018A (zh) * 2016-09-14 2018-03-20 北京京东尚科信息技术有限公司 分布式锁的控制方法和装置
CN109391630B (zh) * 2018-11-28 2022-10-25 平安科技(深圳)有限公司 移动终端锁定方法及系统
CN111464571B (zh) * 2019-01-18 2022-04-26 阿里巴巴集团控股有限公司 一种通信方法及系统、服务端、客户端
CN110716944B (zh) * 2019-09-12 2022-10-04 苏宁云计算有限公司 数据截断方法和装置
US12182634B2 (en) 2020-08-03 2024-12-31 Juniper Networks, Inc. Device access control for applications of multiple containers
CN111737021A (zh) * 2020-08-07 2020-10-02 腾讯科技(深圳)有限公司 并行任务的处理方法、装置、电子设备及存储介质
CN113791915B (zh) * 2021-08-05 2024-02-20 广东核电合营有限公司 一种核电站业务管理方法、装置、终端设备及存储介质
CN113840011A (zh) * 2021-10-11 2021-12-24 南方电网数字电网研究院有限公司 数据同步方法、装置、计算机设备和存储介质
CN116561459A (zh) * 2022-01-27 2023-08-08 华为技术有限公司 一种内容管理方法、电子设备及系统
CN115062036A (zh) * 2022-06-30 2022-09-16 中国光大银行股份有限公司 一种并行业务处理方法及装置
CN115630119A (zh) * 2022-09-08 2023-01-20 中国联合网络通信集团有限公司 异地业务处理方法、设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6304924B1 (en) * 1999-02-02 2001-10-16 International Business Machines Corporation Two lock-free, constant-space, multiple-(impure)-reader, single-writer structures
CN1556954A (zh) * 2002-06-25 2004-12-22 ������������ʽ���� 信息存储器件、存储器访问控制方法以及计算机程序
CN102006179A (zh) * 2009-08-28 2011-04-06 中兴通讯股份有限公司 一种备份数据及回退数据的方法和装置
CN102394867A (zh) * 2011-10-10 2012-03-28 深圳市金槌拍卖行有限公司 网络并发通讯请求转串行队列技术

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5226159A (en) * 1989-05-15 1993-07-06 International Business Machines Corporation File lock management in a distributed data processing system
US5907675A (en) * 1995-03-22 1999-05-25 Sun Microsystems, Inc. Methods and apparatus for managing deactivation and shutdown of a server
US5933824A (en) * 1996-12-23 1999-08-03 Lsi Logic Corporation Methods and apparatus for locking files within a clustered storage environment
US6023712A (en) * 1997-07-30 2000-02-08 Quarterdeck Corporation Method and apparatus for brokering memory resources
JPH11259395A (ja) * 1998-03-11 1999-09-24 Nec Corp ネットワーク管理システム及びその管理方法並びにその制御プログラムを記録した記録媒体
US6247099B1 (en) * 1999-06-03 2001-06-12 International Business Machines Corporation System and method for maintaining cache coherency and data synchronization in a computer system having multiple active controllers
US7496574B2 (en) * 2003-05-01 2009-02-24 International Business Machines Corporation Managing locks and transactions
EP1684193A1 (en) * 2005-01-25 2006-07-26 Sap Ag Central lock service for database applications
US7587564B2 (en) * 2006-09-26 2009-09-08 International Business Machines Corporation System, method and computer program product for managing data versions
CN101370027A (zh) * 2008-07-09 2009-02-18 中国网通集团宽带业务应用国家工程实验室有限公司 网络存储系统、方法及应用服务器
CN101631310A (zh) * 2009-07-27 2010-01-20 深圳华为通信技术有限公司 锁定方法、解锁方法及其装置、网络设备和通信终端
CN101650646B (zh) * 2009-09-22 2012-02-08 杭州华三通信技术有限公司 一种共享数据一致性的实现方法及装置
US8352658B2 (en) * 2010-05-27 2013-01-08 Microsoft Corporation Fabric based lock manager service
CN102081557A (zh) * 2011-01-27 2011-06-01 浪潮(北京)电子信息产业有限公司 云计算操作系统中资源管理方法及系统
CN102156928A (zh) * 2011-04-29 2011-08-17 浪潮通信信息系统有限公司 一种通过业务逻辑锁进行系统并发控制的方法
CN102508872A (zh) * 2011-10-12 2012-06-20 恒生电子股份有限公司 一种基于内存的联机处理系统的数据处理方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6304924B1 (en) * 1999-02-02 2001-10-16 International Business Machines Corporation Two lock-free, constant-space, multiple-(impure)-reader, single-writer structures
CN1556954A (zh) * 2002-06-25 2004-12-22 ������������ʽ���� 信息存储器件、存储器访问控制方法以及计算机程序
CN102006179A (zh) * 2009-08-28 2011-04-06 中兴通讯股份有限公司 一种备份数据及回退数据的方法和装置
CN102394867A (zh) * 2011-10-10 2012-03-28 深圳市金槌拍卖行有限公司 网络并发通讯请求转串行队列技术

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116647600A (zh) * 2023-05-30 2023-08-25 中国银行股份有限公司 业务处理方法、装置、设备及可读存储介质

Also Published As

Publication number Publication date
US10310913B2 (en) 2019-06-04
CN103634347B (zh) 2019-04-12
US20150160986A1 (en) 2015-06-11
CN103634347A (zh) 2014-03-12

Similar Documents

Publication Publication Date Title
WO2014029323A1 (zh) 一种并行业务处理方法、设备及系统
CN109688586B (zh) 一种网络功能认证的方法、装置及计算机可读存储介质
CN102752269B (zh) 基于云计算的身份认证的方法、系统及云端服务器
KR20160139493A (ko) 클라우드 서비스를 위한 암호화 키 관리 방법 및 그 장치
CN105634778B (zh) 实现vnf实例化的方法、系统及nfvo和vnfm
CN101197664A (zh) 一种密钥管理协议协商的方法、系统和装置
WO2020173502A1 (zh) 一种基于区块链的交易系统及交易方法
CN108055311B (zh) Http异步请求方法、装置、服务器、终端和存储介质
CN110392998B (zh) 一种数据包校验方法及设备
CN108898032A (zh) 一种基于区块链技术的电子数据存证的高效处理方法
WO2018103658A1 (zh) 接入处理方法、基站及移动通信终端
CN114238262A (zh) 镜像分发方法、镜像分发装置、电子设备以及存储介质
US20110258261A1 (en) Phase based prioritization of ims signaling messages for overload throttling
WO2014180392A1 (zh) 一种基于m2m的信息处理方法和m2m业务平台
CN114118447A (zh) 新型联邦学习系统、方法、装置、计算机设备及存储介质
CN107872588A (zh) 呼叫处理方法、相关装置及系统
WO2015027931A1 (en) Method and system for realizing cross-domain remote command
WO2013107402A1 (zh) 一种针对网元重启后释放资源的方法、装置和系统
EP3341853B1 (en) Message processing node and database in a message processing system and methods of operating the same
CN113612732B (zh) 一种资源调用方法、装置和多方安全计算系统
CN114640994B (zh) 协议数据单元会话鉴权认证方法、系统和相关设备
CN101155071B (zh) 选择本地域管理器的方法、装置及通信系统
CN113162922B (zh) 客户端数据的获取方法及装置、存储介质、电子设备
CN107026739B (zh) 短信签名认证方法及装置
CN104038532B (zh) 一种分布式系统互联方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13831672

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 10/07/2015)

122 Ep: pct application non-entry in european phase

Ref document number: 13831672

Country of ref document: EP

Kind code of ref document: A1