CN111400263A - Monitoring switch-back method and device based on file change - Google Patents

Monitoring switch-back method and device based on file change Download PDF

Info

Publication number
CN111400263A
CN111400263A CN202010180106.XA CN202010180106A CN111400263A CN 111400263 A CN111400263 A CN 111400263A CN 202010180106 A CN202010180106 A CN 202010180106A CN 111400263 A CN111400263 A CN 111400263A
Authority
CN
China
Prior art keywords
file
monitoring
time
local
receiving module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010180106.XA
Other languages
Chinese (zh)
Inventor
杨杰
陈勇铨
吕爱民
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Yingfang Software Co ltd
Original Assignee
Shanghai Yingfang Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Yingfang Software Co ltd filed Critical Shanghai Yingfang Software Co ltd
Priority to CN202010180106.XA priority Critical patent/CN111400263A/en
Publication of CN111400263A publication Critical patent/CN111400263A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/178Techniques for file synchronisation in file systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for monitoring switch-back based on file change, wherein the method comprises the following steps: step S1, configuring monitoring directory and files, scanning in real time by using a monitoring module to obtain local file attributes, and detecting whether file updating is overtime; step S2, when detecting the file updating overtime, stopping the monitoring module, starting the receiving module, and establishing connection with the standby server; and step S3, acquiring the content of the corresponding file from the standby server, and synchronously updating the real-time changed data to the corresponding local file.

Description

