Data transmission method and device, electronic equipment and storage medium

By using message queues and hash functions to record and compare the number of file records during data transmission, the problem of data loss during data transmission is solved, timely discovery and re-uploading of data is realized, and the accuracy of data transmission is improved.

CN118802897AActive Publication Date: 2024-10-18ZUNYI BRANCH OF CHINA MOBILE GRP GUIZHOU COMPANY +1
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410715434.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-10-18
Estimated Expiration
2044-06-04

AI Technical Summary

Technical Problem

Data loss is prone to occur during the data transmission process, and due to the failure to detect the data loss in time, it cannot be retransmitted in time, resulting in the problem that the lost data cannot be retrieved.

Method used

Obtain the name of the target transfer file and the number of file records through the configuration parameters based on the message queue, write it into the record file, use the hash function to store the key-value pairs, and compare the key-value pairs in the record file with the key-value pairs in the hash function. , determine whether there is an abnormality in data transmission, and retransmit the data if an abnormality is found.

Benefits of technology

It realizes the timely detection of lost data during data transmission and re-uploads it, which improves the accuracy of data transmission and solves the problem of data loss during data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118802897A_ABST
    Figure CN118802897A_ABST
Patent Text Reader

Abstract

The invention discloses a data transmission method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a first name and a first file record number of a target transmission file based on a configuration parameter of a message queue, and writing the first name as a key and the first file record number as a value into a first record file; obtaining a second name and a second file record number of the target transmission file from the target partition, and writing the second name and the second file record number into a second record file; reading a second record file, and storing the second record file in the hash function by taking a second name as a key and a second file record number as a value; and reading the first record file, comparing the value of the key value pair in the first record file with the value of the key value pair in the hash function, and determining whether data transmission is abnormal or not according to a comparison result. The method is simple in logic, easy to implement, low in dependence on the network and the terminal, high in detection efficiency and capable of improving the data transmission accuracy and solving the problem that data loss is prone to occurring in the data transmission process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data transmission, and in particular to a data transmission auditing method and device, an electronic device and a storage medium. Background Art

[0002] With the development of computer technology, more and more enterprises use message queue (MQ) as the core mode of data transmission within enterprise IT systems. It has a series of functions such as low coupling, reliable delivery, broadcasting, flow control, and eventual consistency. Currently, the most commonly used message queues include RabbitMQ, RocketMQ, ActiveMQ, Kafka, ZeroMQ, MetaMQ, etc.

[0003] In the data transmission technology of related technologies, during the data transmission process, the accuracy of data transmission and whether the data transmission is successful are usually determined by the message fed back by the receiver. Take Kafka data transmission as an example: when Kafka transmits data, when the data is transmitted to the leader node and synchronized to all replicas, the producer will receive a successful response from the Kafka server. When the producer sends data to the server, if a temporary error occurs and the data cannot be delivered, the producer will resend it to ensure the integrity of the data.

[0004] Although the relevant message queue technology provides a relatively reliable guarantee for data loss, data loss may occur in some special scenarios. For example, taking Kafka as an example for data transmission, data loss is likely to occur when the following situations occur:

[0005] 1. Component process problem: Data loss occurs in the upstream or downstream segment of Kafka.

[0006] 2. Network problem: The Kafka rate exceeds the network bandwidth. Once a sending failure occurs and there is no retry mechanism, data will be lost and cannot be retrieved.

[0007] 3. Data size problem: A single batch of data that is too long will cause data loss. The data size produced by the producer is larger than the maximum message size configured by the consumer to pull, which far exceeds the consumer's pulling capacity. This large data will fail to be consumed, and in serious cases, Kafka may get stuck, resulting in data loss.

[0008] 4. Hard disk problem: The Kafka message queue is stored in the form of log files. When the host disk fails and the data cannot be recovered, data loss may occur.

[0009] In the above scenario, not only is data loss likely to occur, but the lost data may also be unable to be recovered due to failure to promptly detect the data loss and retransmit the lost data. Summary of the invention

[0010] The present disclosure provides a data transmission audit method, device, electronic device and storage medium. Its main purpose is to solve the problem that data loss is easy to occur during data transmission, and the lost data cannot be recovered due to failure to timely discover the data loss and timely retransmit the lost data.

[0011] According to a first aspect of the present disclosure, a data transmission method is provided, comprising:

[0012] Based on the configuration parameters of the message queue, a first name and a first file record number of the target transmission file are obtained, and the first name is used as a key and the first file record number is used as a value to write into the first record file, wherein the configuration parameters also include a target partition of the target transmission file, the message queue is used to store the target transmission file in the target partition, and the first file record number is used to record the number of the target transmission file sent;

