Disclosure of Invention
In view of the above, it is desirable to provide a data transmission method and system capable of shortening a transmission time.
A method of data transmission, the method comprising:
a sending end acquires file data to be sent, and blocks the file data to obtain at least one file data block;
the sending end creates a corresponding data block compression task for each file data block and adds the data block compression task to a task processing queue;
the sending end concurrently executes the data block compression tasks in the task processing queue through a plurality of threads to obtain corresponding compressed data blocks, and sends the compressed data blocks to a target receiving end which is closest to the sending end in a receiving end list; the receiving end list comprises a plurality of receiving ends arranged according to the distance between the receiving ends and the sending end;
and the target receiving terminal forwards the compressed data block to a receiving terminal which is next closest to the transmitting terminal in the receiving terminal list until all receiving terminals receive the compressed data block.
In one embodiment, the method further comprises:
when the target receiving end receives the compressed data blocks, decompressing each compressed data block through a thread in a decompression thread pool, and storing the decompressed data blocks into corresponding files.
In one embodiment, the corresponding agent programs are deployed on each receiving end in the sending end and the receiving end list; after obtaining the corresponding compressed data block, the method further includes:
the sending end stores the compressed data block into a ring queue;
the sending the compressed data block to a target receiving end closest to the sending end in a receiving end list comprises:
the sending end sequentially extracts each compressed data block from the annular queue through threads, and sends the extracted compressed data blocks to an agent program deployed on the target receiving end through the agent program deployed on the sending end;
the step of forwarding the compressed data block to a receiving end which is next closest to the transmitting end in the receiving end list by the target receiving end comprises the following steps:
and forwarding the compressed data block to an agent program deployed on a receiving end next to the transmitting end through the agent program deployed on the target receiving end.
In one embodiment, the sending the compressed data block to a target receiver closest to the sender in a receiver list includes:
the sending end stores the compressed data block into a sending end kernel buffer area and copies the compressed data block from the sending end kernel buffer area to a sending end network layer buffer area;
the sending end sends the compressed data block in the network layer buffer area of the sending end to the target receiving end and stores the compressed data block in a receiving end kernel buffer area;
the step of forwarding the compressed data block to a receiving end which is next closest to the transmitting end in the receiving end list by the target receiving end comprises the following steps:
and the target receiving terminal copies the compressed data block from the receiving terminal kernel buffer area to a receiving terminal network layer buffer area, and sends the compressed data block in the receiving terminal network layer buffer area to a receiving terminal which is next closest to the sending terminal in the receiving terminal list.
In one embodiment, the method further comprises:
when a sending end receives a data distribution request, extracting a receiving end list before sequencing from the data distribution request;
respectively sending a network detection command to each receiving end in the list of the receiving ends before sequencing;
when response commands returned by the receiving terminals in response to the network detection commands are received, respectively acquiring the response time of the receiving terminals returning the response commands;
and sequencing all the receiving ends according to the response time to obtain the receiving end list.
In one embodiment, the method further comprises:
when the last receiving end in the receiving end list receives all the compressed data blocks, feeding back successful receiving information to the previous receiving end;
for the receiving ends except the tail receiving end and the target receiving end in the receiving end list, when receiving the receiving success information fed back by all the subsequent receiving ends in the receiving end list, sending the receiving success information fed back by all the subsequent receiving ends and the receiving success information generated by the receiving ends to the previous receiving end;
and when the target receiving end receives the successful receiving information fed back by all the subsequent receiving ends, the successful receiving information fed back by all the subsequent receiving ends and the successful receiving information generated by the target receiving end are sent to the sending end together.
A data transmission system, the system comprising:
the system comprises a sending end, a receiving end and a sending end, wherein the sending end is used for obtaining file data to be sent and blocking the file data to obtain at least one file data block;
the sending end is further configured to create a corresponding data block compression task for each file data block, and add the data block compression task to a task processing queue;
the sending end is further used for concurrently executing the data block compression tasks in the task processing queue through a plurality of threads to obtain corresponding compressed data blocks, and sending the compressed data blocks to target receiving ends which are closest to the sending end in a receiving end list; the receiving end list comprises a plurality of receiving ends arranged according to the distance between the receiving ends and the sending end;
and the target receiving end is used for forwarding the compressed data block to a receiving end which is next closest to the transmitting end in the receiving end list until all receiving ends receive the compressed data block.
In one embodiment, the system further comprises:
and the target receiving end is further used for decompressing each compressed data block through the thread in the decompression thread pool when receiving the compressed data blocks, and storing the decompressed data blocks into corresponding files.
In one embodiment, the corresponding agent programs are deployed on each receiving end in the sending end and the receiving end list; the system further comprises:
the sending end is also used for storing the compressed data block into a ring queue;
the sending end is further configured to sequentially extract each compressed data block from the circular queue through a thread, and send the extracted compressed data block to an agent deployed on the target receiving end through an agent deployed on the sending end;
and the target receiving end is further used for forwarding the compressed data block to an agent program deployed on a receiving end which is next closest to the transmitting end through the agent program deployed on the target receiving end.
In one embodiment, the system further comprises:
the sending end is also used for storing the compressed data block into a sending end kernel buffer area and copying the compressed data block from the sending end kernel buffer area to a sending end network layer buffer area;
the sending end is further configured to send the compressed data block in the network layer buffer area of the sending end to the target receiving end, and store the compressed data block in a receiving end kernel buffer area;
the target receiving end is further configured to copy the compressed data block from the receiving end kernel buffer area to a receiving end network layer buffer area, and send the compressed data block in the receiving end network layer buffer area to a receiving end in the receiving end list, which is next closest to the sending end.
In one embodiment, the sending end is further configured to:
when a data distribution request is received, extracting a pre-sequencing receiving end list from the data distribution request;
respectively sending a network detection command to each receiving end in the list of the receiving ends before sequencing;
when response commands returned by the receiving terminals in response to the network detection commands are received, respectively acquiring the response time of the receiving terminals returning the response commands;
and sequencing all the receiving ends according to the response time to obtain the receiving end list.
In one embodiment, the system further comprises: a last receiving end which is farthest away from the transmitting end and a middle receiving end except the last receiving end and the target receiving end;
the last receiving end is used for feeding back the information of successful receiving to the previous receiving end when receiving all the compressed data blocks;
the middle receiving end is used for sending the successful receiving information fed back by all the subsequent receiving ends and the successful receiving information generated by the middle receiving end to the previous receiving end when receiving the successful receiving information fed back by all the subsequent receiving ends in the receiving end list;
and the target receiving end is also used for sending the successful receiving information fed back by all the subsequent receiving ends and the successful receiving information generated by the target receiving end to the sending end when receiving the successful receiving information fed back by all the subsequent receiving ends.
In the above embodiment, the sending end obtains file data to be sent, divides the file data into a plurality of file data blocks, creates a corresponding data block compression task for each file data block, and adds the data block compression task to the task processing queue. And the sending end concurrently executes the data block compression task in the task processing queue through a plurality of threads to compress the file data block. The sending end compresses the file data blocks in a multi-thread compression mode, and the compression time is shortened. And the sending end only sends the compressed data block to a target receiving end which is closest to the sending end in the receiving end list, and then the target receiving end forwards the compressed data block to a receiving end which is next closest to the sending end in the receiving end list, and then the compressed data block is forwarded in sequence until all the receiving ends receive the compressed data block. Therefore, based on the full duplex characteristic of the network, each receiving end in the receiving end list can send the compressed data block to other receiving ends while receiving the compressed data block, so that the time for transmitting the compressed data block from the sending end to each receiving end is reduced, and the data sending efficiency is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The data transmission method provided by the application can be applied to the application environment shown in fig. 1. The sender 102 communicates with a target receiver 104 closest to the sender via a network, and the target receiver 104 may communicate with a receiver 106 next closest to the sender. The sending end 102 obtains file data to be sent, blocks the file data to obtain at least one file data block, and creates a corresponding data block compression task for each file data block and adds the data block compression task to a task processing queue. The sending end 102 concurrently executes the data block compression task in the task processing queue through a plurality of threads to obtain a corresponding compressed data block, and sends the compressed data block to the target receiving end 104. The target receiving end 104 forwards the compressed data blocks to the receiving end 106 which is next closest to the transmitting end in the receiving end list, and the transmitting end and each receiving end forward each compressed data block in sequence in a chained manner until each receiving end receives the compressed data block. The sending end 102, the target receiving end 104, and the receiving end 106 that is the next closest to the sending end are computer devices, the computer devices may be terminals or servers, the terminals may be but are not limited to various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the servers may be implemented by independent servers or server clusters formed by multiple servers.
In an embodiment, as shown in fig. 2, a data transmission method is provided, which is described by taking an example that the method is applied to a transmitting end and each receiving end in fig. 1, and includes the following steps:
s202, the sending end obtains file data to be sent, and blocks the file data to obtain at least one file data block.
The file data to be sent is data generated by the sending end, or data acquired by the sending end from the network, and may be, for example, an installation file of an application program or a file that needs to be distributed to each receiving end, such as a multimedia file. The file data to be sent may be stored locally at the sending end, for example, in a local hard disk at the sending end, or may be stored in a cloud server.
In one embodiment, when a sender needs to send file data to a receiver, a client sends a data distribution request to the sender, where the data distribution request includes a source file path. When a sending end receives a data distribution request, a source file path is extracted from the data distribution request, file data to be sent are obtained according to the source file path, and the file data are partitioned, so that parallel compression of all file data blocks is achieved.
And S204, the sending end creates a corresponding data block compression task for each file data block, and adds the data block compression task to the task processing queue.
The data block compression task is a data object which encapsulates a corresponding file data block and a compression algorithm, and the file data block can be compressed through the compression algorithm encapsulated in the data block compression task. The task processing queue is a first-in first-out queue for storing data block compression tasks. In an embodiment, when a sending end requests a thread in a thread pool to execute a data block compression task, if no idle thread exists in the thread pool, the data block compression task is temporarily stored in a task processing queue, and when an idle thread occurs in the thread pool, the idle thread extracts the data block compression task arranged at the head of the queue from the task processing queue for processing.
S206, the sending end concurrently executes the data block compression tasks in the task processing queue through a plurality of threads to obtain corresponding compressed data blocks, and sends the compressed data blocks to a target receiving end which is closest to the sending end in the receiving end list; the receiving end list includes a plurality of receiving ends arranged according to a distance from the transmitting end.
The thread is a basic unit for CPU scheduling and allocation, and is an execution path of a process, wherein a plurality of threads in the process share resources of the process, but each thread has an independent execution stack and a program counter. The concurrent execution means that a plurality of threads are in a running state in the same time period and respectively execute the data block compression tasks in the task processing queue. The target receiving end is a computer device deployed in the same distributed system as the sending end, and can be located in the same region as the sending end or in a different region from the sending end. The receiving end list includes a plurality of receiving ends and network addresses corresponding to the receiving ends, and the network addresses may be IP addresses.
The receivers in the receiver list are arranged according to the distance from the sender, for example, the receivers in the receiver list are arranged from near to far according to the distance from the sender. In one embodiment, a client sends a data distribution request to a sending end, the data distribution request includes network addresses of each receiving end, the sending end sorts the receiving ends according to the network addresses of the receiving ends and the sequence from near to far from the sending end to generate a receiving end list, and the receiving end list includes serial numbers and network addresses of the receiving ends.
And S208, the target receiving terminal forwards the compressed data block to a receiving terminal which is next closest to the transmitting terminal in the receiving terminal list until all receiving terminals receive the compressed data block.
Based on the full duplex characteristic of the network, when the target receiving end receives the compressed data block, the target receiving end can simultaneously send the received compressed data block to other receiving ends. For example, as shown in fig. 3, the receiving end list includes 4 receiving ends, where the receiving ends 1-4 are arranged according to the distance to the transmitting end, the distance between the receiving end 1 and the transmitting end is the closest, the receiving end 2 times, and the distance between the receiving end 4 and the transmitting end is the farthest. The sending end firstly sends the compressed data block 1 to the receiving end 1, and then sends the compressed data block 2 to the receiving end 1, based on the full duplex characteristic of the network, the receiving end 1 can send the compressed data block 1 to the receiving end 2 at the same time when receiving the compressed data block 2. When receiving the compressed data block 1, the receiving end 2 forwards the compressed data block 1 to the receiving end 3, and the receiving end 3 forwards the compressed data block 1 to the receiving end 4. Therefore, the transmitting end and each receiving end form a chained data transmission path, and the compressed data block is transmitted from the transmitting end to each receiving end in a chained manner.
As shown in fig. 3, the file data distribution method makes full use of the full duplex characteristic of the network connection, and the network bandwidth occupied by the data transmission from the sending end to the receiving end 1 and the data transmission between the receiving end 1 and the receiving end 2 is independent. Therefore, the time taken for the transmitting end to distribute the compressed data blocks to all the receiving ends is the time taken for the transmitting end to transmit the compressed data blocks to the receiving end 1 + the time taken for the last compressed data block to be transmitted from the receiving end 1 to the last receiving end. The distribution time is therefore: (file size/sender bandwidth) + (number of receivers-1) × (size of compressed data block/receiver bandwidth). The time for transmitting one compressed data block is far shorter than the time for transmitting the whole file, and the sending end only needs to send the compressed data block to the receiving end 1, and does not need to distribute the compressed data block to all the receiving ends through the sending end, so that the file distribution speed is less influenced by the bandwidth of the sending end, and the time for distributing the file data is greatly reduced.
In the above embodiment, the sending end obtains file data to be sent, divides the file data into a plurality of file data blocks, creates a corresponding data block compression task for each file data block, and adds the data block compression task to the task processing queue. And the sending end concurrently executes the data block compression task in the task processing queue through a plurality of threads to compress the file data block. The sending end compresses the file data blocks in a multi-thread compression mode, and the compression time is shortened. And the sending end only sends the compressed data block to a target receiving end which is closest to the sending end in the receiving end list, and then the target receiving end forwards the compressed data block to a receiving end which is next closest to the sending end in the receiving end list, and then the compressed data block is forwarded in sequence until all the receiving ends receive the compressed data block. Therefore, based on the full duplex characteristic of the network, each receiving end in the receiving end list can send the compressed data block to other receiving ends while receiving the compressed data block, so that the time for transmitting the compressed data block from the sending end to each receiving end is reduced, and the data sending efficiency is improved.
In one embodiment, the sender concurrently executes the data block compression task in the task processing queue through a plurality of threads in the thread pool. The thread pool maintains a plurality of threads and waits for allocation of concurrently executable tasks, thereby reducing the overhead of creating and destroying threads while processing short-time tasks. The thread pool not only can ensure the full utilization of the kernel, but also can prevent over-scheduling. The thread pool has a certain number of core threads and non-core threads. A core thread is a thread that is not reclaimed while in an idle state. When a data block compression task is created in a sending end, firstly, whether core threads in a thread pool are in an idle state is judged, and if any core thread is in the idle state, the data block compression task is handed over to the core threads for processing. If no core thread is in an idle state, judging whether the number of the non-core threads exceeds a number threshold, if the number of the non-core threads does not exceed the number threshold, creating a non-core thread, and handing the data block compression task to the newly created non-core thread for processing; and if the number of the non-core threads exceeds the number threshold, waiting for the idle threads to appear, and enabling the idle threads to process the data block compression task in the task processing queue after releasing the idle threads.
In the above embodiment, the sending end maintains a certain number of core threads and non-core threads through the thread pool, and keeps the number of created non-core threads smaller than the number threshold, so that blocking caused by excessive created threads can be avoided, the overhead of creating and destroying threads can be reduced, and the efficiency of the CPU can be improved.
In one embodiment, the sending end has multiple cores of CPUs, each CPU can schedule and allocate a thread, and the multiple CPUs simultaneously and parallelly process the data block compression tasks in the task processing queue through the respective scheduled threads.
In one embodiment, when the target receiving end receives the compressed data blocks, each compressed data block is decompressed through a thread in the decompression thread pool, and the decompressed data blocks are stored in the corresponding files.
The target receiving end maintains a plurality of threads for executing decompression tasks through the decompression thread pool. When the target receiving end receives the compressed data blocks, a corresponding decompression task is created for each compressed data block, and the decompression tasks are added to the decompression task queue. And the threads in the decompression thread pool extract the decompression tasks from the decompression task queue and concurrently execute the decompression tasks so as to decompress the compressed data blocks. When other receiving ends in the receiving end list receive the compressed data blocks, decompressing each compressed data block through the thread in the decompression thread pool, and storing the decompressed data blocks into corresponding files.
In one embodiment, a plurality of core threads and a plurality of non-core threads are maintained in a decompression thread pool of a target receiving end, when a compressed data block is received, whether an idle core thread exists in the thread pool is judged firstly, if yes, the compressed data block is delivered to the core threads for decompression, if not, whether the number of the non-core threads reaches a number threshold value is judged, if not, a new non-core thread is created, and the compressed data block is delivered to the created non-core threads for decompression.
In the above embodiment, the target receiving end maintains a certain number of core threads and non-core threads through the decompression thread pool, and keeps the number of created non-core threads smaller than the number threshold, so that blocking due to excessive created threads can be avoided, overhead of creating and destroying threads can be reduced, and efficiency of the CPU can be improved.
In one embodiment, the target receiving end is provided with a multi-core CPU, when the target receiving end receives the compressed data blocks, each CPU schedules a corresponding thread, and processes data block decompression tasks in parallel through the scheduled threads so as to decompress the compressed data blocks, and stores the decompressed data blocks into corresponding files, thereby improving the decompression efficiency.
In an embodiment, as shown in fig. 4, a corresponding agent is deployed on each receiving end in the sending end and the receiving end list; after the sending end obtains the corresponding compressed data block, the data sending method also comprises the following steps:
s402, the sending end stores the compressed data block into a ring queue.
S404, the sending end sequentially extracts each compressed data block from the circular queue through the thread, and sends the extracted compressed data block to the agent deployed on the target receiving end through the agent deployed on the sending end.
S406, the agent program deployed on the target receiving end forwards the compressed data block to the agent program deployed on the receiving end which is next closest to the transmitting end.
The agent program is a software program installed on the transmitting end or the receiving end, and is used for receiving data, transmitting data and the like. The agent program deployed on the sending end or each receiving end can establish network connection with the switch, and when the connection request of other agent programs is monitored, the network connection with the agent program sending the connection request is established. The circular queue is a first-in first-out data structure connected end to end and is realized by adopting a linear space of an array.
In the above embodiment, the sending end stores the compressed data blocks into the circular queue, and sequentially extracts the compressed data blocks from the circular queue through the agent program to send, so that congestion in the sending process can be effectively avoided.
In an embodiment, the file data distribution method shown in fig. 5 is applied to a distributed system, in which a main data center, a backup data center, and a disaster backup data center are deployed, a sending end and a client are deployed in the main data center, receiving ends 1 to 9 are respectively deployed in each data center, and agent programs deployed on each receiving end are agent programs 1 to 9, respectively. Each agent listens for connection requests from other agents. When a sending end receives a data distribution request of a client, a receiving end list is extracted from the data distribution request, and the receiving end list has IP addresses of receiving ends 1-9. And then the sending end sorts the receiving ends in the receiving end list from near to far according to the distance between the sending end and each receiving end in the receiving end list to obtain a sorted receiving end list. The agent program corresponding to the sending end firstly sends a connection request to the agent program 1 according to the IP address of the first-ranked receiving end 1 in the sorted receiving end list, the agent program 1 responds to the connection request of the agent program corresponding to the sending end and establishes TCP network connection with the agent program corresponding to the sending end, and then the sending end sends the sorted receiving end list to the agent program 1. When the agent program 1 receives the sorted receiving end list, the IP address of the receiving end 2 arranged behind the agent program is searched, a connection request is sent to the agent program 2 according to the IP address of the receiving end 2, the sorted receiving end list is sent to the agent program 2 after TCP network connection is established with the agent program 2, and the like is repeated until network connection is established between the agent programs corresponding to the adjacent receiving ends in the sorted receiving end list, and all the agent programs receive the sorted receiving end list.
The method comprises the steps that a sending end stores compressed data blocks into an annular queue, then sequentially extracts the compressed data blocks from the annular queue through threads, and sends the extracted compressed data blocks to an agent program 1 deployed on a receiving end 1 through an agent program deployed on the sending end; the agent program 1 stores the compressed data block into the circular queue, extracts the compressed data block from the circular queue, and forwards the compressed data block to the agent program 2 deployed on the receiving end 2 according to the IP address of the receiving end 2. And each receiving terminal transmits the compressed data blocks to the next adjacent receiving terminal one by one through the agent program until the compressed data blocks are transmitted to the last receiving terminal.
In the above embodiment, the chained compressed data block transmission path is formed between the sending end and the agent programs corresponding to the receiving ends through the established network connection, so that the compressed data blocks can be transmitted from the sending end to the receiving ends in a chained manner, and the sending efficiency of the file is improved.
In one embodiment, when a sending end receives a data distribution request, a pre-ordering receiving end list is extracted from the data distribution request; respectively sending a network detection command to each receiving terminal in the list of the receiving terminals before sequencing; when response commands returned by the receiving terminals in response to the network detection commands are received, respectively acquiring the response time of the response commands returned by the receiving terminals; and sequencing the receiving ends according to the response time to obtain a receiving end list.
The data distribution request is a request instruction for requesting a sending end to distribute file data to a plurality of receiving ends. The data distribution request may include a source file path, a destination file path, and a pre-sort recipient list. The list of receivers before sorting may include the number and network address of each receiver.
The network probing command is a service command of an application layer in a TCP/IP network architecture, and is used to send an ICMP (Internet Control Message Protocol) request Message to a target host to test whether the target host can reach and know the relevant status of the target host. For example, the network probing command may be a PING command.
When the response time of the response command returned by the receiving end is longer than the time interval of the network detection command sent by the sending end, the longer the distance between the receiving end and the sending end is. The sending end sorts the receiving ends according to the response time, namely sorts the receiving ends according to the distance between the receiving ends and the sending end. In one embodiment, the sending end sorts the receiving ends from near to far according to the distance to the sending end, and a receiving end list is obtained.
In another embodiment, the sender determines the distance between the sender and each receiver according to the information recorded when the sender and the receivers are deployed. The recorded information includes the switches connected with the sending end and the receiving end, the machine room and the region. The receiving end closest to the sending end is the receiving end connected to the same switch with the sending end, the receiving end next closest to the sending end is in the same machine room with the sending end, but is not connected to the same switch with the sending end, and is in the same region with the sending end again, but is not in the same machine room with the sending end, and the receiving end farthest from the sending end is the receiving end in a different region with the sending end.
In the above embodiment, the sending end sorts the receiving ends, and may send the compressed data block to the receiving end closest to the sending end according to the receiving end list, and each receiving end may forward the compressed data block to the next receiving end adjacent to the sending end according to the arrangement order of the receiving ends in the receiving end list. Because each receiving end sequentially forwards the compressed data blocks according to the distance between the receiving end and the transmitting end, network resources are saved, and the data distribution efficiency is improved.
In one embodiment, the receiving ends in the receiving end list are located in a plurality of different regions, the sending end groups the receiving ends according to the region where each receiving end is located, divides the receiving ends located in the same region into a group, and then sends the compressed data block to the receiving ends in each group in parallel.
In one embodiment, the sending, by the sender, the compressed data block to a target receiver closest to the sender in the receiver list includes: the sending end stores the compressed data block into a sending end kernel buffer area and copies the compressed data block from the sending end kernel buffer area to a sending end network layer buffer area; the sending end sends the compressed data block in the network layer buffer area of the sending end to a target receiving end and stores the compressed data block in a kernel buffer area of the receiving end; the target receiving end forwards the compressed data block to the receiving end which is next closest to the transmitting end in the receiving end list, and the method comprises the following steps: and the target receiving terminal copies the compressed data block from the receiving terminal kernel buffer area to the receiving terminal network layer buffer area, and sends the compressed data block in the receiving terminal network layer buffer area to the receiving terminal which is next closest to the sending terminal in the receiving terminal list.
Wherein the sending end kernel buffer is a buffer located in a kernel space of the sending end. The receive side kernel buffer is a buffer located in the kernel space of the receive side. The kernel space is the virtual address space in which the operating system kernel runs. When the process runs in the kernel space, the process is in the kernel state, and when the process runs in the user space, the process is in the user state. The kernel of the operating system is a kernel, which can access the protected memory space and also can access the underlying hardware devices. In order to ensure the security of the kernel, the operating system generally forces the user process not to directly operate the kernel, so the operating system divides the virtual address space into a kernel space and a user space. For example, for a 32-bit operating system, the address space (virtual address space) is 4G, that is, the maximum address space of the processes running on the operating system is 4G. The top 1 Gbyte (from virtual address 0xC0000000 to 0 xFFFFFFFF) is used by the kernel, called kernel space, while the lower 3 Gbytes (from virtual address 0x00000000 to 0 xBFFFFFFF) are used by individual user processes, called user space. In one embodiment, the target receiving end stores the compressed data block into a kernel map file in a kernel buffer upon receipt of the compressed data block.
The sending end stores the compressed data block into the network layer buffer area, encapsulates the stored compressed data block according to a network protocol, and sends the encapsulated compressed data block to the receiving end, wherein the network protocol may be, for example, a TCP protocol, a UDP protocol, or a custom protocol.
In the above embodiment, because the sending-end kernel buffer area, the sending-end network layer buffer area, the receiving-end kernel buffer area, and the receiving-end network layer buffer area all exist in the kernel space, when the sending end and each receiving end send the compressed data block, the compressed data block does not need to be copied back and forth between the kernel space and the user space, so that the resource utilization rate of the CPU is reduced, and the distribution efficiency of the file data is improved.
In one embodiment, when the last receiving end in the receiving end list receives all the compressed data blocks, the receiving success information is fed back to the previous receiving end; for the receiving ends except the tail receiving end and the target receiving end in the receiving end list, when receiving the receiving success information fed back by all the subsequent receiving ends in the receiving end list, sending the receiving success information fed back by all the subsequent receiving ends and the receiving success information generated by the receiving ends to the previous receiving end; and when the target receiving end receives the successful receiving information fed back by all the subsequent receiving ends, the successful receiving information fed back by all the subsequent receiving ends and the successful receiving information generated by the target receiving end are sent to the sending end together.
As shown in fig. 6, the receiving end list includes receiving ends 1-5, and the agents 1-5 are respectively deployed on the receiving ends 1-5, and when the receiving end 5 receives all the compressed data blocks, the agent 5 feeds back the information of successful reception to the agent 4. When receiving all the compressed data blocks, the receiving end 4 combines the receiving success information generated by itself with the receiving success information fed back by the agent program 5, and sends the combined information to the agent program 3, and so on until the receiving success information fed back by the agent programs 1 to 5 is sent to the sending end.
In the above embodiment, when receiving all the compressed data blocks, each agent program feeds back the reception success information to the previous agent program, and finally feeds back the reception success information generated by all the agent programs to the sending end, so that the sending end knows whether each receiving end receives a complete compressed data block, and when the receiving end does not receive a complete compressed data block, resends the compressed data block to the receiving end, thereby ensuring reliable transmission of the compressed data block.
In one embodiment, the receivers in the receiver list are deployed in the main data center; after the sending end acquires the receiving end list, the method further comprises the following steps: when the main data center fails, the sending end replaces the receiving ends in the receiving end list with the receiving ends deployed in the standby data center, and establishes network connection with each receiving end in the replaced receiving end list; when the main data center and the standby data center both have faults, the sending end replaces the receiving ends in the receiving end list with the receiving ends deployed in the disaster standby data center, and establishes network connection with the receiving ends in the replaced receiving end list.
The main data center and the backup data center are located in the same region, and the disaster backup data center is located in a different region. When the main data center fails, the receiving end in the standby data center is started, and the sending end replaces the receiving end deployed in the main data center in the receiving end list with the receiving end deployed in the standby data center. And when the backup data center also breaks down, the disaster backup data center is started, and the sending end replaces the receiving ends deployed in the main data center and the backup data center in the receiving end list with the receiving ends deployed in the disaster backup data center.
In the above embodiment, for the distributed system, by deploying three data centers in two regions, the backup data center can be started when the primary data center fails, or the disaster backup data center can be started when both the primary data center and the backup data center fail, so as to replace the failed receiving end, thereby sufficiently ensuring the normal operation of the distributed system.
It should be understood that although the steps in the flowcharts of fig. 2 and 4 are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2 and 4 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least some of the other steps or stages.
In one embodiment, as shown in fig. 7, there is provided a data transmission system including: a sender 702 and a target receiver 704, wherein:
a sending end 702, configured to obtain file data to be sent, and block the file data to obtain at least one file data block;
the sending end 702 is further configured to create, for each file data block, a corresponding data block compression task, and add the data block compression task to the task processing queue;
the sending end 702 is further configured to concurrently execute a data block compression task in the task processing queue through a plurality of threads to obtain a corresponding compressed data block, and send the compressed data block to a target receiving end closest to the sending end in the receiving end list; the receiving end list comprises a plurality of receiving ends arranged according to the distance between the receiving ends and the sending end;
the target receiving end 704 is configured to forward the compressed data block to a receiving end in the receiving end list that is next closest to the transmitting end until each receiving end receives the compressed data block.
In the above embodiment, the sending end obtains file data to be sent, and blocks the file data to obtain at least one file data block, and then creates a corresponding data block compression task for each file data block, and adds the data block compression task to the task processing queue. And the sending end concurrently executes the data block compression task in the task processing queue through a plurality of threads to compress the file data block. The sending end compresses the file data blocks in a multi-thread compression mode, and the compression time is shortened. And the sending end only sends the compressed data block to a target receiving end which is closest to the sending end in the receiving end list, and then the target receiving end forwards the compressed data block to a receiving end which is next closest to the sending end in the receiving end list, and then the compressed data block is forwarded in sequence until all the receiving ends receive the compressed data block. Therefore, based on the full duplex characteristic of the network, each receiving end in the receiving end list can send the compressed data block to other receiving ends while receiving the compressed data block, so that the time for transmitting the compressed data block from the sending end to each receiving end is reduced, and the data sending efficiency is improved.
In one embodiment, the system further comprises:
the target receiving end 704, when receiving the compressed data blocks, is further configured to decompress the compressed data blocks through the threads in the decompression thread pool, and store the decompressed data blocks in the corresponding files.
In one embodiment, a corresponding agent program is deployed on each receiving end in a sending end list and a receiving end list; the system further comprises:
the sending end 702 is further configured to store the compressed data block into a circular queue;
the sending end 702 is further configured to sequentially extract each compressed data block from the circular queue through a thread, and send the extracted compressed data block to an agent deployed on a target receiving end through an agent deployed on the sending end;
the target receiver 704 is further configured to forward the compressed data block to an agent deployed on a receiver located next to the sender through the agent deployed on the target receiver.
In one embodiment, the system further comprises:
the sending end 702 is further configured to store the compressed data block in a sending end kernel buffer, and copy the compressed data block from the sending end kernel buffer to a sending end network layer buffer;
the sending end 702 is further configured to send the compressed data block in the network layer buffer of the sending end to a target receiving end, and store the compressed data block in a receiving end kernel buffer;
the target receiving end 704 is further configured to copy the compressed data block from the receiving end kernel buffer to the receiving end network layer buffer, and send the compressed data block in the receiving end network layer buffer to a receiving end that is next closest to the sending end in the receiving end list.
In one embodiment, the sender 702 is further configured to:
when a data distribution request is received, extracting a receiving end list before sequencing from the data distribution request;
respectively sending a network detection command to each receiving terminal in the list of the receiving terminals before sequencing;
when response commands returned by the receiving terminals in response to the network detection commands are received, respectively acquiring the response time of the response commands returned by the receiving terminals;
and sequencing the receiving ends according to the response time to obtain a receiving end list.
In one embodiment, as shown in fig. 8, the system further comprises: a last receiving end 706 farthest from the transmitting end and an intermediate receiving end 708 excluding the last receiving end and the target receiving end;
a last receiving end 706, configured to feed back a reception success message to a previous receiving end when receiving all the compressed data blocks;
the middle receiving end 708, when receiving the successful receiving information fed back by all the subsequent receiving ends in the receiving end list, is configured to send the successful receiving information fed back by all the subsequent receiving ends and the successful receiving information generated by itself to the previous receiving end;
the target receiving end 702, when receiving the successful receiving information fed back by all the subsequent receiving ends, is further configured to send the successful receiving information fed back by all the subsequent receiving ends and the successful receiving information generated by itself to the transmitting end.
For specific limitations of the data transmission system, reference may be made to the above limitations of the data transmission method, which is not described herein again. The various modules in the data transmission system described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.