Monitoring switch-back method and device based on file change
Technical Field
The invention relates to the field of computer data analysis and data disaster recovery, in particular to a monitoring switch-back method and a monitoring switch-back device based on file change.
Background
With the rapid development of information technology, the information construction requirements of various industries are gradually improved, and the requirements on the real-time property of data transmission and the high availability of data are higher and higher.
Generally, stock company market documents are transmitted from a headquarters to a business department, which generally uses satellite market as a primary stock and the headquarters' ground market as a backup. However, satellite signals are susceptible to extreme weather or interference signals, and the reception of the market is often interrupted, and in this case, an automatic switching and back-switching technique is required to enable the system to automatically operate and ensure that the downstream market is updated normally.
Disclosure of Invention
In order to overcome the defects of the prior art, the present invention provides a monitoring switch-back method and device based on file change, so as to monitor the update of a file in real time, and under the condition of abnormal file update, the method and device can be operated quickly by a substitution scheme, and simultaneously, after the original main program is recovered, the main program can be switched immediately, thereby ensuring that the file is not abnormal due to concurrent writing.
In order to achieve the above object, the present invention provides a method for monitoring switch-back based on file change, comprising the following steps:
step S1, configuring monitoring directory and files, scanning in real time by using a monitoring module to obtain local file attributes, and detecting whether file updating is overtime;
step S2, when detecting the file updating overtime, stopping the monitoring module, starting the receiving module, and establishing connection with the standby server;
and step S3, acquiring the content of the corresponding file from the standby server, and synchronously updating the real-time changed data to the corresponding local file.
Preferably, in step S1, the file modification time obtained this time is compared with the file modification time obtained last time through the file attribute, and whether the time difference between two times exceeds the set threshold is calculated to detect whether the file update is time out.
Preferably, in step S3, before updating the file, it is further detected whether the current local file is updated by another program according to the local file attribute, if it is detected that the file is updated by another program, the receiving module is stopped, the monitoring module is switched to, and the step S1 is continued to monitor whether the file update is time-out.
Preferably, the step S3 further includes:
step S300, after the receiving module is successfully connected with the standby server, acquiring a data packet containing file change information of a corresponding file, and acquiring file attributes of the corresponding local file;
step S301, judging whether the local file is modified by other applications or not according to the local file attribute, if so, jumping to step S303, otherwise, entering step S302;
step S302, updating file change block information to a local file according to the received data packet;
step S303, when it is monitored that the local file has been updated by another application, the received current file change block is discarded, the receiving module is stopped, and the monitoring module is started to complete the switchback.
Preferably, in step S301, according to the modification time and the file size in the acquired local file attribute, comparing the modification time of the local file, and whether the file size is consistent with the previous information in the cache, if not, jumping to step S303, and if so, continuing to execute step S302.
Preferably, before step S302, the method further includes the following steps:
and S301-a, acquiring a microsecond precision value of the creation time in the local file attribute, comparing the microsecond precision value with the corresponding information of the previous time and judging whether the microsecond precision value is consistent with the corresponding information of the previous time, if not, jumping to the step S303, otherwise, entering the step S302.
Preferably, after step S302, the method further includes the following steps:
step S302-a, a microsecond precision value is generated by taking the current system clock frequency as a calculation factor, the microsecond precision value is set to the microsecond precision of the file creating time of the local file attribute to be used as creating time, and the processed creating time, the modification time synchronized from the standby server and the file size information are used as new file attributes to be set in the local file.
Preferably, in step S300, after the receiving module establishes a connection with the standby service end, the standby service end starts a file detection and transmission service, reads file content and attributes according to a file name in the connection request, detects whether a corresponding file changes, and prepares to transmit a data packet according to file change information, when it is determined that the connection is normal, sends the data packet to the receiving module in sequence, continues to perform the next detection in a loop, and if the connection is disconnected, ends the current detection and transmission service.
Preferably, in step S300, the standby server sets four types, i.e., a start identifier, a file content, a file attribute, and an end identifier, in sequence according to the data packet prepared by the file change information.
In order to achieve the above object, the present invention further provides a device for monitoring back-cut based on file change, including:
the monitoring module is used for configuring a monitoring directory and a file, scanning in real time to obtain file attributes, detecting whether the file is updated overtime or not, stopping the monitoring module when the file is detected to be updated overtime, and starting the receiving module;
and the receiving module is used for sending a connection request to the standby server to establish connection, acquiring the content of the corresponding file from the standby server, and synchronously updating the real-time changed data to the corresponding local file.
Compared with the prior art, the monitoring switch-back method and the device based on the file change acquire the file attribute by utilizing the monitoring module to scan in real time, detect whether the file is updated overtime or not, when detecting that the file is updated overtime, stopping the monitoring module, starting the receiving module, establishing connection with the standby server, acquiring the content of the corresponding file from the standby server, synchronously updating the real-time changed data to the corresponding file of the current client node, detecting whether the main program is recovered before updating the file, if so, the receiving module is stopped and switched to the monitoring module, so that the update of the real-time monitoring file is realized, under the condition of abnormal file updating, the method can quickly operate by a substitution scheme, and simultaneously, after the original main program is recovered, the main program can be immediately switched, so that the file is ensured not to have abnormality caused by concurrent writing.
Drawings
FIG. 1 is a flowchart illustrating the steps of a method for monitoring switchback based on file changes according to the present invention;
FIG. 2 is a system architecture diagram of a monitored switchback device based on file changes in accordance with the present invention;
FIG. 3 is a detailed structure diagram of a receiving module according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a monitoring service of the monitoring module according to an embodiment of the present invention;
FIG. 5 is a flow chart of the service receiving process of the receiving module in the embodiment of the present invention
Fig. 6 is a flowchart illustrating a transmission procedure of an upper level server according to an embodiment of the present invention.
Detailed Description
Other advantages and capabilities of the present invention will be readily apparent to those skilled in the art from the present disclosure by describing the embodiments of the present invention with specific embodiments thereof in conjunction with the accompanying drawings. The invention is capable of other and different embodiments and its several details are capable of modification in various other respects, all without departing from the spirit and scope of the present invention.
FIG. 1 is a flowchart illustrating steps of a method for monitoring switchback based on file changes according to the present invention. As shown in fig. 1, the method for monitoring switchback based on file change of the present invention includes the following steps:
step S1, configuring the monitoring directory and the file, using the monitoring module to scan and obtain the file attribute in real time, and detecting whether the file update is overtime.
In the present invention, the configured monitoring directory and file refers to a receiving program of a third-party application (i.e. a main program in the present invention) receiving a real-time file from a superior server, writing the real-time file into a directory and a file specified by a local or mapping disk, starting a monitoring service by using a monitoring module, scanning a file state update condition under the specified directory in real time, that is, obtaining a file attribute by scanning the configured monitoring directory and file in real time, wherein the file attribute includes but is not limited to a file name, creation time, modification time, a file size, and the like, and judging whether the file update is overtime according to the obtained file attribute. In the embodiment of the present invention, it is determined whether the file update is overtime, the file modification time obtained this time may be compared with the file modification time obtained last time by the file attribute, and whether the time difference between two times exceeds the set threshold is calculated.
And step S2, when detecting that the file is updated overtime, stopping the monitoring module, starting the receiving module, and establishing connection with the standby server.
That is, in step S1, the file modification time (i.e. the current file update time) obtained this time is compared with the file modification time (i.e. the previous file update time) obtained last time according to the obtained file attributes, and when the time difference exceeds the set threshold, it is determined that the current file update is overtime, the monitoring module is stopped, and the receiving module is started at the same time, and a TCP connection request is initiated from the receiving module to the standby server to connect the standby server.
Step S3, the receiving module obtains the content of the corresponding file from the standby server, and synchronously updates the real-time changing data to the corresponding local file. Preferably, in step S3, before updating the file, it is further detected whether the current local file has been updated by another program according to the local file attribute, and if it is detected that the file has been updated by another program, it indicates that the primary program has recovered, at this time, the current receiving module needs to be stopped, the monitoring module is switched to, and the step S1 is continuously returned to monitor whether the file update is overtime.
Specifically, step S3 further includes:
step S300, after the connection with the standby server is successful, acquiring a data packet containing file change information of the corresponding file, and acquiring information such as modification time, file size, creation time and the like in the local file attribute.
In the embodiment of the present invention, when it is detected that a file is updated overtime, the monitoring module is stopped from starting the receiving module, the receiving module serving as a subordinate client sends a connection request to establish a connection with the standby server, and the connection with the standby server is maintained after the connection with the standby server is successful, in the present invention, the connection request sent by the subordinate client (i.e. the receiving module) at least includes a file name, after the connection is established, the standby server serving as an upper level starts a file detection and sending service, obtains corresponding file content and attributes according to the file name included in the connection request, checks whether the corresponding file has a change, for example, determines whether the corresponding file has a change according to the file attribute, and prepares to transmit a data packet according to file change information, and the data packet is sequentially set with four types: the system comprises a start identifier, file contents, file attributes and an end identifier, wherein the start identifier records a current file name and a start mark of the file change, a subordinate client starts initialization work after receiving the packet, if a corresponding file is opened or created, the file contents refer to specific contents of a current file change block packaged by a data packet, the subordinate client starts to update the file according to the packet after receiving the packet, the file attributes refer to file modification time, file size and other related information and are assembled into a data packet, the subordinate client synchronizes the file attributes according to the packet after receiving the packet, the end mark indicates that all the change blocks are transmitted at this time, and the subordinate client closes the corresponding file after receiving the packet.
When the standby server judges that the connection with the lower client (namely the receiving module of the invention) is normal, the standby server sends each data packet to the lower client in sequence, continues to circularly execute the next detection, if the connection is disconnected, the lower client is switched to the monitoring mode, and the current detection sending service is ended.
Step S301, judging whether the local file is modified by other applications or not according to the local file attribute, if so, jumping to step S305, otherwise, entering step S302. Specifically, according to the obtained information of modification time, file size, creation time and the like in the local file attribute, comparing whether the modification time, file size and the like of the local file are consistent with the previous information in the cache, if the modification time, file size and the like are inconsistent with the previous information in the cache, indicating that the file has been modified by other applications, jumping to step S305, and if the information is consistent, continuing to execute step S302.
Step S302, acquiring microsecond precision value of file creating time in local file attributes, comparing whether the microsecond precision value is consistent with corresponding information in a cache or not, if not, indicating that the file is modified by other applications, and jumping to step S305, otherwise, continuing to step S303. The microsecond precision value is used for information comparison, so that the control precision of monitoring is improved, the condition that the operation of updating the file attribute is synchronous with the operation of updating the system after other applications are recovered from the fault is prevented, the conflict condition of concurrent file writing is caused, and the file is prevented from being damaged.
Step S303, update the file change block information to the local file according to the received data packet.
Step S304, a microsecond value is generated by using the current system clock frequency as a calculation factor (for example, a non-repeating random number is generated by using the current system clock frequency as a calculation factor), and is set to the file creation time microsecond precision of the local file attribute as the file creation time, while the creation time of the source file millisecond precision remains unchanged, that is, the low-level millisecond microsecond is used in the present invention, and each modification is only to modify the low-level value, for example, in a normal case, the time for viewing the file attribute is year, month, day, time minute and second, and the low-level millisecond microsecond is used here, so the year, month, day, time minute and second seen is still normal, and the use of other applications is not affected. The invention takes the processed creation time (the time with microsecond precision set), the modification time (the modification time of the source file) and the size and other information synchronized from the standby server as the new file attribute to be set on the local file, and simultaneously, the mapping relation between the new file attribute and the file name is stored in the system cache.
Step S305, when it is monitored that the file is updated by other applications, the current file change block is discarded, the receiving module is stopped, and the monitoring module is started to complete the switchback.
Therefore, the method and the device can detect the update change of the local file, automatically switch to the receiving mode after the update is overtime, receive the real-time file from the superior server, synchronize to the current file, judge whether the previous update of the file is other applications or not while receiving the file, and automatically switch back to the monitoring mode if the main program is recovered, so that the file data can not be damaged due to multiple concurrent writes, and the file is still updated in real time. It should be noted that the switching and back-switching actions in the abnormal condition of the present invention are not perceived by the subordinate user, and do not affect the final use.
FIG. 2 is a system architecture diagram of a monitored switchback device based on document changes in accordance with the present invention. As shown in fig. 2, the present invention provides a monitoring switchback device 2 based on document change, which comprises:
the monitoring module 20 is configured to configure a monitoring directory and a file, scan in real time to obtain file attributes, detect whether file update is overtime, stop the monitoring module when detecting that file update is overtime, and start the receiving module.
In the invention, the configured monitoring directory and file refers to a directory and file specified by a local or mapping disk, which are received by a third-party application and written in real time, and the monitoring module scans the configured monitoring directory and file in real time to obtain the file attribute and judges whether the file update is overtime according to the obtained file attribute. In the embodiment of the present invention, the monitoring module determines whether the file update is overtime, and compares the file modification time obtained this time with the file modification time obtained last time according to the file attribute, and calculates whether the time difference between two times exceeds a set threshold, but the present invention is not limited thereto.
When the monitoring module judges that the time of updating the current file is compared with the time obtained last time and the time difference exceeds the set threshold, the monitoring module judges that the updating of the current file is overtime, the monitoring module stops working, and simultaneously the receiving module 21 is started, and the receiving module 21 initiates a TCP connection request to connect a standby server.
And the receiving module 21 sends a connection request to the standby server to establish a connection, acquires the content of the corresponding file from the standby server, and synchronously updates the real-time changed data to the corresponding file of the current client node. Preferably, the receiving module 21 further detects whether the current local file has been updated by another program before the file is updated, and if it is detected that the file has been updated by another program, it indicates that the main program has been recovered, and at this time, stops the current receiving module and switches to the monitoring module.
Specifically, as shown in fig. 3, the receiving module 21 further includes:
a connection obtaining unit 210, configured to obtain a data packet containing file change information of a corresponding file after successful connection with the standby server, and obtain information of modification time, file size, creation time, and the like in the local file attribute at the same time
In the embodiment of the present invention, when the receiving module 21 sends a connection request and the connection with the standby service end is successful, the connection is maintained, the connection request sent by the receiving module 21 at least includes a file name, the standby service end as the upper level will start a file detection and sending service, obtain the file content and attributes according to the file name, check whether the corresponding file has a change, for example, determine whether the file attribute has a change, and prepare a transmission data packet according to the file change information, and the data packet sets four types in sequence: the system comprises a start identifier, file contents, file attributes and an end identifier, wherein the start identifier records a current file name and a start mark of the file change, a lower-level client side starts initialization work after receiving the packet, if a corresponding file is opened or created, the file contents refer to specific contents of a data packet packaging current file change block, the lower-level client side starts to update the file according to the packet after receiving the packet, the file attributes refer to relevant information such as file modification time and file size and assemble the file into a data packet, the lower-level client side synchronizes the file attributes according to the packet after receiving the packet, the end mark indicates that all the change blocks are transmitted, and the lower-level client side closes the corresponding file after receiving the packet.
When the connection of the client side of the lower level (namely the receiving module of the invention) is judged to be normal, the changed block data packets are sent to the client side of the lower level in sequence, the next detection is continuously and circularly executed, if the connection is disconnected, the client side of the lower level is indicated to be switched to the monitoring mode, and the current detection sending service is ended.
The file attribute determining unit 211 is configured to determine whether the local file is modified by another application according to the local file attribute, if so, start the switchback unit 215, otherwise, start the microsecond precision obtaining determining unit 212. Specifically, according to the information such as modification time, file size, creation time, and the like in the acquired local file attribute, whether the modification time, file size, and the like of the local file are consistent with the previous information in the cache is compared, if the modification time, file size, and the like are inconsistent with the previous information in the cache, it is indicated that the file has been modified by other applications, the switching-back unit 215 is skipped, and if the information is consistent, the microsecond precision acquisition determining unit 212 is continuously executed.
The microsecond precision obtaining and judging unit 212 is configured to obtain a microsecond precision value in the creation time in the local file attribute, compare the microsecond precision value with corresponding information in the previous time in the cache to determine whether the microsecond precision value is consistent, if the microsecond precision value is inconsistent with the corresponding information in the previous time, indicate that the file has been modified by another application, and jump to the switchback unit 215, otherwise, start the file updating unit 213. The method aims to improve the control precision, prevent the operation of updating the file attribute from being synchronous with the operation of updating by the system after other applications are recovered from the fault, thereby causing the conflict situation of concurrent writing of files and ensuring that the files are not damaged.
The file updating unit 213 updates the file change block information to the local file according to the received data packet.
The microsecond precision value generating and setting unit 214 is configured to generate a microsecond value (for example, a non-repeating random number is generated by using the current system clock frequency as a calculation factor) by using the current system clock frequency as a calculation factor, set the microsecond value to the file creation time microsecond precision of the local file attribute as the file creation time, and keep the creation time of the source file millisecond precision unchanged, that is, the lower-order millisecond is used in the present invention, and each modification is only to modify the lower-order value, for example, in a normal case, it is checked that the file attribute time is year, month, hour, minute and second. The invention takes the processed creation time (the time with microsecond precision set), the modification time (the modification time of the source file) and the size and other information synchronized from the standby server as the new file attribute to be set on the local file, and simultaneously, the mapping relation between the new file attribute and the file name is stored in the system cache.
And the back-cut unit 215 is configured to discard the current file change block, stop the receiving module, and start the monitoring module to complete the back-cut when it is monitored that the file is updated by other applications.
Examples
Fig. 2 is an architecture diagram of an application of the monitoring switchback device based on file change according to the embodiment of the present invention, which describes the relationship between the sending service, the receiving service and the monitoring service. In this embodiment, the following market scenario is taken as an example: the invention relates to a satellite market (primary) and a ground market (standby), which starts to receive market from a standby source after detecting that the primary market is abnormal, wherein the market is consistent because the market comes from a trading exchange, and the invention is used for realizing automatic monitoring and switching, and is specifically described as follows:
firstly, the service is normally operated, the main system is a third-party application, a third-party receiving program receives a real-time file from a superior server and writes the real-time file into a local or mapping disk specified directory, and the third-party receiving program can be a satellite sending and receiving program or other application file transmission applications; then, the monitoring switching-back device of the invention starts the monitoring service of the monitoring module, scans the file state update under the appointed directory in real time, when detecting that the update is overtime, namely when the third party receiving program is abnormal, automatically switches to the receiving mode of the receiving module, stops the monitoring service, and the receiving module automatically receives the same file from the system server (namely the standby server) to the current directory; when the third-party program resumes working, in order to avoid file abnormality caused by duplicate writing of the same file on both sides, the receiving module of the monitoring switchback device of the invention can automatically detect the previous state before writing, if updated by other applications, abandons the update, automatically switchback to the monitoring mode, monitors the file state, and the process is transparent to the end user, thereby enhancing the robustness of the system and ensuring the continuous and stable operation of the service.
Fig. 4 is a specific flowchart of the monitoring service of the monitoring module in the embodiment of the present invention, and the monitoring process is as follows:
firstly, starting a monitoring module service, scanning a specified directory or file, acquiring file attributes, comparing the file modification time acquired this time with the file modification time acquired last time, and judging whether the file modification time exceeds a set threshold value so as to detect whether the file update exceeds the value.
If not, continuing monitoring and waiting for next detection;
if overtime is detected, the monitoring service is stopped, the receiving service of the receiving module is started, and the receiving module acquires data from the standby server to update the local file.
Fig. 5 is a flow chart of a process of receiving a service by a receiving module in an embodiment of the present invention, where the process of the receiving module is as follows:
step 1, a receiving module initiates a connection request to connect with an upper-level standby server.
And after the connection with the superior standby server is successful, acquiring file change information. Meanwhile, information such as modification time, file size, creation time and the like in the local file attribute is obtained.
And 2, comparing whether the file modification time, the file size and the like in the local file attribute are consistent with the previous information in the cache or not, if not, indicating that the file is modified by other applications, and jumping to the step 6, and if the information is consistent, continuing to execute the step 3.
And 3, acquiring the creation time in the local file attribute, intercepting a microsecond precision value, comparing whether the microsecond precision value is consistent with the corresponding information in the previous time in the cache, indicating that the file is modified by other applications if the microsecond precision value is inconsistent with the corresponding information in the previous time, and skipping to the step 6, otherwise, continuing to the step 4. The step is to improve the control precision, and prevent the operation of updating the file attribute from being synchronous with the operation of updating the system after other applications are recovered from the fault, thereby causing the conflict situation of concurrent writing of files and ensuring that the files are not damaged.
And 4, updating the change block information to the local file.
And 5, generating a microsecond precision value by taking the current system clock frequency as a calculation factor, setting the microsecond precision value to the microsecond precision of the file creation time as the creation time, and keeping the creation time of the millisecond precision of the source file unchanged. Setting the processed creation time and the information such as the modification time and the size synchronized from the server side as new file attributes to the local file. Meanwhile, the mapping relation between the attribute and the file name is stored in a system cache.
And 6, monitoring that the file is updated by other systems, discarding the current change block, stopping the system from receiving the service, starting the monitoring service, and finishing the back switch.
Fig. 6 is a sending flowchart of the upper-level standby service in the embodiment of the present invention, specifically, a sending process of the upper-level standby service is as follows:
first, the backup server at the upper level monitors the service port, waits for the connection of the client at the lower level (the receiving module of the monitoring switch-back device of the present invention), and maintains the connection after the connection of the lower level is successful.
And then, starting a file detection sending service, reading file content and attributes according to the file name in the connection request, preparing to transmit a data packet, and sequentially setting four types, a start identifier, the file content, the file attributes and an end identifier for the data packet.
And finally, judging the connection state of the lower client, if the connection is normal, sending the data packets to the lower client in sequence, continuing to circularly execute the next detection, and if the connection is disconnected, indicating that the lower client is switched to a monitoring mode, and ending the current detection sending service.
Therefore, in the embodiment of the present invention, whether the updated file of the third-party application is normal or not is detected in real time, if the updated file is abnormal, the monitoring switchback device of the present invention is automatically switched to update the file, and after the third-party application system is recovered, the monitoring switchback device of the present invention is automatically switched back to the monitoring state.
In summary, the monitoring switch-back method and device based on file change of the present invention utilizes the monitoring module to scan and obtain the file attribute in real time, detect whether the file update is overtime, when detecting that the file is updated overtime, stopping the monitoring module, starting the receiving module, establishing connection with the upper-level standby server, acquiring the content of the corresponding file from the upper-level standby server, synchronously updating the real-time changed data to the corresponding file of the current client node, detecting whether the main program is recovered before updating the file, if so, the receiving module is stopped and switched to the monitoring module, so that the update of the real-time monitoring file is realized, under the condition of abnormal file updating, the method can quickly operate by a substitution scheme, and simultaneously, after the original main program is recovered, the main program can be immediately switched, so that the file is ensured not to have abnormality caused by concurrent writing.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Modifications and variations can be made to the above-described embodiments by those skilled in the art without departing from the spirit and scope of the present invention. Therefore, the scope of the invention should be determined from the following claims.