[0013] Acquire a second name and a second file record number of the target transmission file from the target partition, and write the second name and the second file record number into a second record file, where the second file record number is used to record the number of received target transmission files;

[0014] Read the second record file, use the second name as a key, use the second file record number as a value, and store it in a hash function, where the hash function is stored in a key-value pair format;

[0015] The first record file is read, the value of the key-value pair in the first record file is compared with the value of the key-value pair in the hash function, and whether there is an abnormality in data transmission is determined according to the comparison result.

[0016] Optionally, before obtaining the first name and the first file record number of the target transmission file based on the configuration parameters of the message queue, the method further includes:

[0017] The file to be transferred is transferred from the input directory to the temporary directory in a scramble mode and added to the message queue;

[0018] Read the file name and file content of the file to be transmitted from the message queue, and determine the size, path, temporary directory and backup directory of the file to be transmitted as file information;

[0019] The file to be transmitted is encapsulated and packaged by taking the file name corresponding to the file to be transmitted as the key and concatenating the file content and file information corresponding to the file to be transmitted as the value to obtain the target transmission file.

[0020] Optionally, after obtaining the target transmission file, the method further includes:

[0021] Based on the target partition in the configuration parameters, the target transfer file is sent to the target partition, and a target number of target transfer files sent to the target partition is determined.

[0022] Optionally, the input-end configuration parameter based on the message queue obtains the first name and the first file record number of the target transmission file, and writes the first name as a key and the first file record number as a value into the first record file, including:

[0023] Determine the target number as the first file record number of the target transmission file;

[0024] Write the first record file using the first name as a key and the number of records in the first file as a value;

[0025] After receiving the recording signal of the first recording file, it is determined that the sending of the target transmission file is completed, and the recording signal is used to determine that the writing of the first name and the number of records of the first file is completed.

[0026] Optionally, the reading the first record file, comparing the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determining whether there is an abnormality in data transmission according to the comparison result includes:

[0027] Traversing the first record file, searching the hash function for the same key as that in the first record file, and determining the same key in the hash function as the target key;

[0028] After determining the target key, determining whether the value of the target key is consistent with the value in the first record file;

[0029] Whether there is an abnormality in data transmission is determined according to a comparison result between the value of the target key and the value in the first record file.

[0030] Optionally, determining whether data transmission is abnormal according to the comparison result includes:

[0031] If it is determined that the key in the first record file does not exist in the hash function, the key in the first record file is determined as an abnormal key, and the number of second file records corresponding to the abnormal key is determined to be 0;

[0032] If it is determined that the value of the target key is consistent with the value in the first record file, then it is determined that the data transmission is normal;

[0033] If it is determined that the value of the target key is inconsistent with the value in the first record file, then determining that the data transmission is abnormal;

[0034] Determine the target transmission file corresponding to the abnormal key and the target key with abnormal data transmission as an abnormal file;

[0035] The first name, the first file record number, and the second file record number corresponding to the abnormal file are output.

[0036] Optionally, the method further comprises:

[0037] After the abnormal file is determined, a backup file corresponding to the abnormal file is obtained, and the backup file is retransmitted.

[0038] According to a second aspect of the present disclosure, there is provided a data transmission device, comprising:

[0039] A first writing unit is used to obtain a first name and a first file record number of a target transmission file based on configuration parameters of a message queue, and write the first name as a key and the first file record number as a value into a first record file, wherein the configuration parameters further include a target partition of the target transmission file, the message queue is used to store the target transmission file in the target partition, and the first file record number is used to record the number of sent target transmission files;

[0040] A second writing unit, used for obtaining a second name and a second file record number of the target transmission file from the target partition, and writing the second name and the second file record number into a second record file, wherein the second file record number is used for recording the number of received target transmission files;

[0041] a storage unit, used for reading the second record file, using the second name as a key and the number of records in the second file as a value, and storing the result in a hash function, wherein the hash function is stored in a key-value pair manner;

[0042] The comparison unit is used to read the first record file, compare the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determine whether there is an abnormality in data transmission according to the comparison result.

[0043] Optionally, the device further comprises a packaging unit, wherein the packaging unit comprises:

[0044] An adding module is used to transfer the to-be-transmitted file from the input directory to a temporary directory and add it to the message queue in a scramble mode before obtaining the first name and the first file record number of the target transmission file based on the configuration parameters of the message queue;

[0045] A reading module, used for reading the file name and file content of the file to be transmitted from the message queue, and determining the size, path, temporary directory and backup directory of the file to be transmitted as file information;

[0046] The encapsulation module is used to encapsulate and package the file to be transmitted by taking the file name corresponding to the file to be transmitted as a key and concatenating the file content and file information corresponding to the file to be transmitted as a value to obtain the target transmission file.

