Block file information acquisition method and device, storage medium and electronic equipment
By setting up a dynamic monitoring module on the storage device and using inotify and epoll technologies, the problem that upper-level applications cannot quickly obtain block file information when video data is written fails, and fast and accurate information acquisition is achieved, improving the stability of video storage services sex.
Patent Information
- Application Number
- CN202411345286.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-09-25
AI Technical Summary
In the case where video data is written fails, the upper-level application service cannot quickly obtain the block file information of the block file used to write the video data, resulting in low efficiency during query and affecting the normal operation of the video storage service.
By setting up a dynamic monitoring module on the storage device, preset monitoring technology is used to determine whether the threads in the thread pool receive callback events, obtain the result of the write operation, and obtain the information of the block file when the write fails, establish the block file and The mapping relationship of directories is used to monitor file system events in real time using inotify and epoll technology to achieve fast and accurate acquisition of block file information.
It realizes the rapid and accurate acquisition of block file information when video data is written failed, reduces the efficiency of query, improves the efficiency of operation and maintenance personnel's positioning problems, and avoids interruptions in video storage services.
Smart Images

Figure CN119311215A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of storage technology, and in particular, to a method and device for acquiring block file information, a storage medium, and an electronic device. Background Art
[0002] Streaming media projects are deployed on a single node. In a single node scenario, the underlying layer combines multiple hard disk drives in a raid manner to form a logical disk to improve data storage performance. The streaming media storage system mounts multiple logical disks locally in the form of a directory, and pre-creates multiple video block files in the local directory. When the video storage service is launched, the video data is stored in the block file under the mounted directory. After the video data is successfully written to the file, the corresponding video metadata (i.e., the block file information) is stored in the database. The video metadata contains information such as the channel to which the current video is written, the write size, and the write block.
[0003] When video data writing fails at the streaming media project site, the upper-layer application business cannot directly and quickly obtain the block file information (including block file status, logical disk load, and block file write size) of the block file used to write the video data. The common way to query block file information is to obtain block file information by querying the database. However, when the project runs for a long time, the amount of video metadata stored in the database is often large. Since it is impossible to accurately locate which block file failed to be written, the query efficiency is low, which makes it slow for operation and maintenance personnel to locate the problem. Due to the real-time characteristics of video streaming, this situation will cause subsequent video storage services to be interrupted, which will affect the normal operation of the entire video storage service.
[0004] In the related art, when video data writing fails, the problem that the upper layer application service cannot quickly obtain the block file information of the block file used to write the video data has not been effectively solved. Summary of the invention
[0005] The embodiments of the present application provide a method and device for obtaining block file information, a storage medium, and an electronic device, so as to at least solve the problem in the related art that when video data writing fails, the upper-layer application service cannot quickly obtain the block file information of the block file used to write the video data.
[0006] According to an embodiment of the present application, a method for obtaining block file information is provided, which is applied to a dynamic monitoring module on a storage device, wherein the dynamic monitoring module communicates with a storage module on the storage device; the method comprises: in the case of executing a write operation of video data, determining by a preset monitoring technology whether there is a second thread among multiple first threads in a thread pool that receives a callback event, wherein the callback event is an event that the operating system on the storage device feeds back to the thread pool when detecting that the write operation is executed on a block file in the storage module; in the case of the existence of the second thread that receives the callback event, determining a write result of the write operation by obtaining the callback event from the second thread; and in the case of a write result being a write failure, obtaining the block file information of the block file by obtaining the callback event.
[0007] In an exemplary embodiment, before determining whether there is a second thread that receives a callback event among multiple first threads in a thread pool through a preset monitoring technology, the method also includes: determining multiple logical disks mounted on a storage device, and establishing directories corresponding to the multiple logical disks; dividing each logical disk into multiple block files according to a target granularity, and establishing a mapping relationship between the multiple block files and the directory to obtain a mapping directory list, wherein the multiple block files are blank block files, and all block files on the storage device include: the block file, and all block files include: multiple block files corresponding to multiple logical disks respectively.
[0008] In an exemplary embodiment, establishing a mapping relationship between the multiple block files and the directory to obtain a mapping directory list includes: naming the multiple block files corresponding to each logical disk according to a preset rule to obtain a file name corresponding to each block file, wherein the file name of each block file allows unique identification of each block file; establishing a mapping relationship between the multiple block files and the directory through the file name to obtain a mapping directory list.
[0009] In an exemplary embodiment, before determining whether there is a second thread that receives a callback event among multiple first threads in a thread pool through a preset monitoring technology, the method also includes: initializing the preset monitoring technology to obtain a first instance, wherein the first instance is used to monitor the callback event; creating a target handle corresponding to the preset monitoring technology to obtain a second instance corresponding to the target handle, wherein the second instance is used to determine the write result of the write operation through the callback event; registering a file descriptor to be monitored in the second instance, wherein the file descriptor is used to indicate the correspondence between the target field carried in the callback event and the write result of the write operation; adding the mapping directory list to the watch monitoring of the preset detection technology; and when it is determined that the file descriptor has been registered and the mapping directory list has been added, starting the thread pool and waiting for the callback event.
[0010] In an exemplary embodiment, the write result of the write operation is determined by the callback event obtained from the second thread, including: parsing the callback event to determine the target field carried in the callback event; querying the file descriptor through the target field to determine a preset field in multiple preset fields in the file descriptor that is the same as the target field; and determining the write result through the description information corresponding to the preset field in the file descriptor.
[0011] In an exemplary embodiment, after determining whether there is a second thread that receives a callback event among multiple first threads in a thread pool through a preset monitoring technology, the method further includes: determining the number of block files on which write operations are being performed under each of the directories; and regulating the order in which all block files are written according to the number to achieve load balancing of all block files.
[0012] In an exemplary embodiment, obtaining the block file information of the block file through the callback event includes: determining a target file name of the block file carried in the callback event; and requesting the block file information of the block file from a database through the target file name, wherein the database is used to store the block file information when performing a write operation of video data.
[0013] According to another embodiment of the present application, a device for obtaining block file information is provided, which is applied to a dynamic monitoring module on a storage device, wherein the dynamic monitoring module communicates with a storage module on the storage device; the device includes: a first determination module, which is used to determine whether there is a second thread that receives a callback event among multiple first threads in a thread pool by a preset monitoring technology when executing a write operation of video data, wherein the callback event is an event that the operating system on the storage device feeds back to the thread pool when detecting that the write operation is executed on a block file in the storage module; a second determination module, which is used to determine the write result of the write operation by obtaining the callback event from the second thread when the second thread receives the callback event when the second thread exists; and an acquisition module, which is used to obtain the block file information of the block file by using the callback event when the write result is a write failure.
[0014] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0015] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0016] According to another embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0017] Through the present application, a method for obtaining block file information is provided, which is applied to a dynamic monitoring module on a storage device, wherein the dynamic monitoring module communicates with the storage module on the storage device; the method includes: in the case of executing a write operation of video data, determining whether there is a second thread that receives a callback event among multiple first threads in the thread pool through a preset monitoring technology, wherein the callback event is an event that the operating system on the storage device feeds back to the thread pool when detecting that the block file in the storage module is executed with the write operation; in the case of the existence of the second thread that receives the callback event, determining the write result of the write operation through the callback event obtained from the second thread; in the case where the write result is a write failure, obtaining the block file information of the block file through the callback event. Therefore, the problem in the related art that the upper application service cannot quickly obtain the block file information of the block file used to write the video data in the case of a video data write failure can be solved. The technical effect of quickly and accurately obtaining the block file information of the block file used to write the video data is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a hardware structure block diagram of a computer terminal of a method for obtaining block file information in an embodiment of the present application;
[0019] Figure 2 is a flowchart of a method for obtaining block file information according to an embodiment of the present application;
[0020] Figure 3 is an architecture diagram of an execution device of a method for obtaining block file information according to an embodiment of the present application;
[0021] Figure 4 It is a structural block diagram of a device for acquiring block file information according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0024] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 1 is a hardware structure block diagram of a computer terminal of a method for obtaining block file information in an embodiment of the present application. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned computer terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0025] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for allocating load resources in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above method is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0026] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0027] Figure 2 is a flowchart of a method for obtaining block file information according to an embodiment of the present application, the method is applied to a dynamic monitoring module on a storage device, wherein the dynamic monitoring module communicates with a storage module on the storage device; Figure 2 As shown, the process includes the following steps:
[0028] Step S202, when executing a write operation of video data, determining whether there is a second thread in a thread pool that receives a callback event by using a preset monitoring technology, wherein the callback event is an event fed back to the thread pool by the operating system on the storage device when detecting that the write operation is executed on a block file in the storage module;
[0029] Step S204: if there is the second thread that receives the callback event, determine the writing result of the writing operation by using the callback event obtained from the second thread;
[0030] Step S206: When the writing result is a writing failure, obtaining the block file information of the block file through the callback event.
[0031] Through the above steps, a method for obtaining block file information is provided, which is applied to a dynamic monitoring module on a storage device, wherein the dynamic monitoring module communicates with the storage module on the storage device; the method includes: in the case of executing a write operation of video data, determining whether there is a second thread that receives a callback event among multiple first threads in the thread pool through a preset monitoring technology, wherein the callback event is an event that the operating system on the storage device feeds back to the thread pool when detecting that the block file in the storage module is executed with the write operation; in the case of the existence of the second thread that receives the callback event, determining the write result of the write operation through the callback event obtained from the second thread; in the case where the write result is a write failure, obtaining the block file information of the block file through the callback event. Therefore, the problem in the related art that the upper-layer application service cannot quickly obtain the block file information of the block file used to write the video data in the case of a video data write failure can be solved. The technical effect of quickly and accurately obtaining the block file information of the block file used to write the video data is achieved.
[0032] In an exemplary embodiment, before determining whether there is a second thread that receives a callback event among multiple first threads in a thread pool through a preset monitoring technology, the method also includes: determining multiple logical disks mounted on a storage device, and establishing directories corresponding to the multiple logical disks; dividing each logical disk into multiple block files according to a target granularity, and establishing a mapping relationship between the multiple block files and the directory to obtain a mapping directory list, wherein the multiple block files are blank block files, and all block files on the storage device include: the block file, and all block files include: multiple block files corresponding to multiple logical disks respectively.
[0033] It is understandable that a plurality of hard disk drives are combined together in a RAID manner in a storage device to obtain a logical disk. The storage device establishes directories for the mounted plurality of logical disks. Optionally, in the process of dividing block files, the target strength adopted may be 1G, and the divided block files are blank block files. For example, 12 hard disk drives form one logical disk. Three logical disks may correspond to three directories. Thus, the embodiment of the present application can achieve the technical effect of accurately locating block files by establishing directories and dividing block files, and further constructing a mapping relationship between block files and directories.
[0034] In an exemplary embodiment, establishing a mapping relationship between the multiple block files and the directory to obtain a mapping directory list includes: naming the multiple block files corresponding to each logical disk according to a preset rule to obtain a file name corresponding to each block file, wherein the file name of each block file allows unique identification of each block file; establishing a mapping relationship between the multiple block files and the directory through the file name to obtain a mapping directory list.
[0035] For example, the three directories can be named A, B, and C respectively. The naming method of the block files can be named using Arabic numerals, where the first block file divided out of each directory is named 1, the second block file divided out is named 2, and so on. The actual naming method of the block files (equivalent to the mapping relationship) can be: "directory naming + block file naming", for example, the name of block file 9 under directory A is "A9". The above naming method is only an example, and the embodiments of the present application do not limit the specific naming method.
[0036] Therefore, the embodiment of the present application establishes a mapping relationship between block files and directories by naming the directory and block files respectively, so that when a callback event is received later, it is possible to quickly and accurately know which block file the callback message corresponds to based on the mapping relationship.
[0037] In an exemplary embodiment, before determining whether there is a second thread that receives a callback event among multiple first threads in a thread pool through a preset monitoring technology, the method also includes: initializing the preset monitoring technology to obtain a first instance, wherein the first instance is used to monitor the callback event; creating a target handle corresponding to the preset monitoring technology to obtain a second instance corresponding to the target handle, wherein the second instance is used to determine the write result of the write operation through the callback event; registering a file descriptor to be monitored in the second instance, wherein the file descriptor is used to indicate the correspondence between the target field carried in the callback event and the write result of the write operation; adding the mapping directory list to the watch monitoring of the preset detection technology; and when it is determined that the file descriptor has been registered and the mapping directory list has been added, starting the thread pool and waiting for the callback event.
[0038] Optionally, the preset monitoring technology in the embodiment of the present application is inotify technology. inotify technology is a Linux kernel feature for monitoring file system events. Through the i notify technology, the program can monitor events of specific files or directories, such as the creation, modification, and deletion of files, so as to make corresponding processing when these events occur.
[0039] Then, in the embodiment of the present application, before determining whether there is a second thread that receives a callback event among the multiple first threads in the thread pool by using a preset monitoring technology, the preparation work that needs to be performed includes:
[0040] 1) Initialize the preset monitoring technology and create a monitoring instance, for example, an inotify instance, to monitor callback events;
[0041] 2) creating a target handle and obtaining a second instance corresponding to the target handle, wherein the target handle may be an epoll handle and the second instance is an epoll instance;
[0042] 3) Register the file descriptor to be monitored in the second instance, that is, register the file descriptor to be monitored in the epol 1 instance;
[0043] 4) Add the mapping directory list to inotify's watch monitoring;
[0044] 3) Start the thread pool and wait for the callback event, which is a kind of epoll event.
[0045] Therefore, through the above-mentioned preparation work, the embodiment of the present application can realize real-time monitoring of the write operation through the prepared preset monitoring technology and thread pool when executing the write operation of video data in the storage device.
[0046] In an exemplary embodiment, the write result of the write operation is determined by the callback event obtained from the second thread, including: parsing the callback event to determine the target field carried in the callback event; querying the file descriptor through the target field to determine a preset field in multiple preset fields in the file descriptor that is the same as the target field; and determining the write result through the description information corresponding to the preset field in the file descriptor.
[0047] It should be noted that the file descriptors registered to the second instance in the preparation work of the embodiment of the present application include:
[0048] I N_CLOSE_WRITE: the file is closed normally for writing;
[0049] IN MODIFY: The file is being written;
[0050] IN_ATTRIB: file attributes are modified;
[0051] I N_CLOSE_NOWRITE: The file was closed without a write operation after it was opened;
[0052] The above-mentioned multiple preset fields include: IN_CLOSE_WRITE, IN_MODIFY, IN_ATTRIB, IN_CLOSE_NOWRITE; the description information corresponding to the multiple preset fields is: the file is closed and written normally, the file is being written, the file attribute is modified, and the file is closed without writing operation after being opened. The description information corresponding to the preset field in the multiple preset fields that is the same as the target field carried in the callback event is the writing result.
[0053] Therefore, the embodiment of the present application can determine the description information of the target field through the pre-registered file descriptor by matching the target field with multiple preset fields, and then determine the write result of the write operation corresponding to the callback event.
[0054] In an exemplary embodiment, after determining whether there is a second thread that receives a callback event among multiple first threads in a thread pool through a preset monitoring technology, the method further includes: determining the number of block files on which write operations are being performed under each of the directories; and regulating the order in which all block files are written according to the number to achieve load balancing of all block files.
[0055] Optionally, the video data to be written is written into a free block file in a directory with the least “number of block files being written to”.
[0056] Optionally, a hysteresis threshold value may be set for each directory, and a load value that can be accumulated may be set. When the block files under each directory are written with video data, the load value of each directory may be accumulated to a first value (the first value may be selected to be 1). Video data is written to multiple directories in a preset order. When the load value of a certain directory reaches the hysteresis threshold value, the corresponding order of the certain directory in the preset order is adjusted to the end of the preset order, and the load value corresponding to the certain directory is reset to zero. Optionally, if the load values of multiple directories reach the hysteresis threshold value within a preset time interval, an alarm event is generated to indicate that the current storage device load may be overloaded.
[0057] Therefore, by adjusting the preset order in real time based on the load value, video data can be written to multiple directories in a balanced manner without overloading.
[0058] In an exemplary embodiment, obtaining the block file information of the block file through the callback event includes: determining a target file name of the block file carried in the callback event; and requesting the block file information of the block file from a database through the target file name, wherein the database is used to store the block file information when performing a write operation of video data.
[0059] Optionally, the database stores the block file information when executing the video data write operation, and the block file information may include the file name of the block file. Thus, the technical effect of accurately obtaining the block file information from the database according to the target file name in the callback event can be achieved. Thus, the time for querying the block file information is saved.
[0060] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0061] In order to better understand the process of the above-mentioned method for obtaining block file information, the implementation process of the above-mentioned method for obtaining block file information is described below in combination with an optional embodiment, but it is not used to limit the technical solution of the embodiment of the present application.
[0062] The optional embodiment of the present application proposes a method for dynamic monitoring of video block files (equivalent to the method for obtaining block file information in the above embodiment). The optional embodiment of the present application implements asynchronous real-time monitoring of block files through technologies such as inotify, epoll, thread pool, and database. Specifically, the changes in the directory where the block files are located are monitored in real time through the i notify method, and the inotify asynchronous notification mechanism is used to generate a callback event when a block file in the mounted directory changes. The application layer can quickly receive and analyze the callback event, and quickly locate the problem by obtaining detailed metadata information from the database once. At the same time, it is convenient for upper-level operation and maintenance, and the operation and maintenance end can obtain information such as block file status in real time.
[0063] like Figure 3 As shown, the main structure of the method for dynamically monitoring a video block file in the embodiment of the present application includes: a storage module, a dynamic monitoring module, and a block file information display module;
[0064] Among them, the storage module. The storage module mainly establishes the mounting of directories and disks, pre-creates blank files, and writes video data. Before the video service is launched, the storage module completes the creation of local directories and the mounting of disks. After the mounting is successful, multiple blank block files (equivalent to multiple block files) are created according to certain rules based on the disk space. The blank block files are named according to certain rules (i.e., preset rules). When the video service is launched, the video data is evenly written to the block files under the mounting directory, and the metadata information is synchronized to the database in real time. Therefore, the optional embodiment of the present application designs the corresponding relationship between the block file name and the metadata, and synchronizes the metadata information to the database in real time when the video is written, and establishes an effective association relationship.
[0065] Among them, the dynamic monitoring module. The dynamic monitoring module mainly includes real-time monitoring of changes in block files under the mount directory, block file management and abnormal alarms, establishing a local block file information table, using thread pools, inotify and other technologies to handle asynchronous event callbacks, and when a block write exception is detected (equivalent to a write failure), querying the database according to the block file number to obtain detailed information (i.e., block file information), generating an alarm and notifying the operation and maintenance. Cooperate with the database to perform block file status analysis.
[0066] Among them, the block file information display module interacts with the dynamic monitoring module, obtains the real-time information of the block files from the dynamic monitoring module regularly and displays it.
[0067] Specifically, the storage module of the optional embodiment of the present application has the characteristics of metadata synchronization and balanced distribution of services. It realizes the association with the database metadata information by defining the naming of blank files. When the upper layer receives abnormal block file write events, it is convenient for the dynamic monitoring module to quickly obtain detailed information from the database according to the block file number, and at the same time realizes the balanced distribution of video services in multi-disk scenarios, avoiding excessive load of services on a certain disk. The dynamic monitoring module of the optional embodiment of the present application has the characteristics of real-time monitoring, rapid analysis, abnormal alarm, etc. The dynamic monitoring module asynchronously monitors the file directory of the storage service in real time. When a block file has a write abnormality, it promptly analyzes the callback event, queries the database for detailed information on the metadata, analyzes the root cause of the problem, and generates an alarm in time, so that the operation and maintenance personnel can perceive the write abnormality at the first time. The block file information display module of the optional embodiment of the present application allows the operation and maintenance personnel to visually view the write status of the block file, effectively improving the operation and maintenance efficiency.
[0068] It should be noted that the streaming media system provides the function of writing video data for applications. A single node (i.e., storage device) includes a storage module, a dynamic monitoring module, a database module, and a block file information display module. The storage module is mainly responsible for writing data, the dynamic monitoring module is responsible for monitoring directories and files, the database module records metadata information, and the block file information display module is used to display block file related information. When the storage module pre-creates a blank file (i.e., divides it into multiple block files), it follows fixed rules, such as increasing by numbers, which makes the file name correspond to the metadata created in the database, making it convenient for the dynamic monitoring module to retrieve the database module.
[0069] Based on the above main structure, a method for dynamic monitoring of video block files in an optional embodiment of the present application is applicable to a scenario where streaming media storage is deployed at a single point. The specific implementation of the method includes:
[0070] Step 1: When initializing the streaming media scene, multiple logical disks are created in raid mode. The storage module creates a corresponding number of directories according to certain rules based on the number of logical disks, and mounts the logical disks to the directories.
[0071] Step 2: The storage module pre-creates blank files in each directory. The number of blank files depends on the size of the logical disk. A single blank file is 1G. The names of blank files start from 1 and increase in number. The file names in multiple directories are not repeated.
[0072] It should be noted that the video data storage directory has no subdirectories, and the storage directory contains block files of video data;
[0073] Step 3: The storage module receives the video data and writes the video data into the block file under the storage directory. The dynamic monitoring module records the load of each directory and notifies the storage module to perform load balancing.
[0074] Step 4: Dynamic monitoring module monitoring; the monitoring process includes:
[0075] 1) Get the mapping directory list from the storage service;
[0076] 2) inotify initialization, creating epoll handle and registering epoll events;
[0077] 3) Add directory information (i.e., mapped directory list) to inotify's watch monitoring;
[0078] 4) Start the thread pool to wait for the epoll event (i.e. callback event);
[0079] 5) read block file event (i.e. callback event);
[0080] 6) Block file event analysis.
[0081] Specifically, the dynamic monitoring module uses thread pool technology to asynchronously monitor the status of block files, which helps to improve monitoring efficiency; the dynamic monitoring module records the directory and its block file information in the storage service, and when a block file callback is received, it parses the callback event and makes a single request to the database according to the file name to obtain detailed information of the corresponding block file (i.e., block file information); the dynamic monitoring module notifies the operation and maintenance in the form of an alarm after obtaining detailed information from the database based on the abnormal information returned by the block file;
[0082] Optionally, the dynamic monitoring module may record the number of block files being written in each directory, and provide the information to the storage service at a regular interval. The storage service performs load balancing of the video service according to the number of block files being written in each directory.
[0083] It should be noted that inotify provides a variety of events for application analysis and processing, including:
[0084] 1) IN_CLOSE_WRITE: The file is closed normally for writing;
[0085] 2) IN_MODIFY: The file is being written;
[0086] 3) IN_ATTRIB: file attributes are modified;
[0087] 4)IN_CLOSE_NOWRITE: The file was closed without any write operation after it was opened.
[0088] Step 5: The block file information display module communicates with the dynamic monitoring module through RPC to obtain block file information from the dynamic monitoring module. Users can query the writing status of block files in real time through the block file information display module;
[0089] In summary, the optional embodiment of the present application proposes a solution for dynamic monitoring of video block files, which realizes dynamic monitoring of the status of video block files in video storage through database technology, thread pool, inotify and epoll, and realizes dynamic monitoring of block file directories and files by using inotify+epoll. When a block file has a write exception, the operating system calls back the corresponding event to the business layer, and the business parses the event and obtains detailed information of the block file in combination with the database to quickly locate the problem. In the case of a fault, there is no need to frequently query the database to obtain the status of the block file. In this way, the block status can be located in the first time, and the operation and maintenance can be notified in the form of an alarm, which greatly improves the efficiency of problem solving.
[0090] In this embodiment, a device for obtaining block file information is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made are omitted. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0091] Figure 4 is a structural block diagram of a device for acquiring block file information according to an embodiment of the present application, the device is applied to a dynamic monitoring module on a storage device, wherein the dynamic monitoring module communicates with a storage module on the storage device; Figure 4 As shown, the device comprises:
[0092] A first determination module 42 is used to determine, when executing a write operation of video data, whether there is a second thread in a thread pool that receives a callback event by using a preset monitoring technology, wherein the callback event is an event fed back to the thread pool by the operating system on the storage device when detecting that the write operation is executed on a block file in the storage module;
[0093] A second determining module 44 is configured to determine a writing result of the writing operation by using the callback event obtained from the second thread when there is the second thread that receives the callback event;
[0094] The acquisition module 46 is used to acquire the block file information of the block file through the callback event when the writing result is a writing failure.
[0095] Through the above device, a method for obtaining block file information is provided, which is applied to a dynamic monitoring module on a storage device, wherein the dynamic monitoring module communicates with the storage module on the storage device; the method includes: in the case of executing a write operation of video data, determining whether there is a second thread that receives a callback event among multiple first threads in the thread pool through a preset monitoring technology, wherein the callback event is an event that the operating system on the storage device feeds back to the thread pool when detecting that the block file in the storage module is executed with the write operation; in the case of the existence of the second thread that receives the callback event, determining the write result of the write operation through the callback event obtained from the second thread; in the case where the write result is a write failure, obtaining the block file information of the block file through the callback event. Therefore, the problem in the related art that the upper-layer application service cannot quickly obtain the block file information of the block file used to write the video data in the case of a video data write failure can be solved. The technical effect of quickly and accurately obtaining the block file information of the block file used to write the video data is achieved.
[0096] In an exemplary embodiment, before determining whether there is a second thread that receives a callback event among multiple first threads in a thread pool through a preset monitoring technology, the device also includes an establishment module, which is used to: determine multiple logical disks mounted on a storage device, and establish directories corresponding to the multiple logical disks; divide each logical disk into multiple block files according to a target granularity, and establish a mapping relationship between the multiple block files and the directory to obtain a mapping directory list, wherein the multiple block files are blank block files, and all block files on the storage device include: the block files, and all block files include: multiple block files corresponding to multiple logical disks respectively.
[0097] In an exemplary embodiment, the establishment module is also used to: name the multiple block files corresponding to each logical disk according to preset rules to obtain a file name corresponding to each block file, wherein the file name of each block file allows unique identification of each block file; establish a mapping relationship between the multiple block files and the directory through the file name to obtain a mapping directory list.
[0098] In an exemplary embodiment, before determining whether there is a second thread that receives a callback event among multiple first threads in a thread pool through a preset monitoring technology, the device also includes a startup module, which is used to: initialize the preset monitoring technology to obtain a first instance, wherein the first instance is used to monitor the callback event; create a target handle corresponding to the preset monitoring technology to obtain a second instance corresponding to the target handle, wherein the second instance is used to determine the write result of the write operation through the callback event; register a file descriptor to be monitored in the second instance, wherein the file descriptor is used to indicate the correspondence between the target field carried in the callback event and the write result of the write operation; add the mapping directory list to the watch monitoring of the preset detection technology; and when it is determined that the file descriptor has been registered and the mapping directory list has been added, start the thread pool and wait for the callback event.
[0099] In an exemplary embodiment, the second determination module 44 is also used to: parse the callback event to determine the target field carried in the callback event; query the file descriptor through the target field to determine a preset field in the file descriptor that is the same as the target field; and determine the write result through the description information corresponding to the preset field in the file descriptor.
[0100] In an exemplary embodiment, after determining whether there is a second thread that receives a callback event among multiple first threads in the thread pool through a preset monitoring technology, the device also includes a control module, which is used to: determine the number of block files on which write operations are being performed in each of the directories; and control the writing order of all the block files according to the number to achieve load balancing of all the block files.
[0101] In an exemplary embodiment, the acquisition module 46 is further used to: determine the target file name of the block file carried in the callback event; and request block file information of the block file from a database through the target file name, wherein the database is used to store the block file information when performing a write operation of video data.
[0102] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0103] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0104] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0105] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0106] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0107] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0108] An embodiment of the present application also provides a computer program, which includes computer instructions stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in any one of the above method embodiments.
[0109] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0110] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0111] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for obtaining block file information, characterized in that: A dynamic monitoring module applied to a storage device, wherein the dynamic monitoring module communicates with a storage module on the storage device; the method comprises: In the case of executing a write operation of video data, determining whether there is a second thread that receives a callback event among multiple first threads in the thread pool by using a preset monitoring technology, wherein the callback event is an event fed back to the thread pool by the operating system on the storage device when detecting that the block file in the storage module is subjected to the write operation; in the case of the existence of the second thread that receives the callback event, determining a write result of the write operation by using the callback event obtained from the second thread; When the writing result is a writing failure, the block file information of the block file is obtained through the callback event.
2. The method according to claim 1, characterized in that Before determining by a preset monitoring technology whether there is a second thread in the thread pool that receives a callback event, the method further includes: Determine multiple logical disks mounted on the storage device and create directories corresponding to the multiple logical disks; Each logical disk is divided into a plurality of block files according to a target granularity, and a mapping relationship between the plurality of block files and the directory is established to obtain a mapping directory list, wherein the plurality of block files are blank block files, and all block files on the storage device include: the block files, and the all block files include: a plurality of block files corresponding to the plurality of logical disks respectively.
3. The method according to claim 2, characterized in that Establishing a mapping relationship between the plurality of block files and the directories to obtain a mapping directory list includes: According to a preset rule, the plurality of block files corresponding to each logical disk are named respectively to obtain a file name corresponding to each block file, wherein the file name of each block file allows to uniquely identify each block file; A mapping relationship between the plurality of block files and the directories is established through the file names to obtain a mapping directory list.
4. The method according to claim 2, characterized in that: Before determining by a preset monitoring technology whether there is a second thread in the thread pool that receives a callback event, the method further includes: Initializing the preset monitoring technology to obtain a first instance, wherein the first instance is used to monitor the callback event; Creating a target handle corresponding to the preset monitoring technology, and obtaining a second instance corresponding to the target handle, wherein the second instance is used to determine a writing result of the writing operation through the callback event; Registering a file descriptor to be monitored in the second instance, wherein the file descriptor is used to indicate a corresponding relationship between a target field carried in the callback event and a write result of the write operation; Add the mapping directory list to the watch monitoring of the preset detection technology; When it is determined that the file descriptor has been registered and the mapping directory list has been added, the thread pool is started to wait for the callback event.
5. The method according to claim 4, characterized in that Determining a write result of the write operation by the callback event obtained from the second thread includes: Parsing the callback event to determine the target field carried in the callback event; The file descriptor is queried through the target field to determine a preset field in the plurality of preset fields in the file descriptor that is the same as the target field; The writing result is determined by the description information corresponding to the preset field in the file descriptor.
6. The method according to claim 2, characterized in that After determining whether there is a second thread receiving a callback event among the plurality of first threads in the thread pool by using a preset monitoring technology, the method further includes: Determine the number of block files being written to in each directory; The writing order of all the block files is regulated by the number to achieve load balancing of all the block files.
7. The method according to claim 1, characterized in that Obtaining the block file information of the block file through the callback event includes: Determine the target file name of the block file carried in the callback event; The block file information of the block file is requested from a database through the target file name, wherein the database is used to store the block file information when a write operation of video data is performed.
8. A device for obtaining block file information, characterized in that: A dynamic monitoring module applied to a storage device, wherein the dynamic monitoring module communicates with a storage module on the storage device; the device comprises: A first determination module is used to determine, by a preset monitoring technology, whether there is a second thread in a thread pool that receives a callback event when a video data write operation is performed, wherein the callback event is an event fed back to the thread pool by the operating system on the storage device when it detects that the block file in the storage module is written. A second determining module is used to determine the writing result of the writing operation by using the callback event obtained from the second thread when there is the second thread that receives the callback event; The acquisition module is used to acquire the block file information of the block file through the callback event when the writing result is a writing failure.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Cloud storage quota management method based on Linux kernel monitoring
CN105468989A
Storage management method and apparatus as well as stream media system
CN105867836A
Task scheduling method, device, electronic device and storage medium
CN109284180A
Real-time video processing method and device, equipment and storage medium
CN115955581A
Streaming media storage method and system, server, electronic equipment and storage medium
CN117880553A