CN113486121B - Resource transfer method, device and storage medium - Google Patents

Resource transfer method, device and storage medium Download PDF

Info

Publication number
CN113486121B
CN113486121B CN202110841697.5A CN202110841697A CN113486121B CN 113486121 B CN113486121 B CN 113486121B CN 202110841697 A CN202110841697 A CN 202110841697A CN 113486121 B CN113486121 B CN 113486121B
Authority
CN
China
Prior art keywords
transfer
sub
result
resource
state
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
CN202110841697.5A
Other languages
Chinese (zh)
Other versions
CN113486121A (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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202110841697.5A priority Critical patent/CN113486121B/en
Publication of CN113486121A publication Critical patent/CN113486121A/en
Application granted granted Critical
Publication of CN113486121B publication Critical patent/CN113486121B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system
    • G06F9/5088Techniques for rebalancing the load in a distributed system involving task migration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Abstract

The present disclosure relates to the field of computers, and discloses a resource transfer method, a device and a storage medium, wherein the method is applied to a server comprising a plurality of nodes, and each node completes a partial transfer operation in a resource transfer process, and the method comprises: the first client performs a resource transfer process on an object associated with the second client, namely, triggers the last node to execute a first transfer operation and obtains an operation result after the first transfer operation, so that after the target node obtains the operation result of the last node to execute the first transfer operation, based on the obtained operation result, after the last node is determined to complete the first transfer operation, a second transfer operation is executed, in the processing process, asynchronous processing of resource transfer is realized through the first transfer operation and the second transfer operation, and consistency of the reduced transfer resource number of the first client and the increased transfer resource number of the second client is effectively ensured through confirmation of the operation result, and processing efficiency of the resource transfer process is improved.

Description

Resource transfer method, device and storage medium
Technical Field
The present disclosure relates to computer technology, and in particular, to a method and apparatus for transferring resources, and a storage medium.
Background
In recent years, with the development of streaming media technology, short video software has become hot-feeling social software. Life, chat friends, merchandise purchased, etc. may be recorded by short video software.
For example, a client as a publisher may shoot a work of cooking, a work of funny, a work of understanding about life in short video software, and then share the works on the short video software, so that not only the works can be viewed but also the works can be evaluated, and resource transfer and the like can be performed on the works through other clients.
However, in the current process of transferring resources to works, the situations of failure in updating the resource state, inconsistent deduction and addition of resources and the like often occur. In order to avoid the occurrence of the above-mentioned error, the server needs to record multiple state processes of each transfer process, i.e. monitor each transfer process in real time and in an all-round manner. This can result in high maintenance costs for the server and, in severe cases, even slow running and even crashing of the short video software.
Disclosure of Invention
The embodiment of the disclosure provides a resource transfer method, a device and a storage medium, which are used for guaranteeing the consistency of the number of transfer resources reduced by a first client and the number of transfer resources increased by a second client in a resource transfer process.
The specific technical scheme provided by the disclosure is as follows:
in a first aspect, a method for transferring resources is applied to a server including a plurality of nodes, where each node completes a portion of a transfer operation in a resource transfer process, and the method includes:
the target node obtains an operation result of executing a first transfer operation by the previous node, wherein the first transfer operation is an operation in a resource transfer process of a first client aiming at an object associated with a second client;
and the target node executes a second transfer operation after determining that the previous node completes the first transfer operation based on the acquired operation result.
Optionally, before the target node obtains the operation result of the first transfer operation performed by the previous node, the method further includes:
the previous node responds to the transfer operation triggered by the first client for the object associated with the second client, and generates a corresponding transfer message;
based on the transfer message, the last node executes a first transfer operation on the first client, obtains the resource state sub-results corresponding to the sub-operations contained in the first transfer operation, and generates an operation result based on the resource state sub-results.
Optionally, based on the transfer message, the previous node performs a first transfer operation on the first client, obtains a resource state sub-result corresponding to each sub-operation included in the first transfer operation, and generates an operation result based on each resource state sub-result, including:
For each sub-operation included in the first transfer operation, the previous node performs the following operations:
when one obtained sub-operation is a recording resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result;
when one obtained sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the resource number of the first client based on the transfer message, and a deduction state sub-result is obtained;
when one obtained sub-operation is a state updating sub-operation, the last node updates the total value of the resource number of the first client based on the transfer message, and obtains an updated state sub-result;
the previous node generates an operation result based on at least one of the obtained write state sub-result, deduction state sub-result and update state sub-result corresponding to each sub-operation.
Optionally, when the obtained sub-operation is a record resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result, including:
when the obtained sub-operation is a resource recording sub-operation, the upper node writes the transfer message into a first database corresponding to the first client;
When the transfer message is successfully written into a first database corresponding to the first client, the last node sets the writing state sub-result as successful, feeds back the writing state sub-result to a service processing end corresponding to the last node, and sets the state of the transfer message as initialization;
when the transfer message is not successfully written into the first database corresponding to the first client, the last node sets the writing state sub-result as failed, feeds back the writing state sub-result to the service processing end corresponding to the last node, and continues responding to the transfer operation triggered by the first client for the object associated with the second client.
Optionally, when the obtained one sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the number of resources of the first client based on the transfer message, and obtains a deduction state sub-result, including:
when one obtained sub-operation is a deduction resource sub-operation, the last node extracts the number of transfer resources in the transfer message;
the last node obtains the total value of the resource number of the first client from the first database corresponding to the first client, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number;
Based on the number of the remaining resources, the last node determines a deduction state sub-result of the deduction resource sub-operation, and feeds back the deduction state sub-result to a service processing end corresponding to the last node.
Optionally, when the obtained one sub-operation is a state update sub-operation, the previous node updates the total value of the number of resources of the first client based on the transfer message, and obtains an updated state sub-result, including:
when one obtained sub-operation is a state updating sub-operation, the last node writes a total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number;
based on the total value of the resource number, the last node determines an update state sub-result of the state update sub-operation, and feeds back the update state sub-result to the service processing end corresponding to the last node.
Optionally, the previous node generates an operation result based on at least one of the obtained writing state sub-result, deducting state sub-result and updating state sub-result corresponding to each sub-operation, including:
when the sub-results corresponding to each sub-operation obtained by the previous node comprise three kinds of writing state sub-results, deducting state sub-results and updating state sub-results, the previous node generates a resource transfer success message according to the writing state sub-results, deducting state sub-results and updating state sub-results, the resource transfer success message is sent to a transfer success message queue, the resource transfer success message is recorded in a cache, and the state of the transfer message is set to be successful;
When any one of the written state sub-result, the deducted state sub-result or the updated state sub-result is unsuccessful, the previous node generates a resource transfer failure message, records the resource transfer failure message into a cache, and sets the state of the transfer message as failed;
and the previous node feeds back a resource transfer success message or a resource transfer failure message to the service processing end corresponding to the previous node.
Optionally, after generating the operation result, the previous node further includes:
when the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether a transfer message exists in the first database;
if yes, the last node feeds back a successful writing confirmation message to the service processing end corresponding to the last node;
otherwise, when the number of transfer resources is larger than a preset value, the previous node continues to respond to the transfer operation triggered by the first client for the object associated with the second client; and when the number of the transfer resources is not greater than the preset value, the previous node writes the transfer information into the first database corresponding to the first client again.
Optionally, the target node obtains an operation result of performing a first transfer operation by the previous node, where the first transfer operation is an operation in a resource transfer process performed by the first client for an object associated with the second client, and the operation includes:
when the resource transfer success information is recorded in the cache, the target node sends the resource transfer success confirmation information to the service processing end corresponding to the previous node;
when the resource transfer success message is not recorded in the cache, and the previous node generates the resource transfer success message according to the writing state sub-result of which the sub-result is successful, deducting the state sub-result and updating the state sub-result, the target node sends the resource transfer success message to a transfer success message queue.
Optionally, before the target node sends the resource transfer success message to the transfer success message queue, the method further includes:
the target node inquires whether a transfer message exists in the first database;
if yes, the target node confirms the operation result based on the state of the transfer message;
otherwise, the target node feeds back a writing state sub-result confirmation failure message to the service processing end corresponding to the previous node.
Optionally, the target node confirms the operation result based on the state of the transfer message, including:
If the state of the transfer message is found to be successful, the target node sends a resource transfer success message to a transfer success message queue, and feeds back the transfer message with the successful state to a service processing end corresponding to the previous node;
if the state of the transfer message is found to be failed, the target node feeds back the transfer message with the failed state to the service processing end corresponding to the previous node;
if the state of the transfer message is inquired to be initialized, the target node sequentially executes the deduction resource sub-operation and the state updating sub-operation.
Optionally, the target node sequentially performs a deduction resource sub-operation and a status update sub-operation, including:
the target node obtains the total value of the resource number of the first client from the first database, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number;
the target node obtains the total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number.
Optionally, the target node performs a second transfer operation after determining that the previous node completes the first transfer operation based on the obtained operation result, including:
if the successful message queue of the transfer success message has the successful message of the resource transfer, the target node inquires the number of the transfer resources based on the successful message of the resource transfer;
The target node obtains the total value of the resources of the object from a second database corresponding to the second client;
based on the number of transferred resources, the target node updates the total value of the resources of the object.
Optionally, based on the number of transferred resources, the target node updates the total value of the resources of the object, including:
the target node adds the total value of the resources with the number of the transferred resources to obtain the number of updated resources;
the target node replaces the total value of the resources with the updated resource number;
the target node increments the number of transfers of the object by one.
In a second aspect, an apparatus for transferring resources, applied to a server including a plurality of nodes, where each node completes a portion of a transfer operation in a resource transfer process, includes:
the acquisition module is used for acquiring an operation result of executing a first transfer operation by the previous node by the target node, wherein the first transfer operation is an operation in a resource transfer process of a first client for an object associated with a second client;
and the determining module is used for the target node to execute the second transfer operation after determining that the previous node completes the first transfer operation based on the acquired operation result.
Optionally, before the target node obtains the operation result of the first transfer operation performed by the previous node, the target node further includes an execution module, where the execution module is configured to:
The previous node responds to the transfer operation triggered by the first client for the object associated with the second client, and generates a corresponding transfer message;
based on the transfer message, the last node executes a first transfer operation on the first client, obtains the resource state sub-results corresponding to the sub-operations contained in the first transfer operation, and generates an operation result based on the resource state sub-results.
Optionally, based on the transfer message, the last node performs a first transfer operation on the first client, obtains a resource state sub-result corresponding to each sub-operation included in the first transfer operation, and generates an operation result based on each resource state sub-result, and the execution module is configured to:
for each sub-operation included in the first transfer operation, the previous node performs the following operations:
when one obtained sub-operation is a recording resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result;
when one obtained sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the resource number of the first client based on the transfer message, and a deduction state sub-result is obtained;
When one obtained sub-operation is a state updating sub-operation, the last node updates the total value of the resource number of the first client based on the transfer message, and obtains an updated state sub-result;
the previous node generates an operation result based on at least one of the obtained write state sub-result, deduction state sub-result and update state sub-result corresponding to each sub-operation.
Optionally, when the obtained sub-operation is a record resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result, and the execution module is configured to:
when the obtained sub-operation is a resource recording sub-operation, the upper node writes the transfer message into a first database corresponding to the first client;
when the transfer message is successfully written into a first database corresponding to the first client, the last node sets the writing state sub-result as successful, feeds back the writing state sub-result to a service processing end corresponding to the last node, and sets the state of the transfer message as initialization;
when the transfer message is not successfully written into the first database corresponding to the first client, the last node sets the writing state sub-result as failed, feeds back the writing state sub-result to the service processing end corresponding to the last node, and continues responding to the transfer operation triggered by the first client for the object associated with the second client.
Optionally, when the obtained one sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the number of resources of the first client based on the transfer message, and obtains a deduction state sub-result, and the execution module is configured to:
when one obtained sub-operation is a deduction resource sub-operation, the last node extracts the number of transfer resources in the transfer message;
the last node obtains the total value of the resource number of the first client from the first database corresponding to the first client, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number;
based on the number of the remaining resources, the last node determines a deduction state sub-result of the deduction resource sub-operation, and feeds back the deduction state sub-result to a service processing end corresponding to the last node.
Optionally, when the obtained one sub-operation is a state update sub-operation, the previous node updates the total value of the number of resources of the first client based on the transfer message, and obtains an updated state sub-result, and the execution module is configured to:
when one obtained sub-operation is a state updating sub-operation, the last node writes a total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number;
based on the total value of the resource number, the last node determines an update state sub-result of the state update sub-operation, and feeds back the update state sub-result to the service processing end corresponding to the last node.
Optionally, the previous node generates an operation result based on at least one of the obtained writing state sub-result, deducting state sub-result and updating state sub-result corresponding to each sub-operation, and the execution module is used for:
when the sub-results corresponding to each sub-operation obtained by the previous node comprise three kinds of writing state sub-results, deducting state sub-results and updating state sub-results, the previous node generates a resource transfer success message according to the writing state sub-results, deducting state sub-results and updating state sub-results, the resource transfer success message is sent to a transfer success message queue, the resource transfer success message is recorded in a cache, and the state of the transfer message is set to be successful;
when any one of the written state sub-result, the deducted state sub-result or the updated state sub-result is unsuccessful, the previous node generates a resource transfer failure message, records the resource transfer failure message into a cache, and sets the state of the transfer message as failed;
and the previous node feeds back a resource transfer success message or a resource transfer failure message to the service processing end corresponding to the previous node.
Optionally, the previous node further includes a transaction query module after generating the operation result based on the obtained writing state sub-result, deducting state sub-result and updating state sub-result corresponding to each sub-operation, where the transaction query module is configured to:
when the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether a transfer message exists in the first database;
if yes, the last node feeds back a successful writing confirmation message to the service processing end corresponding to the last node;
otherwise, when the number of transfer resources is larger than a preset value, the previous node continues to respond to the transfer operation triggered by the first client for the object associated with the second client; and when the number of the transfer resources is not greater than the preset value, the previous node writes the transfer information into the first database corresponding to the first client again.
Optionally, the target node obtains an operation result of performing a first transfer operation by the previous node, where the first transfer operation is an operation in a resource transfer process performed by the first client with respect to an object associated with the second client, and the obtaining module is configured to:
When the resource transfer success information is recorded in the cache, the target node sends the resource transfer success confirmation information to the service processing end corresponding to the previous node;
when the resource transfer success message is not recorded in the cache, and the previous node generates the resource transfer success message according to the writing state sub-result of which the sub-result is successful, deducting the state sub-result and updating the state sub-result, the target node sends the resource transfer success message to a transfer success message queue.
Optionally, before the target node sends the resource transfer success message to the transfer success message queue, the target node further includes a query module, where the query module is configured to:
the target node inquires whether a transfer message exists in the first database;
if yes, the target node confirms the operation result based on the state of the transfer message;
otherwise, the target node feeds back a writing state sub-result confirmation failure message to the service processing end corresponding to the previous node.
Optionally, the target node confirms the operation result based on the state of the transfer message, and the determining module is configured to:
if the state of the transfer message is found to be successful, the target node sends a resource transfer success message to a transfer success message queue, and feeds back the transfer message with the successful state to a service processing end corresponding to the previous node;
If the state of the transfer message is found to be failed, the target node feeds back the transfer message with the failed state to the service processing end corresponding to the previous node;
if the state of the transfer message is inquired to be initialized, the target node sequentially executes the deduction resource sub-operation and the state updating sub-operation.
Optionally, the target node sequentially executes a deduction resource sub-operation and a state update sub-operation, and the determining module is configured to:
the target node obtains the total value of the resource number of the first client from the first database, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number;
the target node obtains the total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number.
Optionally, the target node executes a second transfer operation after determining that the previous node completes the first transfer operation based on the obtained operation result, and the determining module is configured to:
if the successful message queue of the transfer success message has the successful message of the resource transfer, the target node inquires the number of the transfer resources based on the successful message of the resource transfer;
the target node obtains the total value of the resources of the object from a second database corresponding to the second client;
based on the number of transferred resources, the target node updates the total value of the resources of the object.
Optionally, based on the number of transferred resources, the target node updates the total value of the resources of the object, and the determining module is configured to:
the target node adds the total value of the resources with the number of the transferred resources to obtain the number of updated resources;
the target node replaces the total value of the resources with the updated resource number;
the target node increments the number of transfers of the object by one.
In a third aspect, a server includes:
a memory for storing executable instructions;
a processor for reading and executing executable instructions stored in a memory to implement the method of any one of the first aspects.
In a fourth aspect, a computer readable storage medium, which when executed by a processor, causes the processor to perform the method of any of the first aspects.
In a fifth aspect, a computer program product comprising executable instructions which, when executed by a processor, enable the method of any one of the first aspects to be carried out.
In summary, in an embodiment of the present disclosure, a method, an apparatus, and a storage medium for transferring resources are applied to a server including a plurality of nodes, where each node completes a portion of a transfer operation in a resource transfer process, and the method includes: the first client performs a resource transfer process on an object associated with the second client, namely, triggers the last node to execute a first transfer operation and obtains an operation result after the first transfer operation, so that after the target node obtains the operation result of the last node to execute the first transfer operation, based on the obtained operation result, after the last node is determined to complete the first transfer operation, a second transfer operation is executed, in the processing process, asynchronous processing of resource transfer is realized through the first transfer operation and the second transfer operation, and consistency of the reduced transfer resource number of the first client and the increased transfer resource number of the second client is effectively ensured through confirmation of the operation result, and processing efficiency of the resource transfer process is improved.
Drawings
FIG. 1 is a schematic diagram of a system architecture for transferring resources according to an embodiment of the present application;
fig. 2 is a schematic flow chart of a target node executing a second transfer operation in the embodiment of the present application;
FIG. 3 is a flowchart illustrating a first transfer operation performed by a previous node according to an embodiment of the present application;
fig. 4 is a schematic diagram of a first client triggering a transfer operation in an embodiment of the present application;
FIG. 5 is a schematic diagram of a previous node generating a transfer message according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a processing mechanism of a previous node according to an embodiment of the present application;
FIG. 7 is a flowchart illustrating a method for generating an operation result by a previous node according to an embodiment of the present application;
FIG. 8 is a flowchart illustrating a recording resource sub-operation performed by an upper node in an embodiment of the present application;
FIG. 9 is a schematic diagram of a previous node storing a transfer message in a first database according to an embodiment of the present application;
FIG. 10 is a schematic diagram illustrating a previous node confirming that the write status sub-result is failed in the embodiment of the present application;
FIG. 11 is a flowchart illustrating an execution of a deduction resource sub-operation by an upper node in the embodiment of the present application;
FIG. 12 is a schematic diagram illustrating a previous node calculating a total value of the number of resources of the first client in the embodiment of the present application;
FIG. 13 is a flow chart illustrating a method for recording a transfer message status of a previous node according to an embodiment of the present application;
FIG. 14 is a schematic diagram of a previous node updating a total value of a resource number of a first client in a first database according to an embodiment of the present application;
FIG. 15 is a schematic diagram illustrating a previous node determining that the update status sub-result is successful in the embodiment of the present application;
FIG. 16 is a diagram illustrating another embodiment of a previous node determining that the update status sub-result is failed;
FIG. 17 is a flow chart illustrating a situation that a previous node processes an operation sub-result in the embodiment of the present application;
FIG. 18 is a schematic diagram of a previous node generating a resource transfer success message in an embodiment of the present application;
FIG. 19 is a flowchart illustrating a target node acknowledging that a transfer message is written into a first database according to an embodiment of the present application;
fig. 20 is a schematic flow chart of determining a transfer message by a target node in an embodiment of the present application;
fig. 21 is a schematic flow chart of a resource transfer success message determined by a target node in an embodiment of the present application;
FIG. 22 is a schematic diagram of a target node calculating the number of remaining resources according to an embodiment of the present application;
FIG. 23 is a schematic diagram of a target node updating a total value of the number of resources in a first database according to an embodiment of the present application;
FIG. 24 is a schematic diagram of a processing mechanism of another previous node according to an embodiment of the present application;
fig. 25 is a flowchart of a target node performing a second transfer operation according to an embodiment of the present application;
FIG. 26 is a flowchart of a target node updating a second client resource number according to an embodiment of the present application;
FIG. 27 is a schematic diagram of a target node updating a total value of resources in a second database according to an embodiment of the present application;
FIG. 28 is a schematic diagram of a logic architecture of a server according to an embodiment of the disclosure;
FIG. 29 is a schematic diagram of a logic architecture of another server according to an embodiment of the disclosure;
fig. 30 is a schematic diagram of a physical architecture of a server according to an embodiment of the disclosure.
Detailed Description
In order to ensure the consistency of the number of transfer resources reduced by the first client and the number of transfer resources increased by the second client in the resource transfer process, in the embodiment of the invention, the first client performs the resource transfer process for the object associated with the second client, that is, triggers the previous node to execute the first transfer operation and obtains the operation result after the first transfer operation, so that the target node obtains the operation result of the previous node for executing the first transfer operation, and then executes the second transfer operation after determining that the previous node completes the first transfer operation based on the obtained operation result, thereby realizing the confirmation of the operation result and further improving the processing efficiency of the resource transfer process.
The preferred embodiments of the present application will be described in detail with reference to the accompanying drawings.
Referring to fig. 1, in an embodiment of the present disclosure, a method for transferring resources is applied to a server including a plurality of nodes, where each node completes a partial transfer operation in a resource transfer process, that is, a system includes at least one previous node and a target node, and in fig. 1, a case of one previous node and one target node is described, where a specific processing object corresponding to the previous node is a first client, and a processing object corresponding to the target node is an object associated in a second client.
In the implementation process, the method of jointly executing the resource transfer by the previous node and the target node, that is, the implementation of the method of resource transfer, is mainly divided into two types, namely, the previous node side and the target node side, and is described below respectively.
The last node side: and performing resource transfer on the first client, namely executing a first transfer operation, and obtaining an operation result after executing the first transfer operation.
Target node side: and acquiring an operation result of the previous node, and executing a second transfer operation on the second client after determining that the previous node completes the first transfer operation according to the operation result.
Referring to fig. 2, in the embodiment of the disclosure, a specific flow of a method for executing resource transfer by a target node is as follows:
step 201: the target node obtains an operation result of executing a first transfer operation by the previous node, wherein the first transfer operation is an operation in a resource transfer process of a first client for an object associated with a second client.
Before describing this step 201 in detail, the details of the first transfer operation performed by the previous node will be described. That is, in the implementation process, before the target node obtains the operation result of the first transfer operation performed by the previous node in step 201, referring to fig. 3, the method further includes:
step 301: the previous node responds to the transfer operation triggered by the first client for the object associated with the second client, and generates a corresponding transfer message.
Here, the object associated with the second client is a work on the second client, and the first client may trigger a transfer operation on the work, for example, referring to fig. 4, where work 1 just published on the second client allows the first client to perform resource transfer on the work 1. The first client-side triggered transfer operation may be a single click operation, a double click operation, a drag operation, etc. triggered on the associated object.
In the implementation process, when the second client issues the associated object work 1, and the first client triggers a transfer operation (for example, a clicking operation) for the work 1, the previous node responds to the transfer operation to generate a corresponding transfer message, and the specific transfer message includes the identification number of the first client, the identification number of the second client, the identification number of the associated object, the transfer number, the transfer time and the like.
In order to ensure the validity of the transfer message, the previous node checks the transfer message, for example, checks the bonus amount of the transfer message to determine that the number of transfers is within a preset reasonable range, checks the risk control of the transfer message, and the like to determine the validity of the transfer message.
Assume that, referring to fig. 5, the transfer message generated after the first client performs the clicking operation on the work 1 specifically includes an identification number of the first client, an identification number of the second client, an identification number ID1 of the associated object, a transfer number of 10, and a transfer time of 09:30. If the preset reasonable range is 5-50, the previous node determines that the transfer number belongs to the reasonable range, if the transfer number exceeds the preset reasonable range, the previous node prompts the first client to transfer invalid messages, the previous node also performs risk control check on the transfer messages, and if the transfer messages are found to carry hacker information, the previous node prompts the first client to fail to transfer messages.
In addition, referring to fig. 6, since the previous node has not yet acknowledged the transfer message, the transfer message is usually a half message in the implementation process, and is stored in the service processing end corresponding to the previous node. The service processing end is also arranged in the server, and is usually in the form of a message queue, that is, the service processing end uniformly stores messages (for example, half messages and other acknowledgement messages, etc.) for processing by consumers (for example, target nodes) as message producers, and ensures asynchronous processing through the form of the message queue.
Step 302: based on the transfer message, the last node executes a first transfer operation on the first client, obtains the resource state sub-results corresponding to the sub-operations contained in the first transfer operation, and generates an operation result based on the resource state sub-results.
Through step 301 and step 302, it can be effectively determined whether the first transfer operation of the previous node is successful, that is, the previous node performs result tracking on each sub-operation included in the first transfer operation, and generates an operation result corresponding to the first transfer operation based on the result of each sub-operation, so that the validity of executing the first transfer operation is ensured through the confirmation process of the first transfer operation of the previous node.
In the implementation process, after the previous node generates the transfer message, that is, after the previous node determines that the first client has triggered the transfer operation, the previous node performs the first transfer operation on the first client according to the transfer message, as shown in fig. 7, specifically including:
step 3021: for each sub-operation included in the first transfer operation, the previous node performs the following operations:
first case: when one obtained sub-operation is a recording resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result.
In the implementation process, the first transfer operation is subdivided into the record resource sub-operation, and the state sub-result is written into the first database, so that whether the first client actually generates the transfer message or not can be effectively reflected, and the transfer message is taken as the basis of whether the first client needs to execute the first transfer operation or not.
In order to facilitate supervision of the process of the first transfer operation, in the implementation process, the previous node may confirm the execution condition of the sub-operations of the first transfer operation in different stages in real time, where the division of the different stages is set according to the execution sequence of the first transfer operation, as shown in fig. 8, and specifically includes:
Step 30211: when the obtained sub-operation is the recording resource sub-operation, the upper node writes the transfer message into a first database corresponding to the first client.
In the process of executing the first transfer operation, the previous node first records the generated transfer message and uses the generated transfer message as the basis for executing the subsequent steps. In the implementation process, when the sub-operation in the first transfer operation acquired by the previous node is the resource recording sub-operation, the previous node writes the transfer message into the first database corresponding to the first client, that is, records the identification number of the first client, the identification number of the second client, the identification number of the associated object, the transfer number, the transfer time and the like included in the transfer message into the first database corresponding to the first client.
Still referring to fig. 9, in the process of recording the resource sub-operation, the previous node records the identification number of the first client in the work 1, the identification number of the second client, the identification number ID1 of the associated object, the transfer number 10, and the transfer time 09:30 into the first database corresponding to the first client.
Under the condition that the first database is a first database special for the first client, the first database can be distinguished from the first database of the second client, and therefore the number of resources in the respective processes of the first transfer operation and the second transfer operation can be independent and clear.
Step 30212: when the transfer message is successfully written into the first database corresponding to the first client, the last node sets the writing state sub-result as successful, feeds back the writing state sub-result to the service processing end corresponding to the last node, and sets the state of the transfer message as initialization.
In order to determine whether the transfer message is successfully written in the first database, the previous node also confirms the writing state of the transfer message. In the implementation process, when the transfer message is successfully written into the first database corresponding to the first client, the last node sets the writing state sub-result corresponding to the recording resource sub-operation as successful.
When the transfer message is successfully written into the first database, the state of the transfer message is set to be initialized, so that the validity of the execution operation is confirmed, and the confirmation is taken as the execution starting point of the subsequent first transfer operation.
In addition, in order to uniformly store the confirmation results in each sub-operation process, the writing state sub-result is fed back to the service processing end corresponding to the previous node, that is, the writing state of the service processing end is the successful writing state sub-result. And the last node sets the state of the transfer message to be initialized in the first database, and on the basis of the initialization, the last node is allowed to continue to execute other sub-operations in the first transfer operation.
Step 30213: when the transfer message is not successfully written into the first database corresponding to the first client, the last node sets the writing state sub-result as failed, feeds back the writing state sub-result to the service processing end corresponding to the last node, and continues responding to the transfer operation triggered by the first client for the object associated with the second client.
In the implementation process, when the transfer message is not successfully written into the first database corresponding to the first client, for example, in the case that the network abnormality leads to the writing failure, the previous node sets the writing state sub-result corresponding to the record resource sub-operation as failure, that is, the previous node does not successfully record the identification number of the first client, the identification number of the second client, the identification number of the associated object, the transfer number, the transfer time and the like into the first database.
In this case, the previous node sets the write state sub-result as failed, i.e., the acknowledgement result obtained by the previous node is failed. And the last node feeds back a writing state sub-result to the service processing end corresponding to the last node, namely, the writing state of the service processing end is a failed writing state sub-result. On the basis, the previous node is not allowed to continue to execute other sub-operations in the first transfer operation, which means that the transfer message of this time is invalid, and in this case, the previous node continues to respond to the transfer operation triggered by the first client for the object associated with the second client, that is, the previous node waits again for processing the transfer operation of the next time.
When the transfer message is not successfully written into the first database, the service processing end corresponding to the previous node feeds back a failed writing state sub-result, and the situation declares the invalidity of the transfer operation and allows the first client to execute the transfer operation again.
Still referring to fig. 10, in the process of recording the resource sub-operation, the previous node should record the identification number of the first client in the transfer message of the work 1, the identification number of the second client, the identification number ID1 of the associated object, the transfer number 10, and the transfer time 09:30 in the first database corresponding to the first client. If the network temporarily fails, the information of the identification number Li IV of the second client fails to be recorded in the first database, and then the writing state sub-result is set to fail, namely the first client is invalid to transfer the resource of the work 1, and the previous node waits for processing the next transfer operation of the first client on the objects associated with the second client Li IV.
Second case: when one obtained sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the resource number of the first client based on the transfer message, and obtains a deduction state sub-result.
In the process that the previous node continues to execute other sub-operations in the first transfer operation, when one obtained sub-operation is a deduction resource sub-operation, referring to fig. 11, the executing steps of the previous node specifically include:
step 30211': when one obtained sub-operation is a deduction resource sub-operation, the last node extracts the number of transfer resources in the transfer message.
In the process of executing the first transfer operation, the previous node executes the sub-operation of deducting the resources on the first client. In the implementation process, after the last node determines that the writing state sub-result is set to be successful, the deduction resource sub-operation can be obtained from the first transfer operation, and the number of transfer resources, namely the number of transfer, is extracted from the transfer message and is used as the reduction number of the deduction process.
Taking work 1 as an example, the previous node performs a sub-operation of deducting resources on the first client, and extracts the number of transferred resources, that is, the number of transferred 10, from the transfer message as the number of deductions in the deduction process.
Step 30212': the last node obtains the total value of the resource number of the first client from the first database corresponding to the first client, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number.
In the specific deduction process, the last node also needs to obtain the total value of the resource number of the first client from the first database corresponding to the first client, namely, the deducted number in the deduction process, and subtract the transferred resource number (namely, the deducted number) from the total value of the resource number (namely, the deducted number) to obtain the residual resource number, wherein the residual resource number is the new total value of the resource number of the first client.
Assuming that the total number of resources for the first client is 200, still referring to fig. 12, in the implementation process, the last node subtracts 10 from 200 to obtain the remaining number of resources 190, and takes 190 as the new total number of resources for the first client.
The above-mentioned last node executes the deduction process of the resource, is the direct feedback to transfer operation, has guaranteed the correctness of the surplus resource number after carrying out the first transfer operation of the first customer end.
Step 30213': based on the number of the remaining resources, the last node determines a deduction state sub-result of the deduction resource sub-operation, and feeds back the deduction state sub-result to a service processing end corresponding to the last node.
After the deduction operation is finished, the previous node also needs to confirm the correctness of the deduction operation, specifically, the deduction state sub-result of the deduction resource sub-operation can be determined by checking whether the number of the remaining resources is correct, namely, when the number of the remaining resources is correct, the deduction state sub-result is determined to be successful; and when the number of the residual resources is incorrect, determining that the deduction state sub-result is failure.
Still taking the total value of the number of the resources of the work 1 and the third client as 200 as an example for explanation, after the execution of the deduction resource sub-operation is finished, if the obtained number of the remaining resources is 190, determining that the deduction state sub-result is successful; if the number of remaining resources is not 190, determining that the deduction state sub-result is failure.
In the implementation process, the first transfer operation is subdivided into deduction resource sub-operations, and the deduction state sub-result is fed back to the service processing end corresponding to the previous node, so that whether the first client actually executes the deduction resource sub-operations can be effectively reflected, and the effectiveness of the first transfer operation is ensured.
In order to effectively record the confirmation result, the last node feeds back the deduction state sub-result to the service processing end corresponding to the last node, for example, a message of which the deduction state sub-result is successful or failed is put into a message queue.
Third case: when one obtained sub-operation is a state updating sub-operation, the last node updates the total value of the resource number of the first client based on the transfer message, and obtains an updated state sub-result.
In the process that the previous node continues to execute other sub-operations in the first transfer operation, when one obtained sub-operation is a state update sub-operation, referring to fig. 13, the executing steps of the previous node specifically include:
Step 30211": when one obtained sub-operation is a state updating sub-operation, the last node writes the total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number.
When a sub-operation obtained from the first transfer operation by the previous node is a state update sub-operation during the execution of the first transfer operation, the previous node needs to confirm the total value of the resources of the first client, that is, the previous node writes the total value of the resources in the first database, and because the previous node executes the deduction sub-operation, the total value of the resources of the first client changes, and in the implementation process, the previous node replaces the total value of the resources with the remaining resource values, thereby obtaining a new total value of the resources of the first client.
Still taking the above work 1 and the first client page three as an example, the total value of the resource numbers of the first client page three is 200, and referring to fig. 14, in the state updating sub-operation, the previous node shall correspondingly update the total value of the resource numbers of the first client page three stored in the first database 200, that is, update 200 to 190.
Step 30212": based on the total value of the resource number, the last node determines an update state sub-result of the state update sub-operation, and feeds back the update state sub-result to the service processing end corresponding to the last node.
After obtaining a new total value of the resource number of the first client, the last node needs to determine an updated state sub-result of the state updating sub-operation according to the total value of the resource number, namely, after the new total value of the resource number is confirmed to be correct, the last node determines that the updated state sub-result of the state updating sub-operation is successful; when the new total value of the resource number is confirmed to be wrong, the last node determines that the update state sub-result of the state update sub-operation is failure.
Referring to fig. 15, still taking 200 as an example of the total value of the resource numbers of the work 1 and the first client, if the total value of the resource numbers is 200 and is updated to 190, the last node determines that the update status sub-result of the status update sub-operation is successful; referring to fig. 16, if the total value of the number of resources is 200 and updated to 10, the last node determines that the update status sub-result of the status update sub-operation is failed.
In order to effectively record the confirmation result, the previous node feeds back an update state sub-result to the service processing end corresponding to the previous node, and specifically, the sub-result of which the update state sub-result is successful or failed is put into the message queue for the target node to use.
In the implementation process, the first transfer operation is subdivided into the state update sub-operation, and the updated state sub-result is fed back to the service processing end corresponding to the previous node, so that whether the first client executes the updated state operation or not can be effectively tracked, and the effectiveness of the first transfer operation is further ensured.
Step 3022: the previous node generates an operation result based on at least one of the obtained write state sub-result, deduction state sub-result and update state sub-result corresponding to each sub-operation.
In the implementation process, after each sub-operation is obtained, the previous node generates an operation result based on the sub-result of at least one sub-operation, as shown in fig. 17, which specifically includes:
step 30221: when the sub-results corresponding to each sub-operation obtained by the previous node comprise three kinds of writing state sub-results, deduction state sub-results and updating state sub-results, the previous node generates a resource transfer success message according to the writing state sub-results, deduction state sub-results and updating state sub-results, the resource transfer success message is sent to a transfer success message queue, the resource transfer success message is recorded in a cache, and the state of the transfer message is set to be successful.
Considering the integrity of the first transfer operation, the previous node further confirms each sub-result in the first transfer operation after completing the first transfer operation, and specifically, the previous node generates a resource transfer success message after determining that the recording resource sub-operation, the deduction resource sub-operation and the state update sub-operation are all successful. In a specific implementation process, whether the record resource sub-operation, the deduction resource sub-operation and the state updating sub-operation are successful or not can be obtained from the writing state sub-result, the deduction state sub-result and the updating state sub-result, so that when the record resource sub-operation, the deduction resource sub-operation and the state updating sub-operation are successful, the last node generates a resource transfer success message and sends the resource transfer success message to a transfer success message queue, wherein the transfer success message queue is different from the service processing end, and only the transfer success message is stored in the transfer success message queue.
Referring to fig. 18, the above-mentioned work 1 is still taken as an example, only when the identification number of the first client, the identification number of the second client, the identification number ID1 of the associated object, the number of transitions 10, and the transition time 09:30 of the transition message related to the work 1 are recorded in the first database, and the total value 200 of the number of resources corresponding to the third client is successfully subtracted by the total value 200 of the number of resources corresponding to the third client in the sub-operation of deducting resources, so that the correct number of remaining resources 190 is obtained, and the total value 200 of the number of resources corresponding to the third client is updated to 190, in this case, the previous node generates a successful resource transfer message, and sends the successful resource transfer message to the successful resource transfer message queue.
In order to facilitate the target node to search, the previous node records the resource transfer success message into the cache, and sets the state of the transfer message to be successful, namely, the transfer message is indicated to be successfully recorded into the first database, the deduction operation corresponding to the transfer message is successfully executed, and the total value of the resource number of the first client corresponding to the transfer message is updated.
Step 30222: when any one of the writing state sub-result, the deduction state sub-result or the updating state sub-result is unsuccessful, the previous node generates a resource transfer failure message, records the resource transfer failure message in a cache, and sets the state of the transfer message as failed.
Accordingly, in the implementation process, when any one of the writing state sub-result, the deduction state sub-result or the updating state sub-result is unsuccessful, it indicates that a certain sub-operation of the first transfer operation is abnormal. In this case, the previous node generates a resource transfer failure message and records the resource transfer failure message in the cache so that the target node can quickly look up the resource transfer failure message.
Still referring to the above work 1 as an example, if the identification number of the first client, the identification number of the second client, the identification number ID1 of the associated object, the number of transitions 10, and the transition time 09:30 are all not successfully recorded in the first database in the transition message related to the work 1, or the total number of resources 200 corresponding to the third client fails to be subtracted by the total number of resources 200 corresponding to the third client (assuming that 11 is subtracted), or the correct remaining number of resources 190 is not obtained (assuming that 189 is obtained), or the total number of resources 200 corresponding to the third client is updated to 189, in this case, the previous node generates a resource transition failure message.
Further, the previous node sets the state of the transfer message to fail, i.e., changes the state of the transfer message from the original initialization to fail.
Step 30223: and the previous node feeds back a resource transfer success message or a resource transfer failure message to the service processing end corresponding to the previous node.
In order to uniformly record the confirmation result, in the implementation process, the last node feeds back a resource transfer success message or a resource transfer failure message to the service processing end corresponding to the last node, that is, the service processing end monitors whether the whole process of the first transfer operation is successful or failed.
In the process of implementing the steps 3021 to 3022, the previous node generates the operation result according to the obtained write state sub-result, the deduction state sub-result and the update state sub-result corresponding to each sub-operation, and then further includes:
step 3023: when the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether a transfer message exists in the first database.
In the implementation process of the first transfer operation, when the service processing end does not receive any sub-result and the previous node determines that there is a transfer message in the first database, step 3024 is executed; when the service processing end receives one of the above sub-results and the previous node determines that the transfer message does not exist in the first database, step 3025 is executed.
In a specific implementation, the step 3023 may be implemented by transaction review under a half message mechanism.
By the query step of the previous node, the progress condition of the first transfer operation in the execution process can be further confirmed, and in the case that the first transfer operation does not have any progress, whether the first transfer operation needs to be executed or not is verified again through confirmation of the transfer message, so that the influence on the progress of each sub-operation caused by network abnormality, abnormal number of transfer resources and the like is avoided.
Step 3024: the last node feeds back a successful writing confirmation message to the service processing end corresponding to the last node.
If the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether a transfer message exists in the first database so as to confirm whether the transfer message exists.
When the transfer message is determined to exist in the first database, the last node feeds back a successful writing confirmation message to the service processing end corresponding to the last node so as to eliminate the condition that the writing state sub-result, the deduction state sub-result and the updating state sub-result are abnormal to send due to network abnormality and the like, but the transfer message is recorded successfully.
Still taking the work 1 as an example, when the identification number of the first client of the transfer message related to the work 1 is recorded in the first database successfully, the identification number of the second client is recorded in the third database successfully, the identification number of the second client is recorded in the fourth database successfully, the transfer number is 10, and the transfer time is 09:30, the service processing end corresponding to the previous node does not receive the writing state sub-result, the deduction state sub-result and the update state sub-result which are successful or failed, and in this case, the service processing end corresponding to the previous node feeds back the information that the writing state sub-result, the deduction state sub-result and the update state sub-result which are successfully recorded to the first client of the transfer message related to the work 1, the identification number of the second client is recorded in the fourth database successfully, the identification number of the associated object is recorded in the third database, the transfer number is 10, and the transfer time is 09:30.
Step 3025: when the number of the transfer resources is larger than a preset value, the previous node continues to respond to the transfer operation triggered by the first client for the object associated with the second client; and when the number of the transfer resources is not greater than the preset value, the previous node writes the transfer information into the first database corresponding to the first client again.
If the service processing end corresponding to the previous node receives any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether a transfer message exists in the first database in the situation, so that whether the transfer message exists is confirmed.
When the fact that the transfer message does not exist in the first database is determined, the previous node judges whether the number of transfer resources corresponding to the transfer message is larger than a preset value or not, wherein the preset value is the preset upper limit value of the range.
When the number of the transfer resources is larger than a preset value, the previous node continues to respond to the transfer operation triggered by the first client for the object associated with the second client, namely, the previous node considers that the transfer message is invalid, and continues to respond to the transfer operation triggered by the first client for the object associated with the second client, namely, continues to respond to the new transfer operation of the first client.
Still taking the above work 1 as an example, assuming that the current preset value is 5, the number of transfer resources 10 corresponding to the work 1 is greater than the preset value 5, and the previous node considers that the transfer message corresponding to the work 1 is invalid, and accordingly, the first transfer operation is not executed.
When the number of the transfer resources is not greater than a preset value, that is, the transfer message is within a reasonable range, in order to eliminate the situation that the transfer message fails to be written into the first database caused by network abnormality and the like, the upper node writes the transfer message into the first database corresponding to the first client again.
Still taking the work 1 as an example for illustration, assuming that the current preset value is 15, the number of transfer resources 10 corresponding to the work 1 is not greater than the preset value 5, the previous node considers that the transfer message corresponding to the work 1 is within a reasonable range, and the corresponding previous node writes the transfer message into the first database corresponding to the first client side three again.
After describing the process of performing the first transfer operation by the previous node, the process of obtaining the corresponding operation result by the target node and further performing the second transfer operation is further described, and referring to fig. 20, the step 201 specifically includes:
in the implementation process, compared with other acquisition modes, the target node can acquire the resource transfer success message fastest according to whether the resource transfer success message is recorded in the cache, and the method is specific:
step 2011: when the resource transfer success information is recorded in the cache, the target node sends the resource transfer success confirmation information to the service processing end corresponding to the previous node.
In the implementation process, when the target node determines that the resource transfer success message is recorded in the cache, a corresponding resource transfer success confirmation message is generated. In order to effectively record the confirmation message and asynchronously process the confirmation message, the target node sends the successful confirmation message of the resource transfer to the service processing end corresponding to the previous node.
Step 2012: when the resource transfer success message is not recorded in the cache, and the previous node generates the resource transfer success message according to the writing state sub-result of which the sub-result is successful, deducting the state sub-result and updating the state sub-result, the target node sends the resource transfer success message to a transfer success message queue.
In the implementation process, when the target node determines that the resource transfer success message is not recorded in the cache, the network condition in the writing process and the like are considered to be possibly caused, so that when the last node is determined to be a successful writing state sub-result according to the sub-result, the deduction state sub-result and the updating state sub-result generate the resource transfer success message, and in this case, the target node sends the resource transfer success message to a transfer success message queue, namely sends the resource transfer success message again.
The process of querying the cache by the target node to determine whether the resource transfer success confirmation message exists or not can verify the validity of the first transfer operation again from the perspective of the target node, and further indicate whether the target node executes the second transfer operation.
It should be noted that, when the target node determines that the cache does not record the resource transfer success message, the target node determines whether the resource transfer success message is actually generated in a step-by-step check mode, and if the resource transfer success message is not generated, the target node needs to verify each sub-operation of the first transfer operation. Specifically, as shown in fig. 21, before the target node sends the resource transfer success message to the transfer success message queue, the method further includes:
Step 2013': the target node queries whether a transfer message exists in the first database.
In the implementation process, if yes, that is, when the target node queries that the transfer message exists in the first database, the target node executes step 2014'; otherwise, i.e. when the target node queries that no transfer message exists in the first database, the target node performs step 2015'.
Step 2014': the target node confirms the operation result based on the state of the transfer message.
In the specific implementation process, the target node confirms the operation result according to the state (initialization, success or failure) of the transfer message recorded in the cache, that is, the target node verifies each sub-operation of the first transfer operation through the state of the transfer message, and correspondingly, the step of confirming the operation result specifically includes the following three cases:
case 1: if the state of the transfer message is found to be successful, the target node sends a resource transfer success message to a transfer success message queue, and feeds back the transfer message with the successful state to the service processing end corresponding to the previous node.
In the implementation process, if the target node inquires that the state of the transfer message is successful, that is, confirms that the resource transfer success message is generated, it should be noted that an exception may occur when the resource transfer success message is written in the cache. In this case, the target node sends a resource transfer success message to the transfer success message queue, and feeds back a transfer message with a successful state to the service processing end corresponding to the previous node, that is, the target node sends the resource transfer success message to the transfer success message queue and the service processing end.
Still taking the work 1 as an example for illustration, when the target node confirms that the resource transfer success message corresponding to the work 1 is generated, but the resource transfer success message is not written in the cache, the target node sends the resource transfer success message to the transfer success message queue and the service processing end corresponding to the last node.
Case 2: if the state of the transfer message is found to be failed, the target node feeds back the transfer message with the failed state to the service processing end corresponding to the previous node.
In the implementation process, if the target node inquires that the state of the transfer message is failure, namely that no resource transfer success message is generated, the target node can confirm that the record resource sub-operation of the first transfer operation is abnormal in processing. And the target node feeds back a transfer message with a failed state to the service processing end corresponding to the previous node, namely declaring the resource transfer process invalid.
Still taking the work 1 as an example for illustration, if the target node confirms that the resource transfer success message corresponding to the work 1 is not generated, the target node feeds back a transfer message with a failed state to the service processing end corresponding to the previous node.
Case 3: if the state of the transfer message is inquired to be initialized, the target node sequentially executes the deduction resource sub-operation and the state updating sub-operation.
In the implementation process, if the target node inquires that the state of the transfer message is initialized, namely, the transfer message is confirmed to be successfully written into the first database corresponding to the first client, but the corresponding resource transfer success message is not generated, the exception of the previous node in the process of processing the deduction resource sub-operation and the state updating sub-operation can be deduced.
Still taking the work 1 as an example for illustration, the target node confirms that the transfer message corresponding to the work 1 has been successfully written into the first database corresponding to the first client, but does not generate the corresponding resource transfer success message, so as to infer that the previous node is abnormal in the process of processing the deduction resource sub-operation and the state update sub-operation corresponding to the work 1.
According to the schemes of the case 1, the case 2 and the case 3, the target node can specifically locate to which stage (transfer message record, deduction resource and state update stage, etc.) has an abnormality in the process of executing the first transfer operation of the previous node, so that the target node performs the supplementary operation again to ensure the consistency of the first transfer operation.
In this case, the target node performs the deduction resource sub-operation and the status updating sub-operation which are not successfully processed by the previous node instead of the previous node, that is, the target node sequentially performs the deduction resource sub-operation and the status updating sub-operation, and it should be noted that, in the process that the target node sequentially performs the deduction resource sub-operation and the status updating sub-operation, only the relevant resource number is operated, and the status of the transfer message is not updated any more, which specifically includes:
(1) And the target node acquires the total value of the resource number of the first client from the first database, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number.
In the implementation process, in order to obtain the original total value of the resource number of the first client, and the like, the target node obtains the total value of the resource number of the first client from the first database corresponding to the first client, and in the process of executing the deduction resource sub-operation, the target node subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number.
Referring to fig. 22, still taking the above-mentioned total value of the resources of the work 1 and the first client side third as 200 as an example, when the previous node does not successfully execute the deduction resource sub-operation, the target node executes the deduction resource sub-operation, that is, the target node obtains the total value of the resources of the first client side third as 200 from the first database corresponding to the first client side third, reads the transferred resource number 10 from the transfer message corresponding to the work 1, and subtracts the transferred resource number 10 from the total value of the resources as 200 to obtain the remaining resource number 190.
(2) The target node obtains the total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number.
In the implementation process, in the process of executing the state updating sub-operation by the target node, the target node acquires the total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource value, namely, the target node updates the total number of the resources of the first client.
Referring to fig. 23, still taking the above work 1 and the first client third as an example, when the previous node does not successfully execute the state update sub-operation, the target node executes the state update sub-operation, that is, the target node obtains the first client third as 200 from the first database corresponding to the first client third, and replaces the resource 200 with the remaining resource 190.
The above-mentioned target node executes the deduction resource and status updating process, and can make up the process that the previous node is successfully executed, i.e. the target node guarantees the integrity of the first transfer operation.
Step 2015': the target node feeds back a writing state sub-result confirmation failure message to the service processing end corresponding to the upper node.
In the implementation process, when the target node inquires that the transfer message does not exist in the first database, that is, when the first database does not successfully write the whole content of the transfer message (including the identification number of the first client, the identification number of the second client, the identification number of the associated object, the transfer number, the transfer time and the like), the target node feeds back a writing state sub-result confirmation failure message to the service processing end corresponding to the upper node.
In the resource transfer process, the resource deduction operation is mainly performed on the first client, and the resource addition operation is performed on the second client, so that the target node performs the confirmation process on the operation result after acquiring the operation result of the first transfer operation performed by the previous node, and after the confirmation is completed, the target node continues to perform the second transfer operation on the second client according to the result of successful confirmation. The following describes in detail the resource adding operation performed by the target node on the second client.
Step 202: and the target node executes a second transfer operation after determining that the previous node completes the first transfer operation based on the acquired operation result.
It should be noted that, referring to fig. 24, the step of the target node confirming the operation result of the first transfer operation may be implemented by a transaction message consumer, and the process of the target node executing the second transfer operation on the second client may be implemented by a success message consumer, that is, implementing an asynchronous process of confirmation and execution. The step of the target node performing the second transfer operation based on the obtained operation result, as shown in fig. 25, specifically includes:
Step 2021: if the successful message queue has the successful message of resource transfer, the target node inquires the number of transferred resources based on the successful message of resource transfer.
In the implementation process, if a resource transfer success message exists in the transfer success message queue, that is, the target node determines that each sub-operation of the first transfer operation is successful, in this case, the target node searches for the corresponding identification number of the first client, the identification number of the second client, the identification number of the associated object, the transfer number, the transfer time, and the like according to the resource transfer success message.
Still taking the above work 1 and the first client as an example, the total value of the number of resources of the first client is 200, when there is a successful resource transfer message in the successful transfer message queue, the target node may execute a second transfer operation on the second client, and in the process of executing the second transfer operation, the target node first obtains the number of transferred resources 10.
Step 2022: and the target node acquires the total value of the resources of the object from a second database corresponding to the second client.
After the number of transferred resources is obtained, the target node also obtains the total value of the resources corresponding to the second client, namely the added number, and in order to distinguish the second client from the first database, the second client is provided with a corresponding second database, and in the specific implementation, the target node obtains the total value of the resources of the associated object from the second database, where the total value of the resources of the associated object can be understood as the total number of the resources of the second client, and also can be understood as the total number of the resources of a certain work of the second client.
Still taking the above work 1 and the first client side as an example, the total value of the resource numbers of the third client side is 200, and after the target node obtains the transferred resource number 10, the target node obtains the total value of the resource numbers of the objects from the second database corresponding to the second client side Lifour as 100.
Step 2023: based on the number of transferred resources, the target node updates the total value of the resources of the object.
The above-mentioned target node performs the second transfer operation on the second client through steps 2021, 2022 and 2023, so that it can be ensured that the second client can obtain the number of transfer resources consistent with the number of transfer resources subtracted in the first execution operation on the basis of determining the correctness of the first transfer operation.
In the implementation process, after the target node obtains the transferred resource number and the resource total value, the operation of executing the resource total value of the new object comprises the following specific steps:
since the target node may need to process the total value of the resources of multiple updated objects at the same time during the processing, in order to ensure the independence and the integrity of each processing, the target node may perform the locking processing on the updated operations according to the unique identifier of the first client, the identifier of the second client, the identifier of the associated object, the number of transitions, the transition time, and the like. Referring to fig. 26, the method specifically includes:
step 20231: the target node adds the total value of the resources with the number of the transferred resources to obtain the updated number of the resources.
In the process of specifically executing the total resource value of the updated object, the target node uses the total resource value of the second client object plus the successfully transferred resource number subtracted by the first client to obtain the updated resource number, namely the sum value, as the new total resource value of the second client object.
Taking the above work 1 and the first client side as an example, the total value of the resource numbers of the third client side is 200, and the target node adds the total value of the resource numbers of the fourth client side 100 to the transferred resource number of the third client side 10 to obtain the updated resource number of the fourth client side 110 in the process of executing the second transfer operation.
Step 20232: the target node replaces the total value of resources with the updated number of resources.
After the resources are successfully added, the target node updates the total value of the resources stored in the second database by the second client, namely the target node replaces the total value of the resources by the updated resource number. In order to describe the resource transfer situation of the second client in more detail, in the implementation process, the target node may update the total resource value of a certain object according to the identification number of the associated object, and the target node may also update the total resource value (i.e. the total resource value including all the objects) according to the identification number of the second client.
Still referring to fig. 27, after the target node obtains the updated resource number 110, the updated resource number 110 is used to replace the total resource value 100, resulting in a new total resource value 110.
Step 20233: the target node increments the number of transfers of the object by one.
Correspondingly, after the target object updates the total value of the resources of the object, the target node increases the transfer times of the object by one, namely the target node correspondingly increases the recorded transfer times of the object. It should be noted that, when the number of transfer times of a certain object in the second client increases faster, the unified update may be performed by adopting a manner of updating at regular time or updating when a preset condition (for example, a preset number of transfer) is reached, so as to improve the processing efficiency of the second client.
For the second transfer operation to be described as an example, the target node also updates the number of transfers of the object, and assuming that the number of transfers that have been recorded by the associated work 1 of the second client side Lifour before the first client side Lifour performs the first transfer operation is 60, after the target node replaces the total value of resources with the updated number of resources, the recorded number of transfers is added by one, resulting in the updated number of transfers being 61.
Based on the same inventive concept, referring to fig. 28 and 29, in an embodiment of the present application, there is provided a resource transfer device, including:
in a server comprising a plurality of nodes, each node performing a partial transfer operation in a resource transfer process, the apparatus comprising:
an obtaining module 2810, configured to obtain, by the target node, an operation result of performing a first transfer operation by the previous node, where the first transfer operation is an operation in a resource transfer process performed by the first client with respect to an object associated with the second client;
the determining module 2820 is configured to perform the second transfer operation after determining that the previous node completes the first transfer operation based on the obtained operation result.
Optionally, before the target node obtains the operation result of the first transfer operation performed by the previous node, the target node further includes an execution module 2800, where the execution module 2800 is configured to:
The previous node responds to the transfer operation triggered by the first client for the object associated with the second client, and generates a corresponding transfer message;
based on the transfer message, the last node executes a first transfer operation on the first client, obtains the resource state sub-results corresponding to the sub-operations contained in the first transfer operation, and generates an operation result based on the resource state sub-results.
Optionally, based on the transfer message, the previous node performs a first transfer operation on the first client, obtains a resource status sub-result corresponding to each sub-operation included in the first transfer operation, and generates an operation result based on each resource status sub-result, and the execution module 2800 is configured to:
for each sub-operation included in the first transfer operation, the previous node performs the following operations:
when one obtained sub-operation is a recording resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result;
when one obtained sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the resource number of the first client based on the transfer message, and a deduction state sub-result is obtained;
When one obtained sub-operation is a state updating sub-operation, the last node updates the total value of the resource number of the first client based on the transfer message, and obtains an updated state sub-result;
the previous node generates an operation result based on at least one of the obtained write state sub-result, deduction state sub-result and update state sub-result corresponding to each sub-operation.
Optionally, when the obtained one sub-operation is a record resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result, and the execution module 2800 is configured to:
when the obtained sub-operation is a resource recording sub-operation, the upper node writes the transfer message into a first database corresponding to the first client;
when the transfer message is successfully written into a first database corresponding to the first client, the last node sets the writing state sub-result as successful, feeds back the writing state sub-result to a service processing end corresponding to the last node, and sets the state of the transfer message as initialization;
when the transfer message is not successfully written into the first database corresponding to the first client, the last node sets the writing state sub-result as failed, feeds back the writing state sub-result to the service processing end corresponding to the last node, and continues responding to the transfer operation triggered by the first client for the object associated with the second client.
Optionally, when the obtained one sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the number of resources of the first client based on the transfer message, and obtains a deduction state sub-result, and the execution module 2800 is configured to:
when one obtained sub-operation is a deduction resource sub-operation, the last node extracts the number of transfer resources in the transfer message;
the last node obtains the total value of the resource number of the first client from the first database corresponding to the first client, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number;
based on the number of the remaining resources, the last node determines a deduction state sub-result of the deduction resource sub-operation, and feeds back the deduction state sub-result to a service processing end corresponding to the last node.
Optionally, when the obtained one sub-operation is a state update sub-operation, the previous node updates the total value of the number of resources of the first client based on the transfer message, and obtains an updated state sub-result, and the execution module 2800 is configured to:
when one obtained sub-operation is a state updating sub-operation, the last node writes a total value of the resource number in the database, and replaces the total value of the resource number with the residual resource number;
based on the total value of the resource number, the last node determines an update state sub-result of the state update sub-operation, and feeds back the update state sub-result to the service processing end corresponding to the last node.
Optionally, the previous node generates an operation result based on at least one of the obtained write state sub-result, the deduction state sub-result and the update state sub-result corresponding to each sub-operation, and the execution module 2800 is configured to:
when the sub-results corresponding to each sub-operation obtained by the previous node comprise three kinds of writing state sub-results, deducting state sub-results and updating state sub-results, the previous node generates a resource transfer success message according to the writing state sub-results, deducting state sub-results and updating state sub-results, the resource transfer success message is sent to a transfer success message queue, the resource transfer success message is recorded in a cache, and the state of the transfer message is set to be successful;
when any one of the written state sub-result, the deducted state sub-result or the updated state sub-result is unsuccessful, the previous node generates a resource transfer failure message, records the resource transfer failure message into a cache, and sets the state of the transfer message as failed;
and the previous node feeds back a resource transfer success message or a resource transfer failure message to the service processing end corresponding to the previous node.
Optionally, the previous node further includes a transaction query module after generating the operation result based on the obtained writing state sub-result, deducting state sub-result and updating state sub-result corresponding to each sub-operation, where the transaction query module is configured to:
when the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether a transfer message exists in the first database;
if yes, the last node feeds back a successful writing confirmation message to the service processing end corresponding to the last node;
otherwise, when the number of transfer resources is larger than a preset value, the previous node continues to respond to the transfer operation triggered by the first client for the object associated with the second client; and when the number of the transfer resources is not greater than the preset value, the previous node writes the transfer information into the first database corresponding to the first client again.
Optionally, the target node obtains an operation result of performing a first transfer operation by the previous node, where the first transfer operation is an operation in a resource transfer process performed by the first client with respect to an object associated with the second client, and the obtaining module 2810 is configured to:
When the resource transfer success information is recorded in the cache, the target node sends the resource transfer success confirmation information to the service processing end corresponding to the previous node;
when the resource transfer success message is not recorded in the cache, and the previous node generates the resource transfer success message according to the writing state sub-result of which the sub-result is successful, deducting the state sub-result and updating the state sub-result, the target node sends the resource transfer success message to a transfer success message queue.
Optionally, before the target node sends the resource transfer success message to the transfer success message queue, the target node further includes a query module, where the query module is configured to:
the target node inquires whether a transfer message exists in the first database;
if yes, the target node confirms the operation result based on the state of the transfer message;
otherwise, the target node feeds back a writing state sub-result confirmation failure message to the service processing end corresponding to the previous node.
Optionally, the target node confirms the operation result based on the state of the transfer message, and the determining module 2820 is used for:
if the state of the transfer message is found to be successful, the target node sends a resource transfer success message to a transfer success message queue, and feeds back the transfer message with the successful state to a service processing end corresponding to the previous node;
If the state of the transfer message is found to be failed, the target node feeds back the transfer message with the failed state to the service processing end corresponding to the previous node;
if the state of the transfer message is inquired to be initialized, the target node sequentially executes the deduction resource sub-operation and the state updating sub-operation.
Optionally, the target node sequentially performs a deduction resource sub-operation and a status update sub-operation, and the determining module 2820 is configured to:
the target node obtains the total value of the resource number of the first client from the first database, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number;
the target node obtains the total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number.
Optionally, the target node performs a second transfer operation after determining that the previous node completes the first transfer operation based on the obtained operation result, and the determining module 2820 is configured to:
if the successful message queue of the transfer success message has the successful message of the resource transfer, the target node inquires the number of the transfer resources based on the successful message of the resource transfer;
the target node obtains the total value of the resources of the object from a second database corresponding to the second client;
based on the number of transferred resources, the target node updates the total value of the resources of the object.
Optionally, based on the number of transferred resources, the target node updates the total value of the resources of the object, and the determining module 2820 is configured to:
the target node adds the total value of the resources with the number of the transferred resources to obtain the number of updated resources;
the target node replaces the total value of the resources with the updated resource number;
the target node increments the number of transfers of the object by one.
Based on the same inventive concept, referring to fig. 30, an embodiment of the present disclosure provides a server 3000, including: a memory 3001 for storing executable instructions; the processor 3002 is configured to read and execute the executable instructions stored in the memory, and perform any one of the methods of the first aspect.
The processor 3002 generally controls the overall operations of the server 3000, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The memory 3001 is configured to store various types of data to support operations at the server 3000. Examples of such data include instructions for any application or method operating on server 3000, contact data, phonebook data, messages, pictures, video, and the like. The memory 3001 may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
Based on the same inventive concept, embodiments of the present application provide a computer-readable storage medium, which when executed by a processor, causes the processor to perform the method of any one of the above-described first aspects.
In summary, in the embodiments of the present application, a method, an apparatus, and a storage medium for transferring resources are applied to a server including a plurality of nodes, where each node completes a portion of transfer operations in a resource transfer process, and the method includes: the first client performs a resource transfer process on an object associated with the second client, namely, triggers the last node to execute a first transfer operation and obtains an operation result after the first transfer operation, so that after the target node obtains the operation result of the last node to execute the first transfer operation, based on the obtained operation result, after the last node is determined to complete the first transfer operation, a second transfer operation is executed, in the processing process, asynchronous processing of resource transfer is realized through the first transfer operation and the second transfer operation, and consistency of the reduced transfer resource number of the first client and the increased transfer resource number of the second client is effectively ensured through confirmation of the operation result, and processing efficiency of the resource transfer process is improved.
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 system. 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 system embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) 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 product systems according to 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.
It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to cover such modifications and variations.