[0047] Optionally, the device further includes a sending unit, and the sending unit is configured to:

[0048] After obtaining the target transfer file, the target transfer file is sent to the target partition based on the target partition in the configuration parameters, and a target number of target transfer files sent to the target partition is determined.

[0049] Optionally, the first writing unit includes:

[0050] A first determining module, configured to determine the target number as the first file record number of the target transmission file;

[0051] A writing module, used for writing the first record file using the first name as a key and the number of records in the first file as a value;

[0052] The second determination module is used to determine that the sending of the target transmission file is completed after receiving the recording signal of the first recording file, and the recording signal is used to determine that the writing of the first name and the first file record number is completed.

[0053] Optionally, the comparison unit includes:

[0054] A search module, configured to traverse the first record file, search the hash function for the same key as that in the first record file, and determine the same key in the hash function as a target key;

[0055] A judgment module, configured to judge whether the value of the target key is consistent with the value in the first record file after determining the target key;

[0056] The third determination module is used to determine whether there is an abnormality in data transmission according to a comparison result of the value of the target key and the value in the first record file.

[0057] Optionally, the comparison unit further includes:

[0058] a fourth determination module, configured to determine the key in the first record file as an abnormal key if it is determined that the key in the first record file does not exist in the hash function, and determine the number of second file records corresponding to the abnormal key to be 0;

[0059] a fifth determination module, configured to determine that the data transmission is normal if it is determined that the value of the target key is consistent with the value in the first record file;

[0060] A sixth determination module, configured to determine that data transmission is abnormal if it is determined that the value of the target key is inconsistent with the value in the first record file;

[0061] A seventh determination module, configured to determine the target transmission file corresponding to the abnormal key and the target key with abnormal data transmission as an abnormal file;

[0062] The output module is used to output the first name, the first file record number and the second file record number corresponding to the abnormal file.

[0063] Optionally, the device further comprises a retransmission unit, configured to:

[0064] After the abnormal file is determined, a backup file corresponding to the abnormal file is obtained, and the backup file is retransmitted.

[0065] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0066] at least one processor; and

[0067] a memory communicatively connected to the at least one processor; wherein,

[0068] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.

[0069] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the first aspect.

[0070] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method as described in the first aspect above.

[0071] The data transmission method and device, electronic device and storage medium provided by the present disclosure obtain a first name and a first file record number of a target transmission file based on the configuration parameters of a message queue, and write the first name as a key and the first file record number as a value into a first record file, wherein the configuration parameters also include a target partition of the target transmission file, the message queue is used to store the target transmission file in the target partition, and the first file record number is used to record the number of sent target transmission files; obtain a second name and a second file record number of the target transmission file from the target partition, and write the second name and the second file record number into a second record file, and the second file record number is used to record the number of received target transmission files; read the second record file, and store it in a hash function with the second name as a key and the second file record number as a value, wherein the hash function is stored in a key-value pair format; read the first record file, compare the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determine whether there is an abnormality in data transmission according to the comparison result. The data transmission method provided by the present disclosure records the number of file records before and after data transmission through a first record file and a second record file, and compares the values ​​by comparing the key-value pairs. The logic is simple and easy to implement, with low dependence on the network and the terminal, and high detection efficiency. It can timely discover the lost data in the data transmission process and re-upload it, thereby improving the accuracy of data transmission and solving the problem that data loss is prone to occur during the data transmission process. It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become easy to understand through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0073] Figure 1 A flowchart of a data transmission method provided by an embodiment of the present disclosure;

[0074] Figure 2 A detection schematic diagram of a data transmission method provided by an embodiment of the present disclosure;

[0075] Figure 3 A flowchart of another data transmission method provided by an embodiment of the present disclosure;

[0076] Figure 4 A flowchart of another data transmission method provided by an embodiment of the present disclosure;

[0077] Figure 5 A schematic diagram of the structure of a data transmission device provided in an embodiment of the present disclosure;

[0078] Figure 6 A schematic diagram of the structure of another data transmission device provided by an embodiment of the present disclosure;

[0079] Figure 7 A schematic block diagram of an exemplary electronic device 400 provided for an embodiment of the present disclosure. DETAILED DESCRIPTION

[0080] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0081] The following describes a data transmission method and apparatus, an electronic device, and a storage medium according to embodiments of the present disclosure with reference to the accompanying drawings.

[0082] Figure 1 A flowchart of a data transmission method provided by an embodiment of the present disclosure.

[0083] like Figure 1 As shown, the method comprises the following steps:

