CN103037203B - A kind of index restoration methods based on block storage and device - Google Patents
A kind of index restoration methods based on block storage and device Download PDFInfo
- Publication number
- CN103037203B CN103037203B CN201210538931.8A CN201210538931A CN103037203B CN 103037203 B CN103037203 B CN 103037203B CN 201210538931 A CN201210538931 A CN 201210538931A CN 103037203 B CN103037203 B CN 103037203B
- Authority
- CN
- China
- Prior art keywords
- index
- frame group
- storage resource
- end time
- last
- 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.)
- Active
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明提供一种基于块存储的索引恢复方法和装置,属于视频监控技术领域。所述方法包括:当满足索引恢复条件时,从待进行索引恢复的视频编码设备对应的存储资源的超级块中获取数据的结束时间;根据所述存储资源的索引获取所述结束时间对应的I帧组,并从所述I帧组中获取时间戳信息TM_Last;从所述存储资源中获取所述I帧组的后续I帧组,每获取一个I帧组,从该I帧组中获取时间戳信息TM,当0<TM-TM_Last≤Tc时,根据该I帧组的信息对所述存储资源的索引进行更新,其中,Tc为所述视频编码设备对应的索引缓存时间。本发明能够在视频编码设备离线后,对相应的索引数据进行及时的恢复,从而保证索引数据的完整性。
The invention provides a block storage-based index recovery method and device, belonging to the technical field of video surveillance. The method includes: when the index restoration condition is satisfied, obtaining the end time of the data from the super block of the storage resource corresponding to the video coding device to be index restored; obtaining the I corresponding to the end time according to the index of the storage resource frame group, and obtain the timestamp information TM_Last from the I frame group; obtain the subsequent I frame group of the I frame group from the storage resource, and obtain the time from the I frame group for each I frame group Stamp information TM, when 0<TM-TM_Last≤Tc, update the index of the storage resource according to the information of the I frame group, where Tc is the index cache time corresponding to the video encoding device. The present invention can restore the corresponding index data in time after the video encoding device is offline, thereby ensuring the integrity of the index data.
Description
技术领域technical field
本发明涉及视频监控技术领域,尤其涉及一种基于块存储的索引恢复方法和装置。The present invention relates to the technical field of video monitoring, in particular to a block storage-based index recovery method and device.
背景技术Background technique
目前,在视频监控系统中使用互联网协议存储区域网络(InternetProtocolStorageAreaNetwork,IPSAN)作为存储普遍应用。监控编码设备将获取到的监控数据存储到IPSAN中,当用户需要查看历史监控数据时,可以从IPSAN中读取相应的监控数据。Currently, Internet Protocol Storage Area Network (IPSAN) is widely used as storage in video surveillance systems. The monitoring encoding device stores the obtained monitoring data in the IPSAN, and when the user needs to view the historical monitoring data, he can read the corresponding monitoring data from the IPSAN.
图1为一种现有的视频监控系统的典型组网结构示意图,其中,视频编码器(Encoder,EC)通过互联网小型计算机系统接口(internetSmallComputerSystemInterface,iSCSI)与IPSAN连接,并将监控摄像机获取到的监控数据进行编码后存储在IPSAN中。当用户需要查看历史监控数据时,可以通过视频监控客户端(VideoClient,VC)或者视频解码器(Decoder,DC)向视频监控服务器(VideoManagement,VM)发送回放请求,VM接收到该回放请求后,向数据管理服务器(DataManagement,DM)发送指示消息,指示DM读取IPSAN中存储的相应监控数据,并返回给VC或者DC。Figure 1 is a schematic diagram of a typical network structure of an existing video surveillance system, in which a video encoder (Encoder, EC) is connected to an IPSAN through an Internet Small Computer System Interface (iSCSI), and the video acquired by the surveillance camera The monitoring data is encoded and stored in IPSAN. When users need to view historical monitoring data, they can send a playback request to the video monitoring server (VideoManagement, VM) through the video monitoring client (VideoClient, VC) or video decoder (Decoder, DC). After the VM receives the playback request, Send an instruction message to the data management server (Data Management, DM), instruct the DM to read the corresponding monitoring data stored in the IPSAN, and return it to the VC or DC.
在上述的组网结构中,IPSAN将多个磁盘组成独立磁盘冗余阵列(RAID)后,将RAID分成一系列逻辑单元,每个逻辑单元都有一个逻辑单元号(LUN),然后将LUN分配给EC进行存储。EC录像数据的一种存储格式可以如图2所示,其中,该存储格式是基于块的存储格式,包括超级块、主索引区和多个数据区,每个数据区对应一个数据块,数据块的大小可以为256M,每个数据块包括副索引区和多个I帧组,可选地,所述数据块中还包括有填充区。In the above networking structure, after IPSAN forms multiple disks into a redundant array of independent disks (RAID), the RAID is divided into a series of logical units, each logical unit has a logical unit number (LUN), and then the LUN is allocated To EC for storage. A kind of storage format of EC recording data can be shown in Figure 2, wherein, this storage format is based on block storage format, comprises super block, main index area and multiple data areas, and each data area corresponds to a data block, data The size of the block may be 256M, and each data block includes a secondary index area and a plurality of I frame groups. Optionally, the data block also includes a padding area.
EC按照图2所示的索引结构将录像数据存入IPSAN,每次数据写入都需要更改索引区,因此索引区数据读写频繁。回放录像时,首先是读取主索引区(一级索引),然后找到指定的数据区,再从数据区中根据副索引(二级索引)查找到指定时间的I帧组数据,然后读取I帧组数据发给客户端进行播放。其中,主索引区和副索引区的结构如图3所示,包括索引描述和索引项,索引项的内容为时间和/或空间信息,根据索引项的内容可以查询指定时刻的录像数据所在的位置。EC stores video data into IPSAN according to the index structure shown in Figure 2, and the index area needs to be changed every time data is written, so the data in the index area is frequently read and written. When playing back the video, first read the main index area (first-level index), then find the specified data area, and then find the I frame group data at the specified time according to the sub-index (secondary index) from the data area, and then read The I frame group data is sent to the client for playback. Among them, the structure of the main index area and the sub-index area is shown in Figure 3, including index descriptions and index items. The content of the index items is time and/or space information. Location.
为了避免频繁的读写索引区域,现有的一种解决方案为,EC将索引区存于自身的缓存中,设定一个索引缓存时间(例如16秒),当索引缓存时间到达时进行一次索引区数据的写入,I帧组数据则是持续的写入数据区。In order to avoid frequent reading and writing of the index area, an existing solution is that the EC stores the index area in its own cache, sets an index cache time (for example, 16 seconds), and performs an index when the index cache time arrives Area data is written, and I frame group data is continuously written into the data area.
在上述解决方案中,由于索引数据非即时写入物理硬盘,当EC发生故障或被人为损坏时,录像数据已经写入存储设备,但缓存中的索引数据可能还没有写入存储设备,导致一部分录像数据无法查看。In the above solutions, since the index data is not written to the physical hard disk immediately, when the EC fails or is artificially damaged, the video data has been written to the storage device, but the index data in the cache may not have been written to the storage device, resulting in some Recorded data cannot be viewed.
发明内容Contents of the invention
有鉴于此,本发明的目的是提供一种基于块存储的索引恢复方法和装置,能够在视频编码设备离线后,对索引数据进行及时的恢复,从而保证索引数据的完整性。In view of this, the purpose of the present invention is to provide a method and device for index recovery based on block storage, which can recover index data in time after the video encoding device is offline, thereby ensuring the integrity of the index data.
为实现上述目的,本发明提供技术方案如下:To achieve the above object, the present invention provides technical solutions as follows:
一种基于块存储的索引恢复方法,应用于视频监控系统中,所述索引恢复方法包括:A block storage-based index recovery method applied in a video surveillance system, the index recovery method comprising:
当满足索引恢复条件时,从待进行索引恢复的视频编码设备对应的存储资源的超级块中获取数据的结束时间;When the index recovery condition is satisfied, the end time of data is obtained from the super block of the storage resource corresponding to the video encoding device to be index recovered;
根据所述存储资源的索引获取所述结束时间对应的I帧组,并从所述I帧组中获取时间戳信息TM_Last;Obtain the I frame group corresponding to the end time according to the index of the storage resource, and obtain the time stamp information TM_Last from the I frame group;
从所述存储资源中获取所述I帧组的后续I帧组,每获取一个I帧组,从该I帧组中获取时间戳信息TM,当0<TM-TM_Last≤Tc时,根据该I帧组的信息对所述存储资源的索引进行更新,其中,Tc为所述视频编码设备对应的索引缓存时间。Obtain the subsequent I-frame group of the I-frame group from the storage resource, and acquire time stamp information TM from the I-frame group for each I-frame group, and when 0<TM-TM_Last≤Tc, according to the I-frame group The frame group information updates the index of the storage resource, where Tc is the index cache time corresponding to the video encoding device.
一种基于块存储的索引恢复装置,应用于视频监控系统中,所述索引恢复装置包括:An index recovery device based on block storage, applied in a video surveillance system, the index recovery device includes:
结束时间获取模块,用于当满足索引恢复条件时,从待进行索引恢复的视频编码设备对应的存储资源的超级块中获取索引的结束时间;The end time acquisition module is used to obtain the end time of the index from the super block of the storage resource corresponding to the video coding device to be indexed when the index recovery condition is met;
结束帧组获取模块,用于根据所述存储资源的索引获取所述结束时间对应的I帧组,并从所述I帧组中获取时间戳信息TM_Last;An end frame group acquisition module, configured to acquire the I frame group corresponding to the end time according to the index of the storage resource, and obtain time stamp information TM_Last from the I frame group;
索引更新模块,用于从所述存储资源中获取所述I帧组的后续I帧组,每获取一个I帧组,从该I帧组中获取时间戳信息TM,当0<TM-TM_Last≤Tc时,根据该I帧组的信息对所述存储资源的索引进行更新,其中,Tc为所述视频编码设备对应的索引缓存时间。An index update module, configured to obtain the subsequent I frame group of the I frame group from the storage resource, and obtain time stamp information TM from the I frame group for each I frame group obtained, when 0<TM-TM_Last≤ At Tc, the index of the storage resource is updated according to the information of the I frame group, where Tc is the index cache time corresponding to the video encoding device.
根据本发明的上述技术方案,在视频编码设备离线后需要进行索引恢复时,从与该视频编码设备对应的存储资源的超级块中获取索引的结束时间,并根据所述存储资源的索引获取所述结束时间对应的I帧组,根据所述I帧组就能够获取后续的I帧组,并根据获取到的I帧组的信息对所述存储资源的索引进行更新,如此,实现了对索引数据的及时恢复,从而保证了索引数据的完整性,使得客户端可以根据完整的索引数据查看任意时刻的录像数据。According to the above technical solution of the present invention, when the video coding device needs to restore the index after being offline, the end time of the index is obtained from the super block of the storage resource corresponding to the video coding device, and the index is obtained according to the index of the storage resource. According to the I frame group corresponding to the end time, the subsequent I frame group can be obtained according to the I frame group, and the index of the storage resource is updated according to the information of the obtained I frame group, so that the index The timely recovery of data ensures the integrity of the index data, so that the client can view the video data at any time according to the complete index data.
附图说明Description of drawings
图1为现有的视频监控系统的典型组网结构示意图;Fig. 1 is a schematic diagram of a typical networking structure of an existing video surveillance system;
图2为是录像数据的一种存储格式示意图;Fig. 2 is a schematic diagram of a storage format of video data;
图3为主索引区和副索引区的结构示意图;Figure 3 is a schematic structural diagram of the main index area and the sub-index area;
图4为本发明实施例的基于块存储的索引恢复方法流程图;FIG. 4 is a flow chart of an index recovery method based on block storage according to an embodiment of the present invention;
图5为本发明实施例的基于块存储的索引恢复装置结构图。FIG. 5 is a structural diagram of an index restoration device based on block storage according to an embodiment of the present invention.
图6为本发明实施例中超级索引块的结构图。FIG. 6 is a structural diagram of a super index block in an embodiment of the present invention.
图7为本发明实施例中一级索引中的索引描述的数据结构图。FIG. 7 is a data structure diagram of an index description in a first-level index in an embodiment of the present invention.
图8为本发明实施例中一级索引中的索引项的数据结构图。FIG. 8 is a data structure diagram of index items in a primary index in an embodiment of the present invention.
图9为本发明实施例中二级索引中的索引描述的数据结构图。FIG. 9 is a data structure diagram of an index description in a secondary index in an embodiment of the present invention.
图10为本发明实施例中二级索引中的索引项的数据结构图。FIG. 10 is a data structure diagram of index items in a secondary index in an embodiment of the present invention.
具体实施方式detailed description
为解决现有技术中存在的录像数据已经写入存储设备,但缓存中的索引数据可能还没有写入存储设备,导致一部分录像数据无法查看的问题,本发明实施例提供的一种解决方案为,从离线的视频编码设备对应的存储资源的超级块中获取索引的结束时间,然后,根据所述存储资源的索引获取所述结束时间对应的I帧组,根据所述I帧组从所述存储资源中获取后续的I帧组,每获取一个I帧组,并根据该I帧组的信息对所述存储资源的索引进行更新。In order to solve the problem in the prior art that the video data has been written into the storage device, but the index data in the cache may not be written into the storage device, resulting in a part of the video data cannot be viewed, a solution provided by the embodiment of the present invention is Obtain the end time of the index from the super block of the storage resource corresponding to the offline video encoding device, then obtain the I frame group corresponding to the end time according to the index of the storage resource, and obtain the I frame group corresponding to the end time according to the I frame group from the Subsequent I frame groups are acquired from the storage resource, and each I frame group is acquired, and the index of the storage resource is updated according to the information of the I frame group.
以下结合附图对本发明进行详细描述。The present invention will be described in detail below in conjunction with the accompanying drawings.
在本发明的下述实施例中,是以图2所示的存储格式为例来描述索引数据的恢复,需要说明的是,本发明实施例的方案也可以适用于基于块存储方式的其他存储格式。In the following embodiments of the present invention, the storage format shown in Figure 2 is used as an example to describe the restoration of index data. It should be noted that the solutions in the embodiments of the present invention can also be applied to other storage based on block storage Format.
图4为本发明实施例的基于块存储的索引恢复方法流程图,所述索引恢复方法应用于视频监控系统中,所述视频监控系统可以包括视频监控服务器、视频监控客户端、视频编码设备、IPSAN等,视频监控服务器包括数据管理服务器DM和视频管理服务器VM等,所述视频编码设备可以是网络摄像机IPC和视频编码器EC等。其中,所述索引恢复方法可以由视频监控服务器例如DM执行,也可以由视频编码设备执行。下面以所述索引恢复方法由DM执行,且视频编码设备为EC为例进行说明。FIG. 4 is a flow chart of an index restoration method based on block storage according to an embodiment of the present invention. The index restoration method is applied to a video surveillance system, and the video surveillance system may include a video surveillance server, a video surveillance client, a video encoding device, IPSAN, etc., the video monitoring server includes a data management server DM and a video management server VM, etc., and the video encoding device can be a network camera IPC and a video encoder EC, etc. Wherein, the index restoration method may be executed by a video monitoring server such as DM, or may be executed by a video encoding device. In the following, the method for recovering the index is executed by the DM and the video encoding device is an EC as an example for illustration.
参照图4,所述索引恢复方法可以包括如下步骤:Referring to Figure 4, the index recovery method may include the following steps:
步骤401,当满足索引恢复条件时,从待进行索引恢复的视频编码器对应的存储资源的超级块中获取数据的结束时间;Step 401, when the index restoration condition is met, the end time of the data is obtained from the super block of the storage resource corresponding to the video encoder to be index restored;
所述索引恢复条件可以为:视频编码设备离线后,所述数据管理服务器的巡检时间间隔到达;或者,视频编码设备离线后,用户手动查询视频编设备对应的存储资源;或者,视频编码设备重新上线。The index recovery condition may be: after the video encoding device is offline, the inspection time interval of the data management server arrives; or, after the video encoding device is offline, the user manually queries the storage resources corresponding to the video encoding device; or, the video encoding device back online.
具体地,EC的网络异常或被人为破坏之后,VM在一段时间内将检测到EC离线,然后,VM可以查询该EC是否配置存储计划,如果已配置存储计划,则可以将该EC的存储计划做一个“待恢复”标记,并查询该EC对应的DM,将EC离线的信息通知给该DM。其中,VM记录有各个EC的索引缓存时间(Tc,如果全局统一,则记入全局参数)。DM在巡检时间间隔到达或者当有用户手动查询该编码器上通道录像时,DM向VM获取该编码器对应通道的索引缓存时间Tc,然后对该录像数据进行索引恢复过程。Specifically, after the EC's network is abnormal or artificially destroyed, the VM will detect that the EC is offline within a period of time, and then the VM can query whether the EC has a storage plan configured. If the storage plan has been configured, the EC's storage plan can be Make a "to be restored" mark, and query the DM corresponding to the EC, and notify the DM of the offline information of the EC. Among them, the VM records the index cache time of each EC (Tc, if it is unified globally, it will be recorded in the global parameter). When the DM arrives at the inspection time interval or when a user manually inquires the channel recording on the encoder, the DM obtains the index cache time Tc of the corresponding channel of the encoder from the VM, and then performs the index recovery process on the recording data.
另外,当EC上线时,VM收到EC的注册消息后,检测该EC对应的存储计划状态,如果处于“待恢复”状态,则马上进行录像恢复过程,同时通知EC存储计划暂停,直到下述的所述恢复过程结束后,再通知EC开始存储。In addition, when the EC goes online, after receiving the registration message from the EC, the VM detects the status of the storage plan corresponding to the EC. If it is in the "to be resumed" state, it immediately resumes the recording process and notifies the EC that the storage plan is suspended until the following After the recovery process ends, the EC is notified to start storage.
DM在确定需要进行索引恢复时,首先获取对该EC的存储资源的读写权限,具体地,是将EC通道对应的存储资源以读写方式挂载(即在存储设备上将iSCSItarget设置成读写,同时重新通过iSCSI连接存储磁盘);然后,查询该存储资源的超级块信息,获取当前超级块中索引的结束时间。When the DM determines that index recovery is required, first obtain the read and write permissions for the storage resources of the EC, specifically, mount the storage resources corresponding to the EC channel in read and write mode (that is, set the Write, and reconnect to the storage disk through iSCSI at the same time); then, query the superblock information of the storage resource to obtain the end time of the index in the current superblock.
例如,对于图2所示的存储格式,其中的超级块数据结构可以参考图6所示,可以获取其中的end_time作为索引的结束时间。For example, for the storage format shown in FIG. 2 , the super block data structure therein may refer to that shown in FIG. 6 , and the end_time therein may be obtained as the end time of the index.
在上述数据结构中,units是静态配置的,也就是说,其值是固定的,具体值与EC对应的存储资源的大小有关。对于end_time,其对应于有索引信息的最后一个I帧组的时间。In the above data structure, units are statically configured, that is, their values are fixed, and the specific values are related to the size of the storage resources corresponding to ECs. For end_time, it corresponds to the time of the last I-frame group with index information.
步骤402,根据所述存储资源的索引获取所述结束时间对应的I帧组,并从所述I帧组中获取时间戳信息TM_Last;Step 402, obtain the I frame group corresponding to the end time according to the index of the storage resource, and obtain the time stamp information TM_Last from the I frame group;
首先,根据所述存储资源的一级索引定位所述结束时间对应的数据块;然后,根据定位到的数据块中的二级索引获取所述结束时间对应的I帧组。First, locate the data block corresponding to the end time according to the primary index of the storage resource; then, obtain the I frame group corresponding to the end time according to the secondary index in the located data block.
具体地,DM在获取到所述结束时间后,通过查询一级索引项中的时间信息找出该结束时间对应的数据块(一级索引项的时间信息为每个数据块中第一个I帧组的时间,这里的查询过程可以用二分法实现)。Specifically, after obtaining the end time, the DM finds the data block corresponding to the end time by querying the time information in the first-level index item (the time information of the first-level index item is the first I in each data block) The time of the frame group, the query process here can be realized by dichotomy).
例如,对于图2所示的存储格式,其一级索引中的索引描述的数据结构可以参考图7所示。其一级索引中的索引项的数据结构可以参考图8所示。For example, for the storage format shown in FIG. 2 , reference can be made to the data structure shown in FIG. 7 for the index description in the first-level index. The data structure of the index items in the first-level index can be referred to as shown in FIG. 8 .
索引项中包括如下时间信息:year为年,month为月,day为日,hour为小时,minute为分钟,second为秒。将所述结束时间与索引项中的时间信息进行比较,可以确定该结束时间对应的数据块。The index item includes the following time information: year is the year, month is the month, day is the day, hour is the hour, minute is the minute, and second is the second. By comparing the end time with the time information in the index item, the data block corresponding to the end time can be determined.
在定位到所述结束时间对应的数据块后,就可以从该数据块中的二级索引获取所述结束时间对应的I帧组。例如,对于图2所示的存储格式,其二级索引中的索引描述的数据结构可以参考图9所示;而其二级索引中的索引项的数据结构可以参考图10所示。After the data block corresponding to the end time is located, the I frame group corresponding to the end time can be obtained from the secondary index in the data block. For example, for the storage format shown in FIG. 2 , refer to FIG. 9 for the data structure of the index description in the secondary index; and refer to FIG. 10 for the data structure of the index items in the secondary index.
在块存储方案中,可以以例如16k作为一个存储单元,且以存储单元作为最小单位存储接收到的数据。为区别于一级索引中的数据块,将二级索引中的存储单元称为二级数据块。In the block storage scheme, for example, 16k may be used as a storage unit, and the storage unit may be used as a minimum unit to store received data. In order to distinguish it from the data blocks in the primary index, the storage units in the secondary index are called secondary data blocks.
在上述数据结构中,pos表示一个数据块(256M)中最后一个二级数据块(16K)的结束位置,items表示当前写完的二级数据块的索引号;year为年,month为月,day为日,hour为小时,minute为分钟,second为秒;block_offset表示该索引项对应的I帧组的开始位置相对于256M的数据块的开始位置所偏移的二级数据块的数目。In the above data structure, pos indicates the end position of the last secondary data block (16K) in a data block (256M), and items indicates the index number of the currently written secondary data block; year is year, month is month, day is the day, hour is the hour, minute is the minute, and second is the second; block_offset indicates the number of secondary data blocks offset by the start position of the I frame group corresponding to the index item relative to the start position of the 256M data block.
根据二级索引项可以定位到所述结束时间对应的I帧组,从所述I帧组中获取时间戳信息TM_Last。According to the secondary index item, the I frame group corresponding to the end time can be located, and the time stamp information TM_Last is obtained from the I frame group.
例如,对于图2所示的存储格式,每个I帧组的数据结构如下:For example, for the storage format shown in Figure 2, the data structure of each I frame group is as follows:
其中,20字节头的数据结构如下:Among them, the data structure of the 20-byte header is as follows:
可以看出,20字节头中带有时间戳信息。在本发明实施例中,TM_Last是I帧组中起始I帧数据包对应的20字节头中的时间戳信息。It can be seen that the 20-byte header contains timestamp information. In the embodiment of the present invention, TM_Last is the timestamp information in the 20-byte header corresponding to the initial I-frame data packet in the I-frame group.
步骤403,从所述存储资源中获取所述I帧组的后续I帧组,每获取一个I帧组,从该I帧组中获取时间戳信息TM,当0<TM-TM_Last≤Tc时,根据该I帧组的信息对所述存储资源的索引进行更新;当TM-TM_Last>Tc,或者,TM-TM_Last≤0时,结束索引恢复过程。Step 403: Obtain the subsequent I frame group of the I frame group from the storage resource, and obtain time stamp information TM from the I frame group for each I frame group obtained. When 0<TM-TM_Last≤Tc, The index of the storage resource is updated according to the information of the I frame group; when TM-TM_Last>Tc, or TM-TM_Last≤0, the index recovery process ends.
对于后续的I帧组,在索引区中没有这些I帧组的信息,因此根据索引查询不到这些I帧组。由于I帧组数据在存储资源中是连续存储的,因此,在本发明实施例中,通过获取有索引记录的最后一个I帧组的结束位置,并可以根据该结束位置获取后续的没有索引信息的I帧组,具体地,根据该结束位置可以获取下一个I帧组,根据下一个I帧组的结束位置可以获取再下一个I帧组,依此类推,可以获取后续的多个I帧组。之后,根据这些I帧组的信息就可以对索引进行更新,从而能够保证索引数据是完整的。For subsequent I frame groups, there is no information about these I frame groups in the index area, so these I frame groups cannot be queried according to the index. Since the I-frame group data is stored continuously in the storage resource, in the embodiment of the present invention, by obtaining the end position of the last I-frame group recorded with an index, the subsequent non-index information can be obtained according to the end position Specifically, according to the end position, the next I frame group can be obtained, according to the end position of the next I frame group, the next I frame group can be obtained, and so on, subsequent multiple I frames can be obtained Group. Afterwards, the index can be updated according to the information of these I frame groups, so as to ensure that the index data is complete.
在本发明实施例中,还设置了索引恢复的结束条件。具体地,EC进行索引数据写入的周期为Tc,那么,即使由于某种原因导致EC离线,对于TM-TM_Last>Tc的I帧组数据(EC上线后,在没有完成索引恢复时已经开始数据存储的情况下,会出现TM-TM_Last>Tc的情况),在索引区中会存在对应的索引数据,因此,设置索引恢复的一个结束条件为TM-TM_Last>Tc;由于对存储资源是重复写入的,即当存储资源的存储空间被写满,会对存储资源进行覆写,因此,设置索引恢复的另一个结束条件为TM-TM_Last≤0。In the embodiment of the present invention, an end condition for index recovery is also set. Specifically, the cycle for EC to write index data is Tc, then, even if the EC is offline for some reason, for the I frame group data of TM-TM_Last > Tc (after the EC goes online, the data has already started before the index recovery is completed In the case of storage, there will be a situation where TM-TM_Last>Tc), and there will be corresponding index data in the index area. Therefore, an end condition for index recovery is set to TM-TM_Last>Tc; since the storage resource is repeatedly written In, that is, when the storage space of the storage resource is full, the storage resource will be overwritten. Therefore, another end condition for index recovery is set to TM-TM_Last≤0.
根据该I帧组的信息对所述存储资源的索引进行更新的具体过程为:The specific process of updating the index of the storage resource according to the information of the I frame group is:
(1)根据该I帧组的大小、位置以及时间戳信息,更新二级索引;(1) Update the secondary index according to the size, position and timestamp information of the I frame group;
具体地,可以将该I帧组的时间戳对应的时间写入二级索引项的时间字段中,将I帧组的位置和大小(即包括的二级数据块数目)分别写入二级索引项的block_offset和block_num中,并相应更新二级索引描述中的items值和pos值。Specifically, the time corresponding to the timestamp of the I frame group can be written into the time field of the secondary index item, and the position and size of the I frame group (that is, the number of secondary data blocks included) can be written into the secondary index block_offset and block_num of the item, and correspondingly update the items value and pos value in the secondary index description.
(2)如果该I帧组为数据块中的第一个I帧组,还更新一级索引;(2) If the I frame group is the first I frame group in the data block, also update the primary index;
具体地,可以将该I帧组的时间戳对应的时间写入一级索引项中,同时更新一级索引描述中的items值为当前写入的数据块的索引号。Specifically, the time corresponding to the time stamp of the I frame group may be written into the primary index item, and at the same time, the value of items in the primary index description may be updated as the index number of the currently written data block.
(3)更新超级块中索引的结束时间为该I帧组对应的时间戳信息。(3) The end time of the index in the super block is updated to be the timestamp information corresponding to the I frame group.
进一步,DM在完成索引恢复后,还可以向VM发送消息,VM收到消息后清除对应EC的存储计划的“待恢复”标记,然后,VM检测对应的EC通道是否在线,如果在线,则可以通知其恢复存储。Furthermore, after the DM completes the index recovery, it can also send a message to the VM. After receiving the message, the VM clears the "to be recovered" mark of the storage plan corresponding to the EC. Then, the VM checks whether the corresponding EC channel is online. If it is online, it can Notify it to resume storage.
进一步,DM在完成索引恢复后,还可以将EC故障前预定时长(例如,最后1秒)的录像数据发送给VM,由VM将其与EC的离线告警绑定。Furthermore, after the DM completes the index recovery, it can also send the recording data of the predetermined time (for example, the last 1 second) before the failure of the EC to the VM, and the VM binds it to the offline alarm of the EC.
与上述基于块存储的索引恢复方法相对应,本发明实施例还提供一种实现该方法的装置。Corresponding to the above method for restoring an index based on block storage, an embodiment of the present invention further provides an apparatus for implementing the method.
图5为本发明实施例的基于块存储的索引恢复装置图,所述索引恢复装置应用于视频监控系统中,具体地,所述索引恢复装置可以设置在视频监控服务器例如数据管理服务器DM上,也可以设置在视频编码设备例如网络摄像机IPC或视频编码器EC上。FIG. 5 is a diagram of an index recovery device based on block storage according to an embodiment of the present invention. The index recovery device is applied in a video surveillance system. Specifically, the index recovery device can be set on a video surveillance server such as a data management server DM, It can also be set on a video encoding device such as an IP camera IPC or a video encoder EC.
参照图5,所述索引恢复装置可以包括结束时间获取模块10、结束帧组获取模块20和索引更新模块30。其中:Referring to FIG. 5 , the index recovery device may include an end time acquisition module 10 , an end frame group acquisition module 20 and an index update module 30 . in:
结束时间获取模块10,用于当满足索引恢复条件时,从待进行索引恢复的视频编码设备对应的存储资源的超级块中获取数据的结束时间。所述索引恢复条件可以为:视频编码设备离线后,所述数据管理服务器的巡检时间间隔到达;或者,视频编码设备离线后,用户手动查询视频编设备对应的存储资源;或者,视频编码设备重新上线。The end time acquisition module 10 is configured to acquire the end time of data from the super block of the storage resource corresponding to the video encoding device to be index restored when the index restoration condition is met. The index recovery condition may be: after the video encoding device is offline, the inspection time interval of the data management server arrives; or, after the video encoding device is offline, the user manually queries the storage resources corresponding to the video encoding device; or, the video encoding device back online.
结束帧组获取模块20,用于根据所述存储资源的索引获取所述结束时间对应的I帧组,并从所述I帧组中获取时间戳信息TM_Last。具体地,可以根据所述存储资源的一级索引定位所述结束时间对应的数据块,然后,根据定位到的数据块中的二级索引获取所述结束时间对应的I帧组。The end frame group obtaining module 20 is configured to obtain the I frame group corresponding to the end time according to the index of the storage resource, and obtain time stamp information TM_Last from the I frame group. Specifically, the data block corresponding to the end time may be located according to the primary index of the storage resource, and then the I frame group corresponding to the end time may be acquired according to the secondary index in the located data block.
索引更新模块30,用于从所述存储资源中获取所述I帧组的后续I帧组,每获取一个I帧组,从该I帧组中获取时间戳信息TM,当0<TM-TM_Last≤Tc时,根据该I帧组的信息对所述存储资源的索引进行更新,其中,Tc为所述视频编码设备对应的索引缓存时间;当TM-TM_Last>Tc,或者,TM-TM_Last≤0时,结束索引恢复过程。具体地,可以按照如下方式进行索引更新:根据该I帧组的大小、位置以及时间戳信息,更新二级索引;更新超级块中索引的结束时间为该I帧组对应的时间戳信息;如果该I帧组为数据块中的第一个I帧组,还更新一级索引。The index updating module 30 is used to obtain the subsequent I frame group of the I frame group from the storage resource, each time an I frame group is obtained, the time stamp information TM is obtained from the I frame group, when 0<TM-TM_Last ≤Tc, update the index of the storage resource according to the information of the I frame group, where Tc is the index cache time corresponding to the video encoding device; when TM-TM_Last>Tc, or, TM-TM_Last≤0 , end the index recovery process. Specifically, the index update can be performed in the following manner: update the secondary index according to the size, position and timestamp information of the I frame group; update the end time of the index in the super block to be the corresponding timestamp information of the I frame group; if The I frame group is the first I frame group in the data block, and the primary index is also updated.
综上所述,根据本发明实施例的技术方案,在视频编码设备离线后,从与该视频编码设备对应的存储资源的超级块中获取索引的结束时间,并从所述存储资源的索引中获取所述结束时间对应的I帧组,根据所述I帧组就能够获取后续的I帧组,并根据获取到的I帧组的信息对所述存储资源的索引进行更新,如此,实现了对索引数据的及时恢复,从而保证了索引数据的完整性,使得客户端可以根据完整的索引数据查看任意时刻的录像数据。To sum up, according to the technical solution of the embodiment of the present invention, after the video coding device is offline, the end time of the index is obtained from the super block of the storage resource corresponding to the video coding device, and the end time of the index is obtained from the index of the storage resource Obtain the I frame group corresponding to the end time, obtain the subsequent I frame group according to the I frame group, and update the index of the storage resource according to the information of the obtained I frame group, so that the The timely recovery of the index data ensures the integrity of the index data, so that the client can view the video data at any time according to the complete index data.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明保护的范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the present invention. within the scope of protection.
Claims (6)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201210538931.8A CN103037203B (en) | 2012-12-11 | 2012-12-11 | A kind of index restoration methods based on block storage and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201210538931.8A CN103037203B (en) | 2012-12-11 | 2012-12-11 | A kind of index restoration methods based on block storage and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN103037203A CN103037203A (en) | 2013-04-10 |
| CN103037203B true CN103037203B (en) | 2016-06-08 |
Family
ID=48023628
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201210538931.8A Active CN103037203B (en) | 2012-12-11 | 2012-12-11 | A kind of index restoration methods based on block storage and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN103037203B (en) |
Families Citing this family (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105282627B (en) * | 2014-07-22 | 2019-09-10 | 南京中兴新软件有限责任公司 | A kind of method and server obtaining live video slice |
| CN104866239B (en) * | 2015-05-26 | 2018-09-14 | 浙江宇视科技有限公司 | A kind of video storage method of high availability |
| JP6266184B1 (en) * | 2017-03-16 | 2018-01-24 | 三菱電機ビルテクノサービス株式会社 | Monitoring system |
| CN109302574B (en) * | 2017-07-25 | 2021-10-19 | 华为技术有限公司 | A method and apparatus for processing video stream |
| WO2019079944A1 (en) * | 2017-10-23 | 2019-05-02 | 深圳市锐明技术股份有限公司 | Video data storage method and device, and terminal device |
| CN107729566B (en) * | 2017-11-14 | 2021-02-23 | 郑州天迈科技股份有限公司 | Index reconstruction method for bus-mounted hard disk audio/video data access |
| CN112579820B (en) * | 2019-09-27 | 2023-03-24 | 浙江宇视科技有限公司 | Time hopping video data processing method, device, medium and electronic equipment |
| CN111556288A (en) * | 2020-04-16 | 2020-08-18 | 西安万像电子科技有限公司 | Data processing method, server and system |
| CN111797060B (en) * | 2020-09-07 | 2020-12-04 | 杭州觅睿科技有限公司 | Offline video recording method, device and equipment and computer readable storage medium |
| CN114398520B (en) * | 2022-01-18 | 2025-10-31 | 百度在线网络技术(北京)有限公司 | Data retrieval method, system, device, electronic equipment and storage medium |
| CN115905124B (en) * | 2022-11-03 | 2024-04-30 | 昆易电子科技(上海)有限公司 | Method, device, equipment, and medium for playing back multiple types of data files |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101644996A (en) * | 2009-09-25 | 2010-02-10 | 杭州华三通信技术有限公司 | Storage method of index data and storage control device |
| CN102196249A (en) * | 2011-05-17 | 2011-09-21 | 杭州华三通信技术有限公司 | Monitoring data playback method, EC (Encoder) and video management server |
| CN102314383A (en) * | 2011-09-28 | 2012-01-11 | 成都市华为赛门铁克科技有限公司 | Failure recovery method and device for data index |
| CN102325171A (en) * | 2011-08-26 | 2012-01-18 | 杭州华三通信技术有限公司 | Data storage method in monitoring system and system |
-
2012
- 2012-12-11 CN CN201210538931.8A patent/CN103037203B/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101644996A (en) * | 2009-09-25 | 2010-02-10 | 杭州华三通信技术有限公司 | Storage method of index data and storage control device |
| CN102196249A (en) * | 2011-05-17 | 2011-09-21 | 杭州华三通信技术有限公司 | Monitoring data playback method, EC (Encoder) and video management server |
| CN102325171A (en) * | 2011-08-26 | 2012-01-18 | 杭州华三通信技术有限公司 | Data storage method in monitoring system and system |
| CN102314383A (en) * | 2011-09-28 | 2012-01-11 | 成都市华为赛门铁克科技有限公司 | Failure recovery method and device for data index |
Also Published As
| Publication number | Publication date |
|---|---|
| CN103037203A (en) | 2013-04-10 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN103037203B (en) | A kind of index restoration methods based on block storage and device | |
| US20250355769A1 (en) | Partial database restoration | |
| US12229011B2 (en) | Scalable log-based continuous data protection for distributed databases | |
| CN101741536B (en) | Data level disaster-tolerant method and system and production center node | |
| US8380957B2 (en) | Continuous data protection over intermittent connections, such as continuous data backup for laptops or wireless devices | |
| KR101771246B1 (en) | System-wide checkpoint avoidance for distributed database systems | |
| KR101833114B1 (en) | Fast crash recovery for distributed database systems | |
| US10853182B1 (en) | Scalable log-based secondary indexes for non-relational databases | |
| CN103077242B (en) | The method of a kind of fulfillment database server two-node cluster hot backup | |
| CN103929609B (en) | A kind of video recording playback method and device | |
| US20160283329A1 (en) | Virtual point in time access between snapshots | |
| US9923969B2 (en) | Large-scale storage and retrieval of data with well-bounded life | |
| US20130332771A1 (en) | Methods and apparatus for virtual machine recovery | |
| CA3054040A1 (en) | Synchronously replicating datasets and other managed objects to cloud-based storage systems | |
| US10803012B1 (en) | Variable data replication for storage systems implementing quorum-based durability schemes | |
| US11250019B1 (en) | Eventually consistent replication in a time-series database | |
| CN102662795A (en) | Metadata fault-tolerant recovery method in distributed storage system | |
| CN101739313A (en) | Method for protecting and restoring continuous data | |
| CN102314503A (en) | Indexing method | |
| CN102999399B (en) | The method and apparatus that a kind of JBOD array is automatically renewed | |
| EP4300314A2 (en) | Data backup method, apparatus and system | |
| CN105100815A (en) | Distributed Metadata Management Method for Streaming Data Based on Time Series | |
| CN104699566B (en) | Data redundancy backup method, system and memory node server based on cloud storage | |
| CN103544081B (en) | The management method of double base data server and device | |
| CN105389123A (en) | Storage management method and system based on dual controllers |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant |