Summary of the invention
The object of the present invention is to provide a kind of equipment and method that prevents that buffer memory from overflowing; In UNIX or linux system; Through predicting that possible caching system overflows temporary file is moved to equipment and the method that prevents in the NFS that buffer memory from overflowing; Because migration/carry is not whole file system, so can guarantee the not obvious deterioration of the operation of operation.
According to an aspect of the present invention; A kind of equipment that prevents that buffer memory from overflowing is provided; Comprise: the migration judge module, be used for size according to said temporary file, calculate the threshold value of remaining space size in the local buffer according to predetermined algorithm; Calculate remaining space size actual in the current local buffer; The threshold value of remaining space size is compared with actual remaining space size, if the threshold value of remaining space size greater than the remaining space size of reality, is then confirmed to carry out the temporary file migration; The file migration module is moved to temporary file under the expected objective catalogue, and under the catalogue of local buffer, is established to the soft link of the temporary file of migration; The buffer memory monitoring module; The monitoring application job is to the operation of temporary file in the local buffer; When detecting temporary file to local buffer and carry out write operation; Control migration judge module determines whether to carry out the temporary file migration, if confirm to carry out the temporary file migration, then the control documents transferring module is carried out the temporary file migration.
On said equipment, can move UNIX or linux system, and said expected objective catalogue is preferably the predetermined file catalogue in the NFS.
The migration judge module can calculate the threshold value Phi of remaining space size according to following formula: Φ=k * a, and wherein, a is the size of single temporary file, k is a weighting coefficient, is worth for greater than 1 integer.
Said equipment can be confirmed the value of k according to the speed of the I/O of system.
At least one equal-sized temporary file can be arranged in the local buffer; And if the migration judge module is confirmed the remaining space size of the threshold value of remaining space size less than reality; Then move the number of judge module based on the definite temporary file that will move of threshold value of remaining space size, and according to the definite file that will move of the principle of first in first out.
Preferably, said equipment also comprises the migration logging modle, is used to write down the status information of temporary file migration, and said status information comprises filename, access rights, target location and the user mode of the temporary file of migration.
Preferably, said equipment also comprises the cleaning module, is used for after the buffer memory monitoring module confirms to accomplish application job, removing the temporary file under the target directory according to the status information of record.
According to a further aspect in the invention; A kind of method that prevents that buffer memory from overflowing is provided; Comprise of the operation of monitoring application job to temporary file in the local buffer; When carrying out write operation, temporary file to local buffer carries out following steps when detecting:, calculate the threshold value of remaining space size in the local buffer according to predetermined algorithm according to the size of said temporary file; Calculate remaining space size actual in the current local buffer; The threshold value of remaining space size is compared with actual remaining space size; If the threshold value of remaining space size is then moved to temporary file under the expected objective catalogue, and under the catalogue of local buffer, is established to the soft link of the temporary file of migration greater than the remaining space size of reality.
Can under UNIX or Linux environment, carry out said method, and said expected objective catalogue is preferably the predetermined file catalogue in the NFS.
Can calculate the threshold value Phi of remaining space size according to following formula: Φ=k * a, wherein, a is the size of single temporary file, k is a weighting coefficient, is worth for greater than 1 integer.
Can confirm the value of k according to the speed of the I/O of system.
At least one equal-sized temporary file can be arranged in the local buffer; And if the threshold value of remaining space size is less than the remaining space size of reality; The number of the temporary file of then confirming to move based on the threshold value of remaining space size, and confirm the file that will move according to the principle of first in first out.
Can also write down the status information of temporary file migration, said status information comprises filename, access rights, target location and the user mode of the temporary file of migration.
After accomplishing application job, can remove the temporary file under the target directory according to the status information of record.
Embodiment
Below, specify embodiments of the invention with reference to accompanying drawing.
Usually, operating system in local file system, distribute the buffer zone of predetermined size deposit wherein as application program between the storage space of data, be called local buffer at this.The background program that prevents that equipment that buffer memory overflows and method can be embodied as computer system of the present invention, the visit and the use of its monitoring local buffer.When the write operation that detects the temporary file in the local buffer; Calculate the threshold value of a local buffer remaining space size based on the size of temporary file; When the size of confirming the remaining space that local buffer is actual during less than the threshold value of remaining space size; The temporary file of local buffer is moved in the NFS under the expected objective catalogue; And set up with the said target directory that moves under the linking of temporary file, thereby the operation of carrying out write operation is operated the temporary file under the NFS.
Fig. 1 illustrates the logic diagram that prevents the equipment that buffer memory overflows according to of the present invention.
With reference to Fig. 1, be used to prevent that according to of the present invention the equipment that buffer memory removes from comprising that buffer memory monitoring module 110, migration are provided with module 120, migration judge module 130 and file migration module 140.
Buffer memory monitoring module 110 monitoring application jobs are to the operation of local buffer.During the write operation of buffer memory monitoring module 110 temporary file in detecting, determine whether to carry out the migration of temporary file through migration judge module 130 to local buffer.When migration judge module 130 need to confirm the migration temporary file; Buffer memory monitoring module 110 control documents transferring module 140 are moved to temporary file under the target directory in the NFS of appointment; And foundation links with the soft of temporary file under the target directory, thereby the write operation of application job is able to continue to carry out.
Migration is provided with module 120 and is used to store and the relevant information of temporary file migration is set.Said temporary file moves relevant information and includes but not limited to, the information of assigned catalogue under the NFS of parameter that temporary file migration judgement is relevant and conduct migration target directory.But according to exemplary embodiment of the present invention, the relevant information of said temporary file migration can be predefined constant, and in the case, the equipment that prevents that buffer memory from overflowing of the present invention can not comprise that migration is provided with module 120.
Migration judge module 130 is used to judge currently whether need carry out the migration of temporary file.Specifically; Migration judge module 130 is according to the size of temporary file; The threshold value of calculating remaining space size in the local buffer according to predetermined algorithm (just; The minimum remaining space size that can not cause buffer memory to overflow of prediction), calculate remaining space size actual in the current local buffer, the threshold value with the remaining space size compares with actual remaining space size then.If the threshold value of remaining space size greater than the remaining space size of reality, is then moved judge module 130 and is confirmed to carry out the migration of temporary file.
To the calculating of the threshold value of remaining space size in the above-mentioned local buffer,, can confirm the threshold value Phi of said remaining space size according to following algorithm according to exemplary embodiment of the present invention:
Φ=k×a,
Wherein, a is the size of single temporary file, and k is a weighting coefficient, and the value of k is the integer (as 3 or 5) greater than 1.The value major decision of parameter k the size of Φ.Can confirm the value of k according to the I/O speed of system or file system, can be the k assignment according to the empirical value that experiment draws also.Certainly k is big more, prevents that the security that local cache overflows from improving, but under the situation that produces frequent temporary file migration, the operation response of application job is with deterioration.Can use the k value of constant regularly, also module 120 storage k values are set through migration.In the case, migration judge module 130 is provided with module 120 from migration and transfers the k value.
File migration module 140 is provided with the target directory information of module 120 according to migration, and temporary file is moved under the said target directory in the NFS.Said migration operation is meant temporary file is copied under the target directory, and deletion temporary file original.On this basis, file migration module 140 is being the information that said temporary file is set up the temporary file under the target directory of having moved under the catalogue of local buffer.Under UNIX or Linux environment, use the ln order to set up said soft link.
According to exemplary embodiment of the present invention; When handling super amount intermediate data; Often create a plurality of equal-sized temporary files (according to the configuration of temporary file size and the size of local buffer, last of said a plurality of temporary files maybe less than other temporary file) in local buffer.Which at this moment, when confirming to carry out the temporary file migration, need to confirm the several temporary files of migration and move temporary file.At this moment, move the number of judge module 130 based on the definite temporary file that will move of threshold value of the remaining space size of calculating, and according to the definite file that specifically will move of the principle of first in first out.For example, if local buffer has the space of 10G, existing 4 temporary files, each temporary file are the 2G size, and the k in the above-mentioned formula is 3, and the threshold value of the remaining space size of then calculating is 6G.The remaining space of current reality is 2G, so according to exemplary embodiment of the present invention, can confirm to move 2 temporary files.According to another exemplary embodiment of the present invention, also can confirm to move 3 temporary files.
According to a preferred embodiment of the invention, the equipment that prevents that buffer memory from overflowing of the present invention also comprises migration logging modle 150.When file migration module 140 was carried out the temporary file migration operation, migration logging modle 150 write down the status information of temporary files migration, comprises the information such as filename, access rights, target location and user mode of each temporary file of migration.
According to another preferred embodiment of the invention, the equipment that prevents that buffer memory from overflowing of the present invention also comprises cleaning module 160.When buffer memory monitoring module 110 confirms that application job has been accomplished; Cleaning module 160 is under the control of buffer memory monitoring module 110; The status information that the temporary file that writes down according to migration logging modle 150 moves; Corresponding soft link under the deletion local buffer catalogue and the corresponding temporary file under the target directory, and through the corresponding status information of migration logging modle 150 deletions.
This shows; Prevent that according to of the present invention equipment that buffer memory overflows is when the application job needs carry out write operation; Calculate minimum safe remaining space size according to predetermined algorithm; Through the safe remaining space size of said minimum and the size in real surplus space are compared to confirm whether local buffer has enough spaces to be used for operation; If confirm the current enough big spatial cache that do not have, then incite somebody to action the peer link that part or all of (when having only a temporary file) temporary file is moved under the intended target catalogue in the NFS temporarily and is established to the file of having moved, the temporary file that application job is had moved through said links and accesses.Like this, guarantee that local cache does not overflow, simultaneously the response of also not obvious deterioration application job.
Fig. 2 illustrates the process flow diagram that prevents the method that buffer memory overflows according to of the present invention.
With reference to Fig. 2, according to visit and the operation that prevents monitoring of equipment application job that buffer memory overflows to the temporary file of local buffer of the present invention.At step S210, determine whether the temporary file to local buffer is carried out write operation.To carry out write operation to the temporary file of local buffer if confirm; Then at step S220; Said equipment is according to the size of temporary file; Calculate the threshold value (the minimum remaining space size that can not cause buffer memory to overflow of prediction just) of remaining space size in the local buffer according to predetermined algorithm.According to exemplary embodiment of the present invention, can confirm the threshold value Phi of said remaining space size according to following algorithm:
Φ=k×a,
Wherein, a is the size of single temporary file, and k is a weighting coefficient, and the value of k is the integer (as 3 or 5) greater than 1.The value major decision of parameter k the size of Φ.Can confirm the value of k according to the I/O speed of system or file system, can be the k assignment according to the empirical value that experiment draws also.Certainly k is big more, prevents that the security that local cache overflows from improving, but under the situation that produces frequent temporary file migration, the operation response of application job is with deterioration.Can use the k value of constant regularly, also module 120 storage k values are set through migration.In the case, migration judge module 130 is provided with module 120 from migration and transfers the k value.
At step S230, remaining space actual in the current local buffer of said calculation of equipments is big or small.
At step S240, said equipment compares with actual remaining space size through the threshold value with the remaining space size and determines whether to carry out the temporary file migration.If confirm the remaining space size (need carry out temporary file migration) of the threshold value of remaining space size greater than reality; Then at step S250; Temporary file is moved under the expected objective catalogue; And step S260 is established to the soft link of the temporary file of migration under the catalogue of local buffer.
Exist in local buffer under the situation of a plurality of temporary files,, also confirm the several temporary files of migration and move which temporary file when when step S240 confirms to select the migration of carrying out temporary file for use.At this moment, based on the number of the big or small definite temporary file that will move of threshold value of the remaining space that calculates, and according to the definite file that specifically will move of the principle of first in first out.At step S250 and S260, the temporary file of confirming migration is moved under the target directory, and set up soft link for the temporary file of said migration.
According to a preferred embodiment of the invention; When carrying out the migration of temporary file at step S250 and S260 and setting up soft link; Also write down the status information of temporary file migration, comprise the information such as filename, access rights, target location and user mode of each temporary file of migration.According to another preferred embodiment of the invention; When definite application job has been accomplished; The status information of also moving according to the temporary file that writes down, corresponding soft link under the deletion local buffer catalogue and the corresponding temporary file under the target directory, and the corresponding status information of deletion record.
Prevent that according to of the present invention method that buffer memory overflows is when the application job needs carry out write operation; Through guaranteeing that local buffer has enough spaces; And incite somebody to action the peer link that part or all of (when having only a temporary file) temporary file is moved under the intended target catalogue in the NFS temporarily and is established to the file of having moved in case of necessity, the temporary file that application job is had moved through said links and accesses.Like this, guarantee that local cache does not overflow, simultaneously the response of also not obvious deterioration application job.
Although represent with reference to preferred embodiment and described the present invention, it should be appreciated by those skilled in the art that under the situation that does not break away from the spirit and scope of the present invention that are defined by the claims, can carry out various modifications and conversion to these embodiment.