CN104331413A - Switch configuration file storage method and switch configuration file storage system - Google Patents
Switch configuration file storage method and switch configuration file storage system Download PDFInfo
- Publication number
- CN104331413A CN104331413A CN201410509908.5A CN201410509908A CN104331413A CN 104331413 A CN104331413 A CN 104331413A CN 201410509908 A CN201410509908 A CN 201410509908A CN 104331413 A CN104331413 A CN 104331413A
- Authority
- CN
- China
- Prior art keywords
- key
- configuration file
- cryptographic hash
- hash
- file storage
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/14—Details of searching files based on file metadata
- G06F16/148—File search processing
- G06F16/152—File search processing using file content signatures, e.g. hash values
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
Abstract
The invention provides a switch configuration file storage method and a switch configuration file storage system. By dividing a configuration file into a plurality of areas, Hash values which respectively correspond to each area are created and stored in the corresponding areas; a Hash table which records each Hash value and file offsets respectively correlated with each Hash value is created, wherein each file offset corresponds to the position of the data of each area; when a read-write request for the data of the configuration file is monitored, the request Hash value of the requested data is calculated and the configuration file is read, and according to the matching of the request Hash value in the Hash table, by utilizing the file offset corresponding to the matched Hash value, the area data requested to be read and written are accessed. Consequently, system resources consumed during operation are few, the computational efficiency, moreover, the algorithm is simple, the invention is easy to put into practice, and portability is good.
Description
Technical field
The present invention relates to networking technology area, particularly relate to a kind of switch configuration file storage means and system.
Background technology
The processing mode of current most of producer to switch configuration file has several as follows: (1) database purchase mode; (2) xml is used to store; (3) be stored in common text files, but equal existing defects.
Wherein, the advantage of database is: all data can be used by multiple user, multiple Application sharing, can greatly reduce data redundancy, save storage space, avoid the incompatible and inconsistency between data.So, its shortcoming is: run the system resource consumed higher, the efficiency run in some low side embedded devices is undesirable.
The advantage using xml to store is: the format specification that data store, and read-write operation is convenient, and the portability of data is strong.So, its shortcoming is: when data volume is very large time, search for the data wanted and will consume long time.
The advantage be stored in plain text is: when data volume is little, the read or write speed of data is the fastest.So, its shortcoming is: tissue disorder, and portable poor, when data volume is very large time, search time is long.
Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide a kind of switch configuration file storage means and system, solves the problem that in above-mentioned prior art, data storage defect causes data reading performance using redundancy low.
For realizing above-mentioned target and other related objectives, the invention provides a kind of switch configuration file storage means, comprising: configuration file is divided into some regions, set up the cryptographic hash of corresponding described regional respectively, and be stored in corresponding region; Set up the Hash table of the document misregistration amount recorded each described cryptographic hash and associate each described cryptographic hash respectively, wherein, described each document misregistration amount corresponding each area data position respectively; When listening to profile data read-write requests, calculate the request hash value of described request data and read configuration file, mate in Hash table according to described request cryptographic hash, and utilize the document misregistration amount corresponding to cryptographic hash matched to visit the area data of request read-write.
Optionally, described region comprises: key-strings.
Optionally, by obtaining the ASCII value of each respective character that described key-strings comprises to calculate the cryptographic hash obtained in described region.
Optionally, the set of each respective character that described key-strings comprises for key [0], key [1] ..., key [L-1] }, L is key character string length; The computing formula of corresponding cryptographic hash is: Hash Value=(key [0]+key [1]+... key [L-1]) %N, wherein, N is set to described region quantity, and the scope of cryptographic hash is 0 ~ (N-1).
Optionally, before processing described profile data read-write requests, also comprise: load configurations file; Initialization Hash table.
For realizing above-mentioned target and other related objectives, the invention provides a kind of switch configuration file storage system, comprising: cryptographic hash sets up module, when configuration file is divided into some regions, for setting up the cryptographic hash of corresponding described regional respectively, and be stored in corresponding region; Hash table sets up module, for setting up the Hash table of the document misregistration amount recorded each described cryptographic hash and associate each described cryptographic hash respectively, wherein, and described each document misregistration amount corresponding each area data position respectively; Control module, for when listening to profile data read-write requests, calculate the request hash value of described request data and read configuration file, mate in Hash table according to described request cryptographic hash, and utilize the document misregistration amount corresponding to cryptographic hash matched to visit the area data of request read-write.
Optionally, described region comprises: key-strings.
Optionally, described cryptographic hash sets up module, by obtaining the ASCII value of each respective character that described key-strings comprises to calculate the cryptographic hash obtained in described region.
Optionally, the set of each respective character that described key-strings comprises for key [0], key [1] ..., key [L-1] }, L is key character string length; The computing formula of corresponding cryptographic hash is: Hash Value=(key [0]+key [1]+... key [L-1]) %N, wherein, N is set to described region quantity, and the scope of cryptographic hash is 0 ~ (N-1).
Optionally, described switch configuration file storage system, also comprises: configuration file loading module, for load configurations file; Hash table configuration module, for initialization Hash table.
For realizing above-mentioned target and other related objectives, the invention provides a kind of switch, comprising: described switch configuration file storage system.
As mentioned above, switch configuration file storage means provided by the invention and system, be divided into some regions by configuration file, sets up the cryptographic hash of corresponding described regional respectively, and be stored in corresponding region; Set up the Hash table of the document misregistration amount recorded each described cryptographic hash and associate each described cryptographic hash respectively, wherein, described each document misregistration amount corresponding each area data position respectively; When listening to profile data read-write requests, calculate the request hash value of described request data and read configuration file, mate in Hash table according to described request cryptographic hash, and utilize the document misregistration amount corresponding to cryptographic hash matched to visit the area data of request read-write.So, the system resource consumed when not only running is little, and operation efficiency is high, and algorithm is simple, and easily realize, transplantability is good.
Accompanying drawing explanation
Fig. 1 is shown as the schematic flow sheet of the switch configuration file storage means in one embodiment of the invention.
Fig. 2 is shown as the schematic flow sheet of the switch configuration file read-write in one embodiment of the invention.
Fig. 3 is shown as the structural representation of the switch configuration file storage system in one embodiment of the invention.
Element numbers explanation
1 switch configuration file storage system
11 cryptographic hash set up module
12 Hash tables set up module
13 control modules
S1 ~ S3 method step
Embodiment
Below by way of specific instantiation, embodiments of the present invention are described, those skilled in the art the content disclosed by this instructions can understand other advantages of the present invention and effect easily.The present invention can also be implemented or be applied by embodiments different in addition, and the every details in this instructions also can based on different viewpoints and application, carries out various modification or change not deviating under spirit of the present invention.It should be noted that, when not conflicting, the embodiment in the application and the feature in embodiment can combine mutually.
As shown in Figure 1, the invention provides a kind of switch configuration file storage means, comprising:
Step S1: configuration file is divided into some regions, sets up the cryptographic hash of corresponding described regional respectively, and is stored in corresponding region;
Step S2: the Hash table setting up the document misregistration amount recorded each described cryptographic hash and associate each described cryptographic hash respectively, wherein, described each document misregistration amount corresponding each area data position respectively;
Step S3: when listening to profile data read-write requests, calculate the request hash value of described request data and read configuration file, mate in Hash table according to described request cryptographic hash, and utilize the document misregistration amount corresponding to cryptographic hash matched to visit the area data of request read-write.
In one embodiment, the data in configuration file are divided into several regions (region quantity is set to N, and the size of N increases with the scale of data volume and increases) by this programme, and the quantity of cryptographic hash also correspondence is set to N.When storing data, the data of identical cryptographic hash are stored in same region.In configuration process, safeguard a Hash table, in table, record the document misregistration amount in each region, each like this when reading and writing data, only need load the data in a region, shown in concrete form is as shown in the table.
Cryptographic hash | Document misregistration amount |
Hash Value1 | offset1 |
Hash Value2 | offset2 |
… | … |
Hash ValueN | offsetN |
Illustrate how cryptographic hash calculates again, described area stores has outside described cryptographic hash, also comprise key word (key) the symbol string of association, optionally, by obtaining the ASCII value of each respective character that described key-strings comprises to calculate the cryptographic hash obtained in described region; For example, the set of each respective character that described key-strings comprises for key [0], key [1] ..., key [L-1] }, L is key character string length; The computing formula of corresponding cryptographic hash is: HashValue=(key [0]+key [1]+... key [L-1]) %N, wherein, N is set to described region quantity, and the scope of cryptographic hash is 0 ~ (N-1).
In one embodiment, method of the present invention can be realized by process, and involved software engineering content is mainly divided into three parts: configuration file, configuration process, will read and write the process of configuration file.Configuration process is the core of whole scheme, and it is responsible for read-write configuration file and provides interface to other process, can meet multiple process and read and write data concomitantly.
Communicated by the mode of local socket (socket is similar to interface) between configuration process and other process, configuration process as socket service end, other process then as socket client.
In conventional art, by data loading to memory read-write speed, but when configuration file is huge, all data are all loaded in internal memory and can consume ample resources, the present invention uses a kind of brand-new read-write mode, both a large amount of internal memory can not be consumed, the read or write speed of data can not be reduced again, its principle will be told about in detail below, with reference to foregoing hash value algorithms, in order to ensure that the data volume in each region is more or less the same, in each region, data are made up of a key and value, key is a character string, if its length is L, key is decomposed into one by one independently character by us, be respectively key [0], key [1], key [L-1], get the ASCII value of each character, then its cryptographic hash Hash Value=(key [0]+key [1]+... key [L-1]) %N, the scope of the cryptographic hash obtained is 0 ~ (N-1).The cryptographic hash calculated like this can ensure that the data volume in each region is more or less the same.
To sum up, the task of described configuration process is mainly divided into three parts: safeguard Hash table, monitor profile data read-write requests (socket request), read and write configuration file.
See also Fig. 2, for processing a citing of the specific implementation of read-write requests in the inventive method.Wherein, optionally, before the described profile data read-write requests of process, also can comprise: load configurations file; The preferred steps such as initialization Hash table.
As shown in Figure 3, the invention provides a kind of switch configuration file storage system 1, it realizes principle and said method is similar, therefore the ins and outs that part repeats do not remake and repeat; Described system comprises: cryptographic hash sets up module 11, when configuration file is divided into some regions, for setting up the cryptographic hash of corresponding described regional respectively, and is stored in corresponding region; Hash table sets up module 12, for setting up the Hash table of the document misregistration amount recorded each described cryptographic hash and associate each described cryptographic hash respectively, wherein, and described each document misregistration amount corresponding each area data position respectively; Control module 13, for when listening to profile data read-write requests, calculate the request hash value of described request data and read configuration file, mate in Hash table according to described request cryptographic hash, and utilize the document misregistration amount corresponding to cryptographic hash matched to visit the area data of request read-write.
In one embodiment, one section of program that namely described control module 13 can be in aforementioned arrangements process realizes, for safeguarding Hash table, monitoring profile data read-write requests and read-write configuration file; Described cryptographic hash sets up module 11, Hash table sets up module 12 also by software simulating, also can be both same software module realizations function, is not limited with the present embodiment.
Optionally, described region comprises: key-strings.
Optionally, described cryptographic hash sets up module 11, by obtaining the ASCII value of each respective character that described key-strings comprises to calculate the cryptographic hash obtained in described region.
Optionally, the set of each respective character that described key-strings comprises for key [0], key [1] ..., key [L-1] }, L is key character string length; The computing formula of corresponding cryptographic hash is: Hash Value=(key [0]+key [1]+... key [L-1]) %N, wherein, N is set to described region quantity, and the scope of cryptographic hash is 0 ~ (N-1).
Optionally, described switch configuration file storage system 1, also can comprise: configuration file loading module, for load configurations file; Hash table configuration module, for initialization Hash table.Certainly the equal accessible site of those modules is in aforementioned existing module, and such as Hash table is set up in module 12.
In conjunction with foregoing, the present invention also can provide a kind of switch, comprising: described switch configuration file storage system 1.
In sum, switch configuration file storage means provided by the invention and system, be divided into some regions by configuration file, sets up the cryptographic hash of corresponding described regional respectively, and be stored in corresponding region; Set up the Hash table of the document misregistration amount recorded each described cryptographic hash and associate each described cryptographic hash respectively, wherein, described each document misregistration amount corresponding each area data position respectively; When listening to profile data read-write requests, calculate the request hash value of described request data and read configuration file, mate in Hash table according to described request cryptographic hash, and utilize the document misregistration amount corresponding to cryptographic hash matched to visit the area data of request read-write.So, the system resource consumed when not only running is little, and operation efficiency is high, and algorithm is simple, and easily realize, transplantability is good.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all without prejudice under spirit of the present invention and category, can modify above-described embodiment or changes.Therefore, such as have in art usually know the knowledgeable do not depart from complete under disclosed spirit and technological thought all equivalence modify or change, must be contained by claim of the present invention.
Claims (11)
1. a switch configuration file storage means, is characterized in that, comprising:
Configuration file is divided into some regions, sets up the cryptographic hash of corresponding described regional respectively, and is stored in corresponding region;
Set up the Hash table of the document misregistration amount recorded each described cryptographic hash and associate each described cryptographic hash respectively, wherein, described each document misregistration amount corresponding each area data position respectively;
When listening to profile data read-write requests, calculate the request hash value of described request data and read configuration file, mate in Hash table according to described request cryptographic hash, and utilize the document misregistration amount corresponding to cryptographic hash matched to visit the area data of request read-write.
2. switch configuration file storage means according to claim 1, is characterized in that, described region comprises: key-strings.
3. switch configuration file storage means according to claim 2, is characterized in that, by obtaining the ASCII value of each respective character that described key-strings comprises to calculate the cryptographic hash obtained in described region.
4. switch configuration file storage means according to claim 3, is characterized in that, the set of each respective character that described key-strings comprises for key [0], key [1] ..., key [L-1] }, L is key character string length; The computing formula of corresponding cryptographic hash is: Hash Value=(key [0]+key [1]+... key [L-1]) %N, wherein, N is set to described region quantity, and the scope of cryptographic hash is 0 ~ (N-1).
5. switch configuration file storage means according to claim 1, is characterized in that, before processing described profile data read-write requests, also comprises: load configurations file; Initialization Hash table.
6. a switch configuration file storage system, is characterized in that, comprising:
Cryptographic hash sets up module, when configuration file is divided into some regions, for setting up the cryptographic hash of corresponding described regional respectively, and is stored in corresponding region;
Hash table sets up module, for setting up the Hash table of the document misregistration amount recorded each described cryptographic hash and associate each described cryptographic hash respectively, wherein, and described each document misregistration amount corresponding each area data position respectively;
Control module, for when listening to profile data read-write requests, calculate the request hash value of described request data and read configuration file, mate in Hash table according to described request cryptographic hash, and utilize the document misregistration amount corresponding to cryptographic hash matched to visit the area data of request read-write.
7. switch configuration file storage system according to claim 6, is characterized in that, described region comprises: key-strings.
8. switch configuration file storage system according to claim 7, is characterized in that, described cryptographic hash sets up module, by obtaining the ASCII value of each respective character that described key-strings comprises to calculate the cryptographic hash obtained in described region.
9. switch configuration file storage system according to claim 8, is characterized in that, the set of each respective character that described key-strings comprises for key [0], key [1] ..., key [L-1] }, L is key character string length; The computing formula of corresponding cryptographic hash is: Hash Value=(key [0]+key [1]+... key [L-1]) %N, wherein, N is set to described region quantity, and the scope of cryptographic hash is 0 ~ (N-1).
10. switch configuration file storage system according to claim 6, is characterized in that, also comprise: configuration file loading module, for load configurations file; Hash table configuration module, for initialization Hash table.
11. 1 kinds of switches, is characterized in that, comprising: the switch configuration file storage system according to any one of claim 6 to 10.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410509908.5A CN104331413A (en) | 2014-09-28 | 2014-09-28 | Switch configuration file storage method and switch configuration file storage system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410509908.5A CN104331413A (en) | 2014-09-28 | 2014-09-28 | Switch configuration file storage method and switch configuration file storage system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104331413A true CN104331413A (en) | 2015-02-04 |
Family
ID=52406140
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410509908.5A Pending CN104331413A (en) | 2014-09-28 | 2014-09-28 | Switch configuration file storage method and switch configuration file storage system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104331413A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101996217A (en) * | 2009-08-24 | 2011-03-30 | 华为技术有限公司 | Method for storing data and memory device thereof |
US20120203980A1 (en) * | 2006-12-06 | 2012-08-09 | Fusion-Io, Inc. | Apparatus, system, and method for validating that a correct data segment is read from a data storage device |
CN103379138A (en) * | 2012-04-17 | 2013-10-30 | 深圳市腾讯计算机系统有限公司 | Method and system for realizing load balance, and method and apparatus for gray scale publication |
-
2014
- 2014-09-28 CN CN201410509908.5A patent/CN104331413A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120203980A1 (en) * | 2006-12-06 | 2012-08-09 | Fusion-Io, Inc. | Apparatus, system, and method for validating that a correct data segment is read from a data storage device |
CN101996217A (en) * | 2009-08-24 | 2011-03-30 | 华为技术有限公司 | Method for storing data and memory device thereof |
CN103379138A (en) * | 2012-04-17 | 2013-10-30 | 深圳市腾讯计算机系统有限公司 | Method and system for realizing load balance, and method and apparatus for gray scale publication |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR101994021B1 (en) | File manipulation method and apparatus | |
US8868576B1 (en) | Storing files in a parallel computing system based on user-specified parser function | |
CN106874348B (en) | File storage and index method and device and file reading method | |
CN108932257B (en) | Multi-dimensional data query method and device | |
US9372765B2 (en) | System and method for recovering system status consistently to designed recovering time point in distributed database | |
CN105183839A (en) | Hadoop-based storage optimizing method for small file hierachical indexing | |
US9563569B2 (en) | Memory transformation in virtual machine live migration | |
US20220091890A1 (en) | Identifying memory devices for swapping virtual machine memory pages | |
CN110795499B (en) | Cluster data synchronization method, device, equipment and storage medium based on big data | |
US20130282676A1 (en) | Garbage collection-driven block thinning | |
US9110820B1 (en) | Hybrid data storage system in an HPC exascale environment | |
EP3862888A1 (en) | Hybrid data distribution in a massively parallel processing architecture | |
US20140280392A1 (en) | File system operation on multi-tiered volume | |
US20160054951A1 (en) | Apparatus and method for optimizing time series data storage | |
CN110427364A (en) | A kind of data processing method, device, electronic equipment and storage medium | |
US9652416B2 (en) | Storage device for performing in-storage computing operations, method of operation the same, and system including the same | |
CN104407990A (en) | Disk access method and device | |
CN103841168B (en) | Data trnascription update method and meta data server | |
Zhang et al. | A strategy to deal with mass small files in HDFS | |
CN105260266A (en) | Snapshot volume writing method and dependent snapshot system | |
CN107291524B (en) | Remote command processing method and device | |
CN102955808A (en) | Data acquisition method and distributed file system | |
KR102071072B1 (en) | Method for managing of memory address mapping table for data storage device | |
CN114840488B (en) | Distributed storage method, system and storage medium based on super fusion structure | |
CN110221778A (en) | Processing method, system, storage medium and the electronic equipment of hotel's data |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
EXSB | Decision made by sipo to initiate substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20150204 |
|
RJ01 | Rejection of invention patent application after publication |