Claims (10)

1. A monitoring switch-back method based on file change comprises the following steps:
step S1, configuring monitoring directory and files, scanning in real time by using a monitoring module to obtain local file attributes, and detecting whether file updating is overtime;
step S2, when detecting the file updating overtime, stopping the monitoring module, starting the receiving module, and establishing connection with the standby server;
and step S3, acquiring the content of the corresponding file from the standby server, and synchronously updating the real-time changed data to the corresponding local file.
2. The method of claim 1 for monitoring switchback based on file changes, characterized in that: in step S1, the file modification time obtained this time is compared with the file modification time obtained last time according to the file attributes obtained by scanning, and whether the time difference between two times exceeds the set threshold is calculated to detect whether the file update is overtime.
3. The method of claim 2 for monitoring switchback based on file changes, characterized in that: in step S3, before updating the file, it is detected whether the current local file has been updated by other programs according to the local file attribute, if it is detected that the file has been updated by other programs, the receiving module is stopped, the monitoring module is switched to, and step S1 is returned to continue monitoring whether the file update is overtime.
4. The method for monitoring switch-back based on file change as claimed in claim 3, wherein the step S3 further comprises:
step S300, after the receiving module is successfully connected with the standby server, acquiring a data packet containing file change information of a corresponding file from the standby server, and acquiring file attributes of the corresponding local file;
step S301, judging whether the local file is modified by other applications or not according to the local file attribute, if so, jumping to step S303, otherwise, entering step S302;
step S302, updating file change block information to a local file according to the received data packet;
step S303, when it is monitored that the local file has been updated by another application, the received current file change block is discarded, the receiving module is stopped, and the monitoring module is started to complete the switchback.
5. The method of claim 4 for monitoring switchback based on file changes, characterized in that: in step S301, according to the modification time and the file size in the acquired local file attribute, comparing the modification time of the local file, and whether the file size is consistent with the previous information in the cache, if not, jumping to step S303, and if so, continuing to execute step S302.
6. The method for monitoring switch-back based on document change as claimed in claim 5, further comprising the following steps before step S302:
and S301-a, acquiring a microsecond precision value of the creation time in the local file attribute, comparing the microsecond precision value with the corresponding information of the previous time and judging whether the microsecond precision value is consistent with the corresponding information of the previous time, if not, jumping to the step S303, otherwise, entering the step S302.
7. The method for monitoring switch-back based on document change as claimed in claim 6, further comprising the following steps after step S302:
step S302-a, a microsecond precision value is generated by taking the current system clock frequency as a calculation factor, the microsecond precision value is set to the microsecond precision of the file creating time of the local file attribute to be used as creating time, and the processed creating time, the modification time synchronized from the standby server and the file size information are used as new file attributes to be set in the local file.
8. The method of claim 5 for monitoring switchback based on file changes, characterized in that: in step S300, after the receiving module establishes connection with the backup server, the backup server starts a file detection and transmission service, reads file content and attributes of a corresponding file according to a file name in the connection request, detects whether the corresponding file changes, prepares to transmit a data packet according to file change information, sends the data packet to the receiving module in sequence when the connection is determined to be normal, continues to perform the next detection in a loop, and ends the current detection and transmission service if the connection is determined to be disconnected.
9. The method of claim 7 for monitoring switchback based on file changes, characterized in that: in step S300, the standby server sets four types of data packets, i.e., a start identifier, a file content, a file attribute, and an end identifier, in sequence according to the data packets prepared by the file change information.
10. A monitored switchback device based on file changes, comprising:
the monitoring module is used for configuring a monitoring directory and a file, scanning in real time to obtain the attribute of the local file, detecting whether the file is updated overtime or not, stopping the monitoring module and starting the receiving module when the file is detected to be updated overtime;
and the receiving module is used for sending a connection request to the standby server to establish connection, acquiring the content of the corresponding file from the standby server and synchronously updating the real-time changed data to the corresponding local file.
CN202010180106.XA 2020-03-16 2020-03-16 Monitoring switch-back method and device based on file change Pending CN111400263A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010180106.XA CN111400263A (en) 2020-03-16 2020-03-16 Monitoring switch-back method and device based on file change

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010180106.XA CN111400263A (en) 2020-03-16 2020-03-16 Monitoring switch-back method and device based on file change