[0084] Step 101, based on the configuration parameters of the message queue, obtain the first name and the first file record number of the target transfer file, and write the first name as the key and the first file record number as the value into the first record file, wherein the configuration parameters also include the target partition of the target transfer file, the message queue is used to store the target transfer file in the target partition, and the first file record number is used to record the number of the target transfer file sent.

[0085] In the embodiment of the present application, the message queue is a middleware with a queue structure. After the data is put into this middleware, it can be returned directly without the need for the system to process it immediately. Another program will read the data and process them one by one in sequence. The message queue mainly solves problems such as application coupling, asynchronous processing, and traffic clipping. Currently, the more commonly used message queues include RabbitMQ, RocketMQ, ActiveMQ, Kafka, ZeroMQ, MetaMq, etc., and some databases such as Redis, Mysql, and phxsql can also realize the function of message queues.

[0086] In order to detect whether the data transmission is normal, the first name is used as the key and the first file record number is used as the value to write into the first record file, so as to serve as a comparison basis for detection and determine whether the data transmission is successful. The configuration parameters of the message queue include the first name of the target transmission file, the first file record number and the target partition. The first name and the first file record number are used to check the data transmission. The first file record number includes the number of parsing exceptions, the number of successful transmissions, the number of failed transmissions and the number of transmissions to the target partition of the target transmission file. The first record file is a file with the suffix .stat, which is used to record the first name and the first file record number in the form of a key-value pair as a detection basis for data transmission, and the first record file is also used to record other information of the target transmission file, such as the size, storage path, storage time, etc. of the target transmission file.

[0087] In order to better understand the first record file, an embodiment of the present application provides an example of the file content of the first record file, for example:

[0088] The first record file named in_stat_20221020 contains:

[0089] Fi leName:gprs_ol_30200_B_D08_452718909.txt;FileSize:2562235;Earlist:20221023;latest:20221023;ExtALines:0;Total Lines:1512;SendLines:1512;NonTimeoutExceptionLines:0;TimeoutExceptionLines:0;StartTime:20221023112804;EndTim e:20221023112805;Speed:2119;TopicList:{CloudXdrTopicA0.1:1512;};BillDateList:{20221023:1512;};TargetLines:0

[0090] From the first record file in the above example, information related to the target transfer file can be obtained, for example, FileName:gprs_ol_30200_B_D08_452718909.txt is the first name of the target transfer file, FileSize:2562235 is the size of the target transfer file, TotalLines:1512 is the total number of the target transfer files, SendLines:1512 is the number of the target transfer files sent to the target partition, etc.

[0091] Step 102: Obtain a second name and a second file record number of the target transmission file from the target partition, and write the second name and the second file record number into a second record file, where the second file record number is used to record the number of received target transmission files.

[0092] In order to check whether data loss occurs during data transmission, after obtaining the target transmission file, the second name and the second file record number of the target transmission file are written into the second record file. The second file record number is used to record the number of target transmission files received. The second record file is used to record the second name, the second file record number and related information of the received target transmission file, so as to facilitate comparison with the first record file and find the target transmission file where data loss occurs.

[0093] Step 103, read the second record file, use the second name as a key, use the second file record number as a value, and store it in a hash function, where the hash function is stored in a key-value pair format.

[0094] In order to improve the search efficiency, the present invention adopts the hash comparison method in the Perl language, which is a feature-rich computer program language that runs on more than 100 computer platforms and is widely applicable. It was originally developed for text processing and is now used for various tasks, including system management, Web development, network programming, GUI development, etc. In the Perl programming language, a hash data structure can be used to store key-value pairs. A hash function is a mapping relationship that calculates the function of the element storage position according to the keyword key of the data through a certain functional relationship. Hash is to temporarily store data in a memory in a key-value pair manner, and directly find the previously written hash key-value pair (the key-value pair in the first record file in this application) in the hash through a key (the key can be a numerical value or a character, similar to an index), and compare the previously written value and the current value by searching through the key, which can efficiently realize the comparison of two sets of numerical values ​​and improve the search efficiency.

[0095] Step 104 , reading the first record file, comparing the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determining whether there is an abnormality in data transmission according to the comparison result.

[0096] In an embodiment of the present application, after storing the second record file in a hash function, the first record file is read, the first record file is traversed one by one, and the same key as that in the first record file is searched in the hash function. If it is determined that the key in the first record file does not exist in the hash function, the key in the first record file is determined as an abnormal key, and the number of second file records corresponding to the abnormal key is determined to be 0. If it is determined that the key in the first record file exists in the hash function, the same key in the hash function is determined as the target key; after determining the target key, it is determined whether the value of the target key is consistent with the numerical value of the value in the first record file; if it is determined that the value of the target key is consistent with the numerical value of the value in the first record file, it is determined that the data transmission is normal; if it is determined that the value of the target key is inconsistent with the numerical value of the value in the first record file, it is determined that the data transmission is abnormal; the target transmission file corresponding to the abnormal key and the target key of the data transmission abnormality is determined as an abnormal file; and the first name, the number of first file records and the number of second file records corresponding to the abnormal file are output.

