Background technology
Distributed file system includes client and service end.Client and service end are indivisible entirety, to be made
With distributed file system, it is necessary to be accessed by client, substantial amounts of data content is stored by service end.
Distributed type file system client side program, can be by local electricity as the access layer in the structural model of storage system
The file of brain is saved in the server on internet, can also operate the system as operation local file system.Simultaneously
User can rapidly access at any time by other computers for being provided with the distributed type file system client side and acquisition belongs to this
The file of user.
The problem of file-sharing problem is individual long-standing, is naturally also to keep away in distributed type file system client side
Exempt from, to handle this problem well, the security of data should be ensured, ensure the high efficiency of processing mode again, in order to avoid influence
The overall performance of program.
Usual user must provide two patterns when asking a file, one is request mode, the i.e. user need
What operation (reading and writing, deletion and combinations thereof) is carried out to file, the second is shared model, the i.e. user allow other users to enter
What operation of row.For identical file, system can preserve its request mode and shared mould for the user of all this files of request
Formula, and ensure that request (shared) pattern of any user does not conflict with shared (request) pattern of other users.Collision detection
The problem of being one most important, be that assuring data security is essential, and most straightforward approach is by the request of new user
(shared) pattern is compared one by one with shared (request) pattern of all users before, although this method is simple, easily realize,
Efficiency is very low.For NFS, this poor efficiency can cause the Consumer's Experience of extreme difference.
The content of the invention
In view of this, it is a primary object of the present invention to provide a kind of method of multiple users share identical file, this method
It is that can effectively improve the management service efficiency of file-sharing.
In order to achieve the above object, technical scheme proposed by the present invention is:
A kind of implementation method of multiple users share identical file, it is characterised in that including:
Step 101, when distributed file system receive to a shared file F carry out file operation request when, according to
Shared file F file described in request mode information and shared model information in the request and currently safeguard one group
Operational counter, conflict inspection is carried out to the request;The file operation includes any group of reading and writing and/or deletion action
Close;
Step 102, when the inspection result is the presence of conflict, sent to the corresponding user of the request and ask failure
Configured information;
Step 103, when the inspection result is in the absence of conflict, set up the operation of corresponding client file for the request
Object ClientFile, and request mode information and shared model information in the request, update the shared file F
File operation counter;When the operation of the request is completed, the client file operation object is destroyed, is asked according to described
Request mode information and shared model information in asking, update the file operation counter of the shared file F.
In summary, the implementation method of multiple users share identical file proposed by the present invention, is that each shared file is matched somebody with somebody
One group of file operation counter is put, when there is new file operation requests, the request mode that is provided according to the request and shared
Pattern, and the one group of user's counter currently safeguarded, can quickly judge whether asked file operation can cause text
The shared collision problem of part, therefore, it can effectively improve the management service efficiency of multiple users share identical file.
Embodiment
It is right below in conjunction with the accompanying drawings and the specific embodiments to make the object, technical solutions and advantages of the present invention clearer
The present invention is described in further detail.
The present invention core concept be:Shared file is needed for each, configures and safeguards one group of user's counter,
For to currently this document is read and write, deleted and do not share reading and writing, the user that deletes counts, so, when having
During new file operation requests, the request mode and shared model that can be provided according to the new file operation requests, and work as
One group of user's counter of preceding maintenance, quickly judges whether asked file operation can cause the conflict of file-sharing to be asked
Topic, so as to improve the management service efficiency of multiple users share identical file.
Fig. 1 is the schematic flow sheet of the embodiment of the present invention one, as shown in figure 1, the embodiment mainly includes:
Step 101, when distributed file system receive to a shared file F carry out file operation request when, according to
Shared file F file described in request mode information and shared model information in the request and currently safeguard one group
Operational counter, conflict inspection is carried out to the request.
The file operation includes any combination of reading and writing and/or deletion action.
In this step, system is when receiving file operation requests, it is necessary to conflict inspection first be carried out, here with existing system
Except that, it is necessary to one group of file operation counter is safeguarded for each shared file, for counting for the shared text
The request number of times for each file operation that part has currently received and do not completed and it is current received and do not completed each file is grasped
The number of times do not shared is asked, so as to based on this progress conflict inspection.So only need to asking according to current request file operation
Ask one group of counter of pattern information and shared model information and shared file that conflict can be achieved to check, without considering
Other have received the request mode information and shared model information of request, and therefore, implementation complexity is very low, can effectively improve file
Shared management service efficiency.
Specifically, one group of file operation counter can include following counter:
For counting the current request counter that read operation is carried out for the shared file F for having received and not completed
S1;
For counting the current request counter that write operation is carried out for the shared file F for having received and not completed
S2;
For counting the current request counting number that deletion action is carried out for the shared file F for having received and not completed
Device S3;
For counting the current request counting number for not sharing read operation for the shared file F for having received and not completed
Device S4;
For counting the current request counting number for not sharing write operation for the shared file F for having received and not completed
Device S5;
Based on counting the current number of request for not sharing deletion action for the shared file F for having received and not completed
Number device S6.
It is preferred that carrying out conflict for the request checks that the specific conflict judgment rule of when institute's foundation is as follows:
When request mode packet when containing read operation of the request, if the counter S4 is more than 0, judge exist
Conflict;
When request mode packet when containing write operation of the request, if the counter S5 is more than 0, judge exist
Conflict;
When request mode packet when containing deletion action of the request, if the counter S6 is more than 0, judgement is deposited
In conflict;
When the shared model information of the request does not include read operation, if the counter S1 is more than 0, judgement is deposited
In conflict;
When the shared model information of the request does not include write operation, if the counter S2 is more than 0, judgement is deposited
In conflict;
When the shared model information of the request does not include deletion action, if the counter S3 is more than 0, judge
In the presence of conflict.
Step 102, when the inspection result is the presence of conflict, sent to the corresponding user of the request and ask failure
Configured information.
Here the request of the file operation will be refused when checking conflict, to avoid grasping with accepted file before
Clashed as request, it is ensured that the reliability of file-sharing.Therefore will be sent in this step to the user for sending file request please
Seek the information of failure.
Step 103, when the inspection result is in the absence of conflict, set up the operation of corresponding client file for the request
Object ClientFile, and request mode information and shared model information in the request, update the shared file F
File operation counter;When the file operation of the request is completed, described client file operation object is destroyed, according to
Request mode information and shared model information in the request, update the file operation counter of the shared file F.
In this step, when checking current request and accepted ongoing file operation is not clashed,
Then receive the request, be that it sets up client file operation object, so that user is using the client file operation object
Carry out file operation, specifically, user using the client file operation object progress file operation method compared with system,
It will not be repeated here.
Here with existing system except that, receive request when and request file operation complete when, be required to
One group of file operation counter of shared file is updated accordingly, i.e., needed when receiving request by the request
The value that request mode information and shared model information distinguish corresponding counter carries out Jia one accordingly, is completed in file operation
When, the value of the corresponding counter respectively of the request mode information and shared model information in the request is subtracted accordingly
One, to ensure validity that this group of file operation counter of shared file is counted to file operation, and then ensure file-sharing
Reliability.
In summary, presently preferred embodiments of the present invention is these are only, is not intended to limit the scope of the present invention.
Within the spirit and principles of the invention, any modification, equivalent substitution and improvements made etc., should be included in the present invention's
Within protection domain.