Disclosure of Invention
In view of the above, the present invention has been made to provide a method, apparatus and system for acquiring a file that overcomes or at least partially solves the above problems.
According to an aspect of the present invention, there is provided a method for acquiring a file, which is applied to a file processing server, and includes:
receiving a file acquisition request from the client, which is forwarded by the web cluster;
when determining that the file content requested by the file acquisition request is not stored locally, waiting for a monitoring notification from a file monitoring server, wherein the monitoring notification carries new file content generated due to system file change;
when the monitoring notification is received, reading the new file content carried in the monitoring notification, and further judging whether the new file content contains an end mark indicating that the file is ended; if the end mark is contained, deleting the end mark, and sending the deleted file content to the web cluster so as to forward the deleted file content to the client by the web cluster; if the end mark is not included, forwarding the new file content to the web cluster so that the new file content is forwarded to the client by the web cluster, and continuing to receive a monitoring notification carrying the new file content from the file monitoring server until the new file content includes the end mark.
Optionally, if it is determined that the file content requested by the file obtaining request is locally stored, sending the requested file content to the web cluster, so that the requested file content is forwarded to the client by the web cluster.
Optionally, when waiting for a monitoring notification from the file monitoring server, which carries new file content generated due to a change of the system file, the method further includes:
if the file monitoring server monitors that the system file is created, modified or deleted, the file generation server generates the new file content according to the created, modified or deleted system file and sends the new file content to the file monitoring server, and then receives a monitoring notice carrying the new file content from the file monitoring server.
Optionally, the method further comprises: monitoring, by the file monitoring server, a network connection status between the client and the web cluster;
if the file monitoring server monitors that the file acquisition request sent by the client to the web cluster is disconnected when reading the new file content carried in the monitoring notification, the reading of the new file content is interrupted, and an interruption notification message is sent to the web cluster, so that the interruption notification message is forwarded to the client by the web cluster.
Optionally, when waiting for a monitoring notification from the file monitoring server, which carries new file content generated due to a change of the system file, the method further includes:
judging whether the waiting time for waiting for the monitoring notice from the file monitoring server exceeds the preset time or not;
if not, when the monitoring notification is received, reading the new file content carried in the monitoring notification, and further judging whether the new file content contains an end mark indicating that the file is ended;
if so, determining that the file acquisition request fails, and sending a notification message of the file acquisition request failure to the web cluster so that the notification message of the file acquisition request failure is forwarded to the client by the web cluster.
Optionally, the file obtaining request includes any one of:
a hypertext transfer protocol request, a hypertext transfer security protocol request, and a file transfer protocol request.
According to another aspect of the present invention, there is also provided a method for acquiring a file, which is applied to a file monitoring server, and includes:
monitoring system file changes;
when the system file is monitored to be changed, receiving new file content after the change;
and carrying the received new file content in a monitoring notice and sending the new file content to a file processing server, so that the file processing server sends the new file content to a web cluster, and then the web cluster sends the new file content to a client.
Optionally, when the system file is monitored to be changed, receiving new file content after the change, including:
when the system file is monitored to be created, modified or deleted, the file generation server receives new file contents from the file generation server after generating the new file contents according to the created, modified or deleted system file.
Optionally, the method further comprises: monitoring the network connection state between the client and the web cluster;
and if the file acquisition request sent by the client to the web cluster is monitored to be disconnected, triggering the file processing server to interrupt the reading of the new file content, and triggering the file processing server to send an interrupt notification message to the web cluster, so that the interrupt notification message is forwarded to the client by the web cluster.
According to still another aspect of the present invention, there is provided an apparatus for acquiring a file, which is applied to a file processing server, and includes:
a first receiving module, adapted to receive a file acquisition request from the client forwarded by a web cluster;
the determining module is suitable for waiting for a monitoring notice which comes from a file monitoring server and carries new file contents generated due to system file changes when the file contents requested by the file obtaining request are not stored locally;
the reading module is suitable for reading the new file content carried in the monitoring notice when the monitoring notice is received, and further judging whether the new file content contains an end mark indicating that the file is ended;
the first sending module is suitable for deleting the end mark if the new file content contains the end mark, and sending the deleted file content to the web cluster so as to forward the deleted file content to the client by the web cluster;
if the new file content does not contain the end mark, forwarding the new file content to the web cluster so that the new file content is forwarded to the client by the web cluster, and continuously receiving a monitoring notification carrying the new file content from the file monitoring server until the new file content contains the end mark.
Optionally, if the determining module determines that the file content requested by the file obtaining request is locally stored, the first sending module forwards the requested file content to the web cluster, so that the requested file content is forwarded to the client by the web cluster.
Optionally, the first receiving module is further adapted to: if the file monitoring server monitors that the system file is created, modified or deleted, the file generation server generates the new file content according to the created, modified or deleted system file and sends the new file content to the file monitoring server, and then receives a monitoring notice carrying the new file content from the file monitoring server.
Optionally, the apparatus further comprises an interrupt module adapted to: when the reading module reads the new file content carried in the monitoring notification, the file monitoring server monitors that a file acquisition request sent to the web cluster by the client is disconnected, interrupts reading of the new file content, and triggers the first sending module to send an interrupt notification message to the web cluster, so that the interrupt notification message is forwarded to the client by the web cluster.
Optionally, the apparatus further comprises a determining module adapted to: judging whether the waiting time for waiting for the monitoring notice from the file monitoring server exceeds the preset time or not;
if not, when the monitoring notification is received, the reading module reads the new file content carried in the monitoring notification, and further judges whether the new file content contains an end mark indicating that the file is ended;
if so, determining that the file acquisition request fails, and sending a notification message of the file acquisition request failure to the web cluster by the first sending module, so that the notification message of the file acquisition request failure is forwarded to the client by the web cluster.
Optionally, the file obtaining request includes any one of: a hypertext transfer protocol request, a hypertext transfer security protocol request, and a file transfer protocol request.
According to still another aspect of the present invention, there is provided an apparatus for acquiring a file, which is suitable for a file monitoring server, and includes:
the monitoring module is suitable for monitoring system file changes;
the second receiving module is suitable for receiving the changed new file content when the system file is monitored to be changed;
the second sending module is suitable for carrying the received new file content in the monitoring notice and sending the new file content to the file processing server, so that the file processing server sends the new file content to the web cluster, and then the web cluster sends the new file content to the client.
Optionally, the second receiving module is further adapted to: when the monitoring module monitors that the system file is created, modified or deleted, the file generation server generates new file content according to the created, modified or deleted system file, and then receives the new file content from the file generation server.
Optionally, the monitoring module is further adapted to: monitoring the network connection state between the client and the web cluster;
and if the file acquisition request sent by the client to the web cluster is monitored to be disconnected, triggering the file processing server to interrupt the reading of the new file content, and triggering the file processing server to send an interrupt notification message to the web cluster, so that the interrupt notification message is forwarded to the client by the web cluster.
According to another aspect of the present invention, there is also provided a system for acquiring a file, including a client, a web cluster, a file processing server and a file monitoring server,
the client is suitable for sending a file acquisition request to the web cluster;
the web cluster is suitable for receiving the file acquisition request and forwarding the file acquisition request to the file processing server;
the file processing server is suitable for receiving the file acquisition request forwarded by the web cluster, and waiting for a monitoring notification from the file monitoring server when determining that the file content requested by the file acquisition request is not stored in the file processing server;
the file monitoring server is suitable for monitoring the change of the system file, receiving the changed new file content, carrying the new file content in a monitoring notice and sending the new file content to the file processing server;
the file processing server is further adapted to read the new file content carried in the monitoring notification when the monitoring notification is received, and further determine whether the new file content includes an end mark indicating that the file has ended; if the end mark is contained, deleting the end mark, and sending the deleted file content to the web cluster; if the new file content does not contain the end mark, forwarding the new file content to the web cluster, and continuously receiving a monitoring notification carrying the new file content from the file monitoring server until the new file content contains the end mark;
the web cluster is further adapted to forward file content received from the file processing server to the client.
Optionally, the web cluster is further adapted to: and selecting a web server for receiving the file acquisition request in the web cluster according to a load balancing algorithm.
Optionally, the file processing server is further adapted to: and if the file processing server is determined to store the file content requested by the file acquisition request, sending the requested file content to the web cluster.
Optionally, the system further comprises a file generation server adapted to: and if the file monitoring server monitors that the system file is created, modified or deleted, generating the new file content according to the created, modified or deleted system file and sending the new file content to the file monitoring server.
Optionally, the file generation server is further adapted to: and if the new file content is the complete file content of the request, adding the end mark in the new file content.
Optionally, the file monitoring server is further adapted to: monitoring the network connection state between the client and the web cluster;
and if the file acquisition request sent to the web cluster by the client is monitored to be disconnected when the file processing server reads the new file content carried in the monitoring notification, triggering the file processing server to interrupt reading of the new file content and triggering the file processing server to send an interrupt notification message to the web cluster, so that the interrupt notification message is forwarded to the client by the web cluster.
Optionally, the file processing server is further adapted to: judging whether the waiting time for waiting for the monitoring notice from the file monitoring server exceeds the preset time or not;
if not, when the monitoring notification is received, reading the new file content carried in the monitoring notification, and further judging whether the new file content contains an end mark indicating that the file is ended;
if so, determining that the file acquisition request fails, and sending a notification message of the file acquisition request failure to the web cluster so that the notification message of the file acquisition request failure is forwarded to the client by the web cluster.
Optionally, the file obtaining request includes any one of: a hypertext transfer protocol request, a hypertext transfer security protocol request, and a file transfer protocol request.
In the embodiment of the invention, when the file processing server receives a file acquisition request from the client, which is forwarded by the web cluster, and determines that the file content requested by the file acquisition request is not stored locally, the file processing server can select to wait for a monitoring notification from the file monitoring server, which carries new file content generated due to the change of the system file. If the file processing server receives the monitoring notification sent by the file monitoring server and knows that the new file content carried in the monitoring notification contains the end mark through judgment, the new file growth is finished, the file processing server can send the file content with the end mark deleted to the web cluster, and then the web cluster forwards the file content to the user. If the new file content does not include the end mark, it indicates that the new file is growing, i.e. the requested file content requested by the user is in a dynamic growth state, and the file processing server needs to continue to wait for the monitoring notification of the file monitoring server until the new file content includes the end mark. Therefore, no matter whether the file content requested by the user is in a dynamic growth state or not, the scheme of the invention can ensure that the user can acquire the requested file content in time. Particularly, if it is known through the judgment that the new file content does not include the end flag, that is, the requested file content requested by the user is in the dynamic growth state, the file processing server will wait for the monitoring notification of the file monitoring server, timely receive the generated new file content until the new file content includes the end flag, and when the new file content includes the end flag, the file content requested by the user at this time is completely acquired. In the process, the user does not need to acquire the requested file content after waiting for all the requested file content to be generated, so that the file acquisition instantaneity can be effectively improved, the time for the user to wait for the requested file content to be generated is reduced, and the operation experience of the user is further improved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments thereof, taken in conjunction with the accompanying drawings.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to solve the above technical problem, an embodiment of the present invention provides a method for obtaining a file, which is applicable to a file processing server. Fig. 1 is a flowchart illustrating a method for acquiring a file according to an embodiment of the present invention. Referring to fig. 1, the method includes at least steps S102 to S110.
Step S102, receiving a file acquisition request from a client forwarded by a web cluster.
In this step, the File acquisition request may be in the form of a hypertext Transfer Protocol (HTTP), a hypertext Transfer Protocol secure Socket L layer, a File Transfer Protocol (FTP), and the like.
In this step, the web cluster may include a plurality of web servers, such as an Nginx server, an Internet server, and the like, and the type of the server in the embodiment of the present invention is not particularly limited.
And step S104, when determining that the file content requested by the file acquisition request is not stored locally, waiting for a monitoring notification from the file monitoring server, wherein the monitoring notification carries new file content generated due to system file change.
In this step, the file monitoring server may monitor the change of the system file, and may receive the new file content after the change. When the file monitoring server monitors that the system file changes, the file generation server is triggered to generate new file content, the new file content generated by the file generation server is received, and meanwhile the new file content is carried in the monitoring notification and sent to the file processing server.
And step S106, when the monitoring notice is received, reading the new file content carried in the monitoring notice, and judging whether the new file content contains an end mark for ending the file.
In this step, the end flag that the file has ended is actually an identifier indicating whether or not the file content requested by the file acquisition request has been completely generated. The ending mark may be a number, letter, a string, etc. If the new file content contains the end mark, it indicates that the file content requested by the file obtaining request is completely generated, and if the new file content does not contain the end mark, it indicates that the file content requested by the file obtaining request is not completely generated, only a part of the file content is generated, and at this time, the file content requested by the file obtaining request is in a dynamic growth state.
The ending mark in this step may be added to the new file content by the file generation server after the new file content is generated, or may be added to the new file content by the file monitoring server after the new file content sent by the file generation server is received, which is not limited in this embodiment of the present invention.
And step S108, if the end mark is included, deleting the end mark, and sending the deleted file content to the web cluster so as to enable the deleted file content to be forwarded to the client side by the web cluster.
Step S110, if the end mark is not included, the new file content is forwarded to the web cluster, so that the new file content is forwarded to the client by the web cluster, and the monitoring notification carrying the new file content from the file monitoring server is continuously received until the new file content includes the end mark.
In the embodiment of the invention, when the file processing server receives a file acquisition request from the client, which is forwarded by the web cluster, and determines that the file content requested by the file acquisition request is not stored locally, the file processing server can select to wait for a monitoring notification from the file monitoring server, which carries new file content generated due to the change of the system file. If the file processing server receives the monitoring notification sent by the file monitoring server and knows that the new file content carried in the monitoring notification contains the end mark through judgment, the new file growth is finished, the file processing server can send the file content with the end mark deleted to the web cluster, and then the web cluster forwards the file content to the user. If the new file content does not include the end mark, it indicates that the new file is growing, i.e. the requested file content requested by the user is in a dynamic growth state, and the file processing server needs to continue to wait for the monitoring notification of the file monitoring server until the new file content includes the end mark. Therefore, no matter whether the file content requested by the user is in a dynamic growth state or not, the scheme of the invention can ensure that the user can acquire the requested file content in time. Particularly, if it is known through the judgment that the new file content does not include the end flag, that is, the requested file content requested by the user is in the dynamic growth state, the file processing server will wait for the monitoring notification of the file monitoring server, timely receive the generated new file content until the new file content includes the end flag, and when the new file content includes the end flag, the file content requested by the user at this time is completely acquired. In the process, the user does not need to acquire the requested file content after waiting for all the requested file content to be generated, so that the file acquisition instantaneity can be effectively improved, the time for the user to wait for the requested file content to be generated is reduced, and the operation experience of the user is further improved.
Referring to step S102 above, in an embodiment of the present invention, when the web cluster receives a request from a client, a web server for receiving a file obtaining request may be selected in the web cluster according to a load balancing algorithm. Load balancing refers to dynamically adjusting the load condition of each station (e.g., server) in the system to eliminate or reduce the phenomenon of load imbalance of each station in the system as much as possible. The specific implementation method can be that the tasks on the heavy-load sites are transferred to other light-load sites, and the load balance of all the sites in the system is realized as much as possible, so that the throughput of the system is improved. In this embodiment, the file retrieval request may be distributed to the server with a lower load in the web cluster, so that the server with a lower load may process the file retrieval request task.
Referring to step S104 above, in an embodiment of the present invention, if the file processing server determines that the file content requested by the file obtaining request is locally stored, the file processing server may directly read the requested file content and send the file content to the web cluster, so that the requested file content is forwarded to the client by the web cluster. When the file content requested by the file acquisition request is sent to the web cluster, the requested file content can be packaged into a chunk form, and then the requested file content is sent to the web cluster in the chunk package form.
With continued reference to step S104 above, in an embodiment of the present invention, when the file monitoring server monitors that the system file changes, for example, the system file is created, deleted, or modified, the file generation server may generate new file content according to the created, modified, or deleted system file, so that the file monitoring server carries the generated new file content in the monitoring notification and sends the monitoring notification to the file processing server.
In this embodiment, when the file processing server waits for a monitoring notification from the file monitoring server, which carries new file content generated due to a change in the system file, it may further determine whether the file processing server needs to continue to wait for the monitoring notification by determining whether a waiting time for the monitoring notification from the file monitoring server exceeds a preset time. For example, the preset time may be 3 seconds, 4 seconds, 5 seconds, and the like, and the preset time is not specifically limited in the embodiment of the present invention.
If the waiting time of the file processing server for waiting the monitoring notification does not exceed the preset time, reading the new file content carried in the monitoring notification when the monitoring notification is received, and further judging whether the new file content contains an end mark indicating that the file is ended or not.
If the waiting time of the file processing server for waiting the monitoring notification exceeds the preset time, determining that the file acquisition request fails, sending a notification message of the file acquisition request failure to the web cluster by the file processing server, and forwarding the notification message of the request failure to the client by the web cluster. The notification message of the request failure may be in the form of voice, text, number, etc. For example, a text notification message "file acquisition failed, please acquire file again".
Referring to step S106, in an embodiment of the present invention, when the file processing server reads new file content carried in the monitoring notification, the file monitoring server monitors that the file acquisition request sent by the client to the web cluster is disconnected, for example, when any one of the client and the web cluster fails, the network is disconnected, or a user closes the client, refreshes a page displayed by the client, and the like, the connection of the file acquisition request between the client and the web cluster is disconnected. At this time, the file monitoring server triggers the file processing server to interrupt reading of new file contents, and the file processing server sends an interrupt notification message to the web cluster, and then the web cluster forwards the interrupt notification message to the client, so that the user knows that file acquisition fails.
In order to more clearly embody the embodiments of the present invention, the present invention will be described with reference to embodiments in a specific context. In this embodiment, the client is a "360-degree secure browser," and the file content requested by the file acquisition request is video content.
When a user opens the 360-degree safety browser and clicks the video on the 360-degree safety browser page, the 360-degree safety browser sends an http protocol request to the corresponding web cluster. When the web cluster receives the http protocol request, a web server with a lower current load can be selected to receive the http protocol request, and after the selected web server receives the http protocol request, the http protocol request is forwarded to the file processing server.
When a file processing server receives an http protocol request of a video file 'cheering', whether the content of the video file 'cheering' is stored in the local is determined, if yes, the video file 'cheering' is directly sent to a web server, and after transcoding and caching are carried out on the video file 'cheering' according to the sequence of a video timeline, the web server sends the transcoded video file to a '360-degree safety browser', so that the video 'cheering' is played on the '360-degree safety browser'.
If the file processing server is determined not to store the video file content of the 'cheering-opening', the file processing server can select to wait for the monitoring notification from the file monitoring server. When the file monitoring server monitors that a video file 'cheering-opening' in the system is created, the file generating server is triggered to generate the video file 'cheering-opening'. After the file generation server generates partial contents of the video file, the generated partial contents of the video file are sent to the file monitoring server, and then the file monitoring server carries the partial contents of the video file in a monitoring notice and sends the monitoring notice to the file processing server. After receiving the monitoring notification, the file processing server reads out part of the video file content from the monitoring notification, namely 'cheering open'.
If the file processing server knows that the content of the part of the video file 'cheering' does not contain the end mark through judgment, the content of the part of the video file 'cheering' is directly forwarded to the web server and continues to wait for the monitoring notification. Then, the web server transcodes and caches the received partial video file content according to the sequence of the video timeline, and then sends the content to the 360-degree safety browser. And then the 360-degree safe browser plays the received partial video file content 'cheering' according to the transcoding sequence.
And if the file processing server knows that the part of the video file content contains the end mark through judgment, deleting the end mark and sending the part of the video file content to the web server. The web server transcodes and caches the received part of the video file content according to the sequence of the video timeline, and then sends the part of the video file content to the 360-degree safety browser. And then the 360-degree safe browser plays the received partial video file content 'cheering' according to the transcoding sequence.
Of course, the above embodiments are merely illustrative, the file content requested by the file obtaining request is not limited to the video file, but may be any other file content, such as text file content, audio file content, and the like. However, the process of file acquisition is substantially the same, and this is not described in any more embodiments of the present invention.
The embodiment of the invention also provides another method for acquiring the file, which is suitable for the file monitoring server. Fig. 2 is a flowchart illustrating a method of acquiring a file according to another embodiment of the present invention. Referring to fig. 2, the method includes at least steps S202 to S206.
Step S202, system file change is monitored.
In this step, the monitoring system file change may specifically be various change states of the system file such as the system file being created, modified, or deleted.
And step S204, when the system file is monitored to be changed, receiving the changed new file content.
In this step, the changed new file content may be generated by the file generation server according to the created, modified or deleted system file.
Step S206, the received new file content is carried in the monitoring notice and sent to the file processing server, so that the file processing server sends the new file content to the web cluster, and then the web cluster sends the new file content to the client.
Referring to step S204 above, in an embodiment of the present invention, when the file monitoring server monitors that the system file is created, modified, or deleted, the file generation server may generate new file content according to the created, modified, or deleted system file and send the new file content to the file monitoring server, and then the file monitoring server forwards the received new file content to the file processing server.
In an embodiment of the present invention, the file monitoring server may be further configured to monitor a network connection status between the client and the web cluster. When it is monitored that a file acquisition request sent by a client to a web cluster is disconnected, for example, a failure occurs in any one of the client and the web cluster, a network is disconnected, or a user closes the client, refreshes a page displayed by the client, and the like, the connection of the file acquisition request between the client and the web cluster is disconnected. And triggering the file processing server to interrupt the reading of the new file content, and triggering the file processing server to send an interrupt notification message to the web cluster, so that the interrupt notification message is forwarded to the client by the web cluster, and the user knows that the file acquisition fails.
The embodiment of the invention utilizes the file monitoring server to monitor the change of the system file in real time, so that when the file monitoring server monitors the change of the system file, a user can acquire the generated new file content in time, thereby effectively improving the real-time property of acquiring the file.
Based on the same inventive concept, the embodiment of the invention also provides a device for acquiring the file, which is suitable for the file processing server. Fig. 3 is a schematic structural diagram of an apparatus for acquiring a file according to an embodiment of the present invention. Referring to fig. 3, the apparatus for acquiring a file 300 may include at least afirst receiving module 310, a determiningmodule 320, areading module 330, and afirst transmitting module 340.
The functions of the components or devices of the apparatus 300 for acquiring a file and the connection relationship between the components will now be described:
afirst receiving module 310 adapted to receive a file acquisition request from a client forwarded by a web cluster;
a determiningmodule 320, coupled to thefirst receiving module 310, adapted to wait for a monitoring notification from the file monitoring server carrying new file content generated due to a change of the system file when determining that the file content requested by the file obtaining request is not stored locally;
areading module 330, coupled to the determiningmodule 320, adapted to read, when the monitoring notification is received, new file contents carried in the monitoring notification, and further determine whether the new file contents include an end flag indicating that the file has ended;
thefirst sending module 340 is coupled to thereading module 330, and is adapted to delete the end mark if the new file content includes the end mark, and send the deleted file content to the web cluster, so that the deleted file content is forwarded from the web cluster to the client;
and if the new file content does not contain the end mark, forwarding the new file content to the web cluster so that the new file content is forwarded to the client by the web cluster, and continuously receiving a monitoring notice carrying the new file content from the file monitoring server until the new file content contains the end mark.
In an embodiment of the present invention, the file acquisition request includes any one of the following items: a hypertext transfer protocol request, a hypertext transfer security protocol request, and a file transfer protocol request.
In an embodiment of the present invention, if the determiningmodule 320 determines that the file content requested by the file obtaining request is locally stored, thefirst sending module 340 forwards the requested file content to the web cluster, so that the requested file content is forwarded from the web cluster to the client.
In an embodiment of the present invention, thefirst receiving module 310 is further adapted to, if the file monitoring server monitors that the system file is created, modified, or deleted, generate new file content by the file generating server according to the created, modified, or deleted system file, and send the new file content to the file monitoring server, and then receive a monitoring notification carrying the new file content from the file monitoring server.
The embodiment of the invention also provides another device for acquiring the file, which is suitable for the file processing server. Referring to fig. 4, the apparatus 300 for acquiring a file may further include at least aninterruption module 350 and adetermination module 360, in addition to the above modules in the apparatus 300 for acquiring a file (applicable to a file processing server).
The interruptingmodule 350 is coupled to thereading module 330, and is adapted to, when thereading module 330 reads new file content carried in the monitoring notification, monitor that the file acquisition request sent by the client to the web cluster is interrupted, interrupt reading of the new file content, and trigger thefirst sending module 340 to send an interrupt notification message to the web cluster, so that the interrupt notification message is forwarded from the web cluster to the client.
The determiningmodule 360 is coupled to the determiningmodule 320 and adapted to determine whether the waiting time for the monitoring notification from the file monitoring server exceeds a preset time. If not, when receiving the monitoring notification, thereading module 330 reads the new file content carried in the monitoring notification, and further determines whether the new file content includes an end flag indicating that the file has ended; if so, it is determined that the file acquisition request fails, and thefirst sending module 340 sends a notification message of the file acquisition request failure to the web cluster, so that the notification message of the request failure is forwarded to the client by the web cluster.
The embodiment of the invention also provides another device for acquiring the file, which is suitable for the file monitoring server. Fig. 5 is a schematic structural diagram of an apparatus for acquiring a file according to another embodiment of the present invention. Referring to fig. 5, the apparatus 500 for acquiring a file may include at least amonitoring module 510, asecond receiving module 520, and asecond sending module 530.
The functions of the components or devices of the apparatus 500 for acquiring a file and the connection relationship between the components will be described:
amonitoring module 510 adapted to monitor system file changes;
asecond receiving module 520, coupled to themonitoring module 510, adapted to receive the changed new file content when the system file is monitored to be changed;
thesecond sending module 530, coupled to thesecond receiving module 520, is adapted to send the received new file content to the file processing server in the monitoring notification, so that the file processing server sends the new file content to the web cluster, and then the web cluster sends the new file content to the client.
In an embodiment of the present invention, themonitoring module 510 is further adapted to monitor a network connection state between the client and the web cluster, and if it is monitored that the file acquisition request sent by the client to the web cluster is disconnected, trigger the file processing server to interrupt reading of new file content, and trigger the file processing server to send an interrupt notification message to the web cluster, so that the interrupt notification message is forwarded from the web cluster to the client.
In an embodiment of the present invention, thesecond receiving module 520 is further adapted to receive new file contents from the file generation server after the file generation server generates new file contents according to the created, modified or deleted system file when themonitoring module 510 monitors that the system file is created, modified or deleted.
The embodiment of the invention also provides a system for acquiring the file. Fig. 6 is a schematic structural diagram of a system for acquiring a file according to an embodiment of the present invention. Referring to FIG. 6, the system 600 for obtaining files may include at least aclient 610, aweb cluster 620, a file processing server 630, and a file monitoring server 640.
Now, the functions of the components or devices of the system 600 for acquiring files and the connection relationship between the components will be described:
aclient 610 adapted to send a file acquisition request to aweb cluster 620;
web cluster 620, coupled toclient 610, adapted to receive a file acquisition request, and forward to file processing server 630;
a file processing server 630, coupled toweb cluster 620, adapted to receive the file obtaining request forwarded byweb cluster 620, and wait for a monitoring notification from file monitoring server 640 when it is determined that the file processing server 630 does not store the file content requested by the file obtaining request;
the file monitoring server 640 is coupled with the file processing server 630 and is suitable for monitoring the change of the system file, receiving the changed new file content and carrying the new file content in a monitoring notice to be sent to the file processing server 630;
the file processing server 630 is further adapted to, when receiving the monitoring notification, read the new file content carried in the monitoring notification, and further determine whether the new file content includes an end flag indicating that the file has ended; if the end mark is included, deleting the end mark, and sending the deleted file content to theweb cluster 620; if the end mark is not included, forwarding the new file content to theweb cluster 620, and continuing to receive a monitoring notification carrying the new file content from the file monitoring server 640 until the new file content includes the end mark;
web cluster 620 is also adapted to forward file content received from file handling server 630 toclient 610.
In an embodiment of the invention,web cluster 620 is further adapted to select a web server inweb cluster 620 for receiving the file retrieval request according to a load balancing algorithm.
In an embodiment of the present invention, the file processing server 630 is further adapted to, if it is determined that the file content requested by the file obtaining request is stored in the file processing server 630, send the requested file content to theweb cluster 620.
In an embodiment of the present invention, file monitor server 640 is further adapted to monitor a network connection status betweenclient 610 andweb cluster 620. If the file acquisition request sent by theclient 610 to theweb cluster 620 is monitored to be disconnected when the file processing server 630 reads new file content carried in the monitoring notification, the file processing server 630 is triggered to interrupt reading of the new file content, and the file processing server 630 is triggered to send an interrupt notification message to theweb cluster 620, so that the interrupt notification message is forwarded to theclient 610 by theweb cluster 620.
In an embodiment of the present invention, the file processing server 630 is further adapted to determine whether the waiting time for waiting for the monitoring notification from the file monitoring server 640 exceeds a preset time. If not, reading new file contents carried in the monitoring notification when the monitoring notification is received, and further judging whether the new file contents contain an end mark indicating that the file is ended; if yes, it is determined that the file acquisition request fails, and a notification message of the file acquisition request failure is sent toweb cluster 620, so that the notification message of the request failure is forwarded toclient 610 byweb cluster 620.
In an embodiment of the present invention, the file obtaining request may include any one of a hypertext transfer protocol request, a hypertext transfer security protocol request, and a file transfer protocol request.
The embodiment of the invention also provides another system for acquiring the file. Fig. 7 is a schematic structural diagram of a system for acquiring a file according to an embodiment of the present invention. Referring to fig. 7, the system 600 for obtaining files may include a file generation server 650 in addition to the devices in the above-mentioned system.
The file generation server 650, coupled to the file monitoring server 640, is adapted to generate new file contents according to the created, modified or deleted system file and send the new file contents to the file monitoring server 640 if the file monitoring server 640 monitors that the system file is created, modified or deleted.
In an embodiment of the present invention, the file generation server 650 is further adapted to add an end flag to the new file content if the new file content is the complete requested file content.
To more clearly embody the embodiments of the present invention, the embodiments of the present invention will now be described in detail by referring to the signal flow between the devices in the system 600 for acquiring files, which is shown in fig. 8:
client 610 sends a file acquisition request toweb cluster 620;
web cluster 620 receives a file acquisition request fromclient 610 and forwards the file acquisition request to file processing server 630;
file processing server 630 receives the forwarded file retrieval request fromweb cluster 620, and determines whether the file content requested by the file retrieval request is stored locally,
if so, reading the requested file content, sending the requested file content to theweb cluster 620, receiving the requested file content from the file processing server 630 by theweb cluster 620, and forwarding the requested file content to theclient 610;
if not, the file processing server 630 waits for a monitoring notification from the file monitoring server 640;
the file monitoring server 640 monitors the change of the system file in real time, and when the system file is monitored to be created, modified or deleted, the file generation server 650 is triggered to generate the system file according to the created, modified or deleted system file, and new file content is sent to the file monitoring server 640;
the file monitoring server 640 receives the new file content, and forwards the new file content carried in the monitoring notification to the file processing server 630;
after receiving the monitoring notification carrying the generated new file content forwarded by the file monitoring server 640, the file processing server 630 reads the new file content carried in the monitoring notification, and determines whether the new file content includes an end flag indicating that the file has ended,
if not, forwarding the new file content to theWeb cluster 620, forwarding the new file content from the file processing server 630 to theclient 610 by theWeb cluster 620, and continuing to receive a monitoring notification carrying the new file content from the file monitoring server 640 until the new file content contains an end mark;
if so, deleting the end mark, sending the file content after deleting the end mark to theWeb cluster 620, and forwarding the file content after deleting the end mark from the file processing server 630 to theclient 610 by theWeb cluster 620;
theclient 610 receives the new file content or the file content after the end flag is deleted.
The embodiment of the invention can enable the user to acquire the requested file content without waiting for the requested file content to be generated completely, thereby not only effectively improving the real-time property of acquiring the file, but also reducing the time for the user to wait for the requested file content to be generated and improving the operation experience of the user.
According to any one or a combination of the above preferred embodiments, the following advantages can be achieved by the embodiments of the present invention:
in the embodiment of the invention, when the file processing server receives a file acquisition request from the client, which is forwarded by the web cluster, and determines that the file content requested by the file acquisition request is not stored locally, the file processing server can select to wait for a monitoring notification from the file monitoring server, which carries new file content generated due to the change of the system file. If the file processing server receives the monitoring notification sent by the file monitoring server and knows that the new file content carried in the monitoring notification contains the end mark through judgment, the new file growth is finished, the file processing server can send the file content with the end mark deleted to the web cluster, and then the web cluster forwards the file content to the user. If the new file content does not include the end mark, it indicates that the new file is growing, i.e. the requested file content requested by the user is in a dynamic growth state, and the file processing server needs to continue to wait for the monitoring notification of the file monitoring server until the new file content includes the end mark. Therefore, no matter whether the file content requested by the user is in a dynamic growth state or not, the scheme of the invention can ensure that the user can acquire the requested file content in time. Particularly, if it is known through the judgment that the new file content does not include the end flag, that is, the requested file content requested by the user is in the dynamic growth state, the file processing server will wait for the monitoring notification of the file monitoring server, timely receive the generated new file content until the new file content includes the end flag, and when the new file content includes the end flag, the file content requested by the user at this time is completely acquired. In the process, the user does not need to acquire the requested file content after waiting for all the requested file content to be generated, so that the file acquisition instantaneity can be effectively improved, the time for the user to wait for the requested file content to be generated is reduced, and the operation experience of the user is further improved.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of the apparatus and system for acquiring files according to embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
Thus, it should be appreciated by those skilled in the art that while a number of exemplary embodiments of the invention have been illustrated and described in detail herein, many other variations or modifications consistent with the principles of the invention may be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the invention. Accordingly, the scope of the invention should be understood and interpreted to cover all such other variations or modifications.