[0097] In order to better understand the first record file and the second record file by comparison, the embodiment of the present application also provides a detection schematic diagram of a data transmission method, such as Figure 2 As shown, first read the first record file and the second record file respectively, then find the same key in the two record files, after determining the same key, compare the value corresponding to the key, if the value is consistent, then end the data transmission, if not consistent, then output the relevant information of the abnormal file, the relevant information includes the first name of the abnormal file, the number of first file records and the number of second file records, so as to determine the data lost in the abnormal file during the transmission process, after outputting the relevant information of the abnormal file, end the data transmission.

[0098] By generating a first record file to record the first file record number and other related information of the target transmission file before data transmission, and generating a second record file to record the second transmission information of the target transmission file after data transmission, data transmission is detected only by comparing the first record file and the second record file, without detecting the data transmission process. The logic is simple and easy to implement, and efficient detection is achieved through the hash comparison method, so that abnormal files in data transmission can be quickly found.

[0099] The data transmission method provided by the present disclosure obtains a first name and a first file record number of a target transmission file based on configuration parameters of a message queue, and writes the first name as a key and the first file record number as a value into a first record file, wherein the configuration parameters also include a target partition of the target transmission file, the message queue is used to store the target transmission file in the target partition, and the first file record number is used to record the number of sent target transmission files; obtains a second name and a second file record number of the target transmission file from the target partition, and writes the second name and the second file record number into a second record file, and the second file record number is used to record the number of received target transmission files; reads the second record file, uses the second name as a key and the second file record number as a value, and stores it in a hash function, wherein the hash function is stored in a key-value pair format; reads the first record file, compares the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determines whether there is an abnormality in data transmission according to the comparison result. Compared with other related technologies that determine the accuracy of data transmission and whether the data transmission is successful through messages fed back by the receiving party during the data transmission process, the data transmission method provided by the present invention records the number of file records before and after data transmission through the first record file and the second record file, and compares the values ​​of key-value pairs. The logic is simple and easy to implement, with low dependence on the network and the terminal, high detection efficiency, and can realize timely discovery of lost data in the data transmission process and re-upload, thereby improving the accuracy of data transmission and solving the problem of data loss that is prone to occur during the data transmission process.

[0100] In the embodiment provided in the present application, the data transmission method further includes a data transmission encapsulation process and a data transmission sending process. In order to better understand the encapsulation process in the data transmission method, Figure 3 A flowchart of another data transmission method provided by an embodiment of the present disclosure.

[0101] like Figure 3 As shown, the method further comprises the following steps:

[0102] Step 201: The file to be transmitted is transferred from the input directory to a temporary directory in a contention mode, and is added to a message queue.

[0103] The contention mode is also called the Work mode. The producer in the message queue sends a message to the switch. The switch sends the message to the message queue according to the attributes of the message. Multiple consumers are bound to monitor a message queue at the same time, forming an effect of competing for messages.

[0104] Step 202: read the file name and file content of the file to be transmitted from the message queue, and determine the size, path, temporary directory and backup directory of the file to be transmitted as file information.

[0105] Encapsulating a file refers to combining related resources such as software, files or data and packaging them into a separate file or archive. This process combines multiple files or resources into a single entity to facilitate distribution, transmission or deployment. In order to facilitate the transmission of the target transmission file and to obtain relevant information about the target transmission file written into the first record file, file information is obtained from the message queue.

[0106] Step 203 , using the file name corresponding to the file to be transmitted as a key and the file content and file information corresponding to the file to be transmitted as a value, encapsulates and packages the file to be transmitted to obtain the target transmission file.

[0107] In order to obtain the target transfer file, the concatenation of the file content and the file information is used as the value, and the file name is used as the key to encapsulate it into a file of the FileInfo class as the target transfer file. The FileInfo class is a class located in the System.IO namespace, which provides a series of properties and methods for manipulating files. Through the FileInfo class, we can easily obtain information about the file, such as file size, creation date, modification date, etc. In addition, the FileInfo class also provides some convenient methods for performing operations such as file copying, moving, and deleting. For example, in the kafka cluster, the producer record component (Producer Record) is used to encapsulate the file to be transferred into a target transfer file such as ProducerRecord (CloudXdrTopicA0.1, filename, text@info).

