Data transmission method and device
By creating a ring queue and offset pointer on the production server, priority is given to transmitting other cached data and delaying retransmission of failed data, the problem of difficult data timeliness and integrity in the prior art is solved, and more efficient data transmission is achieved.
Patent Information
- Application Number
- CN202311797980.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2025-06-27
AI Technical Summary
The prior art immediately initiates the retransmission strategy when data transmission fails, resulting in delays in transmission of other data and fails to take into account both data timeliness and integrity.
The data transmission method of ring queue and offset pointer is used to determine whether data transmission is started through the head and tail pointers, and other cached data are transferred first when the transmission fails, delaying the retransmission of failed data.
To a certain extent, take into account data timeliness and data integrity, avoid excessive storage space occupied by data transmission failure, and reduce the impact on other processes.
Smart Images

Figure CN120223773A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a data transmission method and apparatus. Background Art
[0002] In the field of computers, the importance of data is self-evident. In recent years, with the booming development of big data technology, data has great application potential in improving production efficiency, realizing intelligent production, enhancing factor allocation efficiency, stimulating new driving forces, and cultivating new business forms, and has become an innovative power source for promoting the development of the digital economy. In a distributed architecture, the production, storage, and calculation of data are often completed in different systems, so data often needs to be transferred or copied. Maximize the timeliness and reliability of data transmission under limited conditions.
[0003] Figure 1 FIG. is a schematic diagram of the data transmission process of a production server in the prior art. As Figure 1 shown, in the prior art, the production server writes newly generated production data into a local storage medium, then starts a process to periodically scan the local storage medium to obtain production data to be transmitted, and sends the production data to be transmitted to the target device through a network request. During the data transmission process, the production data is generally written into a linear storage space, and the storage location of the transmitted data in the linear storage space is recorded by a flag bit. When the target device feedbacks that the data transmission at this storage location fails, the production server will start a data retransmission strategy to attempt to retransmit the production data at this flag bit.
[0004] It is found that the data transmission scheme in the prior art has at least the following problems:
[0005] When the data transmission fails, since the retransmission strategy is immediately started to attempt to retransmit the data, other data written later into the linear storage space will be delayed in transmission. This method only takes into account data integrity and does not take into account data timeliness. If some application scenarios have high requirements for both data timeliness and integrity, the later-produced data may lose its application value due to being delayed in transmission.
[0006] In addition, during the data retransmission process, new production data will continue to be written into the linear storage space, and the production data will occupy more storage space, which may affect other processes on the production server. Summary of the Invention
[0007] The purpose of the embodiments of this application aims to solve at least one of the above technical defects, and particularly provides a data transmission method and apparatus.
[0008] The embodiments of this application adopt the following technical solutions:
[0009] In a first aspect, an embodiment of the present application provides a data transmission method, which is executed by a production server. The production server creates a circular queue and an offset pointer. The circular queue includes a head pointer, a tail pointer, and a plurality of cache units. The production data generated by the production server is cached through the cache units. The data transmission method includes:
[0010] Determine whether to start the current round of data transmission according to whether the head pointer and the tail pointer point to the same cache unit;
[0011] If they point to different cache units, start the current round of data transmission, determine the target production data to be transmitted according to the offset pointer and the head pointer, and perform data transmission;
[0012] When the transmission of the target production data is completed, update the offset of the offset pointer and the offset of the head pointer according to different update strategies, so that when there is production data with transmission failure during the current round of data transmission, other cached production data is preferentially transmitted, and the production data with transmission failure is retransmitted later.
[0013] In a second aspect, an embodiment of the present application further provides a data transmission device, which is applied to a production server. The production server creates a circular queue and an offset pointer. The circular queue includes a head pointer, a tail pointer, and a plurality of cache units. The production data generated by the production server is cached through the cache units. The data transmission device includes:
[0014] A start judgment unit, configured to determine whether to start the current round of data transmission according to whether the head pointer and the tail pointer point to the same cache unit;
[0015] A data transmission unit, configured to start the current round of data transmission if they point to different cache units, determine the target production data to be transmitted according to the offset pointer and the head pointer, and perform data transmission;
[0016] A pointer update unit, configured to update the offset of the offset pointer and the offset of the head pointer according to different update strategies when the transmission of the target production data is completed, so that when there is production data with transmission failure during the current round of data transmission, other cached production data is preferentially transmitted, and the production data with transmission failure is retransmitted later.
[0017] In a third aspect, an embodiment of the present application further provides an electronic device, which includes:
[0018] A memory, storing computer-executable instructions;
[0019] A processor, when the computer-executable instructions are executed, causes the processor to execute the data transmission method.
[0020] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, cause the electronic device to execute a data transmission method.
[0021] The above at least one technical solution adopted in the embodiment of the present application can achieve the following beneficial effects:
[0022] In the embodiment of the present application, a circular queue and an offset pointer are pre-created on the production server. The production data of the production server is cached through the circular queue, and the circular queue is jointly maintained by three pointers: the offset pointer, the head pointer, and the tail pointer. When implementing data transmission, the production server in the embodiment of the present application first uses the cache units pointed to by the head pointer and the tail pointer as the starting condition for each round of data transmission. When they point to different cache units, this round of data transmission is started. Secondly, during each round of data transmission, the target production data to be transmitted is determined according to the offset pointer and the head pointer, and data transmission is performed. Finally, when the transmission of the target production data is completed, the offsets of the offset pointer and the head pointer are updated according to different update policies. In this way, when there is production data with transmission failure during this round of data transmission, other cached production data is preferentially transmitted, and the production data with transmission failure is retransmitted later, which can balance data timeliness and data integrity to a certain extent.
[0023] In addition, the circular queue is a buffer with a bounded storage. By caching the production data into the circular queue in the embodiment of the present application, it is possible to prevent the production data from occupying other storage spaces without limit and reduce the impact on other processes on the production server. Moreover, the circular queue mechanism in the embodiment of the present application enables the newly generated production data to overwrite the old production data, which can further ensure the timeliness of the transmitted data. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0025] Figure 1 It is a schematic diagram of the data transmission process of the production server in the prior art;
[0026] Figure 2 It is a schematic diagram of the circular queue shown in the embodiment of the present application;
[0027] Figure 3 It is a flowchart of a data transmission method shown in the embodiment of the present application;
[0028] Figure 4A schematic diagram showing that an offset pointer and a head pointer point to different cache units as shown in an embodiment of the present application;
[0029] Figure 5 A schematic diagram showing a process of updating the offsets of an offset pointer and a head pointer as shown in an embodiment of the present application;
[0030] Figure 6 A schematic diagram of the structure of a data transmission device as shown in an embodiment of the present application;
[0031] Figure 7 A schematic diagram of the structure of an electronic device as shown in an embodiment of the present application. Detailed implementation manners
[0032] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0033] In response to the problems described above, in the embodiments of the present application, production data is cached in a circular queue, and the transmission process of the production data is controlled by the head pointer of the circular queue and the offset pointer of the production server, so that when a certain production data in the circular queue fails to be transmitted, other production data in the circular queue is preferentially transmitted, and the production data that fails to be transmitted is retransmitted with a delay, so as to balance data integrity and data timeliness during the transmission process. In addition, since the length of the circular queue is fixed, in the case of data retransmission, it will not occupy other storage spaces, and can reduce the impact on other processes.
[0034] To facilitate the understanding of the following embodiments of the present application, the following first introduces relevant technical terms.
[0035] A circular queue is a linear data structure that operates on data based on the first-in, first-out principle, and the tail of the queue is connected after the head to form a cycle. Therefore, the circular queue is also called a circular memory or a circular buffer. Logically, the circular queue is circular, but physically it is a fixed-length array. After the circular queue is created, its length is determined, the number of elements that can be cached is determined, and the circular queue needs to maintain the queue state through pointers.
[0036] Figure 2Shown is a schematic diagram of a circular queue. The circular queue includes 16 buffer units 0 to 15, a head pointer Head, and a tail pointer Tail. The head pointer points to the readable position of the circular queue, and the tail pointer points to the writable position of the circular queue. Specifically, the head pointer points to the first element in the circular queue, and the tail pointer points to the position next to the last element in the circular queue. Taking Figure 2 the circular queue shown as an example, in the current state, the element "11" cached in buffer unit [1] can be obtained from the circular queue through the head pointer, and a new element can be written into buffer unit
[11] through the tail pointer.
[0037] When the head pointer catches up with the tail pointer, there are no untransmitted elements in the circular queue; when the tail pointer catches up with the head pointer, the circular queue is full, and at this time, production data has been cached in each buffer unit of the circular queue.
[0038] The following will describe in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
[0039] The embodiment of the present application provides a data transmission method, which is executed by a production server. The production server creates a circular queue and an offset pointer. The circular queue includes a head pointer, a tail pointer, and a plurality of buffer units, and the production data generated by the production server is cached through the buffer units.
[0040] As Figure 3 shown, a flowchart of a data transmission method in an embodiment of the present application is provided. The method at least includes the following steps S310 to step S330:
[0041] Step S310, determine whether to start the current round of data transmission according to whether the head pointer and the tail pointer point to the same buffer unit.
[0042] The production server in the embodiment of the present application determines whether there is production data cached in the circular queue according to the pointing positions of the head pointer and the tail pointer. When the two pointers point to the same buffer unit, it means that there is no production data cached in the circular queue at this time, and data transmission does not need to be started. This step can be continuously executed according to the pre-established strategy so that when new production data is generated, the newly generated production data can be transmitted in a timely manner to ensure data timeliness. When the two pointers point to different buffer units, it means that there is production data cached in the circular queue, and the current round of data transmission should be started to transmit the cached production data to the peer end.
[0043] Among them, in the embodiment of the present application, the transmission process of the production data corresponding to the head pointer to the production data corresponding to the tail pointer is used as one round of data transmission. The amount of data transmitted in each round of data transmission is not fixed and is related to the production situation of the production data.
[0044] It can be understood that when creating a circular queue, the production server according to an embodiment of the present application can create a first thread. The first thread includes an offset pointer, and the first thread sends the production data cached in the circular queue to the peer end through a network request, and the network request is related to the transmission protocol between the production server and the peer end.
[0045] Step S320, if they point to different cache units, start the current round of data transmission, determine the target production data to be transmitted according to the offset pointer and the head pointer of the queue, and perform data transmission.
[0046] In the prior art, the readable position of the circular queue is determined by the head pointer of the circular queue itself. When the data transmission fails, if data retransmission is not started, the offset of the head pointer is directly updated to point to the next cache unit to continue transmitting the next production data. At this time, although the timeliness of other cached data is not affected, the data with transmission failure will be overwritten by the newly written data, so that the peer end of the production server cannot obtain the production data, and the peer end service may be affected. If data retransmission is started, the prior art is to resend the retransmission data according to the configured number of retransmission times, which will affect the timeliness of other cached data.
[0047] To address the above problems and balance the timeliness and integrity of data, different from the prior art, in the embodiment of the present application, when starting the current round of data transmission, the readable position of the circular queue is jointly determined by the offset pointer and the head pointer. At this time, the production data that needs to be retransmitted can be determined by the head pointer, and each production data in the process of the current round of data transmission is preferentially transmitted through the offset pointer.
[0048] Step S330, when the transmission of the target production data is completed, update the offsets of the offset pointer and the head pointer according to different update strategies, so that when there is production data with transmission failure in the process of the current round of data transmission, other cached production data is preferentially transmitted, and the production data with transmission failure is retransmitted later.
[0049] In the process of the current round of data transmission, in the embodiment of the present application, when the transmission of each target production data is completed, the offsets of the offset pointer and the head pointer are updated according to different update strategies. The update strategy of the offset pointer indicates updating the offset of the offset pointer according to the data sending result of the target production data, and the update strategy of the head pointer indicates updating the offset of the offset pointer according to the data receiving result of the target production data.
[0050] Updating the offset pointer and the offset of the head pointer according to the above update strategy can, during the current round of data transmission, when some production data transmission fails, give priority to transmitting other production data. In the next round of data transmission, if the production data that failed to be transmitted is not overwritten by new production data, retransmit the production data that failed to be transmitted. In this way, through the delayed retransmission strategy, the timeliness and integrity of the data during the data transmission process can be taken into account.
[0051] As Figure 3 can be seen from the data transmission method shown, in the embodiments of the present application, a circular queue and an offset pointer are pre-created on the production server. The production data of the production server is cached through the circular queue, and the circular queue is jointly maintained by three pointers: the offset pointer, the head pointer, and the tail pointer. When implementing data transmission, the production server in the embodiments of the present application first uses the cache units pointed to by the head pointer and the tail pointer as the starting conditions for each round of data transmission. When they point to different cache units, start the current round of data transmission. Secondly, during each round of data transmission, determine the target production data to be transmitted according to the offset pointer and the head pointer and perform data transmission. Finally, when the target production data transmission is completed, update the offset of the offset pointer and the head pointer according to different update strategies. In this way, when there is production data that fails to be transmitted during the current round of data transmission, give priority to transmitting other cached production data and delay the retransmission of the production data that failed to be transmitted, which can, to a certain extent, take into account the timeliness and integrity of the data.
[0052] In addition, a circular queue is a buffer with a bounded storage. In the embodiments of the present application, by caching the production data into the circular queue, it is possible to prevent the production data from occupying other storage spaces without limit and reduce the impact on other processes on the production server. And in the embodiments of the present application, the circular queue mechanism is used to make the newly generated production data overwrite the old production data, which can further ensure the timeliness of the transmitted data.
[0053] In some embodiments of the present application, if the above step S320 points to different cache units, start the current round of data transmission, and determine the target production data to be transmitted according to the offset pointer and the head pointer and perform data transmission, which specifically includes:
[0054] Determine whether the offset pointer and the head pointer point to the same cache unit;
[0055] If they point to the same cache unit, use the production data cached in the same cache unit as the target production data;
[0056] If they point to different cache units, use the production data cached in the cache unit pointed to by the offset pointer as the target production data.
[0057] As described above, during each round of data transmission, the offset updates of the offset pointer and the head pointer are controlled by different update strategies. Therefore, in some scenarios, for example, when there is production data with a transmission failure during the current round of data transmission, the offset pointer and the head pointer may point to different cache units. At this time, in the embodiments of the present application, the production data corresponding to the offset pointer is used as the production data to be transmitted for data transmission. In another scenario, for example, when each transmitted production data during the current round of data transmission is successfully transmitted, the offset pointer and the head pointer point to the same cache unit. At this time, in the embodiments of the present application, the production data in the cache unit jointly pointed to by the two pointers is used as the production data to be transmitted.
[0058] In some embodiments of the present application, before the above step S330 updates the offset of the offset pointer and the offset of the head pointer according to different update strategies, Figure 3 the method shown further includes:
[0059] determining whether the offset pointer and the tail pointer point to the same cache unit;
[0060] If they point to the same cache unit, the offset of the head pointer is not updated, but the offset of the offset pointer is updated so that the updated offset pointer and the head pointer point to the same cache unit;
[0061] If they point to different cache units, the offset of the offset pointer and the offset of the head pointer are updated according to different update strategies.
[0062] Through the embodiments of the present application, it can be determined whether the current round of data transmission has been completed. When the offset pointer and the tail pointer point to the same cache unit, it means that there is no untransmitted production data in the circular queue. At this time, the offset pointer and the head pointer should point to the same cache unit so that in the next round of data transmission, the production data corresponding to the head pointer is sent as the first data to avoid data omission. When the offset pointer and the tail pointer point to different cache units, it means that there is still untransmitted production data in the circular queue. At this time, the offsets of the offset pointer and the head pointer should be updated according to the corresponding update strategies.
[0063] In some embodiments of the present application, the above step S330 updates the offset of the offset pointer and the offset of the head pointer according to different update strategies, specifically including:
[0064] determining whether the target production data has completed data transmission. When the data transmission is completed, the offset of the offset pointer is updated so that the updated offset pointer points to the next cache unit;
[0065] Obtain the data reception result of the target production data, and update the offset of the head pointer according to the data reception result and whether the head pointer points to the cache unit of the target production data.
[0066] During the current round of data transmission, the first thread can call the data synchronization sending interface maintained by the production server to send each cached target production data in a synchronous manner, and perceive whether each target production data has been sent successfully according to the status code feedback by this interface, so as to update the offset of the offset pointer when the data sending is completed. In addition, the first thread can also determine whether the peer has received the target production data according to the request response feedback by the peer, and update the offset of the head pointer according to whether the peer has received the target production data and whether the head pointer points to the cache unit of the target production data.
[0067] It should be noted that in the embodiment of the present application, it is the production server itself (or the first thread of the production server) that perceives the sending situation of the production data, which has nothing to do with whether the peer has received the production data; while the data reception result is related to the peer, and it is determined whether the target production data has been successfully received by the peer by whether the peer feedbacks a request response within the set time.
[0068] In addition, it should also be noted that in some application scenarios, if it is necessary to perform a deletion process on the target production data before updating the offset pointer (the implementation process will be described in detail in the subsequent embodiments), then in the embodiment of the present application when updating the offsets of the offset pointer and the head pointer, the offset of the offset pointer should be updated first, and then the offset of the head pointer should be updated. If in some other application scenarios, it is not necessary to perform the deletion process on the target production data before updating the offset pointer, then the embodiment of the present application does not limit the update order of the offset pointer and the head pointer with respect to their offsets.
[0069] In some embodiments of the present application, the data reception result includes reception success and reception failure. Then, the above-mentioned update process of the offset of the head pointer according to the data reception result and whether the head pointer points to the cache unit of the target production data specifically includes:
[0070] When the data reception result of the target production data is reception success, if the head pointer points to the cache unit of the target production data, update the offset of the head pointer so that the updated head pointer points to the next cache unit; if the head pointer does not point to the cache unit of the target production data, do not update the offset of the head pointer;
[0071] When the data reception result of the target production data is reception failure, do not update the offset of the head pointer.
[0072] Taking Figure 4 the scenario shown as an example, the head pointer points to buffer unit [1], the offset pointer points to buffer unit [3], and the production data "-3" cached in buffer unit [3] is the current target production data. Assuming that the target production data has been successfully received by the peer end, since the head pointer does not point to buffer unit [3], the offset of the head pointer is not updated, and the head pointer still points to buffer unit [1]. And when completing this round of data transmission, if the tail pointer does not catch up with the head pointer, the head pointer will always remain pointing to buffer unit [1] unchanged.
[0073] In some application scenarios, such as Figure 4 the scenario shown, when the offset pointer and the head pointer point to different buffer units, if the current target production data is successfully transmitted, that is, the production data "-3" cached in buffer unit [3] is received by the peer end, in order to avoid repeating the transmission of the production data "-3" in buffer unit [3] in the next round of data transmission and affecting the business of the peer end, the production data "-3" in buffer unit [3] should be deleted from the circular queue.
[0074] Specifically, in some embodiments of the present application, it is determined whether the target production data has completed data sending before. When the data sending is completed, the offset of the offset pointer is updated so that the updated offset pointer points to the next buffer unit, which specifically includes:
[0075] When the data sending is completed, the target production data is deleted according to the head pointer before update and the data reception result of the target production data;
[0076] After completing the deletion process, the offset of the offset pointer is updated so that the updated offset pointer points to the next buffer unit.
[0077] Embodiments of the present application jointly determine whether to delete the target production data according to the head pointer before update and the data reception result of the target production data. Specifically:
[0078] Determine whether the head pointer before update points to the buffer unit of the target production data, and determine whether the data reception result of the target production data is successful reception;
[0079] If the head pointer before update does not point to the buffer unit of the target production data and the data reception result of the target production data is successful reception, then the target production data is deleted from the circular queue;
[0080] If the head pointer before update does not point to the buffer unit of the target production data and the data reception result of the target production data is failed reception, then the target production data is retained;
[0081] If the head pointer before the update points to the cache unit of the target production data, and the data reception result of the target production data is reception failure, then the target production data is retained;
[0082] If the head pointer before the update points to the cache unit of the target production data, and the data reception result of the target production data is reception success, then the target production data is deleted from the circular queue or the target production data is retained.
[0083] Taking Figure 5 the scenario shown as an example, assume that when the current round of data transmission is started, the head pointer and the offset pointer both point to the cache unit [1]. At this time, the production data "11" in the cache unit [1] is used as the target production data for transmission. Assume that the peer successfully receives the production data "11", then the offset of the offset pointer and the head pointer is updated according to the update strategy described above. Then, the updated offset pointer and the head pointer both point to the cache unit [2]. At this time, the production data "11" can be deleted, or the production data "11" can be not deleted. When the production data is not deleted, when the tail pointer points to the cache unit [1], the cached old production data can be overwritten by the new production data.
[0084] Next, the production data "5" in the cache unit [2] is used as the target production data for transmission. Assume that the peer does not receive the production data "5". Then, after the offset of the offset pointer and the head pointer is updated according to the update strategy described above, the updated offset pointer points to the cache unit [3], and the head pointer still points to the cache unit [2]. At this time, the production data "5" should be retained to retransmit the production data "5" in the next round of data transmission.
[0085] Then, the production data "-3" in the cache unit [3] is used as the target production data for transmission. At this time, the data can be processed according to one of the following two situations:
[0086] Assume that the peer does not receive the production data "-3", then the production data "-3" should be retained to retransmit the production data "-3" in the next round of data transmission, and the offset pointer is updated to point to the cache unit [4], and so on until the offset pointer points to the cache unit
[10] .
[0087] Assume that the peer receives the production data "-3", then the production data "-3" should be deleted to avoid affecting the peer service by repeatedly transmitting the production data "-3" in the next round of data transmission; and the offset pointer is updated to point to the cache unit [4], and so on until the offset pointer points to the cache unit
[10] .
[0088] In some embodiments of the present application, the production server caches the production data into the circular queue through the following steps:
[0089] Monitor whether the production server generates new production data;
[0090] If new production data is generated, write the new production data into the cache unit pointed to by the tail pointer. After the data is written, update the offset of the tail pointer so that the updated tail pointer points to the next cache unit.
[0091] In practical applications, the production server can create a second thread and write the production data into the circular queue through this second thread.
[0092] In some possible implementation solutions of this embodiment, when updating the offset of the tail pointer after the data is written, the method further includes:
[0093] Determine whether the updated tail pointer and the head pointer point to the same cache unit;
[0094] If they point to the same cache unit, update the offset of the head pointer so that the updated head pointer points to the next cache unit.
[0095] In this implementation solution, when writing production data into the circular queue, it is necessary to update the tail pointer. For the updated tail pointer, it is also necessary to determine whether it has caught up with the head pointer. If it has caught up with the head pointer, it means that the circular queue is full. To ensure the mechanism of the circular queue being connected head to tail, the head pointer should be updated simultaneously so that the head pointer points to the next cache unit.
[0096] In some other possible implementation solutions of this embodiment, the step of if new production data is generated, write the new production data into the cache unit pointed to by the tail pointer includes:
[0097] Determine whether the cache unit pointed to by the tail pointer has already cached production data;
[0098] If it has already cached production data, make the new production data overwrite the cached production data.
[0099] The embodiment of the present application also provides a data transmission device, which is applied to a production server. The production server creates a circular queue and an offset pointer. The circular queue includes a head pointer, a tail pointer, and multiple cache units, and caches the production data generated by the production server through the cache units.
[0100] Such as Figure 6As shown in the figure, a schematic structural diagram of a data transmission device in an embodiment of the present application is provided. The device 600 includes a start determination unit 610, a data transmission unit 620, and a pointer update unit 630;
[0101] The start determination unit 610 is configured to determine whether to start the current round of data transmission according to whether the head pointer and the tail pointer point to the same cache unit;
[0102] The data transmission unit 620 is configured to, if they point to different cache units, start the current round of data transmission, determine the target production data to be transmitted according to the offset pointer and the head pointer, and perform data transmission;
[0103] The pointer update unit 630 is configured to, when the transmission of the target production data is completed, update the offset of the offset pointer and the offset of the head pointer according to different update strategies, so that when there is production data with transmission failure during the current round of data transmission, other cached production data is preferentially transmitted, and the production data with transmission failure is retransmitted later.
[0104] In some embodiments of the present application, the data transmission unit 620 is specifically configured to determine whether the offset pointer and the head pointer point to the same cache unit; if they point to the same cache unit, the production data cached in the same cache unit is used as the target production data; if they point to different cache units, the production data cached in the cache unit pointed to by the offset pointer is used as the target production data.
[0105] In some embodiments of the present application, the pointer update unit 630 is further configured to determine whether the offset pointer and the tail pointer point to the same cache unit; if they point to the same cache unit, the offset of the head pointer is not updated, but the offset of the offset pointer is updated so that the updated offset pointer points to the same cache unit as the head pointer; if they point to different cache units, the offset of the offset pointer and the offset of the head pointer are updated according to different update strategies.
[0106] In some embodiments of the present application, the pointer update unit 630 includes a first update module and a second update module;
[0107] The first update module is configured to determine whether the target production data has completed data sending, and when the data sending is completed, update the offset of the offset pointer so that the updated offset pointer points to the next cache unit;
[0108] The second update module is configured to obtain the data reception result of the target production data, and update the offset of the head pointer according to the data reception result and whether the head pointer points to the cache unit of the target production data.
[0109] In some embodiments of the present application, the data reception result includes reception success and reception failure. The second update module is specifically configured to, when the data reception result of the target production data is reception success, if the head pointer points to the cache unit of the target production data, update the offset of the head pointer so that the updated head pointer points to the next cache unit; if the head pointer does not point to the cache unit of the target production data, do not update the offset of the head pointer; when the data reception result of the target production data is reception failure, do not update the offset of the head pointer.
[0110] In some embodiments of the present application, the first update module is specifically configured to, when the data transmission is completed, perform deletion processing on the target production data according to the head pointer before update and the data reception result of the target production data; after the deletion processing is completed, update the offset of the offset pointer so that the updated offset pointer points to the next cache unit.
[0111] In some embodiments of the present application, the first update module is specifically configured to determine whether the head pointer before update points to the cache unit of the target production data, and determine whether the data reception result of the target production data is reception success; if the head pointer before update does not point to the cache unit of the target production data and the data reception result of the target production data is reception success, delete the target production data from the circular queue; if the head pointer before update does not point to the cache unit of the target production data and the data reception result of the target production data is reception failure, retain the target production data; if the head pointer before update points to the cache unit of the target production data and the data reception result of the target production data is reception failure, retain the target production data; if the head pointer before update points to the cache unit of the target production data and the data reception result of the target production data is reception success, delete the target production data from the circular queue or retain the target production data.
[0112] In some embodiments of the present application, the data transmission device further includes a data writing unit;
[0113] The data writing unit is configured to monitor whether the production server generates new production data; if new production data is generated, write the new production data into the cache unit pointed to by the tail pointer, and update the offset of the tail pointer after the data is written so that the updated tail pointer points to the next cache unit.
[0114] In some embodiments of the present application, the data writing unit is specifically configured to determine whether the updated tail pointer and the head pointer point to the same cache unit when updating the offset of the tail pointer after data writing; if they point to the same cache unit, update the offset of the head pointer so that the updated head pointer points to the next cache unit.
[0115] It can be understood that the above data transmission device can implement each step of the data transmission method provided in the foregoing embodiments. The relevant explanations regarding the data transmission method are applicable to the data transmission device and will not be elaborated here.
[0116] Figure 7 It is a schematic structural diagram of an electronic device shown in an embodiment of the present application. Please refer to Figure 7 , at the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. Among them, the memory may include a memory, such as a high-speed random access memory (Random-Access Memory, RAM), and may also include a non-volatile memory, such as at least one disk memory, etc. Of course, the cross-border payment system may also include other hardware required for other services.
[0117] The processor, network interface, and memory can be interconnected through an internal bus, and the internal bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of representation, Figure 7 only a bidirectional arrow is used in [the figure], but it does not mean that there is only one bus or one type of bus.
[0118] The memory is used to store programs. Specifically, the program may include program code, and the program code includes computer operation instructions. The memory may include a memory and a non-volatile memory, and provide instructions and data to the processor.
[0119] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a data transmission device at the logical level. The processor executes the program stored in the memory, executes the data transmission method, and specifically executes the following steps:
[0120] Determine whether to start the current round of data transmission according to whether the head pointer and the tail pointer point to the same cache unit;
[0121] If they point to different cache units, start the current round of data transmission, determine the target production data to be transmitted according to the offset pointer and the head pointer, and perform data transmission;
[0122] When the transmission of the target production data is completed, update the offsets of the offset pointer and the head pointer according to different update strategies, so that when there is production data with transmission failure during the current round of data transmission, other cached production data is preferentially transmitted, and the production data with transmission failure is retransmitted later.
[0123] The method executed by the data transmission device disclosed in the above embodiments of the present application Figure 3 can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor or by instructions in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed and completed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and combines its hardware to complete the steps of the above data transmission method.
[0124] The electronic device can also execute Figure 3 the method executed by the data transmission device in Figure 3 and implement the functions of the data transmission device in the embodiments shown. The embodiments of the present application will not be elaborated here.
[0125] The embodiments of the present application also propose a computer-readable storage medium, which stores one or more programs. The one or more programs include instructions that, when executed by an electronic device including multiple application programs, can enable the electronic device to execute Figure 3 the method executed by the data transmission device in the illustrated embodiment, and specifically execute the following steps:
[0126] Determine whether to start the current round of data transmission according to whether the head pointer and the tail pointer point to the same cache unit;
[0127] If they point to different cache units, start the current round of data transmission, determine the target production data to be transmitted according to the offset pointer and the head pointer, and perform data transmission;
[0128] When the transmission of the target production data is completed, update the offsets of the offset pointer and the head pointer according to different update policies, so that when there is production data with transmission failure during the current round of data transmission, other cached production data is preferentially transmitted, and the production data with transmission failure is retransmitted later.
[0129] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.
[0130] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0131] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction device that implements the functions specified in one or more of the processes Figure 1 or boxes Figure 1 specified in one or more of the processes and / or boxes
[0132] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operational steps are performed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more of the processes Figure 1 or boxes Figure 1 specified in one or more of the processes and / or boxes
[0133] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0134] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0135] Computer-readable media includes both permanent and non-permanent, removable and non-removable media implemented by any method or technology for storing information. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0136] It should also be noted that the term "comprise", "include" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements not only includes those elements but also other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the phrase "comprising an..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising said element.
[0137] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0138] The above are only the embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A data transmission method, which is executed by a production server, wherein, The production server creates a circular queue and an offset pointer. The circular queue includes a head pointer, a tail pointer, and multiple cache units. The production data generated by the production server is cached through the cache units. The data transmission method includes: Determine whether to start the current round of data transmission based on whether the head pointer and the tail pointer point to the same cache unit; If they point to different cache units, start the current round of data transmission, determine the target production data to be transmitted according to the offset pointer and the head pointer, and perform data transmission; When the transmission of the target production data is completed, update the offset of the offset pointer and the offset of the head pointer according to different update strategies, so that when there is production data with transmission failure during the current round of data transmission, other cached production data is preferentially transmitted, and the production data with transmission failure is retransmitted later.
2. The data transmission method according to claim 1, wherein, The step of if they point to different cache units, start the current round of data transmission, determine the target production data to be transmitted according to the offset pointer and the head pointer, and perform data transmission, includes: Determine whether the offset pointer and the head pointer point to the same cache unit; If they point to the same cache unit, use the production data cached in the same cache unit as the target production data; If they point to different cache units, use the production data cached in the cache unit pointed to by the offset pointer as the target production data.
3. The data transmission method according to claim 1, wherein, Before updating the offset of the offset pointer and the offset of the head pointer according to different update strategies, the method further includes: Determine whether the offset pointer and the tail pointer point to the same cache unit; If they point to the same cache unit, do not update the offset of the head pointer, but update the offset of the offset pointer so that the updated offset pointer points to the same cache unit as the head pointer; If they point to different cache units, update the offset of the offset pointer and the offset of the head pointer according to different update strategies.
4. The data transmission method according to claim 1, wherein, The step of updating the offset of the offset pointer and the offset of the head pointer according to different update strategies includes: Determine whether the target production data has completed data sending. When the data sending is completed, update the offset of the offset pointer so that the updated offset pointer points to the next cache unit; Obtain the data reception result of the target production data, and update the offset of the head pointer according to the data reception result and whether the head pointer points to the cache unit of the target production data.
5. The data transmission method according to claim 4, wherein, The data reception result includes reception success and reception failure. The step of updating the offset of the head pointer according to the data reception result and whether the head pointer points to the cache unit of the target production data includes: When the data reception result of the target production data is reception success, if the head pointer points to the cache unit of the target production data, update the offset of the head pointer so that the updated head pointer points to the next cache unit; if the head pointer does not point to the cache unit of the target production data, do not update the offset of the head pointer; When the data reception result of the target production data is reception failure, the offset of the head pointer is not updated.
6. The data transmission method according to claim 5, wherein, Determining whether the target production data has completed data transmission, and when the data transmission is completed, updating the offset of the offset pointer so that the updated offset pointer points to the next cache unit, includes: When the data transmission is completed, deleting the target production data according to the head pointer before update and the data reception result of the target production data; After completing the deletion process, updating the offset of the offset pointer so that the updated offset pointer points to the next cache unit.
7. The data transmission method according to claim 6, wherein, The deleting the target production data according to the head pointer before update and the data reception result of the target production data includes: Determining whether the head pointer before update points to the cache unit of the target production data, and determining whether the data reception result of the target production data is reception success; If the head pointer before update does not point to the cache unit of the target production data and the data reception result of the target production data is reception success, then deleting the target production data from the circular queue; If the head pointer before update does not point to the cache unit of the target production data and the data reception result of the target production data is reception failure, then retaining the target production data; If the head pointer before update points to the cache unit of the target production data and the data reception result of the target production data is reception failure, then retaining the target production data; If the head pointer before update points to the cache unit of the target production data and the data reception result of the target production data is reception success, then deleting the target production data from the circular queue or retaining the target production data.
8. The data transmission method according to claim 1, wherein Caching the production data into the circular queue through the following steps: Monitoring whether the production server generates new production data; If new production data is generated, writing the new production data into the cache unit pointed to by the tail pointer, and after the data is written, updating the offset of the tail pointer so that the updated tail pointer points to the next cache unit.
9. The data transmission method according to claim 8, wherein, When updating the offset of the tail pointer after the data is written, the method further includes: Determining whether the updated tail pointer and the head pointer point to the same cache unit; If they point to the same cache unit, updating the offset of the head pointer so that the updated head pointer points to the next cache unit. If they point to different cache units, the offset of the head pointer is not updated.
10. A data transmission device, which is applied to a production server, wherein, The production server creates a circular queue and an offset pointer. The circular queue includes a head pointer, a tail pointer, and multiple cache units. The production data generated by the production server is cached through the cache units. The data transmission device includes: A start judgment unit, configured to determine whether to start the current round of data transmission according to whether the head pointer and the tail pointer point to the same cache unit; A data transmission unit, configured to start the current round of data transmission if they point to different cache units, determine the target production data to be transmitted according to the offset pointer and the head pointer, and perform data transmission; A pointer update unit, configured to, when the transmission of target production data is completed, update the offsets of the offset pointer and the head-of-queue pointer according to different update policies, so as to preferentially transmit other cached production data in case there is production data with transmission failure during the current round of data transmission, and delay the retransmission of the production data with transmission failure.