Claims (26)

1. A method for transferring resources, wherein the method is applied to a server comprising a plurality of nodes, and each node completes a part of transfer operation in a resource transfer process, and the method comprises:
the method comprises the steps that a target node obtains an operation result of executing a first transfer operation by a previous node, wherein the first transfer operation is an operation in a resource transfer process of a first client aiming at an object associated with a second client;
the target node executes a second transfer operation after determining that the previous node completes the first transfer operation based on the obtained operation result;
before the target node obtains the operation result of the first transfer operation performed by the previous node, the method further comprises the following steps:
the previous node responds to the transfer operation triggered by the first client for the object associated with the second client, and generates a corresponding transfer message;
based on the transfer message, the last node executes the first transfer operation on the first client to obtain the resource state sub-results corresponding to the sub-operations included in the first transfer operation, and generates the operation result based on the resource state sub-results;
The step of executing the first transfer operation on the first client by the last node based on the transfer message, obtaining the respective corresponding resource state sub-results of each sub-operation included in the first transfer operation, and generating the operation result based on each resource state sub-result, includes:
for each sub-operation included in the first transfer operation, the previous node performs the following operations:
when one obtained sub-operation is a recording resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result;
when one obtained sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the number of resources of the first client based on the transfer message, and obtains a deduction state sub-result;
when one obtained sub-operation is a state updating sub-operation, the previous node updates the total value of the resource number of the first client based on the transfer message, and obtains an updated state sub-result;
the previous node generates the operation result based on at least one of the obtained writing state sub-result, the deduction state sub-result and the updating state sub-result corresponding to each sub-operation;
When the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether the transfer message exists in the first database;
if yes, the previous node feeds back a successful writing confirmation message to the service processing end corresponding to the previous node;
otherwise, when the number of transfer resources is greater than a preset value, the previous node continues to respond to the transfer operation triggered by the first client for the object associated with the second client.
2. The method of claim 1, wherein when the obtained one sub-operation is a record resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result, including:
when the obtained sub-operation is a resource recording sub-operation, the previous node writes the transfer message into a first database corresponding to the first client;
when the transfer message is successfully written into a first database corresponding to the first client, the previous node sets the writing state sub-result as successful, feeds back the writing state sub-result to a service processing end corresponding to the previous node, and sets the state of the transfer message as initialization;
When the transfer message is not successfully written into the first database corresponding to the first client, the previous node sets the writing state sub-result as failure, feeds back the writing state sub-result to the service processing end corresponding to the previous node, and continues responding to the transfer operation triggered by the first client for the object associated with the second client.
3. The method of claim 1, wherein when the obtained one sub-operation is a deduction resource sub-operation, the previous node deducts a total value of the number of resources of the first client based on the transfer message, and obtains a deduction state sub-result, including:
when the obtained sub-operation is a deduction resource sub-operation, the previous node extracts the number of transfer resources in the transfer message;
the last node obtains a total value of the resource number of the first client from a first database corresponding to the first client, and subtracts the transferred resource number from the total value of the resource number to obtain a residual resource number;
based on the number of the remaining resources, the previous node determines a deduction state sub-result of the deduction resource sub-operation, and feeds back the deduction state sub-result to a service processing end corresponding to the previous node.
4. The method of claim 1, wherein when the obtained one sub-operation is a state update sub-operation, the previous node updates the total value of the number of resources of the first client based on the transfer message, and obtains an updated state sub-result, comprising:
when one of the obtained sub-operations is a state updating sub-operation, the previous node writes the total value of the resource number in the first database and replaces the total value of the resource number with the residual resource number;
based on the total value of the resource number, the last node determines an updated state sub-result of the state updating sub-operation, and feeds back the updated state sub-result to a service processing end corresponding to the last node.
5. The method of claim 1, wherein the previous node generates the operation result based on at least one of the write state sub-result, the deduction state sub-result, and the update state sub-result for each sub-operation obtained, comprising:
when the sub-results corresponding to the sub-operations obtained by the previous node comprise the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node generates a resource transfer success message according to the writing state sub-result, the deduction state sub-result and the updating state sub-result, the resource transfer success message is sent to a transfer success message queue, the resource transfer success message is recorded in a cache, and the state of the transfer message is set to be successful;
When any one of the writing state sub-result, the deduction state sub-result or the updating state sub-result is unsuccessful, the previous node generates a resource transfer failure message, records the resource transfer failure message into a cache, and sets the state of the transfer message as failure;
and the previous node feeds back the resource transfer success message or the resource transfer failure message to a service processing end corresponding to the previous node.
6. The method of claim 2, wherein when the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, after the previous node queries whether the transfer message exists in the first database, further comprising:
otherwise, when the number of the transfer resources is not greater than a preset value, the previous node writes the transfer message into a first database corresponding to the first client again.
7. The method of claim 5, wherein the target node obtains a result of an operation performed by a previous node to perform a first transfer operation, wherein the first transfer operation is an operation performed by a first client in a resource transfer process for an object associated with a second client, and comprises:
When the resource transfer success information is recorded in the cache, the target node sends a resource transfer success confirmation information to a service processing end corresponding to the previous node;
and when the resource transfer success message is not recorded in the cache, and the previous node generates the resource transfer success message according to the writing state sub-result of which the sub-result is successful, the deduction state sub-result and the updating state sub-result, and the target node sends the resource transfer success message to a transfer success message queue.
8. The method of claim 7, wherein prior to the target node sending the resource transfer success message into a transfer success message queue, further comprising:
the target node queries whether the transfer message exists in the first database;
if yes, the target node confirms the operation result based on the state of the transfer message;
otherwise, the target node feeds back a writing state sub-result confirmation failure message to the service processing end corresponding to the previous node.
9. The method of claim 8, wherein the target node acknowledges the operation result based on the state of the transfer message, comprising:
If the state of the transfer message is found to be successful, the target node sends the resource transfer success message to the transfer success message queue, and feeds back the transfer message with the successful state to the service processing end corresponding to the previous node;
if the state of the transfer message is found to be failed, the target node feeds back the transfer message with the failed state to the service processing end corresponding to the previous node;
and if the state of the transfer message is inquired to be initialized, the target node sequentially executes the deduction resource sub-operation and the state updating sub-operation.
10. The method of claim 9, wherein the target node performs the deduction resource sub-operation and the status update sub-operation sequentially, comprising:
the target node obtains a total value of the resource number of the first client from the first database, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number;
the target node obtains the total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number.
11. The method of claim 8, wherein the target node performs a second transfer operation after determining that the previous node completed the first transfer operation based on the obtained operation result, comprising:
If the resource transfer success message exists in the transfer success message queue, the target node inquires the transfer resource number based on the resource transfer success message;
the target node obtains the total value of the resources of the object from a second database corresponding to the second client;
based on the number of transferred resources, the target node updates the total value of resources for the object.
12. The method of claim 11, wherein the updating the total value of resources for the object by the target node based on the number of transferred resources comprises:
the target node adds the total value of the resources to the transferred resource number to obtain an updated resource number;
the target node replaces the total value of the resources with the updated resource number;
the target node increments the number of transfers of the object by one.
13. An apparatus for transferring resources, wherein the apparatus is applied to a server including a plurality of nodes, and each node performs a portion of a transfer operation in a resource transfer process, and the apparatus comprises:
the acquisition module is used for acquiring an operation result of executing a first transfer operation by the previous node by the target node, wherein the first transfer operation is an operation in a resource transfer process of a first client for an object associated with a second client;
The determining module is used for the target node to execute a second transfer operation after determining that the previous node completes the first transfer operation based on the obtained operation result;
before the target node obtains the operation result of executing the first transfer operation by the previous node, the target node further comprises an execution module, where the execution module is configured to:
the previous node responds to the transfer operation triggered by the first client for the object associated with the second client, and generates a corresponding transfer message;
based on the transfer message, the last node executes the first transfer operation on the first client to obtain the resource state sub-results corresponding to the sub-operations included in the first transfer operation, and generates the operation result based on the resource state sub-results;
the above node executes the first transfer operation on the first client based on the transfer message, obtains the resource state sub-results corresponding to the sub-operations included in the first transfer operation, and generates the operation result based on the resource state sub-results, and the execution module is configured to:
for each sub-operation included in the first transfer operation, the previous node performs the following operations:
When one obtained sub-operation is a recording resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result;
when one obtained sub-operation is a deduction resource sub-operation, the previous node deducts the total value of the number of resources of the first client based on the transfer message, and obtains a deduction state sub-result;
when one obtained sub-operation is a state updating sub-operation, the previous node updates the total value of the resource number of the first client based on the transfer message, and obtains an updated state sub-result;
the previous node generates the operation result based on at least one of the obtained writing state sub-result, the deduction state sub-result and the updating state sub-result corresponding to each sub-operation;
the previous node generates the operation result based on the obtained writing state sub-result, the deduction state sub-result and the updating state sub-result corresponding to each sub-operation, and further comprises a transaction inquiry module, wherein the transaction inquiry module is used for:
when the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether the transfer message exists in the first database;
If yes, the previous node feeds back a successful writing confirmation message to the service processing end corresponding to the previous node;
otherwise, when the number of transfer resources is greater than a preset value, the previous node continues to respond to the transfer operation triggered by the first client for the object associated with the second client.
14. The apparatus of claim 13, wherein when the obtained one sub-operation is a record resource sub-operation, the previous node writes the transfer message into a first database corresponding to the first client, and obtains a writing state sub-result, and the execution module is configured to:
when the obtained sub-operation is a resource recording sub-operation, the previous node writes the transfer message into a first database corresponding to the first client;
when the transfer message is successfully written into a first database corresponding to the first client, the previous node sets the writing state sub-result as successful, feeds back the writing state sub-result to a service processing end corresponding to the previous node, and sets the state of the transfer message as initialization;
when the transfer message is not successfully written into the first database corresponding to the first client, the previous node sets the writing state sub-result as failure, feeds back the writing state sub-result to the service processing end corresponding to the previous node, and continues responding to the transfer operation triggered by the first client for the object associated with the second client.
15. The apparatus of claim 13, wherein when the obtained one sub-operation is a deduction resource sub-operation, the previous node deducts a total value of the number of resources of the first client based on the transfer message, and obtains a deduction state sub-result, and the execution module is configured to:
when the obtained sub-operation is a deduction resource sub-operation, the previous node extracts the number of transfer resources in the transfer message;
the last node obtains a total value of the resource number of the first client from a first database corresponding to the first client, and subtracts the transferred resource number from the total value of the resource number to obtain a residual resource number;
based on the number of the remaining resources, the previous node determines a deduction state sub-result of the deduction resource sub-operation, and feeds back the deduction state sub-result to a service processing end corresponding to the previous node.
16. The apparatus of claim 13, wherein when the obtained one sub-operation is a state update sub-operation, the previous node updates the total value of the number of resources of the first client based on the transfer message, and obtains an updated state sub-result, the execution module is configured to:
When one of the obtained sub-operations is a state updating sub-operation, the previous node writes the total value of the resource number in the first database and replaces the total value of the resource number with the residual resource number;
based on the total value of the resource number, the last node determines an updated state sub-result of the state updating sub-operation, and feeds back the updated state sub-result to a service processing end corresponding to the last node.
17. The apparatus of claim 13, wherein the previous node generates the operation result based on at least one of the write state sub-result, the deduction state sub-result, and the update state sub-result for each sub-operation obtained, the execution module to:
when the sub-results corresponding to the sub-operations obtained by the previous node comprise the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node generates a resource transfer success message according to the writing state sub-result, the deduction state sub-result and the updating state sub-result, the resource transfer success message is sent to a transfer success message queue, the resource transfer success message is recorded in a cache, and the state of the transfer message is set to be successful;
When any one of the writing state sub-result, the deduction state sub-result or the updating state sub-result is unsuccessful, the previous node generates a resource transfer failure message, records the resource transfer failure message into a cache, and sets the state of the transfer message as failure;
and the previous node feeds back the resource transfer success message or the resource transfer failure message to a service processing end corresponding to the previous node.
18. The apparatus of claim 13, wherein the transaction query module is further to:
when the service processing end corresponding to the previous node does not receive any one of the writing state sub-result, the deduction state sub-result and the updating state sub-result, the previous node inquires whether the transfer message exists in the first database;
otherwise, when the number of the transfer resources is not greater than a preset value, the previous node writes the transfer message into a first database corresponding to the first client again.
19. The apparatus of claim 17, wherein the target node obtains a result of an operation performed by a previous node to perform a first transfer operation, wherein the first transfer operation is an operation performed by a first client in a resource transfer process with respect to an object associated with a second client, and wherein the obtaining module is configured to:
The target node judges whether the resource transfer success message is recorded in the cache;
if yes, the target node sends a successful confirmation message of resource transfer to a service processing end corresponding to the previous node;
otherwise, the target node sends the resource transfer success message to a transfer success message queue.
20. The apparatus of claim 13, wherein the target node further comprises a query module for, prior to sending the resource transfer success message into a transfer success message queue:
the target node queries whether the transfer message exists in the first database;
if yes, the target node confirms the operation result based on the state of the transfer message;
otherwise, the target node feeds back a writing state sub-result confirmation failure message to the service processing end corresponding to the previous node.
21. The apparatus of claim 20, wherein the target node acknowledges the result of the operation based on a state of the transfer message, the determining module to:
if the state of the transfer message is found to be successful, the target node sends the resource transfer success message to the transfer success message queue, and feeds back the transfer message with the successful state to the service processing end corresponding to the previous node;
If the state of the transfer message is found to be failed, the target node feeds back the transfer message with the failed state to the service processing end corresponding to the previous node;
and if the state of the transfer message is inquired to be initialized, the target node sequentially executes the deduction resource sub-operation and the state updating sub-operation.
22. The apparatus of claim 21, wherein the target node performs the deduction resource sub-operation and the status update sub-operation sequentially, the determination module to:
the target node obtains a total value of the resource number of the first client from the first database, and subtracts the transferred resource number from the total value of the resource number to obtain the residual resource number;
the target node obtains the total value of the resource number in the first database, and replaces the total value of the resource number with the residual resource number.
23. The apparatus of claim 20, wherein the target node performs a second transfer operation after determining that the previous node completed the first transfer operation based on the obtained operation result, the determining module is configured to:
if the resource transfer success message exists in the transfer success message queue, the target node inquires the transfer resource number based on the resource transfer success message;
The target node obtains the total value of the resources of the object from a second database corresponding to the second client;
based on the number of transferred resources, the target node updates the total value of resources for the object.
24. The apparatus of claim 23, wherein the target node updates the total value of resources for the object based on the number of transferred resources, the determination module to:
the target node adds the total value of the resources to the transferred resource number to obtain an updated resource number;
the target node replaces the total value of the resources with the updated resource number;
the target node increments the number of transfers of the object by one.
25. A server, comprising:
a memory for storing executable instructions;
a processor for reading and executing executable instructions stored in said memory to implement the method of any one of claims 1-12.
26. A computer readable storage medium, wherein instructions in the storage medium, when executed by a processor, enable the processor to perform the method of any one of claims 1-12.
CN202110841697.5A 2021-07-26 2021-07-26 Resource transfer method, device and storage medium Active CN113486121B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110841697.5A CN113486121B (en) 2021-07-26 2021-07-26 Resource transfer method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110841697.5A CN113486121B (en) 2021-07-26 2021-07-26 Resource transfer method, device and storage medium