[0108] By means of the above encapsulation method, in the process of encapsulating the file to be transmitted, the relevant information written into the first record file is simultaneously obtained, and by encapsulating the file to be transmitted, the subsequent transmission of the target transmission file is facilitated.

[0109] In some embodiments, after encapsulating the file to be transferred and obtaining the target transfer file, the encapsulated target transfer file (FileInfo class file in the above embodiment) is sent to different partitions of different topics of the message middleware (kafka cluster in the above embodiment) in a load balancing manner, and the target number of target transfer files sent to the target partition is determined. The load balancing (Load Balance, LB for short) is an essential key component of a high concurrency and high availability system. The goal is to try to evenly distribute network traffic to multiple servers to improve the overall response speed and availability of the system. For example, if there are n partitions and n target transfer files, each target transfer file is sent to a different partition to achieve load balancing.

[0110] In some embodiments, after the target transfer file is sent to the target partition, wait for the record signal sent by the first record file. After receiving the record signal of the first record file, determine that the sending of the target transfer file is completed. Otherwise, wait until the record signal is received before continuing to send the next target transfer file. The record signal is used to determine the successful writing of the first name and the first file record number to avoid omissions.

[0111] In order to better understand the data transmission process, taking the Kafka cluster as an example, the embodiment of the present application also provides another flow chart of data transmission, such as Figure 4 As shown, when the file to be transmitted is input, the packaging and backup of the file to be transmitted are completed, and a first record file is generated at the same time. When the target transmission file is output, a corresponding second transmission file is generated.

[0112] In some embodiments, after the abnormal file is determined by comparing the first record file and the second record file, a backup file corresponding to the abnormal file is obtained, and the backup file is retransmitted to improve the accuracy of data transmission and avoid data loss.

[0113] By encapsulating the files to be transmitted and transmitting a backup of the abnormal files after determining the abnormal files, the accuracy of data transmission is improved and the probability of data loss is reduced.

[0114] In summary, the embodiments of the present disclosure can achieve the following effects:

[0115] 1. Before data transmission, a first record file is generated to record the first file record number and other related information of the target transmission file, and after data transmission, a second record file is generated to record the second transmission information of the target transmission file. Data transmission is detected only by comparing the first record file and the second record file, without detecting the data transmission process. The logic is simple and easy to implement, and efficient detection is achieved through the hash comparison method, so that abnormal files in data transmission can be quickly found.

[0116] 2. By encapsulating the files to be transmitted and transmitting a backup of the abnormal files after determining the abnormal files, the accuracy of data transmission is improved and the probability of data loss is reduced.

[0117] Corresponding to the above data transmission method, the present invention also provides a data transmission device. Since the device embodiment of the present invention corresponds to the above method embodiment, the details not disclosed in the device embodiment can be referred to the above method embodiment, and will not be repeated in the present invention.

[0118] Figure 5 A schematic diagram of a data transmission device provided in an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, it includes: a first writing unit 31, a second writing unit 32, a storage unit 33 and a comparison unit 34.

[0119] A first writing unit 31 is used to obtain a first name and a first file record number of a target transmission file based on configuration parameters of a message queue, and write the first name as a key and the first file record number as a value into a first record file, wherein the configuration parameters further include a target partition of the target transmission file, the message queue is used to store the target transmission file in the target partition, and the first file record number is used to record the number of sent target transmission files;

[0120] A second writing unit 32 is used to obtain a second name and a second file record number of the target transmission file from the target partition, and write the second name and the second file record number into a second record file, where the second file record number is used to record the number of received target transmission files;

[0121] A storage unit 33 is used to read the second record file, use the second name as a key, and the number of records in the second file as a value, and store it in a hash function, wherein the hash function is stored in a key-value pair manner;

[0122] The comparison unit 34 is used to read the first record file, compare the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determine whether there is any abnormality in data transmission according to the comparison result.

[0123] The data transmission method and device provided by the present disclosure obtain a first name and a first file record number of a target transmission file based on configuration parameters of a message queue, and write the first name as a key and the first file record number as a value into a first record file, wherein the configuration parameters also include a target partition of the target transmission file, the message queue is used to store the target transmission file in the target partition, and the first file record number is used to record the number of sent target transmission files; obtain a second name and a second file record number of the target transmission file from the target partition, and write the second name and the second file record number into a second record file, and the second file record number is used to record the number of received target transmission files; read the second record file, and store it in a hash function with the second name as a key and the second file record number as a value, wherein the hash function is stored in a key-value pair format; read the first record file, compare the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determine whether there is an abnormality in data transmission according to the comparison result. Compared with other related technologies that determine the accuracy of data transmission and whether the data transmission is successful through messages fed back by the receiver during the data transmission process, the data transmission method provided by the present disclosure records the number of file records before and after data transmission through the first record file and the second record file, and compares the values ​​of key-value pairs. The logic is simple and easy to implement, with low dependence on the network and the terminal, high detection efficiency, and can timely discover the lost data in the data transmission process and re-upload it, thereby improving the accuracy of data transmission and solving the problem of data loss that is prone to occur during the data transmission process. Furthermore, in a possible implementation of this embodiment, if Figure 6 As shown, the device further includes a packaging unit 35, and the packaging unit includes:

