A file distribution method, device and medium thereof
By establishing multiple threads in the virtualized resource device for one-to-many configuration file distribution, and using block transmission and compensation sending technology, the problem of low transmission efficiency in the existing technology is solved and an efficient file distribution process is realized.
Patent Information
- Application Number
- CN202210451727.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2042-04-27
AI Technical Summary
When existing technology distributes configuration files to virtualized resource devices, the transmission efficiency is not high. The management end is required to establish a one-to-one connection with each resource device and read the file in full, resulting in low efficiency.
By establishing multiple threads to establish session connections with different nodes to be received, one-to-many configuration file distribution is achieved to avoid frequent reading of files to be transferred by the management end. The file transfer module based on the TCP protocol is used to transfer files in blocks, and on the receiving end Perform data splicing and compensation sending.
It improves the efficiency of configuration file distribution, reduces data transmission time and number of reads, and achieves efficient file transmission.
Smart Images

Figure CN114827129B
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a file distribution method, device and medium thereof. Background Art
[0002] In today's virtualization management platform, there are various resource devices that exist for the normal operation of virtualization, such as servers, storage, switches, etc. Among them, each resource is implemented by specific software, and each software has its own configuration file, which needs to be modified using instructions. However, due to system, network and other problems, there may be problems when modifying the configuration file, resulting in configuration file errors. To solve this problem, a method of uniformly distributing configuration files to each resource device is currently adopted to ensure stability. There are two main existing methods for distributing configuration files to each resource device: one is to transmit through a file transfer tool, such as File Transfer Protocol (FTP), etc.; the other is to use a transmission module to realize the distribution of configuration files, which is developed and implemented in a socket manner using Transmission Control Protocol (TCP).
[0003] At present, the two methods used to distribute configuration files to various resource devices are to establish a one-to-one connection between nodes and then transmit the configuration files. That is, the management end (data sender) needs to establish a one-to-one connection with each resource device (data receiver, that is, the receiving node) and transmit the data. This data transmission method is not efficient enough, and each data transmission requires the management end to re-read the file in full, further reducing the data transmission efficiency.
[0004] Therefore, technicians in this field are in urgent need of a file distribution method to solve the problem of low efficiency in transmitting configuration files. Summary of the invention
[0005] The purpose of this application is to provide a file distribution method, device and medium thereof to solve the problem of insufficient efficiency in transmitting configuration files.
[0006] In order to solve the above technical problems, the present application provides a file distribution method, comprising:
[0007] receiving a configuration file distribution request, the configuration file distribution request including addresses of each to-be-received node and files to be transmitted;
[0008] A corresponding number of threads are established according to the number of nodes to be received, and each thread is used to send a session establishment request to a different node to be received, so as to establish a session connection with the node to be received;
[0009] The file to be transmitted is sent to each receiving node through the established session connection.
[0010] Preferably, before sending the file to be transmitted to each node to be received, the method further includes: reading the file to be transmitted and storing it in a buffer; correspondingly, sending the file to be transmitted to each node to be received includes: sending the data in the buffer to each node to be received.
[0011] Preferably, before sending the file to be transmitted to each node to be received, it also includes: dividing the file to be transmitted into multiple data blocks according to a preset size; correspondingly, sending the file to be transmitted to each node to be received includes: reading in the current data block, and sending the data block to each node to be received through a file transmission module based on the TCP protocol; after the current data block is sent to each node to be received, reading in the next data block until all data blocks are sent to each node to be received; wherein, the order of reading in the data blocks is the order of the data blocks in the file to be transmitted.
[0012] Preferably, sending the file to be transmitted to each to-be-received node through the established session connection includes: sending the file to be transmitted to each to-be-received node after any successfully established session connection exists.
[0013] Preferably, after sending the file to be transmitted to each node to be received, it also includes: generating an end identifier and sending it to each node to be received; judging whether there is still an open session connection; if so, resending the file to be transmitted to the corresponding node to be received through the open session connection; wherein the session connection is closed after the node to be received judges that the file to be transmitted has been fully received.
[0014] Preferably, applied to the receiving node side, the session connection is closed by the receiving node after determining that the entire file to be transmitted has been received, including: when an end identifier is received, comparing the amount of data received with the size of the file to be transmitted; if they are the same, disconnecting the session connection; if they are different, maintaining the session connection.
[0015] Preferably, the method applied to the receiving node side also includes: storing the received data into a first file before receiving the end marker; storing the received data into a second file after receiving the end marker; and connecting the first file and the second file end to end in the order of the second file in front and the first file in the back to obtain the file to be transmitted.
[0016] In order to solve the above technical problems, the present application also provides a file distribution device, comprising:
[0017] A request receiving module, used for receiving a configuration file distribution request, wherein the configuration file distribution request includes the address of each to-be-received node and the to-be-transmitted file;
[0018] A connection establishment module, used to establish a corresponding number of threads according to the number of nodes to be received, and each thread is used to send a session establishment request to a different node to be received, so as to establish a session connection with the node to be received;
[0019] The file transmission module is used to send the file to be transmitted to each receiving node through the established session connection.
[0020] Preferably, it also includes:
[0021] The data cache module is used to read the file to be transmitted and store it in the buffer zone; correspondingly, sending the file to be transmitted to each node to be received includes: sending the data in the buffer zone to each node to be received.
[0022] The data segmentation module is used to divide the file to be transmitted into multiple data blocks according to a preset size; correspondingly, sending the file to be transmitted to each node to be received includes: reading in the current data block, and sending the data block to each node to be received through a file transmission module based on the TCP protocol; after the current data block is sent to each node to be received, reading in the next data block until all data blocks are sent to each node to be received; wherein, the order of reading in the data blocks is the order of the data blocks in the file to be transmitted.
[0023] The compensation sending module is used to generate an end identifier and send it to each node to be received; determine whether there is still an open session connection; if so, resend the file to be transmitted to the corresponding node to be received through the open session connection; wherein the session connection is closed after the receiving node determines that the file to be transmitted has been fully received.
[0024] The file splicing module is used to store the received data into the first file before receiving the end mark; store the received data into the second file after receiving the end mark; and connect the first file and the second file end to end in the order of the second file first and the first file second to obtain the file to be transmitted.
[0025] In order to solve the above technical problems, the present application also provides a file distribution method and device, comprising:
[0026] Memory for storing computer programs;
[0027] A processor is used to implement the steps of the above-mentioned file distribution method when executing a computer program.
[0028] In order to solve the above technical problems, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the file distribution method as described above are implemented.
[0029] The file distribution method provided by the present application establishes multiple threads to establish session connections with different nodes to be received, so as to send the files to be transmitted to multiple nodes to be received, thereby realizing one-to-many configuration file distribution. It is not necessary for the management end to establish session connections with different nodes to be received, and then send the files to be transmitted, thereby improving the efficiency of configuration file distribution. At the same time, since one-to-many file transmission can be realized, the management end does not need to perform multiple file transmission processes, and further does not need to read the files to be transmitted once in each file transmission process, thereby further saving the time of configuration file distribution and improving efficiency.
[0030] The file distribution device and computer-readable storage medium provided in the present application correspond to the above method and have the same effects as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0032] Figure 1 A flowchart of a file distribution method provided by the present invention;
[0033] Figure 2 A structural diagram of a file distribution device provided by the present invention;
[0034] Figure 3 A structural diagram of another file distribution device provided by the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0036] The core of this application is to provide a file distribution method, device and medium thereof.
[0037] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0038] The present application aims to provide a file distribution method for distributing configuration files to resource devices in a unified manner. The method usually adopted is to establish a one-to-one connection and transmit the configuration files. The transmission efficiency is not high enough. Each file transmission requires the data management end to read the configuration file once, which further reduces the efficiency of configuration file distribution. Figure 1 As shown, including:
[0039] S11: receiving a configuration file distribution request, where the configuration file distribution request includes the address of each to-be-received node and the file to be transmitted.
[0040] S12: Establishing a corresponding number of threads according to the number of nodes to be received, and each thread is used to send a session establishment request to a different node to be received, so as to establish a session connection with the node to be received.
[0041] S13: Send the file to be transmitted to each receiving node through the established session connection.
[0042] It should be noted that the configuration file mentioned in this application is the file to be transmitted in the process of distributing the configuration file. In addition, as to when to distribute the files to be transmitted, they can be sent uniformly after all session connections are established, or they can be sent immediately when a session connection is established. The subsequent established session connection ensures that the full amount of the files to be transmitted are received in the form of compensation sending, and this embodiment does not limit this.
[0043] The present application establishes multiple threads, each thread is used to establish a session connection with a different node, so that a one-to-many transmission channel is established between the management end and each resource device, thereby realizing one-to-many configuration file distribution and improving the efficiency of configuration file distribution.
[0044] In actual applications, each time a configuration file is transmitted, the management end needs to read the entire file to be transmitted and then send it to the node to establish the connection to complete the file distribution process. Since the configuration file can only be transmitted to the corresponding node after the session connection is established, and the process of establishing the session connection and the process of the management end reading the configuration file do not affect each other, this embodiment provides a preferred implementation scheme, which includes:
[0045] Read the file to be transferred and store it in the buffer.
[0046] Correspondingly, sending the file to be transmitted to each receiving node includes:
[0047] Send the data in the buffer to each receiving node.
[0048] This embodiment stores the file to be transmitted in a buffer. When the session connection is established, data can be directly retrieved from the buffer for transmission without reading the file to be transmitted again, so that the process of establishing the session connection and the process of reading the file to be transmitted can be started in parallel, thereby further saving the time used for data transmission and improving the efficiency of configuration file distribution. In addition, this method directly distributes configuration files one-to-many, avoids frequent reading of files to be transmitted, further reduces the time used for data transmission, and further improves the efficiency of configuration file distribution.
[0049] Based on the preferred solutions provided in the above embodiments, this embodiment further provides a preferred implementation scheme, which further includes: dividing the file to be transmitted into multiple data blocks according to a preset size before sending the file to be transmitted to each receiving node.
[0050] Correspondingly, sending the file to be transmitted to each node to be received includes: reading in the current data block, and sending the data block to each node to be received through a file transmission module based on the TCP protocol; after the current data block is sent to each node to be received, reading in the next data block until all data blocks are sent to each node to be received.
[0051] The order of reading the data blocks is the order of the data blocks in the file to be transmitted.
[0052] That is, the file to be transmitted is divided into several data blocks of preset size. Generally speaking, the size of the data block is the capacity of the buffer. If the size of the file to be transmitted is not an integer multiple of the buffer capacity, a possible implementation is: the last data block can be smaller than the preset size, and the other data blocks are still the preset size.
[0053] After the file to be transmitted is divided into several data blocks, each data block is sent to each node to which the connection is established in sequence through a file transmission module based on the TCP protocol.
[0054] Since data transmission based on the TCP protocol is completed in sequence and no data loss will occur, the form of dividing the file to be transmitted into several data blocks provided in the above embodiment can effectively save buffer space and avoid excessive requirements on the buffer when the file to be transmitted is too large.
[0055] At the same time, as described in the above embodiment, data transmission can be performed when all session connections are established, or can be performed after a successful session connection exists. Therefore, based on the above embodiment, this embodiment also provides a preferred implementation scheme, in which the file to be transmitted is sent to each receiving node through the established session connection, including:
[0056] After any session connection is successfully established, the file to be transmitted is sent to each receiving node.
[0057] That is, if based on the preferred solution provided by the above embodiment, the file to be transmitted is divided into several parts; when there is a successful session connection, the first data block is transmitted; when the subsequent session connection is established, the corresponding data block is transmitted according to the current transmission progress. Since the data transmission is based on the TCP protocol, the data will not be lost, and the block transmission will not affect the integrity of the data. Moreover, the data blocks missing in each subsequent session connection must be several data blocks starting from the beginning, which can be compensated from the beginning during the compensation transmission.
[0058] Therefore, this method of starting data transmission as soon as any successfully established session connection exists will not cause data loss. On the contrary, because data transmission does not start after all session connections are established, the efficiency of data transmission can be improved, and the efficiency of configuration file distribution can be further improved.
[0059] It can be seen from the above embodiments that when the preferred solution of starting data transmission when any session connection is successfully established is adopted, the session connection established later may have a situation where some data blocks cannot be received and need to be compensated for. Therefore, this embodiment provides a preferred solution, which includes: after sending the file to be transmitted to each receiving node,
[0060] Generate an end marker and send it to each receiving node.
[0061] It is determined whether there is still an open session connection; if so, the file to be transmitted is resent to the corresponding receiving node through the open session connection.
[0062] The session connection is closed after the receiving node determines that the file to be transmitted has been fully received.
[0063] As can be seen from the above, a preferred solution provided by this embodiment is used to provide a compensation transmission method for files to be transmitted. When there is a session connection to be established later, it cannot receive several data blocks located at the head end of the file to be transmitted (the specific number of missing data blocks is determined by when the session connection is established, but it can be seen from the above embodiment that the transmission of data blocks is based on the TCP protocol, so no matter how many data blocks are missing, the missing data blocks must be several consecutive data blocks starting from the head end of the file to be transmitted), so it is necessary to perform data compensation transmission. When the first distribution of the file to be transmitted is completed, an end mark is generated to notify each node that the data transmission is completed. Each node determines whether it has received the file to be transmitted in full, and chooses whether to shut down the session connection accordingly. After that, it enters the data compensation transmission stage, and the management end re-reads the file to be transmitted and performs data transmission according to the existing session connection to ensure that the data is sent in full.
[0064] In addition, it can be seen from the above embodiments that the establishment of the session connection is implemented by the thread, which has no effect on the data transmission process. Therefore, in actual applications, only in an extremely undesirable situation, there will be a session connection that is successfully established when the last data block is transmitted. At this time, the node corresponding to the session connection has not received any data block of the file to be transmitted, and it is necessary to resend the full amount of the file to be transmitted, that is, the management end needs to read the full amount of the file to be transmitted for the second time. In other cases, since the TCP protocol sends data in sequence, when sending compensation to each node, it is only necessary to read in several data blocks from the beginning of the file to be transmitted for resending. Therefore, a preferred solution provided by this embodiment has the effect of requiring the management end to read in the full amount of the file to be transmitted twice at most when performing data compensation transmission. Compared with the current one-by-one connection, and each data transmission requires the reading of the file to be transmitted once, it is necessary to reduce the delay caused by data reading to data transmission, and further improve the distribution efficiency of the configuration file.
[0065] In addition, based on the above embodiment, this embodiment also provides a preferred solution for each node to determine whether the file to be transmitted has been received, including:
[0066] When the end mark is received, the amount of data received is compared with the size of the file to be transferred; if they are the same, the session connection is disconnected; if they are different, the session connection is maintained.
[0067] It can be seen from the above embodiments that data transmission using the file transfer module based on the TCP protocol is sent in sequence, and there will be no data loss. Therefore, for each node (that is, each resource device) as the data receiving end, the same data will not be received repeatedly, and the received data will not be lost. Furthermore, by comparing the amount of received data with the total amount of data of the file to be transmitted, it is possible to simply determine whether the file to be transmitted has been received in full. When the file to be transmitted is received in full, there is no need to receive any more data, and the session connection with the management end can be disconnected.
[0068] It can be seen from the above embodiment that when the full amount of files to be transmitted is distributed, the management end will generate an end mark to inform each node that the first distribution of the configuration file is completed, and the next stage is the data compensation stage, so for each node that has not received the full amount of files to be transmitted, the data received later will no longer be sent in the order of the previous data. Therefore, based on the above embodiment, this embodiment provides a preferred implementation scheme, which is applied to each receiving node side, and the method also includes:
[0069] Before receiving the end mark, the received data is stored in the first file; after receiving the end mark, the received data is stored in the second file; the first file and the second file are connected end to end in the order of the second file first and the first file second to obtain the file to be transmitted.
[0070] As can be seen from the above, the data transmission of this embodiment is implemented based on the TCP protocol, so the data received before the end mark must be continuous, and the data received after the end mark is also continuous, and the data received after the end mark is in the order of the data received before the end mark on the file to be transmitted. Therefore, with the end mark received as the demarcation point, the data received before and after are stored in two different files respectively, and after all are received, the two files are spliced together to obtain a complete file to be transmitted.
[0071] This embodiment saves the data received before and after the end mark separately to avoid confusion in the data order, and subsequently splices the two files head to tail in the order of the first file first and the second file later to obtain a correct file to be transmitted, so that each node that subsequently establishes a session connection can obtain a correct and complete file to be transmitted through data compensation sending, thereby ensuring the accuracy of the configuration file distribution process.
[0072] Since the above description of a file distribution method provided by the present application is progressive, in order to further explain the present method, the above file distribution method is further explained below in combination with actual application scenarios:
[0073] The entire file distribution method can be roughly divided into two parts according to different application entities, which are used on the management side (sender of the configuration file) and the receiving node side (receiver of the configuration file, that is, resource device) respectively.
[0074] When implementing this method on the management side, it can be implemented by the following modules: multiple threads, a file transfer module, a session maintenance module, a data transfer module and a transfer maintenance module.
[0075] The above file distribution method can also be divided into a data initial transmission phase and a data compensation transmission phase according to different data transmission phases. The following describes the differences in data transmission phases from the management end side and the receiving node side.
[0076] 1) The first data transmission stage - management side
[0077] The management end establishes threads when receiving a file distribution request from the user end. The number of threads is consistent with the number of nodes to be received for the configuration file distribution, and is used to establish a session connection between the management end and the corresponding nodes to be received. The process of establishing a session connection is asynchronous and non-blocking, that is, each thread executes a connection establishment request to its corresponding node to be received, and is processed in parallel with each other.
[0078] In addition, after the thread completes establishing the corresponding session connection, the session connection is pulled into the available session queue by the session maintenance module, and the available session queue is initially empty.
[0079] At the same time, the transmission maintenance module adds the task information of the transmission task, including the name of the file to be transmitted, the file size, the transmission status, and the transmitted size, etc., and the relevant information of the above transmission task is updated in real time as the transmission task proceeds.
[0080] While the threads are establishing each session connection, the data transmission module starts to read the input files to be transmitted into data blocks of preset size in sequence and store them in the buffer. When there is data to be sent in the buffer, all available session queues are pulled from the available session queues maintained by the session maintenance module. If there is at least one available session connection, the data in the buffer is transmitted to each receiving node through the file transmission module based on the TCP protocol.
[0081] After the data transmission module pulls the available session connection, it also opens the same number of threads as the available session connections to compare the size of the data block stored in the buffer with the remaining data amount of the file to be transmitted (the remaining data amount of the file to be transmitted can be obtained from the file size and the transmitted size in the transmission maintenance module); if the size of the data block in the buffer is less than or equal to the remaining data amount, the file transfer module transmits it to the connected receiving node through the available session connection; at the same time, the task information in the transmission maintenance module is updated.
[0082] It should be noted that the data transmission module does not interfere with the establishment of session connections when performing data transmission, and the establishment of session connections does not interrupt the current data transmission. That is, when there is any available session connection, the data transmission module starts the data transmission work, and the files to be transmitted are divided into several data blocks and transmitted in sequence. When the subsequent session connection is established, when the data transmission module completes the transmission of the current data block and calls all available session connections, the corresponding receiving node starts to participate in the data transmission, and the progress is based on the data block currently being transmitted by the data transmission module.
[0083] An example is given: session connection A is established first, and the data transmission module starts to transmit data block 1; when transmitting data block 1, session connection B is established; after data block 1 is transmitted, the data transmission module re-pull the available session connection; at this time, session connections A and B are pulled, and data block 2 is started to be transmitted; the same applies to the subsequent steps and will not be repeated.
[0084] Therefore, after the first data transmission phase, the receiving node corresponding to session connection A obtains the full amount of the file to be transmitted, and the receiving node corresponding to session connection B obtains all the files to be transmitted except data block 1. In the subsequent data compensation transmission phase, the receiving node corresponding to session connection B only needs to resend data block 1.
[0085] In addition, when the management end transmits all the data blocks once, it regards the first data transmission phase as over, generates an end mark (usually -1), and sends it to each node to be tested, preparing to enter the data compensation transmission phase.
[0086] 2) The first data transmission phase - the receiving node side
[0087] After receiving the connection establishment request sent by the thread, a session connection is established with the management end, and data transmission is waited for; when data distributed by the management end is received, the received data is directly written to the disk and saved in the form of a file until the end mark is received, and the data received before is saved in the same file (the first file); at this time, the session connection is not disconnected, and data verification is performed first to determine the file size of the file to be transmitted and the amount of received data; if they are the same, the session connection with the management end is disconnected; if they are different, the session connection is maintained and waits for the compensation of data to be sent (because the data is sent based on the TCP protocol, the data blocks are sent in sequence, and there is no situation where the amount of received data is greater than the size of the file to be transmitted).
[0088] Therefore, after the first data sending phase, there should be two states of session connections in the session maintenance module. One is that the file to be transmitted has been fully received, which is a closed state; the other is that the file to be transmitted has not been fully received (in the most undesirable extreme case, such as a session that is successfully connected when the last data block is transmitted, it may be that no part of the file to be transmitted is received), which is an open state.
[0089] At this time, the closed session connection is removed from the available session queue, and the task information in the transmission maintenance module is updated as completed; the unclosed session connection searches the transmission maintenance module for the amount of data it has transmitted, calculates the remaining data amount, and updates it to the transmission maintenance module.
[0090] At this point, the data compensation sending phase begins.
[0091] 3) Data compensation sending stage - management side
[0092] Similar to the first data sending stage, the management end sends the file to be transferred to all available session connections from the beginning until the data transmission module cannot pull any available session connection, and stops reading the remaining data blocks of the file to be transferred, which is considered the end of the management end step of this configuration file distribution process.
[0093] 4) Data compensation sending stage - receiving node side
[0094] In this stage, every time a data block is received from the management end, the data verification work in 2) above is performed. If the file to be transmitted has been received in full, the session connection is disconnected. If not, the session connection is maintained and data transmission is continued. In addition, all the data received in the data compensation transmission stage are stored in another file (the second file). When the data verification determines that the data has been received in full, the first file and the second file are spliced end to end in the order of the second file first and the first file last, and finally the complete file to be transmitted is obtained.
[0095] At this point, the entire configuration file distribution process is completed.
[0096] In the above embodiment, a file distribution method is described in detail, and the present application also provides a corresponding embodiment of a file distribution device. It should be noted that the present application describes the embodiment of the device part from two perspectives, one is based on the functional module perspective, and the other is based on the hardware perspective.
[0097] Based on the perspective of functional modules, this embodiment provides a file distribution device, such as Figure 2 As shown, including:
[0098] The request receiving module 21 is used to receive a configuration file distribution request, where the configuration file distribution request includes the address of each to-be-received node and the file to be transmitted.
[0099] The connection establishing module 22 is used to establish a corresponding number of threads according to the number of nodes to be received, and each thread is used to send a session establishment request to a different node to be received to establish a session connection with the node to be received.
[0100] The file transmission module 23 is used to send the file to be transmitted to each receiving node through the established session connection.
[0101] Preferably, it also includes:
[0102] The data cache module is used to read the file to be transmitted and store it in the buffer zone; correspondingly, sending the file to be transmitted to each node to be received includes: sending the data in the buffer zone to each node to be received.
[0103] The data segmentation module is used to divide the file to be transmitted into multiple data blocks according to a preset size; correspondingly, sending the file to be transmitted to each node to be received includes: reading in the current data block, and sending the data block to each node to be received through a file transmission module based on the TCP protocol; after the current data block is sent to each node to be received, reading in the next data block until all data blocks are sent to each node to be received; wherein, the order of reading in the data blocks is the order of the data blocks in the file to be transmitted.
[0104] The compensation sending module is used to generate an end identifier and send it to each node to be received; determine whether there is still an open session connection; if so, resend the file to be transmitted to the corresponding node to be received through the open session connection; wherein the session connection is closed after the receiving node determines that the file to be transmitted has been fully received.
[0105] The file splicing module is used to store the received data into the first file before receiving the end mark; store the received data into the second file after receiving the end mark; and connect the first file and the second file end to end in the order of the second file first and the first file second to obtain the file to be transmitted.
[0106] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0107] The file distribution device provided by this embodiment establishes multiple threads through a connection establishment module, and each thread is used to establish a session connection with a different node, so that a one-to-many transmission channel is established between the management end and each resource device, and then a one-to-many configuration file distribution is realized through the file transmission module, thereby improving the efficiency of configuration file distribution. Also, because one-to-many file distribution can be realized, the management end is prevented from frequently reading the files to be transmitted, saving the time used for data reading, and further improving the efficiency of configuration file distribution.
[0108] Figure 3 A structural diagram of a file distribution device provided in another embodiment of the present application is shown in FIG. Figure 3 As shown, a file distribution device includes: a memory 30 for storing a computer program;
[0109] The processor 31 is used to implement the steps of a file distribution method in the above embodiment when executing a computer program.
[0110] The file distribution device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer, or a desktop computer.
[0111] Among them, the processor 31 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 31 can be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 31 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 31 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 31 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0112] The memory 30 may include one or more computer-readable storage media, which may be non-transitory. The memory 30 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 30 is at least used to store the following computer program 301, wherein, after the computer program is loaded and executed by the processor 31, it can implement the relevant steps of a file distribution method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 30 may also include an operating system 302 and data 303, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 302 may include Windows, Unix, Linux, etc. Data 303 may include but is not limited to a file distribution method, etc.
[0113] In some embodiments, a file distribution device may further include a display screen 32 , an input / output interface 33 , a communication interface 34 , a power supply 35 , and a communication bus 36 .
[0114] Those skilled in the art will understand that Figure 3 The structure shown in the figure does not constitute a limitation on a file distribution device, and may include more or less components than those shown in the figure.
[0115] A file distribution device provided in an embodiment of the present application includes a memory and a processor. When the processor executes a program stored in the memory, it can implement the following method: a file distribution method.
[0116] The file distribution device provided in this embodiment implements the above-mentioned file distribution method when the processor executes the program stored in the memory, realizes the establishment of one-to-many connections by establishing multiple threads, and then can realize one-to-many configuration file distribution between the management end and each to-be-received node, thereby improving the efficiency of configuration file distribution. Similarly, one-to-many file distribution does not need to read the to-be-transmitted file every time data is transmitted, which reduces the number of times the management end reads the to-be-transmitted file, reduces the total time used for data reading, and further improves the efficiency of configuration file distribution.
[0117] Finally, the present application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps recorded in the above method embodiment are implemented.
[0118] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0119] The computer-readable storage medium provided in this embodiment stores a program for implementing the above-mentioned file distribution method. When executed, it can establish multiple threads to realize a one-to-many session connection between the management end and each receiving node, thereby directly distributing the configuration file, thereby improving the efficiency of the configuration file distribution. At the same time, this one-to-many file distribution process reduces the number of data transmissions performed by the management end, thereby reducing the number of times the file to be transmitted needs to be read during data transmission, reducing the total time used for data reading, and further improving the efficiency of the configuration file distribution.
[0120] The above is a detailed introduction to a file distribution method, device and medium provided by the present application. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referenced to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
[0121] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A file distribution method, It is characterized in that include: receiving a configuration file distribution request, wherein the configuration file distribution request includes addresses of each to-be-received node and a to-be-transmitted file; A corresponding number of threads are established according to the number of the nodes to be received, and each of the threads is used to send session establishment requests to different nodes to be received in parallel to establish session connections with the nodes to be received; Sending the file to be transmitted to each of the nodes to be received through the established session connection; Before sending the file to be transmitted to each of the nodes to be received, the method further includes: Read the file to be transmitted and store it in a buffer; Correspondingly, sending the file to be transmitted to each of the nodes to be received through the established session connection includes: When the session connection is established, calling all the established session connections to send the data in the buffer to the corresponding node to be received; When the session connection is subsequently established and the current data transmission process is completed, all the subsequently established session connections are called to send the data in the buffer from the beginning to the corresponding receiving node; Before sending the file to be transmitted to each of the nodes to be received, the method further includes: Divide the file to be transmitted into multiple data blocks according to a preset size; wherein the preset size is the capacity of the buffer; and when the size of the file to be transmitted is not an integer multiple of the capacity of the buffer, the last data block is smaller than the preset size, and the other data blocks are the preset size; Correspondingly, sending the file to be transmitted to each of the nodes to be received includes: reading the current data block, and sending the data block to each of the nodes to be received through a file transmission module based on the TCP protocol; after the current data block is sent to each of the nodes to be received, reading the next data block until all the data blocks are sent to each of the nodes to be received; wherein the order of reading the data blocks is the order of the data blocks in the file to be transmitted; Correspondingly, when a subsequent session connection is established and the current data block is transmitted, all the session connections are called to transmit the next data block; After sending the file to be transmitted to each of the nodes to be received, the method further includes: Generate an end identifier and send it to each of the nodes to be received; Determine whether the session connection in the open state still exists; if so, resend the file to be transmitted to the corresponding node to be received through the session connection in the open state; The session connection is closed after the receiving node determines that the file to be transmitted has been fully received; Applied to the receiving node side, the session connection is closed after the receiving node determines that the file to be transmitted has been fully received, including: When the end mark is received, the received data amount is compared with the size of the file to be transmitted; if they are the same, the session connection is disconnected; if they are different, the session connection is maintained; Applied to the to-be-received node side, the method further includes: Before receiving the end identifier, storing the received data into a first file; After receiving the end identifier, storing the received data into a second file; The first file and the second file are connected end to end in the order of the second file being in front and the first file being in the back, so as to obtain the file to be transmitted.
2. A file distribution device, It is characterized in that include: A request receiving module, used to receive a configuration file distribution request, wherein the configuration file distribution request includes the address of each to-be-received node and the to-be-transmitted file; A connection establishment module, used to establish a corresponding number of threads according to the number of the nodes to be received, and each of the threads is used to send session establishment requests to different nodes to be received in parallel to establish a session connection with the nodes to be received; A file transmission module, used for sending the file to be transmitted to each of the nodes to be received through the established session connection; The data cache module is used to read the files to be transmitted and store them in the buffer; Correspondingly, sending the to-be-transmitted file to each of the to-be-received nodes through the established session connection includes: when the session connection is established, calling all the established session connections to send the data in the buffer to the corresponding to-be-received node; when the session connection is subsequently established and the current data transmission process is completed, calling all the subsequently established session connections to send the data in the buffer to the corresponding to-be-received node from the beginning; A data segmentation module is used to divide the file to be transmitted into multiple data blocks according to a preset size; wherein the preset size is the capacity of the buffer; and when the size of the file to be transmitted is not an integer multiple of the buffer capacity, the last data block is smaller than the preset size, and the other data blocks are the preset size; correspondingly, sending the file to be transmitted to each node to be received includes: reading in the current data block, and sending the data block to each node to be received through a file transmission module based on the TCP protocol; after the current data block is sent to each node to be received, reading in the next data block until all data blocks are sent to each node to be received; wherein the order of reading in the data blocks is the order of the data blocks in the file to be transmitted; correspondingly, when a subsequent session connection is established and the current data block is transmitted, all the session connections are called to transmit the next data block; The compensation sending module is used to generate an end mark and send it to each receiving node; determine whether there is still an open session connection; if so, resend the file to be transmitted to the corresponding receiving node through the open session connection; wherein the session connection is closed after the receiving node determines that the file to be transmitted has been fully received; The file splicing module is used to store the received data into the first file before receiving the end mark; store the received data into the second file after receiving the end mark; and connect the first file and the second file end to end in the order of the second file first and the first file second to obtain the file to be transmitted.
3. A file distribution method and device, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the file distribution method as claimed in claim 1 when executing the computer program.
4. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the file distribution method according to claim 1 are implemented.
Citation Information
Patent Citations
Fast transmission method of internet larger file
CN101616077A
Method and device for accessing local file
CN102902630A
File transmission method and device, computer equipment and storage medium
CN109862526A
Application program starting method, system and device and computer storage medium
CN110321179A
Data processing method and device of storage system, storage server and storage medium
CN110597452A