Publications (2)

Publication Number Publication Date
CN113486121A CN113486121A (en) 2021-10-08
CN113486121B true CN113486121B (en) 2024-03-12

Family

ID=77943601

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110841697.5A Active CN113486121B (en) 2021-07-26 2021-07-26 Resource transfer method, device and storage medium

Country Status (1)

Country Link
CN (1) CN113486121B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106204217A (en) * 2016-07-08 2016-12-07 腾讯科技(深圳)有限公司 The methods, devices and systems of resource numerical value transfer, the method and apparatus of resource numerical value transfer request
CN107301536A (en) * 2017-06-12 2017-10-27 腾讯科技(深圳)有限公司 Resource transfers method and device
CN109064105A (en) * 2018-09-28 2018-12-21 阿里巴巴集团控股有限公司 A kind of resource transfers request processing method, device and electronic equipment
CN111061573A (en) * 2019-11-15 2020-04-24 北京三快在线科技有限公司 Resource transfer method, device, electronic equipment and storage medium
CN112258187A (en) * 2020-11-23 2021-01-22 中国银联股份有限公司 Resource transfer method, server, exchange device, system and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200218572A1 (en) * 2019-01-09 2020-07-09 Brighthouse Services, LLC System for transformation of resource allocations of predetermined intervals based on dynamic indices

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106204217A (en) * 2016-07-08 2016-12-07 腾讯科技(深圳)有限公司 The methods, devices and systems of resource numerical value transfer, the method and apparatus of resource numerical value transfer request
CN107301536A (en) * 2017-06-12 2017-10-27 腾讯科技(深圳)有限公司 Resource transfers method and device
CN109064105A (en) * 2018-09-28 2018-12-21 阿里巴巴集团控股有限公司 A kind of resource transfers request processing method, device and electronic equipment
CN111061573A (en) * 2019-11-15 2020-04-24 北京三快在线科技有限公司 Resource transfer method, device, electronic equipment and storage medium
CN112258187A (en) * 2020-11-23 2021-01-22 中国银联股份有限公司 Resource transfer method, server, exchange device, system and storage medium

