Embodiment
The embodiment of the invention is a kind of system and method for realizing that file quicken to be downloaded, a kind of specifically high speed, safe, stable file download apparatus system.In order to describe the implementation of this invention more clearly, now specifically describe as follows in conjunction with each accompanying drawing:
One, system constitutes:
The embodiment of the invention is made up of interconnected client (Clients), centralized indexes server (Centralized Index Server) and three parts of caching server (Cache Server), system architecture diagram of the present invention sees also Fig. 1-1, is introduced respectively below:
(1), centralized indexes server (Centralized Index Server) is to be the point-to-point (P2P of user, the abbreviation of Peer to Peer, being direct transmission information between user and the user, rather than by third party's transfer) the file download provides the server of index service.Its major function is that the information of fileinfo, blocks of files, user profile are managed concentratedly, and provide the loading source of optimization for client, avoided like this in the prior art because " seed " disappearance, caused the problem of possible download neutral gear, guaranteed the stability of file source.
Centralized indexes server (Centralized Index Server) is mainly managed concentratedly fileinfo, blocks of files information (the present invention is first with file block to the down operation of file, carries out the operating process that multithreading is downloaded each piecemeal again), user profile by database.Centralized indexes server (Centralized Index Server) is made up of each functional module, and it is to data source, as the database that includes storehouses tables such as fileinfo, blocks of files information, user profile operates, and finishes the task in the file download process.The concrete condition of each functional module sees also following description.
Below introduce the basic stored information in the database, it should be noted that, concrete table and field all are that down operation in conjunction with present embodiment device main functional modules provides in the following stated information and the database, are not that the information that is used to limit apparatus of the present invention is formed.
1, the main contents of fileinfo comprise:
A) uniform resource locator (url), it is the sign of user's download Source Site address information;
B) file size (filesize);
C) file is revised the date (lastmodtime) at last;
D) file feature information: by url, the MD5 characteristic value of the character string that filesize and lastmodtime are combined in order.
Illustrate: MD5 is disclosed algorithm, and this algorithm as input, is exported one 128 information " fingerprint " to the information of random length.See also RFC1321 (the English full name of RFC is Request For Comments, i.e. Request for Comment, major part has developed into the standard of Internet), network address is
Http:// www.faqs.org/rfcs/rfc1321.html
Illustrate, certain URL is
Http: // 61.139.60.86:80/tmp/oicq/2004/03/11/QQmm.exe, its file size is 303786 bytes, revising the date at last is 2004-03-11 17:50:40, can be spliced into character string to it in order
Http: // 61.139.60.86:80/tmp/oicq/2004/03/11/QQmm.exe 2004-03-11The file feature information that 7:50:40_303786 calculates is: a97bb0e6af4e5a8a8bdf7e9b7b179561.
Above information is as described below corresponding to table concrete in the database and main field:
Table name claims urlmd5_to_urlid
The literary name section:
Sequence number |
Field name |
Type |
Explanation |
Function |
① |
Urlid |
Signless integer |
The ID of url |
Be used for searching (seeing following content for details) at urlseq_to_blockmd5 |
② |
urlmd5 |
32 byte character strings |
File feature information |
|
③ |
url |
Varying length string |
The URL of file |
|
④ |
Filesize |
Signless integer |
File size |
|
⑤ |
lastmodtime |
DATETIME |
The last modification time of file |
|
The table explanation: urlmd5 is the key assignments of index in this table, is unique.
Table function: by file feature information urlmd5 inquiry urlid.
2, blocks of files information main contents comprise:
A) characteristic information of blocks of files:, as input, calculate its 128 information " fingerprint " with the size of the data of blocks of files and blocks of files according to above-mentioned explanation to the MD5 algorithm.
B) have the user's of blocks of files index information: user ID.
C) blocks of files number, piece ID.
Above block message is corresponding to table concrete in the database and main field as described below:
Table name claims blockmd5_to_blockid
The literary name section
Sequence number |
Field name |
Type |
Explanation |
① |
Blockid |
Signless integer |
The ID of block number |
② |
blockmd5 |
32 byte character strings |
The characteristic value of block |
The table explanation: the blockmd5 in this table is the key assignments of index, is unique.
Table function: inquire blockid from blockmd5.
Table name claims blockid_to_uuid
The literary name section
Sequence number |
Field name |
Type |
Explanation |
① |
blockid |
Signless integer |
The ID of block number |
② |
uuid |
Signless integer |
The ID users that has this piece |
The table explanation: blockid can be repetition in this table, promptly can go out a plurality of uuid from a blockid index.
Table function: inquire ID number of user from blockid, this table is an one-to-many.
3, user profile main contents:
A) index of user profile: user ID.
B) at line index.
C) IP address: net address and outer net address in comprising.
D) elemental user information: as: user's name, general information such as sex.
Above information is as described below corresponding to table concrete in the database and main field:
Table name claims: uuid
The literary name section:
Sequence number |
Field name |
Type |
Explanation |
Function |
① |
Uuid |
Signless integer |
ID number of user registration |
|
② |
online_flag |
Integer |
The user's online sign |
|
③ |
external_ip |
Signless integer |
The outside ip address that the user connects |
If the public network main frame, then with main frame |
|
|
|
|
The IP address is identical |
④ |
internal_ip |
Signless integer |
The IP address of subscriber's main station |
|
⑤ |
username |
32 byte character strings |
The nickname that the user provides |
|
⑥ |
cookie |
16 byte character strings |
User's login and authenticating operation are used |
|
The table explanation: uuid is unique in this table.
Table function: by the available information of user's uuid inquiring user.
Wherein, cookie is the character string that server is used for authenticating.The user uses this to tie up to system at every turn, and client must sign in to server, and server dynamically produces a cookie character string and sends to client.Request to the centralized indexes server after the client all can attach this character string, after server receives request, can compare the cookie of client and the cookie that is saved in the uuid database, if unanimity then by authentication, otherwise would return mistake.Withdraw from client up to the user, this cookie just lost efficacy.Using the purpose of cookie is in order to prevent the malicious attack from client.
In addition, in conjunction with the narration of concrete down operation in the system of the present invention, also need fileinfo and blocks of files information united and manage, so that the download and inquiry operation.The concrete table that uses thes contents are as follows:
Table name claims urlseq_to_blockmd5
The literary name section:
Sequence number |
Field name |
Type |
Explanation |
① |
urlid |
Signless integer |
The ID of url |
② |
blockseq, |
Signless integer |
The sequence number of blocks of files (sequence number that piecemeal obtains) |
③ |
blockmd5 |
32 byte character strings |
The characteristic information of blocks of files |
④ |
saved_count |
Signless integer |
The number that this document piece was preserved |
Table function: inquire blockmd5 from given urlid and blockseq
The table explanation: the index urlid in this table can be repetition.
The centralized indexes server is made of separate document management module, piece administration module, user management module three parts.
The functional module of centralized indexes server is formed referring to Fig. 2-1.
Wherein, the major function of document management module is a management document information, the operation by the characteristic information of fileinfo, piece sequence number inquiry corresponding document piece is finished in customer in response end fileinfo to the request (detailed content is asked for an interview the description of client to this module) of block message inquiry submodule, customer in response end file is reported the fileinfo that submodule is reported, and finishes the storage work of fileinfo.This module is mainly reported submodule by fileinfo to block message submodule, file storage and is constituted.
Fileinfo to the function of block message submodule is to read file feature information urlmd5 that the client transmission comes and the piece sequence number blockseq in the piecemeal submodule (piecemeal submodule detailed functions is asked for an interview following specifying) to finish inquiry to the characteristic information blockmd5 of blocks of files in this document administration module.
This document information to the operation of block message submodule specific implementation is: when file feature information urlmd5 and piece sequence number blockseq information are delivered to this document information to the block message submodule, this document information to block message submodule is retrieved the characteristic information (corresponding storehouse table name is called urlmd5_to_urlid and urlseq_to_blockmd5) of piece in the database by query statement, specifically: client sends uuid, cookie, urlmd5, blockseq information is to this module, the authentification of user submodule is at first according to uuid in the server end user management module, cookie information is carried out user's authenticating operation, and (native system must carry out authenticating operation when carrying out any operation, see the demonstration of authentification of user submodule in the user management module for details), after authentication is passed through, this module at first is that condition inquires urlid with urlmd5 from database table urlmd5_to_urlid, then, with the urlid and the piece sequence number blockseq that inquire is condition, from database table urlseq_to_blockmd5, inquire the characteristic information blockmd5 of blocks of files, and the characteristic information blockmd5 of this document piece is transmitted back client.If the aforesaid operations authentication is rejected, perhaps query manipulation does not obtain corresponding results, all returns error message.This module concrete operations flow process sees also Fig. 3-4.
The function of file storage report submodule is in this document administration module: behind the down operation of finishing whole file, client will be reported fileinfo, client file is reported submodule fileinfo is delivered to server end file storage report submodule, and this module is upgraded operation to database.The operation of specific implementation is: when client with uuid, cookie, url, urlmd5, filesize, when lastmodtime information is reported to server end, the authentification of user submodule at first carries out user's authenticating operation according to uuid, cookie information in the server end user management module, after authentication is passed through, the server end file storage is reported submodule and is taken urlmd5 as condition query urlmd5_to_urlid table, judges whether to exist corresponding urlid, if exist, then do not store, withdraw from this module operation.If do not exist, then in the urlmd5_to_urlid table, create a new record, file feature information (urlmd5) and fileinfo are stored.If authenticating operation is rejected, perhaps query manipulation does not obtain corresponding results, then carries out and withdraws from operation.Detail flowchart sees also 3-5.
The function of piece administration module mainly is to carry out the operation of relevant document piece in the centralized indexes server, as piecemeal, by operations such as block message searching user's information, piece storage, verification, deletion, reports.Specifically, mainly constitute by block message to user profile submodule, piece storage report submodule, block delete submodule, block delete report submodule, piecemeal module, block check module.
The function of each submodule below makes introductions all round:
The function of piecemeal module is according to file size file to be carried out piecemeal, and specifically, this piecemeal module by certain partition strategy piecemeal, finally obtains the size information of piece and the sequence number of piece after the size information that has obtained file.
This piecemeal is big more according to file, the strategy that the size of each piece is big more carries out piecemeal, specifically: the size of determining reference block according to the magnitude range of file, then file is carried out piecemeal, the blocks of files of not enough this reference block size of residue is separately as a blocks of files, and this method of partition purpose is the piecemeal number that as far as possible reduces big file.
Following table has provided different file size scopes, the foundation of judgment standard block size:
The size of piece |
The file size scope |
256K |
File size<=8.192M |
512K |
8.192M<file size<=16.384M |
1M |
16.384M<file size<=32.768M |
2M |
File size>32.768M |
Now be exemplified below according to above-mentioned partition strategy:
For example, be that the result of certain file block of 1222368 bytes is to size:
The sequence number of piece |
The size of piece (byte) |
The condition code of piece |
0 |
262144 |
d0bb7027e11e2315c38b5b0e094b3c77 |
1 |
262144 |
adf614225776a4aacff28a4bc75e394d |
2 |
262144 |
34d734ee9b4b014a3ebe3e77ed9b0edc |
3 |
262144 |
9a3d0648b2d763155f8f8c2203f2e96c |
4 |
173792 |
9c316baac04e195991d058238ae6cc41 |
Wherein, the size of last piece is a redundancy section.Its size can be calculated according to file total length and piecemeal rule.
Block message to the function of user profile submodule is that the characteristic information according to blocks of files retrieves the optimal user information list that has this document piece, when client is sent the searching user's information request, the characteristic information blockmd5 of blocks of files is delivered to server end, this block message to user profile submodule passes through the inquiry to database table blockmd5_to_blockid, blockid_to_uuid and uuid successively, obtains a user profile that contains some user profile and tabulates.The optimized choice of submodule with IP MAP (IP geographical position map) download optimization submodule (the detailed content relevant narration of face as follows) optimized in this user profile tabulation via common download, determine that (user in the tabulation is by transmission speed sequence arrangement from big to small to the optimal user information list, the information that this tabulation mainly comprises is: uuid,, external ip, internal ip) return client.
Block message to the operation of user profile submodule specific implementation is: when the client block message when user profile inquiry submodule is delivered to the centralized indexes server with the characteristic information blockmd5 of blocks of files, by the server end block message to the user profile submodule by file block message content in the database is retrieved, obtain several (one or more) user's index information, by this index information searching user's information table the user's IP address information retrieval is come out again.Specifically: the authentification of user submodule at first carries out authenticating operation according to user uuid and cookie in the server end user management module, after authentication is passed through, the server end block message to the characteristic information blockmd5 of the blocks of files that the user profile submodule comes according to the client transmission be condition query database table blockmd5_to_blockid, obtain corresponding blockid, be condition query database table blockid_to_uuid with the blockid that obtains again, obtain a plurality of users' uuid, last block message is inquired about from database table uuid according to each uuid to user profile submodule invoke user information inquiry submodule and whether is had the caching server that prestores this document piece (caching server is the client that has higher priority in query script, the narration of relevant caching server below particular content is asked for an interview) in, if have, then pass this caching server information back client and directly carry out down operation from the buffer memory server end, if do not have, then continue to search the user profile that other have this piece, several (one or more) user profile constitute the user profile tabulation, and (this list information comprises uuid, external_ip, internal_ip).Detailed description sees also Fig. 3-6.
After obtaining the user profile tabulation, will pass through and optimize and can realize that for the download of client submodule provide loading source efficiently, the function that submodule and IP MAP download optimization submodule are optimized in this block message to the common download in the user profile submodule is exactly to finish the Optimizing operation of user profile tabulation.
The function that submodule is optimized in common download is to judge download request client user and the user profile user in tabulating whether (a plurality of users' judgement is side by side, carries out simultaneously in this local area network (LAN) or in same group, controlled by thread), if meet this condition, then this user profile tabulation (order of these row his-and-hers watches is at random) is delivered to client and carries out down operation.If do not meet this condition, further tabulation is optimized to user profile then to utilize IP MAP to download the optimization submodule.The process of detail operations sees also Fig. 3-7.
IP MAP is the external IP geographical position tabulation of announcing of national authority department and the access bandwidth of the part network segment.Can calculate the optimal path of communication between two subscriber's main stations according to this tabulation, thereby be converted to the optimum bandwidth that transmits between two users.But relatively expend time in when directly using IP MAP database to calculate, the present invention has adopted IP MAP download optimization submodule to improve computational speed.
Optimize the submodule function in order to illustrate that IP MAP downloads, now illustrate in conjunction with concrete process:
IP MAP has used following database table:
Table name claims: ip_group
The literary name section:
Sequence number |
Field name |
Type |
Explanation |
① |
ipstart |
Signless integer |
The IP From of the network segment is represented with signless integer |
② |
ipend |
Signless integer |
The End IP of the network segment is represented with signless integer |
③ |
groupno |
Signless integer |
Group number, artificial input does not repeat |
Table function: by given IP address (converting signless integer to) index user's group number
Table name claims: group_group
The literary name section:
Sequence number |
Field name |
Type |
Explanation |
① |
group1 |
Signless integer |
Network segment packet number |
② |
group2 |
Signless integer |
Network segment packet number |
③ |
bandwidth |
Signless integer |
Transmission bandwidth between group1 and the group2 |
Table function: inquire two bandwidth between the grouping by given any two packet number.
Transmission bandwidth to each network segment and other network segment among the present invention calculates, and the result after handling is put into database.To have that big bandwidth connects as adjacent node, thereby formed a network segment topology diagram in logic.See also Fig. 3-9.Then each network segment and other network segment are carried out the transmission bandwidth computing by topological diagram, the result is put into database group_group.Thereby can calculate the bandwidth between any two IP efficiently.
It is to calculate optimal path end to end according to IP MAP that IP MAP downloads the major function of optimizing submodule, and the user list after will optimizing turns back to client.Mainly form by bandwidth module between first group of judge module, second group of judge module and inquiry comparative group.
Optimize submodule in above-mentioned common download and judge the user who has piece not in this local area network (LAN) or under the situation on the same group, IP MAP downloads the optimization submodule and continues user list information is optimized, and determines best download user tabulation.For better this module of explanation realizes the process optimized, the user user0 of existing hypothesis request file in download piece, and a plurality of users that preserved the demand file piece in the buffer memory of oneself are respectively user1, user2, user3, user4.Concrete implementation is: this IP MAP downloads and optimizes in submodule first group of judge module and at first inquire about user0 according to the ip address of user user0 from database table ip_group and whether belong to a certain grouping, if do not belong to a certain grouping then directly return the original subscriber user1 that tabulates, user2, user3, user4, if belong to a certain grouping (packet number of supposing user user0 here again is 0), second group of judge module then inquired about user1 in this module from database table ip_group, user2, user3, whether user4 belongs to a certain grouping respectively, and (process of inquiring about each user uses multithreading to carry out simultaneously, here suppose user1, user3 is grouping 1 and 3, user2, user4 does not belong to any grouping), after having obtained grouping information by bandwidth module respectively inquiry packets 0 and grouping 1 from database table group_group between the inquiry comparative group in this module, the grouping 0 and divide into groups between 3 transmission bandwidth (corresponding to the table in bandwidth), and transmission speed sorted from big to small, suppose that the result is grouping 0 to the bandwidth of grouping 3 greater than the bandwidth of grouping 0 to grouping 1.Not being user user2 among the IP MAP, user4 is appended to the end of user list at last, and end user's tabulation in this example is: user3, user1, user2, user4 (user user2, putting in order of user4 is at random), the user list after will optimizing is at last passed client back.The detail flowchart of this module sees also 3-8.
The block check module functions is in the piece administration module: when the characteristic information of the blocks of files of reporting to the centralized indexes server end when client and user ID information, the characteristic information of verification file piece is stored the characteristic information and the user ID of this document piece determining whether.
The operation of this block check submodule specific implementation is: after a certain blocks of files download of client finishes, client's end block storage is reported submodule and is reported the characteristic information and the user ID of blocks of files to the centralized indexes server, the characteristic value that the block check submodule is judged this piece whether with the centralized indexes server in other client users blocks of files characteristic value of reporting consistent.If unanimity is then stored, if inconsistent then proceeding judged, whether the number (saved_count in database table urlseq_to_blockmd5) that present this information stores of judgement is crossed is less than certain particular value (this particular value is an empirical value), if less than this value, then all records before the deletion, and preserve the cash breath of notifying, return success information.If not, (such as recording in the journal file, and notifying the keeper by alternate manner such as E-mail mode) then gives a warning.Because the submodule close relation is reported in this syndrome module and piece storage, concrete realization operation is referring to following description of piece being stored whole process.
The major function that submodule is reported in the storage of piece in the server end block administration module is after client is finished a certain down operation, and the characteristic information and the user ID of the blocks of files that client is reported are stored.
The every download of client finishes a blocks of files, must report the characteristic information of blocks of files to the centralized indexes server, client's end block storage report submodule uploads to the centralized indexes server with the characteristic information and the user ID of piece, and the storage of server end block is reported submodule it is made response.The operation of this module specific implementation is: when the storage of client's end block is reported submodule with uuid, cookie, when the blockmd5 value is delivered to server, the authentification of user submodule is at first according to uuid in the server end user management module, cookie carries out authenticating operation, after the authentication permission, it is condition with blockmd5 that submodule is reported in the storage of server end block, inquiry blockmd5_to_blockid table, whether inquiry exists corresponding blockid, if there has been the record of the information stores of this piece, whether then consistent with the characteristic information of the blocks of files of other users' reports by the characteristic information of block check module verification this document piece, main operation is that the blockmd5 value that client is reported is compared with the blockmd5 value with identical blockid number.If consistent, then inserting one in the blockid_to_uuid table is the new record of content with this blockid with the uuid that reports.If inconsistent, then need inquire about the numerical value of the saved_count among the urlseq_to_blockmd5, whether less than certain particular value (this value is an empirical value); If less than former all record deletions (to prevent malicious attack) then, and deposit piece blockid and the uuid information that reports in blockid_to_uuid, otherwise send the request of reporting an error, carry out manual abnormality processing to the keeper to this download system.Aforesaid operations authentication not by or query manipulation go wrong and then return error message.Detailed content sees also Fig. 3-10,3-12.
The function of block delete report submodule is after client is reported certain blocks of files of deletion in the centralized indexes server end block administration module, and database table is upgraded data manipulation, with the related libraries table record deletion of this piece.
The operation of specific implementation is: when the client block delete is reported the blockmd5 of submodule with deleted block, uuid, when cookie reports server, the authentification of user submodule is at first according to uuid in the server end user management module, cookie carries out authenticating operation, after the authentication permission, the server end block delete is reported submodule and is taken blockmd5 as condition query blockmd5_to_blockid table, whether inquiry exists corresponding blockid, if exist, then invoking server end block deletion submodule is with corresponding record deletion among the blockid_to_uuid.If there is not corresponding blockid, then return error message to client.If authentication is not passed through or the operation appearance is unusual, return error message.Detailed content sees also Fig. 3-11.
The major function of block delete submodule is to carry out the deletion record operation of centralized indexes server end in the centralized indexes server end block administration module.Owing to be simple delete operation, do not do tired stating at this.
Centralized indexes server end (Centralized Index Server) user management module mainly is that user's essential information manages, realize operations such as the user registers, logins, withdraws from, authentication, guarantee and realize searching user's information (corresponding to the customer management information in the database " uuid " table), mainly comprise user's registration management submodule, user login management submodule, user profile inquiry submodule, user and withdraw from submodule, authentification of user submodule.Each submodule institute operation technique of this server end user management module is prior art.
Wherein, user's registration management submodule provides the user registering functional, for using user's distributing user ID of native system.The main concrete operations that realize are: server receives the register requirement of client, user's registration management submodule is uuid table in the Query Database then, find a user ID that is not registered, upgrade the uuid database table then, add this user, the user ID of registration is returned to the user, and idiographic flow sees also accompanying drawing 3-1.
The function of user login management submodule is to realize the function of user's login, and the user is obtained from cookie, as client and the mutual safety certification of index server.And revise the user's online Information sign.Concrete realization operation is: server receives the logging request of client, login module is Query Database table uuid at first, judge whether this user is the registered user, if not, then return mistake, otherwise, upgrade the user's online information (online_flag) among the database table uuid, and dynamically produce a cookie information stores in uuid table, simultaneously this cookie information is returned to client, so that provide authenticating operation for other modules.The flow chart of this module is seen accompanying drawing 3-2.
User profile inquiry submodule mainly is the operations such as online information, IP address information and user basic information according to the user ID inquiring user.This module is that publicly-owned module can be simultaneously by other module invokes, the specific implementation operation is: the authentification of user submodule at first carries out authenticating operation according to uuid and cookie in the server end user management module, after authentication is passed through, according to different query statement (the select statement under the different condition) the uuid table is inquired about, obtain relevant information, and Query Result is returned.
After the user realized down operation, the user in the user management module withdrawed from submodule and is responsible for withdrawing from operation, and the main operation that realizes is the online_flag information of change user message table uuid.Concrete realization operation is: after user end to server sends the request of withdrawing from, the authentification of user submodule at first carries out authenticating operation in the server end user management module, after authentication is passed through, inquiry uuid database, whether inquiry exists this user's record, if exist, then the online_flag in this uuid table is changed to down status, and withdraw from native system.Concrete realization flow sees also Fig. 3-3.
Whether the authentification of user submodule is publicly-owned module in the user management module, and when being the process user request, the uuid and the cookie information of coming with the client transmission are condition, at first inquire the cookie among the server database table uuid, then compare consistent.If consistent, then authentication is passed through.If inconsistent, authentification failure then.Each operation requests after client user's login need be passed through this authentication.
So far, the function introduction of the basic composition of server end and each module finishes.
(2), client (Clients)
Client mainly goes up transmission module and local cache administration module by user management module, IE supplementary module, file download module, P2P (Peer to Peer, point-to-point).Each module composition of client sees also Fig. 2-2.
In down operation, send request by each functional module of client, the centralized indexes server is handled various requests, cooperatively interacts to finish down operation.The communications protocol of client and index server end is all used http protocol.
The user uses native system for the first time, must register, and obtains a user ID from the centralized indexes server when succeeding in registration, and later client need use this user ID to login to the centralized indexes server.User's registration and login are handled it by corresponding module in the centralized indexes server.The user management module of client is corresponding to the user management module of centralized indexes server, by mutually side by side, independent user registration submodule, user login submodule, the user withdraws from submodule and forms.This corresponding relation figure sees also Fig. 2-3,2-4.
It is to send register requirement to server that the user of client user's administration module registers the submodule major function.Concrete operation is, at first, inquires about in the windows registry of client and whether registers (inquiring user ID), has ID users if registered then can inquire in this locality.If local computer does not have user ID then to send register requirement to the centralized indexes server, by the ID users of centralized indexes server-assignment corresponding to uuid in the uuid table, and this user ID returned client, the client user registers submodule this user ID is kept at client.Details see also Fig. 4-1.
The major function that the user logins submodule is to send logging request to the centralized indexes server, and receives the return information of centralized indexes server.Concrete realization operation is: the client user logins submodule and sends logging request to the centralized indexes server, uuid is sent to server end, the centralized indexes server receives this request, handle this request by server end user login management submodule, Query Database table uuid judges whether this user's uuid is present in the uuid table.If not, will return error message, if be the registered user, then upgrade the user's online information (online_flag) among the database table uuid, change into online.Produce cookie and store in the uuid table (authenticating operation of other modules is provided), this user login management submodule will login successful information and cookie returns client.By the client user login that submodule receives successful information and with the cookie information stores returned to client.Details see also Fig. 4-2.
The major function that the user withdraws from submodule is to send the request of withdrawing to the centralized indexes server, concrete realization operation is: client is with uuid, cookie information is sent to server end, authenticate by authentification of user submodule in the server end user management module, after authentication is passed through, this user of server end withdraws from the online_flag information among the submodule change user message table uuid, this information is changed into roll off the production line, and carry out the operation of withdrawing from native system.
The IE supplementary module is the respond module that triggers download event, and this document download system has been registered the readjustment response of click event and the download clauses and subclauses (login mechanism is the disclosed interface Browser of IE Helper Objects (browser is assisted object)) in the right-click menu to the IE control.Its major function is when the user clicks the down operation incident, triggers the native system download function, and obtains the characteristic information of downloaded files information spanned file.
The operation of the specific implementation of this IE supplementary module is: when the user triggers download event by left button click or right-click menu, this IE supplementary module obtains the url (uniform resource locator) of file, url according to file obtains filesize (file size) from the Source Site, lastmodtime (file is revised the date at last), as input parameter, go out urlmd5 according to url, filesize, lastmodtime according to the MD5 algorithm computation.The detailed content that this module realizes sees also Fig. 4-3.
The major function of client (Clients) file download module is after the IE supplementary module triggers download event, send query requests to server end, final acquisition can provide the user profile tabulation (user profile in this tabulation mainly comprises uuid, external_ip, internal_ip) of this document piece download, realizes operations such as download, storage, report blocks of files.
This document download module mainly is made up of four parts such as user profile enquiry module, download realization submodule, piece management submodule, file management submodules.
Summarize: in the down operation process, each functional module of client is sent the process information of asking and receive the centralized indexes server to return to centralized indexes server (Centralized Index Server) and is realized sequence of operations such as download, storage, report.There are relation one to one substantially in client and centralized indexes server module.The graph of a relation of each module sees also Fig. 2-5 in the client downloads process in detail.The effect of relevant each module of native system client in downloading process please see following specific descriptions for details.
Below basically according to the order of module among Fig. 2-5 the make introductions all round function and the formation of each submodule of file download module.
The major function of piecemeal submodule is according to certain partition strategy file to be carried out piecemeal according to the document size information that obtains in the piece management submodule, and obtains the branch block message of piece, and this piecemeal information comprises the size of piece sequence number and each piece.Client distributes multithreading to realize the information inquiry and the down operation of each piece to the centralized indexes server end in following down operation process.
The piecemeal mechanism of this piecemeal submodule is machine-processed identical with centralized indexes server end piecemeal module, and the file block of the two generation is consistent, and this has guaranteed the consistency in the file download process.Relevant concrete partition strategy sees also above-mentioned centralized indexes server end narration, does not do tired stating at this.
The major function of user profile enquiry module is to send query requests and receive the return information of centralized indexes server to the centralized indexes server in the file download module.This module mainly is made of fileinfo to block message inquiry submodule and block message to user profile inquiry submodule.Two submodules corresponding to the fileinfo of centralized indexes server end document management module to the block message of block message submodule and piece administration module to subscriber information module.Connect each other, the operation that obtains best download user information list is finished in acting in conjunction.
Wherein, fileinfo to the major function of block message inquiry submodule is to send the request of query block information and receive return information to the centralized indexes server.Concrete realization operation is: with the urlmd5 of IE supplementary module generation, blockseq by the acquisition of piecemeal submodule, and the uuid that is used for authenticating operation, cookie is delivered to server end, fileinfo to block message submodule by the centralized indexes server end is a condition with these information, realize query manipulation (narration of above-mentioned server end fileinfo to the block message submodule seen in concrete operations), the characteristic information (blockmd5) of the blocks of files that client file information to block message inquiry submodule reception server end returns or do not have this block feature information and then judge next step operation, particularly: if returned the blockmd5 value, then this information is delivered to the client block message and carries out next step query manipulation to user profile inquiry submodule, if there is not this characteristic value, promptly return an error message, then call the client source website and download the realization submodule is realized file from the Source Site download.Detailed process sees also Fig. 4-4.
Client block message to the major function of user profile inquiry submodule is: after above-mentioned fileinfo to block message inquiry submodule obtained the characteristic information (blockmd5) of blocks of files, client block message to user profile inquiry submodule sent the request of searching user's information and the information that reception is returned to the centralized indexes server.Concrete realization operation is: this module is with the characteristic information (blockmd5) of blocks of files and the uuid that is used for authenticating operation, cookie information sends to the centralized indexes server, the block message of centralized indexes server end to user profile submodule is handled concrete query manipulation (narration of above-mentioned server end block message to the user profile submodule seen in concrete operations), user profile tabulation that client block message to user profile inquiry submodule reception server returns or the information that does not have this user profile tabulation, and then judge next step operation, particularly:, then directly call client P2P and download submodule realization down operation if returned the user profile tabulation.If do not have this list information, promptly return an error message, so directly call the client source website and download the realization submodule is realized file from the Source Site download.Detailed process sees also Fig. 4-5.
Downloading the function that realizes submodule in the file download module is to judge according to the information that the centralized indexes server end returns to carry out the download process operation in which way, specifically, the difference according to downloading mode can be divided into Source Site download realization submodule, P2P downloads submodule.
The Source Site is downloaded and is realized that submodule is that directly (the English full name of HTTP is HyperText Transfer Protocol, i.e. Hypertext Transmission Protocol from HTTP/FTP is provided; The English full name of FTP is File Transfer Protocol, i.e. file transfer protocol (FTP)) the Source Site file in download.The reason that adopts this mode to download has following several:
1. client can not find the user who preserves this document piece from the centralized indexes server;
2., download for some reason and can not realize (such as can not passing fire wall, user in the process of transmitting, roll off the production line etc.) though client has obtained a user list of preserving this document piece;
Client from other user's download blocks of files, but the verification of blocks of files is incorrect;
4. the blocks of files transmission is not supported in the Source Site.
The Source Site is downloaded the realization submodule http protocol (HyperText TransferProtocol, i.e. Hypertext Transmission Protocol) and the File Transfer Protocol (File Transfer Protocol, i.e. file transfer protocol (FTP)) of request is handled respectively.Website is downloaded the flow chart of realizing submodule and is seen also Fig. 4-13.
The operation of this module has been avoided in the prior art because the download problem out of stock that " seed " disappearance causes.
The function that P2P downloads submodule is from other user there transfer files piecemeal.Its is asked from other client there transfer files piece successively according to the user profile tabulation of returning from the centralized indexes server, if request error, then from user list, attempt next, if mistakes is all then downloaded from the Source Site.Hop sees also flow chart 4-14.This P2P downloads submodule originally as prior art.
The P2P of client goes up transmission module, and the end that provides as downloading provides a certain transmission of file for the download request client.See also 2-7 about download request end and download in the downloading process provide the end P2P download module graph of a relation that P2P goes up between the transmission module, the last transmission module of P2P is transferred to the download request end subscriber with the blocks of files that local cache extracts submodule (this local cache extraction submodule content please see for details and describe below) acquisition.The flow chart of the last transmission module of P2P sees also Fig. 4-15.It is prior art that this P2P goes up transmission module itself.
The major function of block check submodule is the check code (being the characteristic information blockmd5 of blocks of files) of the blocks of files after each download of calculating in the piece management submodule, and and the characteristic information of the blocks of files that obtains to the block message enquiry module from the centralized indexes server of above-mentioned client file information compare, and return whether consistent information, if the information unanimity of verification, then can store (narration that the details of storage see also following sub module stored) to this document piece, if inconsistent, as then to download piece again operation from the Source Site.The concrete operation of this block check submodule sees 4-10 for details.
The function of piece sub module stored is to store into by the blocks of files after the verification in the local file destination in the piece management submodule, and buffer memory is handled.Concrete realization operation is that blocks of files is stored in the local file destination.Then, spatial cache is judged, judge whether remaining space in addition, if spatial cache is full, then carry out the operation of deleted file piece according to the method (FIFO, First In First Out) of first in first out, this deletion action is carried out by the block delete submodule, after the deletion action, report submodule by block delete the deletion information of piece is reported server end.If buffer memory also has living space, then call local cache and preserve submodule (concrete function of this module sees also the description of following local cache administration module) this document piece is deposited in the local cache, so that provide loading source for down operation.Details see also Fig. 4-8 of storing process.
The major function that above-mentioned block delete is reported submodule is that block delete information is reported server, reports submodule by the server end block delete storehouse table is carried out concrete operation.The client block delete is reported antagonistic relations Fig. 2-6 of submodule and server end block delete report submodule.Concrete realization operation is: this block delete is reported the characteristic information blockmd5 of submodule with the deleted file piece, uuid, cookie information is delivered to the centralized indexes server, at first by authentification of user submodule in the server end user management module according to uuid, cookie information is carried out authenticating operation, and authentication is reported the renewal operation that submodule is carried out the storehouse by back centralized indexes server block deletion.(this renewal operation please see the narration that the server end block delete is reported submodule for details).
To report the function of submodule be that the characteristic information and the user ID of the blocks of files of storage are reported in the piece storage in the piece management submodule, and receive the storage of centralized indexes server end block and report return information after submodule is handled.Concrete realization operation is: the storage of client's end block is reported submodule with piece blockmd5, uuid, cookie are delivered to client and carry out concrete realization operation (this operation please see the narration of this module of server end for details) by centralized indexes server end block storage report submodule.The return information of submodule reception server end is reported in the storage of client's end block, if return correct information, then proof is stored successfully.If return error message, illustrate that then the piece of storing in the local cache just can not provide the transmission of piece for other download request ends, by the deletion submodule blocks of files in the local cache is deleted so.This process sees also Fig. 4-9.
Whether the file management submodule major function in the file download module is to judge downloading in the local file destination piece, all pieces are downloaded to finish, and finishes if download, and then the All Files piece is merged in order, realizes the storage to file.And with the storage fileinfo report the centralized indexes server.This module is mainly reported submodule by file storage submodule and file and is constituted.
Wherein, the function of file storage submodule is to judge whether all modules of file are downloaded to finish, and finishes if download, and then the numeric order of this document according to piece is merged, and is stored in the file destination, does not finish if download, then return.Main operation sees Fig. 4-6 for details.
The function that file is reported submodule is that file is downloaded file is sent in information report request from the back that finishes to the centralized indexes server.Concrete operation is, after file storage, client file is reported submodule with url, urlmd5, filesize, lastmodtime and the uuid that is used for authenticating operation, cookie information is delivered to server end, reports submodule by the file storage of document management module in the centralized indexes server and handles request (detailed information sees also the file storage of document management module in the centralized indexes server and reports the submodule description).Main operation sees Fig. 4-7 for details.
Client's device end local cache administration module is to be responsible for the preservation of local cache and to extract operation.The file of just on user's hard disk, creating when local cache is the native system installation (size of the file of being created is decided according to user's hard disk remaining space).Cache file is divided into blocks of files information index part and blocks of files data division.Index part contain blocks of files blockmd5, divide block size and piece information such as stored position hereof.
No matter user's download is from the Source Site download or from P2P user's file in download, can preserve blocks of files in cache file, reports simultaneously and gives index server.If other user connects to come the demand file piece by network, then client provides corresponding upload service for this request.
The local cache administration module is divided into local cache and preserves submodule and local cache extraction submodule.
The function that local cache is preserved submodule is to preserve blocks of files information in cache file, and sets up the index to this piece in cache file.If this cache file has not had idle space during preservation, then call the blocks of files that the deletion of client block delete submodule is preserved the earliest, and invoking block deletion report submodule is reported the characteristic information of deleted file piece to the centralized indexes server.The flow chart that local cache is preserved submodule sees also Fig. 4-11.
The function that local cache extracts submodule is to index the content of blocks of files and the content information of backspace file piece from local cache.Its flow chart sees also 4-12.
(3), caching server is that special-purpose server only has the function of uploading, caching server is used to store the download of concurrent number than higher file.It has bigger buffer memory and higher bandwidth, occupies very high priority when user inquiring.Caching server is equivalent to only provide the client of upload service, and it is some specific files (comprising blocks of files) of buffer memory in advance.It is identical with host-host protocol and common client between server and other client.Specifically caching server includes the local cache administration module and the last transmission module of P2P of above-mentioned client.
Two, concrete use is described:
The registered user is after login, and the method for down loading that can use native system to provide now specifies the method for down loading that native system provides in conjunction with Fig. 4-16:
As a step among Fig. 4-16: when the user clicks by left button or right-click menu when triggering download event, obtain the url (uniform resource locator) of file by the IE supplementary module, obtain filesize (file size) then from the Source Site, lastmodtime (file is revised the date at last), according to url, filesize, lastmodtime as input parameter, according to MD5 algorithm computation outfile characteristic information urlmd5.
As b step among Fig. 4-16: obtained by client piecemeal submodule file to be carried out piecemeal after the document size information and handled, obtained the sequence number blockseq of blocks of files.
As c step among Fig. 4-16: client file information is to the urlmd5 of block message inquiry submodule with file, the sequence number blockseq information of blocks of files and the uuid that is used to carry out user's authenticating operation, cookie information is sent the request of the characteristic information of inquiry file piece to the centralized indexes server, the authentification of user submodule is at first according to uuid in the server end user management module, cookie information is carried out user's authenticating operation, after authentication is passed through, server end fileinfo to block message submodule inquires urlid from database table urlmd5_to_urlid, from database table urlseq_to_blockmd5, inquire the characteristic information blockmd5 of blocks of files with the sequence number blockseq of blocks of files and the urlid that inquires, the characteristic information blockmd5 of this document piece is transmitted back client.If above-mentioned query manipulation does not inquire the result, then return error message, the operation of file in download is directly downloaded by the client source website and is realized that submodule carries out from the Source Site.
As d step among Fig. 4-16: client is behind the characteristic information blockmd5 that receives the blocks of files that server end returns, send request by client block message to user profile inquiry submodule to server end, with uuid, cookie, blockmd5 information sends to server end, handle by server end block message to user profile submodule, specifically: the authentification of user submodule at first carries out authenticating operation according to user uuid and cookie in the server end user management module, after authentication is passed through, characteristic information blockmd5 Query Database table blockmd5_to_blockid according to the next blocks of files of client transmission obtains corresponding blockid, be the uuid that condition query database table blockid_to_uuid obtains a plurality of users with this blockid again, from database table uuid, inquire the Intranet IP address information internal_ip and the outer net IP address information external_ip of relative users at last according to each uuid, this uuid, internal_ip, external_ip information is formed the user profile tabulation, and this user profile tabulation is turned back to client.If mistake appears in above-mentioned query manipulation, then client is returned in error message, the client source website is downloaded the realization submodule and is realized down operation from the Source Site.
As e step among Fig. 4-16: after server end is passed the user profile tabulation back client, client downloads realizes that P2P downloads submodule according to the user profile tabulation of returning from the centralized indexes server end in the submodule, ask the download from this user profile tabulation that client there transfer files piece is provided successively, if request error, then from the user profile tabulation, attempt next, if all mistake is then downloaded from the Source Site.
As f step among Fig. 4-16: the blocks of files after the download stores blocks of files into local file destination by client's end block sub module stored, also blocks of files will be stored in the local cache simultaneously, so that provide end for down operation provides to download.
As g step among Fig. 4-16: through after the above-mentioned operation, the storage of client's end block is reported submodule and is reported information and the user ID that is stored in blocks of files in the local cache to server, specifically: with uuid, cookie, blockmd5 uploads onto the server, the authentification of user submodule is at first according to uuid in the server end user management module, cookie carries out authenticating operation, after the authentication permission, the storage of server end block is reported submodule and whether is had corresponding blockid according to blockmd5 inquiry blockmd5_to_blockid table, if there has been the information stores of this piece, whether then consistent with the information that other users report by this information of server end block check module verification, main operation is that the blockmd5 that cash is reported is compared with the blockmd5 value of identical blockid.If consistent, then inserting the uuid with this blockid and report in the blockid_to_uuid table is the new record of content.If inconsistent, then need inquire about the numerical value of the saved_count among the urlseq_to_blockmd5, whether less than certain particular value (this value is an empirical value); If less than former all record deletions then, and with the blockid_to_uuid that deposits in of the uuid of blockid and report, otherwise, send the request of reporting an error to the keeper, carry out manual abnormality processing.
As h step among Fig. 4-16: all blocks of files are all passed through above-mentioned downloading process, when all blocks of files of file download finish after, by the client file sub module stored file is merged, preserve this document.
As i step among Fig. 4-16: and report submodule by client file and carry out fileinfo and report the work, this client file is reported submodule with uuid, url, urlmd5, filesize, lastmodtime, cookie information is reported to server end, the authentification of user submodule is at first according to uuid in the server end user management module, cookie information is carried out user's authenticating operation, and after authentication was passed through, the server end file storage was reported submodule according to urlmd5 inquiry urlmd5_to_urlid table, judge whether to exist corresponding urlid, if exist, then do not store, withdraw from this module operation.If do not exist, then in the urlmd5_to_urlid table, create a new record corresponding fileinfo is stored.