[0124] An adding module 351 is used to transfer the to-be-transmitted file from the input directory to a temporary directory and add it to the message queue in a scramble mode before obtaining the first name and the first file record number of the target transmission file based on the configuration parameters of the message queue;

[0125] The reading module 352 is used to read the file name and file content of the file to be transmitted from the message queue, and determine the size, path, temporary directory and backup directory of the file to be transmitted as file information;

[0126] The encapsulation module 353 is used to encapsulate and package the file to be transmitted by taking the file name corresponding to the file to be transmitted as a key and concatenating the file content and file information corresponding to the file to be transmitted as a value to obtain the target transmission file.

[0127] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, the device further includes a sending unit, and the sending unit 36 ​​is used to:

[0128] After obtaining the target transfer file, the target transfer file is sent to the target partition based on the target partition in the configuration parameters, and a target number of target transfer files sent to the target partition is determined.

[0129] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, the first writing unit 31 includes:

[0130] A first determining module 311, configured to determine the target number as the first file record number of the target transmission file;

[0131] A writing module 312, configured to write the first record file using the first name as a key and the number of records in the first file as a value;

[0132] The second determination module 313 is used to determine that the sending of the target transmission file is completed after receiving the recording signal of the first recording file, wherein the recording signal is used to determine that the writing of the first name and the first file record number is completed.

[0133] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, the comparison unit 34 includes:

[0134] A search module 341 is used to traverse the first record file, search the hash function for the same key as that in the first record file, and determine the same key in the hash function as the target key;

[0135] A judgment module 342 is used to judge whether the value of the target key is consistent with the value in the first record file after determining the target key;

[0136] The third determination module 343 is used to determine whether there is an abnormality in data transmission according to the comparison result of the value of the target key and the value in the first record file.

[0137] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the comparison unit 34 also includes:

[0138] A fourth determination module 344 is configured to determine the key in the first record file as an abnormal key if it is determined that the key in the first record file does not exist in the hash function, and determine the number of second file records corresponding to the abnormal key to be 0;

[0139] A fifth determination module 345, configured to determine that the data transmission is normal if it is determined that the value of the target key is consistent with the value in the first record file;

[0140] A sixth determination module 346, configured to determine that data transmission is abnormal if it is determined that the value of the target key is inconsistent with the value in the first record file;

[0141] A seventh determination module 347, configured to determine the target transmission file corresponding to the abnormal key and the target key with abnormal data transmission as an abnormal file;

[0142] The output module 348 is used to output the first name, the first file record number and the second file record number corresponding to the abnormal file.

[0143] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, the device further includes a retransmission unit 37, which is used to:

[0144] After the abnormal file is determined, a backup file corresponding to the abnormal file is obtained, and the backup file is retransmitted.

[0145] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and the principle is the same, which is not limited in this embodiment.

[0146] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0147] Figure 7 A schematic block diagram of an example electronic device 400 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0148] like Figure 7As shown, the device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 402 or a computer program loaded from a storage unit 408 to a RAM (Random Access Memory) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An I / O (Input / Output) interface 405 is also connected to the bus 404.

[0149] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0150] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Units), various dedicated AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, a DSP (Digital Signal Processor), and any appropriate processor, controller, microcontroller, etc. The computing unit 401 performs the various methods and processes described above, such as a data transmission method. For example, in some embodiments, the data transmission method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via the ROM 402 and / or the communication unit 409. When the computer program is loaded into the RAM 403 and executed by the computing unit 401, one or more steps of the method described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to execute the aforementioned data transmission method in any other appropriate manner (for example, by means of firmware).

[0151] Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application Specific Standard Products), SOCs (System On Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor that may be a dedicated or general-purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0152] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0153] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a RAM, a ROM, an EPROM (Electrically Programmable Read-Only-Memory) or a flash memory, an optical fiber, a CD-ROM (Compact Dis sc Read-Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0154] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0155] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network), WAN (Wide Area Network), the Internet, and blockchain networks.

[0156] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0157] It should be noted that artificial intelligence is a discipline that studies how computers can simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.), and includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.