Publications (1)

Publication Number Publication Date
CN111400263A true CN111400263A (en) 2020-07-10

Family

ID=71430813

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010180106.XA Pending CN111400263A (en) 2020-03-16 2020-03-16 Monitoring switch-back method and device based on file change

Country Status (1)

Country Link
CN (1) CN111400263A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113032343A (en) * 2021-03-23 2021-06-25 杭州安恒信息技术股份有限公司 Method and device for judging credibility of file modification time and storage medium
CN113515740A (en) * 2021-04-23 2021-10-19 杭州安恒信息技术股份有限公司 Method, device and medium for detecting Timestop type attacks
CN113965572A (en) * 2021-11-02 2022-01-21 上海佰贝网络工程技术有限公司 Block distribution method and system of block chain, computer equipment and computer readable storage medium
CN115150391A (en) * 2022-07-25 2022-10-04 中电金信软件有限公司 File transmission method and device, electronic equipment and readable storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040236984A1 (en) * 2003-05-20 2004-11-25 Yasuo Yamasaki Data backup method in a network storage system
CN1677887A (en) * 2005-02-01 2005-10-05 北京北方烽火科技有限公司 N+1 duplicates data real-time synchronising method
CN101916224A (en) * 2010-08-20 2010-12-15 迈普通信技术股份有限公司 Test progress abnormality detection method and automatic test control device
CN102880522A (en) * 2012-09-21 2013-01-16 中国人民解放军国防科学技术大学 Hardware fault-oriented method and device for correcting faults in key files of system
CN104932964A (en) * 2014-03-17 2015-09-23 无锡天脉聚源传媒科技有限公司 Monitoring processing method and apparatus of computer functional programs
CN106547649A (en) * 2016-10-31 2017-03-29 黄建文 A kind of file access pattern system and method
CN106856489A (en) * 2015-12-08 2017-06-16 阿里巴巴集团控股有限公司 A kind of service node switching method and apparatus of distributed memory system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040236984A1 (en) * 2003-05-20 2004-11-25 Yasuo Yamasaki Data backup method in a network storage system
CN1677887A (en) * 2005-02-01 2005-10-05 北京北方烽火科技有限公司 N+1 duplicates data real-time synchronising method
CN101916224A (en) * 2010-08-20 2010-12-15 迈普通信技术股份有限公司 Test progress abnormality detection method and automatic test control device
CN102880522A (en) * 2012-09-21 2013-01-16 中国人民解放军国防科学技术大学 Hardware fault-oriented method and device for correcting faults in key files of system
CN104932964A (en) * 2014-03-17 2015-09-23 无锡天脉聚源传媒科技有限公司 Monitoring processing method and apparatus of computer functional programs
CN106856489A (en) * 2015-12-08 2017-06-16 阿里巴巴集团控股有限公司 A kind of service node switching method and apparatus of distributed memory system
CN106547649A (en) * 2016-10-31 2017-03-29 黄建文 A kind of file access pattern system and method

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113032343A (en) * 2021-03-23 2021-06-25 杭州安恒信息技术股份有限公司 Method and device for judging credibility of file modification time and storage medium
CN113032343B (en) * 2021-03-23 2022-08-16 杭州安恒信息技术股份有限公司 Method and device for judging credibility of file modification time and storage medium
CN113515740A (en) * 2021-04-23 2021-10-19 杭州安恒信息技术股份有限公司 Method, device and medium for detecting Timestop type attacks
CN113965572A (en) * 2021-11-02 2022-01-21 上海佰贝网络工程技术有限公司 Block distribution method and system of block chain, computer equipment and computer readable storage medium
CN113965572B (en) * 2021-11-02 2024-05-14 上海佰贝网络工程技术有限公司 Block distribution method, system, computer equipment and computer readable storage medium of block chain
CN115150391A (en) * 2022-07-25 2022-10-04 中电金信软件有限公司 File transmission method and device, electronic equipment and readable storage medium
CN115150391B (en) * 2022-07-25 2023-05-09 中电金信软件有限公司 File transmission method and device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN111400263A (en) Monitoring switch-back method and device based on file change
US9753954B2 (en) Data node fencing in a distributed file system
CA2339783C (en) Fault tolerant computer system
US7793060B2 (en) System method and circuit for differential mirroring of data
US7032089B1 (en) Replica synchronization using copy-on-read technique
US7694177B2 (en) Method and system for resynchronizing data between a primary and mirror data storage system
US9189348B2 (en) High availability database management system and database management method using same
US20070094467A1 (en) Method for rolling back from snapshot with log
EP1376361A1 (en) Server duplexing method and duplexed server system
US20060143497A1 (en) System, method and circuit for mirroring data
US20080288812A1 (en) Cluster system and an error recovery method thereof
EP1622307A1 (en) Communication system including a temporary save server
CN105159795A (en) Data synchronization method, apparatus and system
CN111459749A (en) Prometous-based private cloud monitoring method and device, computer equipment and storage medium
CN114116912A (en) Method for realizing high availability of database based on Keepalived
CN116302352A (en) Cluster disaster recovery processing method and device, electronic equipment and storage medium
CN110109772A (en) A kind of method for restarting of CPU, communication equipment and readable storage medium storing program for executing
CN112929438B (en) Business processing method and device of double-site distributed database
CN110351122B (en) Disaster recovery method, device, system and electronic equipment
CN110958287A (en) Operation object data synchronization method, device and system
CN107291575B (en) Processing method and equipment for data center fault
US6792558B2 (en) Backup system for operation system in communications system
US20050268188A1 (en) Backup method, backup system, disk controller and backup program
CN114422335A (en) Communication method, communication device, server and storage medium
JPH07183891A (en) Computer system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200710

RJ01 Rejection of invention patent application after publication