Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
First embodiment
Referring to fig. 1, a first embodiment of the present invention provides a distribution system 10, where the distribution system 10 includes: data storage server 11, cache counter 12 and a plurality of dispensing servers 13, and counting means 14 to which the plurality of dispensing servers 13 are connected. Wherein each issuing server 13 is further connected to cache counter 12 and data storage server 11.
The data storage server 11 is an integrated electronic device with signal processing and data storage capabilities. A data storage server 11 is applied to the dispensing system 10, and a database in the data storage server 11 stores a current total quantity value of products that can be delivered. When a product is delivered by a dispensing server 13, the current total quantity value in the data storage server 11 may be updated by the dispensing server 13 minus 1. The product in this embodiment may be a prize that needs to be distributed to the client.
The buffer counter 12 is an integrated electronic device with signal processing and data storage capabilities. In this embodiment, the cache counter 12 may be a distributed cache cluster, which can effectively alleviate the load of the data storage server 11 when the product is issued. For storing the current total quantity value of the deliverable products synchronized with the data storage server 11. Also after a product is delivered by a delivery server 13, the current total count value in cache counter 12 may be updated by the delivery server 13 minus 1 in preference to data storage server 11.
The issuing server 13 may be a conventional server with signal processing and data storage capabilities. When the prize is issued, the issuing server 13 obtains a product issuing request sent by the client through the connection with the client. The issuing server 13 processes the product issuing request, sends a product corresponding to the product issuing request to the client, and updates the current total number value of the products in the cache counter 12 by subtracting 1. After that, the issuing server 13 adds 1 to the total number of update requests in the issuing server 13 according to the update request corresponding to the processed product issuing request. For example, the dispensing server 13 generates an update request according to a processed product dispensing request; or generating the updating requests corresponding to the quantity of the product issuing requests according to the quantity of the product issuing requests processed in each preset period. The issuing server 13 updates the current total quantity value of the products in the issuing server 13 by subtracting 1 according to the updating request, and subtracts 1 from the total quantity of the updating request after the updating is successful. When a certain one of the plurality of dispensing servers 13 fails to access the cache counter 12, the dispensing server 13 may serve as the target dispensing server 13 to send a product dispensing exception signal for regression statistics of the number of products to the counting device 14.
The buffer counter 14 may be an integrated electronic device with signal processing and data computation capabilities. In this embodiment, the cache counter 14 may be a zookeeper cluster (distributed application coordination service). The cache counter 14 determines the target dispensing server 13 according to the obtained product dispensing exception signal. And monitors the total sum of the number of update requests in the remaining plurality of issuing servers 13 so that the target issuing server 13 synchronizes the current product quantity value in the data storage server 12 to the cache counter 11 when the total sum of the number of update requests is zero, thereby maintaining the synchronization of the data of the cache counter 11 and the data of the data storage server 12.
Second embodiment
Referring to fig. 2, a second embodiment of the present invention provides a data interaction method, where the data interaction method is applied to a counting device of a distribution system, and the data interaction method includes: step S100 and step S200.
Step S100: and determining whether a target issuing server with abnormal product issuing exists in the plurality of issuing servers.
The counting device is connected with each issuing server so as to realize data interaction with each issuing server. The counting device can detect whether a product dispensing abnormal signal is received in real time. When the judgment is negative, namely the abnormal signal of the product release is not received, the computing device keeps continuously detecting. When one of the target issuing servers is abnormal in product issuing, the counting device can determine that the product issuing abnormal signal sent by the target issuing server is received, namely the counting device can determine that the product issuing abnormal signal contains the ID of the issuing server sending the signal.
The counting device analyzes the product issuing abnormal signal to correspondingly obtain the ID of the issuing server in the product issuing abnormal signal. Furthermore, the counting device can determine the target issuing server with the ID value corresponding to the ID of the issuing server from the issuing servers according to the ID of the issuing server, and also determine that the product issuing of the target issuing server is abnormal and regression statistics of the number of the products needs to be executed.
It is understood that the determination of the corresponding target server by the ID is an implementation manner of the embodiment, and is not limited to the embodiment. For example, the links connecting each of the issuing servers may be correspondingly numbered, and if a product issuing abnormal signal is received through a certain link, the target issuing server connected to the link may be directly determined according to the link.
Step S200: and when the current quantity sum of the updating requests of the plurality of issuing servers is judged to be zero, the current quantity sum of the updating requests of the plurality of issuing servers is obtained, so that all the target issuing servers synchronize the current product quantity value in the data storage server to the cache counter when the current quantity sum is zero.
When the counting device determines yes and starts to execute the regression statistics of the product quantity, the counting device may notify each of the remaining issuing servers except the target issuing server so that each of the remaining issuing servers knows that the regression statistics needs to be executed. Thereafter, each issuing server continuously submits the number of update requests for updating the number of products in the current data storage server to the counting device in real time. It can be understood that the update request is correspondingly generated according to the product release request processed by the release server, and the update request is used for instructing the data storage server to increase or decrease the number of the products according to the number of the update requests.
For example, when the number of update requests in the issuing server a is 3, the current number of products in the data storage server needs to be correspondingly subtracted by 3. When the issuing server a processes a product issuing request again, the number of update requests in the issuing server a is +1, which is increased to 4, and the current number of products in the data storage server is required to be correspondingly reduced by 4. And then, when the issuing server A updates and subtracts 1 from the current product quantity in the data storage server according to an updating request, the issuing server A completes the processing of the updating request and updates the quantity of the requests from-1 to 3.
It is understood that the data storage server reduces the current number of products according to the number of update requests, which is a specific implementation manner of the present embodiment when products are issued. When the data storage server is in the superposition statistics, namely, when the products are stored in the stock, the data storage server can increase the current product quantity according to the quantity of the updating requests. For example, when the number of update requests in the issuing server a is 3, the current number of products in the data storage server needs to be increased by 3 correspondingly. When the issuing server a processes a product issuing request again, the number of update requests in the issuing server a is increased to +1, so that 4 update requests are added, and 4 update requests are added to the current number of products in the data storage server.
The counting device can correspondingly obtain the number of the update requests submitted by each issuing server in real time. The counting means may superimpose the number of the plurality of update requests so as to obtain the plurality of issuance servers. In this embodiment, the counting device continuously obtains the total sum of the number of the update requests in real time as a dynamic process, that is, when the number of the update requests of a certain issuing server is updated to be decreased by 1, the total sum of the current number of the update requests in the counting device is also decreased by 1 correspondingly. Because the total of the number of the update requests obtained by the counting device is dynamically updated, when the total of the number of the update requests is dynamically updated to zero, the target issuing server can also correspondingly obtain the total of the number of the update requests to be zero, at this time, the target issuing server synchronizes the current product number value in the data storage server to the cache counter, so that the current product number value in the cache counter after the regression statistics is performed corresponds to the actually issued product number value.
It should be noted that, the counting device notifies each issuing server of the number of update requests submitted in real time, so that the counting device obtains the total current number of update requests in real time as an optional implementation manner in this embodiment, which is not limited to this embodiment. In this embodiment, the counting device may also be used to obtain the number of the corresponding update requests from each issuing server in real time, so as to obtain the total current number of the update requests in real time. In addition, in this embodiment, each issuing server may be notified by the counting device, so that the number of update requests of each issuing server per se reaches zero, and then the number of update requests is sent to the counting device.
Third embodiment
Referring to fig. 3, a third embodiment of the present invention provides a data interaction method, where the data interaction method is applied to any one of a plurality of distribution servers in a distribution system, and the data interaction method includes: step S300 and step S400.
Step S300: when the accessed cache counter is abnormal, the issuing server serves as a target issuing server to send a product issuing abnormal signal to the counting device.
Each issuing server receives the product issuing request sent by the client and issues the product corresponding to the product issuing request to the client through the connection with the cache counter, and each issuing server needs to access the cache counter to correspondingly update the current product quantity value in the cache counter, namely, the current product quantity value in the cache counter is reduced by 1. But if the cache counter accessed by one issuing server is abnormal, the issuing server can be used as a target issuing server. Wherein, the cache counter being in an exception may be: the current product quantity value in the cache counter is 0 after the cache counter is in a power-on state or in a failure state and the access to the cache counter fails or the current product quantity value in the cache counter is updated and reduced by 1.
At this time, the target issuing server may trigger regression statistics of the product quantity according to a preset control program. Further, the target issuing server may generate a product issuing abnormality signal including its own ID to the counting means so that the counting means obtains a total current number of update requests of the plurality of issuing servers other than the target issuing server.
Step S400: when the total sum of the current numbers of the updating requests of the plurality of issuing servers in the counting device is zero, the current product number value in the data storage server is synchronized to the cache counter.
In order to facilitate the accuracy of subsequent synchronization, the target issuing server can monitor the total current number of the update requests in the counting device in real time. Specifically, the target issuing server determines whether the sum of the obtained current numbers of the update requests of the plurality of issuing servers in the counting apparatus is zero. If the target issuing server judges that the target issuing server is not the target issuing server, the target issuing server continues to monitor and judge according to the preset control program. If the current number of the update requests of each issuing server is zero, the target issuing server may determine that the sum of the current numbers of the update requests is zero. It can now be characterized that the current product quantity value in the data storage server remains in correspondence with the actually dispensed product quantity value. Further, the target issuing server further determines whether access to the cache counter is available at this time. If not, the target issuing server continues to wait and continues to judge whether the access of the cache counter is accessible. If so, the cache counter is indicated to restore or maintain the normal working state, and then the target issuing server reads the current product quantity value in the data storage server and synchronizes the read current product quantity value into the cache counter, so that the current product quantity value in the cache counter and the current product quantity value in the data storage server are kept synchronous and also correspond to the actually issued product quantity, and the over-issuing of the product is avoided.
It should be noted that, the target issuing server monitors the total current number of the update requests in the counting device to perform the supersending of the synchronization as an optional implementation manner in this embodiment, and is not limited to this embodiment. For example, the counting device may send a trigger signal to the target issuing server when the total current number of the update requests is zero, and the target issuing server may perform the synchronization superissue according to the trigger signal.
Fourth embodiment
Referring to fig. 4, a fourth embodiment of the present invention provides a data interaction method, where the data interaction method is applied to any one of a plurality of distribution servers in a distribution system, and a counting device connected to each distribution server. The data interaction method comprises the following steps: step S101, step S201, step S301, and step S401.
Step S101: when the accessed cache counter is abnormal, the issuing server serves as a target issuing server to send a product issuing abnormal signal to the counting device.
Step S201: the counting device determines whether a target issuing server with abnormal product issuing exists in the plurality of issuing servers.
Step S301: the counting means may obtain a total of the current number of update requests of the plurality of issue servers when it is determined that there is a case.
Step S401: and when the total sum of the current numbers of the updating requests of the plurality of issuing servers in the counting device is zero, the target issuing server synchronizes the current product number value in the data storage server to the cache counter.
It should be noted that, as those skilled in the art can clearly understand, for convenience and brevity of description, the specific working process of the method described above may refer to the corresponding process in the foregoing method embodiment, and is not described herein again.
Fifth embodiment
Referring to fig. 5, a fifth embodiment of the present invention provides a data interaction apparatus 100, which is applied to a counting apparatus of a distribution system. The data interaction device 100 comprises:
the determining module 110 is configured to determine whether there is a target issuing server with an abnormal product issuing function in the plurality of issuing servers.
An obtaining module 120, configured to, when it is determined that the current quantity sum of the update requests of the plurality of issuing servers is zero, obtain a current quantity sum of the update requests of the plurality of issuing servers, so that all the target issuing servers synchronize the current quantity value of the product in the data storage server to the cache counter when the current quantity sum is zero.
Referring to fig. 6, in a data interaction apparatus 100 according to a fifth embodiment of the present invention, a determining module 110 includes:
a determining unit 111 configured to determine, from the plurality of issuing servers, an issuing server corresponding to the issuing server ID as the target issuing server, according to the issuing server ID in the received product issuing abnormality signal.
Referring to fig. 7, in a data interaction apparatus 100 according to a fifth embodiment of the present invention, an obtaining module 120 includes:
an obtaining unit 121, configured to obtain, in real time, a current number of update requests of each of the plurality of issuing servers.
And a summing unit 122, configured to obtain a sum of the current number of the update requests according to the current number of the update requests of each issuing server.
Sixth embodiment
Referring to fig. 8, a sixth embodiment of the present invention provides a data interaction apparatus 200, which is applied to any one of a plurality of issuing servers in an issuing system. The data interaction device 200 comprises:
a sending module 210, configured to, when the accessed cache counter is abnormal, serve as a target issuing server to send a product issuing abnormal signal to the counting apparatus.
A synchronization module 220, configured to synchronize the current product quantity value in the data storage server to the cache counter when the total of the current number of update requests of the plurality of issuing servers in the counting apparatus is zero.
Referring to fig. 9, in a data interaction apparatus 200 according to a sixth embodiment of the present invention, a synchronization module 220 includes:
a first judging unit 221, configured to judge whether a sum of the obtained current numbers of the update requests of the plurality of issuing servers in the counting apparatus is zero.
A second determining unit 222, configured to determine whether access to the cache counter is reachable when the determination is zero.
A synchronizing unit 223, configured to synchronize the current product quantity value in the data storage server to the cache counter when it is determined that the current product quantity value is reachable.
It should be noted that, as those skilled in the art can clearly understand, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The computer program product of the computer-readable storage medium for performing the processor-executable nonvolatile program code according to the embodiment of the present invention includes a computer-readable storage medium storing the program code, where instructions included in the program code may be used to execute the method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment, and is not described herein again.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In summary, embodiments of the present invention provide a data interaction method and apparatus, and a readable storage medium. The data interaction method is applied to a counting device of a distribution system, and the distribution system further comprises the following steps: the device comprises a plurality of issuing servers connected with the counting device, and a cache counter and a data storage server which are connected with each issuing server in the plurality of issuing servers. The method comprises the following steps: determining whether a target issuing server with abnormal product issuing exists in the plurality of issuing servers; at the time of the determination, the total current number of the update requests of the plurality of the issuing servers is obtained, so that all the target issuing servers synchronize the current product number value in the data storage server to the cache counter when the total current number is zero.
When the counting device determines that the product of the target issuing server is abnormal, the counting device obtains the total current number of the updating requests in the plurality of issuing servers. Therefore, when the total sum of the updating request quantity in the computing device is zero, the target issuing server synchronizes the current product quantity value in the data storage server to the cache counter. The method effectively ensures that the number value of the current products synchronized by the data storage server to the cache counter is consistent with the actually issued products, avoids the overdissuring of the prize, avoids the malicious utilization of the overdissuring of the prize by a person, and effectively manages and controls the risk of loss to a company due to the overdissuring of the prize.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes will occur to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.