Also Published As

Publication number Publication date
CN113486121A (en) 2021-10-08

Similar Documents

Publication Publication Date Title
CN108376118B (en) Service distribution system, method, device and storage medium
US20190278770A1 (en) Time Series Data Management Method, Device, And Apparatus
CN110602165B (en) Government affair data synchronization method, device, system, computer equipment and storage medium
CN111124755A (en) Cluster node fault recovery method and device, electronic equipment and storage medium
EP3816912A1 (en) Blockchain-based transaction processing method and apparatus, and electronic device
US20150189016A1 (en) Episodic Coordination Model for Distributed Applications
CN111400267A (en) Method and device for recording log
CN111680052A (en) Method and device for generating identity identification number
CN112685391B (en) Service data migration method and device, computer equipment and storage medium
CN113486121B (en) Resource transfer method, device and storage medium
CN113946427A (en) Task processing method, processor and storage medium for multi-operating system
CN112561506B (en) Live broadcast data processing method, system, equipment and medium based on virtual currency
CN114091010A (en) Encryption self-adaptive optimization method and device, electronic equipment and storage medium
JP6613315B2 (en) Transaction processing system and transaction control method
CN110502460B (en) Data processing method and node
CN110489208B (en) Virtual machine configuration parameter checking method, system, computer equipment and storage medium
CN114553859A (en) BMC configuration management method and device, electronic equipment and storage medium
CN110221952B (en) Service data processing method and device and service data processing system
CN112732367A (en) Event flow processing method, device and equipment and readable storage medium
US20230385113A1 (en) Progress Monitoring Service
CN114203305B (en) Data processing method and system based on intelligent medical big data
CN110806917A (en) Anti-split virtual machine high-availability management device and method
US20230367788A1 (en) Atomically bridging transactions across different blockchains
CN115905271B (en) Virus library updating method and device and multi-engine detection system
CN112015758B (en) Product code-fetching method, device, computer equipment and storage medium

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