[0158] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0159] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A data transmission method, characterized in that: include: Based on the configuration parameters of the message queue, a first name and a first file record number of the target transmission file are obtained, and the first name is used as a key and the first file record number is used as a value to write into the first record file, wherein the configuration parameters also include a target partition of the target transmission file, the message queue is used to store the target transmission file in the target partition, and the first file record number is used to record the number of the target transmission file sent; Acquire a second name and a second file record number of the target transmission file from the target partition, and write the second name and the second file record number into a second record file, where the second file record number is used to record the number of received target transmission files; Read the second record file, use the second name as a key, use the second file record number as a value, and store it in a hash function, where the hash function is stored in a key-value pair format; The first record file is read, the value of the key-value pair in the first record file is compared with the value of the key-value pair in the hash function, and whether there is an abnormality in data transmission is determined according to the comparison result.

2. The method according to claim 1, characterized in that Before obtaining the first name and the first file record number of the target transmission file based on the configuration parameters of the message queue, the method further includes: The file to be transferred is transferred from the input directory to the temporary directory in a scramble mode and added to the message queue; Read the file name and file content of the file to be transmitted from the message queue, and determine the size, path, temporary directory and backup directory of the file to be transmitted as file information; The file to be transmitted is encapsulated and packaged by taking the file name corresponding to the file to be transmitted as the key and concatenating the file content and file information corresponding to the file to be transmitted as the value to obtain the target transmission file.

3. The method according to claim 2, characterized in that After obtaining the target transmission file, the method further includes: Based on the target partition in the configuration parameters, the target transfer file is sent to the target partition, and a target number of target transfer files sent to the target partition is determined.

4. The method according to claim 3, characterized in that The input end configuration parameter based on the message queue obtains the first name and the first file record number of the target transmission file, and writes the first name as a key and the first file record number as a value into the first record file, including: Determine the target number as the first file record number of the target transmission file; Write the first record file using the first name as a key and the number of records in the first file as a value; After receiving the recording signal of the first recording file, it is determined that the sending of the target transmission file is completed, and the recording signal is used to determine that the writing of the first name and the number of records of the first file is completed.

5. The method according to claim 1, characterized in that The reading of the first record file, comparing the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determining whether there is an abnormality in data transmission according to the comparison result, includes: Traversing the first record file, searching the hash function for the same key as that in the first record file, and determining the same key in the hash function as the target key; After determining the target key, determining whether the value of the target key is consistent with the value in the first record file; Whether there is an abnormality in data transmission is determined according to a comparison result between the value of the target key and the value in the first record file.

6. The method according to claim 5, characterized in that Determining whether data transmission is abnormal according to the comparison result includes: If it is determined that the key in the first record file does not exist in the hash function, the key in the first record file is determined as an abnormal key, and the number of second file records corresponding to the abnormal key is determined to be 0; If it is determined that the value of the target key is consistent with the value in the first record file, then it is determined that the data transmission is normal; If it is determined that the value of the target key is inconsistent with the value in the first record file, then determining that the data transmission is abnormal; Determine the target transmission file corresponding to the abnormal key and the target key with abnormal data transmission as an abnormal file; The first name, the first file record number, and the second file record number corresponding to the abnormal file are output.

7. The method according to claim 6, characterized in that The method further comprises: After the abnormal file is determined, a backup file corresponding to the abnormal file is obtained, and the backup file is retransmitted.

8. A data transmission method, characterized in that: include: A first writing unit is used to obtain a first name and a first file record number of a target transmission file based on configuration parameters of a message queue, and write the first name as a key and the first file record number as a value into a first record file, wherein the configuration parameters further include a target partition of the target transmission file, the message queue is used to store the target transmission file in the target partition, and the first file record number is used to record the number of sent target transmission files; A second writing unit, used for obtaining a second name and a second file record number of the target transmission file from the target partition, and writing the second name and the second file record number into a second record file, wherein the second file record number is used for recording the number of received target transmission files; a storage unit, used for reading the second record file, using the second name as a key and the number of records in the second file as a value, and storing the result in a hash function, wherein the hash function is stored in a key-value pair manner; The comparison unit is used to read the first record file, compare the value of the key-value pair in the first record file with the value of the key-value pair in the hash function, and determine whether there is an abnormality in data transmission according to the comparison result.

9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Data consistency checking method, apparatus and device and storage medium

    CN108573016A

  • A file management method for message queue

    CN110109873A

  • File transmission method, device and system, electronic device and storage medium

    CN111245748A

  • File transmission method and device, computer equipment and storage medium

    CN116827672A

  • Data transmission verification method, device and equipment and computer readable storage medium

    CN116886268A