WO2016066081A1 - 写入数据的方法和装置技术领域 - Google Patents

写入数据的方法和装置技术领域 Download PDF

Info

Publication number
WO2016066081A1
WO2016066081A1 PCT/CN2015/092945 CN2015092945W WO2016066081A1 WO 2016066081 A1 WO2016066081 A1 WO 2016066081A1 CN 2015092945 W CN2015092945 W CN 2015092945W WO 2016066081 A1 WO2016066081 A1 WO 2016066081A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
version
written
condition
comparison
Prior art date
Application number
PCT/CN2015/092945
Other languages
English (en)
French (fr)
Inventor
杜冠
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2016066081A1 publication Critical patent/WO2016066081A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and apparatus for writing data.
  • the amount of data that needs to be stored is increasing.
  • the data is stored in a storage device, and the user can write new data through the terminal, and can also read and/or modify the data in the storage device.
  • the version comparison condition in the normal write scenario is: if the version of the data to be written is higher than the version of the data stored in the storage device that has the same data identifier as the data to be written, write Enter data to be written.
  • the server acquires certain data (which may be referred to as data to be written), and acquires scene parameters, version information of the data to be written (such as a version number), and data to be written.
  • the identifier wherein the acquisition process of the data to be written is data sent by the user through the terminal, or the server extracts from the storage device, and the scenario parameter is determined by the server when the data is written, and the version information may be set or extracted by the server. Then, the data write request carrying the data to be written, the data identifier, the data version identifier, and the scene parameter is sent to the storage device.
  • the storage device receives the data write request, the storage device determines the version comparison condition of the write scenario corresponding to the scene parameter. And comparing the version of the local data having the same data identifier as the data to be written with the version of the data to be written. If the comparison result of the two meets the version comparison condition in the write scenario corresponding to the scene parameter, the version to be written is to be written.
  • the incoming data is stored in the storage device and the local data is deleted.
  • the embodiment of the invention provides a method and a device for writing data, which can be used to solve the problem of flexibility of storing data in a database in the prior art.
  • the technical solution is as follows:
  • the first aspect provides a method for writing data, where the method is applied to a storage device, where the storage device stores data corresponding to different data identifiers, and the method includes:
  • the storage device receives a data write request sent by the server that carries at least one sub-condition information, data to be written, data identifier of the data to be written, and version information of the data to be written;
  • the storage device acquires a comparison sub-condition corresponding to each sub-condition information carried in the data write request, and determines a union of the obtained comparison sub-conditions as a version comparison condition;
  • the storage device compares the version information of the data to be written with the version information of the local data corresponding to the data identifier, and if the comparison result of the version information satisfies the version comparison condition, the data to be written is Write operation.
  • the storage device acquires a comparison sub-condition corresponding to each sub-condition information carried in the data write request, and acquires the comparison sub-conditions
  • the set is determined to be a version comparison condition, including:
  • the storage device acquires a comparison sub-condition corresponding to each sub-condition information carried in the data write request according to the correspondence between the pre-stored comparison sub-conditions and the sub-condition information, and determines the union of the acquired comparison sub-conditions. For the version comparison conditions.
  • the comparison sub-condition is: the first version is higher than the second version, the first version is equal to the second version, and the first version is lower than the first version The second version, the first version and the second version cannot be compared.
  • a method for writing data is provided, the method being applied to a server, where a plurality of version comparison conditions and a plurality of comparison sub-conditions are pre-stored in the server, the method comprising:
  • the server determines at least one comparison sub-condition in the pre-stored comparison sub-conditions, and the determined union of the comparison sub-conditions is the version comparison condition;
  • the comparison sub-condition is: the first version is higher than the The second version, the first version is equal to the second version, the first version is lower than the second version, and the first version is not comparable to the second version.
  • a storage device comprising:
  • a receiving module configured to receive, by the server, a data write request that carries at least one sub-condition information, data to be written, a data identifier of the data to be written, and version information of the data to be written;
  • a determining module configured to obtain a comparison sub-condition corresponding to each sub-condition information carried in the data writing request, and determine a union of the obtained comparison sub-conditions as a version comparison condition
  • a write module configured to compare the version information of the data to be written with the version information of the local data corresponding to the data identifier, and if the comparison result of the version information meets the version comparison condition, the to-be-written Write data into the write operation.
  • the determining module is configured to:
  • the comparison sub-condition is: the first version is higher than the second version, the first version is equal to the second version, and the first version is lower than the first version The second version, the first version and the second version cannot be compared.
  • a server comprising:
  • An obtaining module configured to acquire data to be written, a data identifier of the data to be written, version information of the data to be written, and a version comparison condition corresponding to the data to be written;
  • a determining module configured to determine, in a pre-stored comparison sub-condition, at least one comparison sub-condition, wherein the determined union of the comparison sub-conditions is the version comparison condition;
  • a sending module configured to send, to the storage device, sub-condition information carrying the at least one comparison sub-condition, the data to be written, the data identifier of the data to be written, and version information of the data to be written Data write request.
  • the comparison sub-condition is: the first version is higher than the second version, the first version is equal to the second version, and the first version is lower than the first version The second version, the first version and the second version cannot be compared.
  • a system for writing data comprising a storage device and a server, wherein:
  • the storage device is configured to receive, by the server, a data write request that carries at least one sub-condition information, data to be written, data identifier of the data to be written, and version information of the data to be written; a comparison sub-condition corresponding to each sub-condition information carried in the data write request, determining a union of the acquired comparison sub-conditions as a version comparison condition; and correspondingly, the version information of the to-be-written data corresponds to the data identifier Comparing the version information of the local data, if the comparison result of the version information satisfies the version comparison condition, performing a write operation on the data to be written;
  • the server is configured to acquire data to be written, a data identifier of the data to be written, version information of the data to be written, and a version comparison condition corresponding to the data to be written; And determining, in the condition, the at least one comparison sub-condition, the determined union of the comparison sub-conditions is the version comparison condition; sending, to the storage device, the sub-condition information carrying the at least one comparison sub-condition, the data to be written And a data write request of the data identifier of the data to be written and the version information of the data to be written.
  • the data write request sent by the receiving server and carrying the at least one sub-condition information, the data to be written, the data identifier of the data to be written, and the version information of the data to be written is acquired in the data write request. Comparing the comparison sub-conditions of each sub-condition information carried, determining the union of the obtained comparison sub-conditions as a version comparison condition, comparing the version information of the data to be written with the version information of the local data corresponding to the data identifier, if the version If the comparison result of the information satisfies the version comparison condition, the write operation is performed on the write data, so that even if the process of writing the data adds a new version comparison condition, the storage device can be completed without corresponding setting.
  • the purpose of writing data to the storage device thereby improving the flexibility of the storage device to store data.
  • FIG. 1 is a flowchart of a method for writing data according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for writing data according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a method for writing data according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a system according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a storage device according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of a server according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a storage device according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of a server according to an embodiment of the present invention.
  • the server needs to send the version comparison condition to the storage device, so that the storage device determines whether to perform the write operation according to the version comparison condition.
  • the version comparison condition for performing the write operation is that the version of the data to be written is higher than the version of the data already existing in the local, or the version of the data to be written is equal to the version of the data already existing locally. If the version comparison condition is met, the write operation is performed; otherwise, it is not executed.
  • the version comparison condition is that the version of the data to be written is higher than the version of the data already in the local, and the write operation is performed.
  • the version comparison condition is: no matter which version of the version is updated, or even if the version cannot be compared, the write operation will be performed.
  • the data identifier of the local already existing data is the same as the data identifier of the data to be written.
  • scenario parameters are used to indicate the write scenario.
  • the distributed storage device and the service processing layer are strongly coupled. That is, the storage device needs to understand different write scenarios. The meaning of using different principles according to different writing scenarios is not conducive to the use of third-party storage devices.
  • the server compares the conditions with the version.
  • the version comparison condition of the repair write is split into the comparison sub-condition A and the sub-condition B.
  • the comparison sub-condition A is: the version of the data to be written is higher than the version of the data already existing in the local;
  • the comparison sub-condition B is: the version of the data to be written is equal to the version of the data already existing locally.
  • the storage device After the storage device receives the two comparison sub-conditions, the two are merged. Equivalent to regenerating the version comparison condition before the split.
  • the server only needs to send any one of the following four comparison sub-conditions in any write scenario: (1) the version of the data to be written is higher than the version of the data already existing locally. (2) or the version of the data to be written is equal to the version of the data already in the local; (3) the version of the data to be written is lower than the version of the data already in the local; (4) the version of the data to be written and the data already in the local The version cannot be compared.
  • the embodiment of the invention thus simplifies the process. The problems in the prior art mentioned above are solved.
  • the higher version is the meaning that the version is newer, and the judgment can be performed by comparing the version numbers.
  • the embodiment of the invention provides a method for writing data, which can be implemented by a server and a storage device.
  • the processing flow of the storage device in the method may include the following steps:
  • Step 101 The storage device receives a data write request sent by the terminal that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written.
  • Step 102 The storage device acquires a comparison sub-condition corresponding to each sub-condition information carried in the data write request, and determines a union of the acquired comparison sub-conditions as a version comparison condition.
  • Step 103 The storage device compares the version information of the data to be written with the version information of the local data corresponding to the data identifier, and if the comparison result of the version information satisfies the version comparison condition, the write operation is performed on the data to be written.
  • the processing flow of the server in the method may include the following steps:
  • Step 201 The server acquires data to be written, data identifier of data to be written, and data to be written. The version information and the version comparison condition corresponding to the data to be written.
  • Step 202 The server determines, in the pre-stored comparison sub-conditions, at least one comparison sub-condition, and the determined union of the comparison sub-conditions is a version comparison condition.
  • Step 203 The server sends, to the storage device, a data write request that carries the sub-condition information of the at least one comparison sub-condition, the data to be written, the data identifier of the data to be written, and the version information of the data to be written.
  • the storage device receives a data write request sent by the server that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written, and acquires data writing.
  • the comparison sub-condition corresponding to each sub-condition information carried in the request determines the union of the obtained comparison sub-conditions as a version comparison condition, and compares the version information of the data to be written with the version information of the local data corresponding to the data identifier.
  • the write operation is performed on the write data, so that even if the process of writing the data adds a new version comparison condition, the storage device may not need to be correspondingly set, that is, The purpose of writing data to the storage device can be completed, thereby improving the flexibility of the storage device to store data.
  • the embodiment of the invention provides a method for writing data, which can be implemented by a server and a storage device.
  • the server may be any server for writing data to the storage device.
  • the server may pre-store multiple version comparison conditions and multiple comparison sub-conditions, and the storage device may pre-store data corresponding to different data identifiers. .
  • the processing flow of the method may include the following steps:
  • Step 301 The server acquires data to be written, a data identifier of the data to be written, version information of the data to be written, and a version comparison condition corresponding to the data to be written.
  • the data identifier may be a name of the data, and the version information may be a version number, a version name, or the like.
  • the data may be written to the storage device through the server in multiple manners, for example, the user writes data to the storage device through the server, or the server detects that an error occurs in the data in the storage device, and may be in the storage device.
  • the data is fixed.
  • the storage device may be a separate data storage device, or may be a storage system composed of multiple storage devices, such as a distributed storage system.
  • the data stored in the storage device usually includes multiple copies, for example, three copies. Thereby ensuring the reliability of the data, the storage device can set a plurality of storage nodes to store the plurality of copies respectively. As shown in FIG.
  • the user may To write a certain data (that is, data to be written), the data to be written may be new data written by the user, or may be modified data of a certain data in the storage device. After the data to be written is completed, the data may be written. The data to be written is sent to the server. After receiving the data to be written, the server may extract the data identifier of the data to be written, and then set the version information for the data to be written, because the data to be written is provided by the user through the terminal. To the server, the server can determine that the write scenario of the write data is a normal write scenario, and then the server determines the version comparison condition corresponding to the normal write scenario.
  • the server can determine that the write scenario of the write data is a normal write scenario, and then the server determines the version comparison condition corresponding to the normal write scenario.
  • the write scenario of the write data includes multiple types, such as a normal write scenario, a repaired write scenario, a conflicting write scenario, and the like, and different write scenarios are set with different version comparison conditions.
  • the version information may be set by the server. For example, the user writes a new data through the terminal and sends it to the server X in the server shown in FIG. 4, and the server X may set the version information of the data to (X, 1). If the user reads a certain data in the storage device and modifies the data, after the modification is completed, the modified data may be sent to the server, and the server extracts the version information before the data modification. If (X, 1), the If the server is the server X, the server X can set the version information of the modified data to be (X, 2).
  • the server Y can be set.
  • the version information of the modified data is (X, 1) (Y, 1).
  • the server Z can set the modified data.
  • the version information is (X, 1) (Z, 1).
  • the version information can be used to determine that the version information is (X, 2), (X, 1) (Y, 1) or (X, 1) (Z, 1), and the version information is based on (X, 1).
  • the data is modified, so the version information (X, 2), (X, 1) (Y, 1) and (X, 1) (Z, 1) are higher than the version information (X, 1), and the version information There is no comparison between (X, 2), (X, 1) (Y, 1) and (X, 1) (Z, 1).
  • the server detects that a certain error occurs in the storage device, the data in the storage device may be repaired, as shown in FIG. 4, when the user requests to read data from the server through the terminal, if the terminal reads the data, In the data, the terminal may send an error message to the server. After receiving the error message, the server may extract the data identifier of the data, and then send the data corresponding to the data identifier to the storage device as the data to be written, and then The version information of the data to be written may be raised, and the server may determine that the write scenario of the write data to be performed is to repair the write scenario, and the server obtains the version comparison condition corresponding to the repaired write scenario.
  • the conflict write may be a comparison of the versions of the data of the two identical data identifiers, and the non-equal version write may include multiple copies of the different versions of the data stored in the storage device with the same data identifier.
  • the user needs to select one.
  • the version or the terminal used by the user determines a version based on the time at which the data is written, as a version of the data in the storage device, and overwrites the data of the different version with the data of the version.
  • Step 302 The server determines, in the pre-stored comparison sub-conditions, at least one comparison sub-condition, and the determined union of the comparison sub-conditions is a version comparison condition.
  • the server may pre-store a plurality of comparison sub-conditions, and the server may split the obtained version comparison condition by using multiple comparison sub-conditions to obtain at least one comparison sub-condition, which is visible, if the calculated comparison is obtained.
  • the union of the sub-conditions results in a version comparison condition.
  • the comparison sub-condition is: One version is higher than the second version, the first version is equal to the second version, the first version is lower than the second version, and the first version is not comparable to the second version.
  • the data to be written may be any data.
  • the plurality of comparison sub-conditions in the server may be stored by comparing the correspondence between the sub-conditions and the sub-condition information, wherein the sub-condition information may be a sub-condition identifier or the like.
  • the correspondence between the comparison sub-conditions and the sub-condition information may be stored in the form of a table, the first version is indicated by B1, the first version is indicated by B2, and the sub-condition information is sub-conditional identifier, and the different write scenes in step 301 are different.
  • the version comparison conditions can be as shown in Table 1.
  • the sub-condition information can be represented by a binary value, such as 0 and 1, and a binary value can be set for the data to be written. Specifically, one byte usually has an 8-bit binary value, as shown in Table 3.
  • Step 303 The server sends, to the storage device, a data write request that carries the sub-condition information of the at least one comparison sub-condition, the data to be written, the data identifier of the data to be written, and the version information of the data to be written.
  • the server may obtain the sub-condition information corresponding to each comparison sub-condition by using the determined comparison sub-conditions, and the sub-condition information may also be the binary value determined in the manner of Table 3 above or The decimal value, the sub-condition information can also be the corresponding contrast sub-condition.
  • the server may generate a data write request by using the sub-condition information, the data to be written, the data identifier of the data to be written, and the version information of the data to be written, and send the data write request to the storage device.
  • the data write request may be some form of command, and the sub-condition information may be a binary value as an example.
  • the data write request may be a write (data, version, mask), wherein the Write may represent a command keyword, and the data may represent Write data, version can represent the version information of the data to be written, and mask can represent the above binary value or decimal value.
  • Step 304 The storage device receives a data write request sent by the terminal that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written.
  • Step 305 The storage device acquires a comparison sub-condition corresponding to each sub-condition information carried in the data write request, and determines a union of the acquired comparison sub-conditions as a version comparison condition.
  • the sub-condition information may be a corresponding comparison sub-condition.
  • the storage device may extract the sub-condition information therein, that is, the comparison sub-condition, and the storage device may calculate The union of the comparison sub-conditions is obtained, and the obtained calculation result is determined as the version comparison condition.
  • the sub-condition information may be a sub-condition identifier or a value. If the sub-condition information is the sub-condition information, the processing of the step 305 may include the following: acquiring, according to the correspondence between the pre-stored comparison sub-conditions and the sub-condition information, respectively acquiring each sub-condition information carried in the data write request The comparison sub-conditions determine the union of the obtained comparison sub-conditions as the version comparison condition.
  • the correspondence between the comparison sub-conditions and the sub-condition information is pre-stored in the storage device, and the correspondence relationship may be as shown in Table 2.
  • the storage device may extract the sub-condition information therein, and then It can be searched in the correspondence relationship between the comparison sub-conditions and the sub-condition information in Table 2, and the contrast sub-condition corresponding to each sub-condition information extracted can be obtained, and the obtained union of the comparison sub-conditions can be determined as the version comparison condition.
  • the data corresponding to the version information with the largest number of the plurality of version information may be determined as the data to be written, because the version of the data to be written may be larger or smaller than the version of the local data, or both. Or the comparison cannot be made. Therefore, the mask can be 00001101. For the processing of this case, refer to the above content, and details are not described herein again.
  • Step 306 The storage device compares the version information of the data to be written with the version information of the local data corresponding to the data identifier. If the comparison result of the version information satisfies the version comparison condition, the write operation is performed on the data to be written.
  • the storage device may determine, by using the version information of the data to be written, the version information of the local data corresponding to the data identifier, and the version comparison condition, whether the version information of the data to be written and the version information of the local data corresponding to the data identifier are satisfied.
  • the version comparison condition if satisfied, the storage device may send a notification message that the write is successful to the server, and if not, the server may send a notification message or an error message to the server for the write failure.
  • the version comparison condition is: If B1 ⁇ B2, the data to be written is written.
  • the storage device compares the version information of the data to be written with the version information of the local data. If the version of the data to be written is higher than the version of the local data, or the version of the data to be written is equal to the version of the local data, the storage device is to be written. The inbound data is written to the storage device, and the local data is deleted. If the version of the data to be written is lower than the version of the local data, the data to be written can be canceled and written to the storage device.
  • the version comparison condition may be first determined by the write scenario corresponding to the data to be written, and then the version comparison condition may be split into one or more The comparison sub-conditions are sent to the storage device, and the storage device may obtain the union of the one or more comparison sub-conditions to obtain the comparison condition of the version, and finally, the version information of the data to be written and the version information of the local data may be performed.
  • the comparison result of the two meets the version comparison condition, the write operation is performed on the write data, so that the storage device does not need to set the version comparison condition corresponding to various write scenarios, and only needs to obtain the corresponding contrast.
  • the condition can complete the write operation of the data to be written, which improves the flexibility of the storage device to store data to some extent.
  • the storage device receives a data write request sent by the server that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written, and acquires data writing.
  • the comparison sub-condition corresponding to each sub-condition information carried in the request determines the union of the obtained comparison sub-conditions as a version comparison condition, and compares the version information of the data to be written with the version information of the local data corresponding to the data identifier.
  • the write operation is performed on the write data, so that even if the process of writing the data adds a new version comparison condition, the storage device may not need to be correspondingly set, that is, The purpose of writing data to the storage device can be completed, thereby improving the flexibility of the storage device to store data.
  • the storage device in this embodiment and other embodiments may be a combination of a storage controller and a storage medium, such as a storage controller and a hard disk. It can also be a storage medium with computing functions, similar to a hard disk integrated with some controller functions, such as IP (Internet Protocol).
  • IP Internet Protocol
  • the embodiment of the present invention further provides a storage device.
  • the storage device includes:
  • the receiving module 510 is configured to receive, by the server, a data write request that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written;
  • the determining module 520 is configured to obtain a comparison sub-condition corresponding to each sub-condition information carried in the data writing request, and determine a union of the obtained comparison sub-conditions as a version comparison condition;
  • the writing module 530 is configured to compare the version information of the data to be written with the local data corresponding to the data identifier The version information is compared. If the comparison result of the version information satisfies the version comparison condition, the write operation is performed on the write data.
  • the determining module 520 is configured to:
  • the comparison sub-conditions corresponding to each sub-condition information carried in the data write request are respectively obtained according to the corresponding relationship between the pre-stored comparison sub-conditions and the sub-condition information, and the obtained union of the comparison sub-conditions is determined as a version comparison condition.
  • the comparison sub-condition is: One version is higher than the second version, the first version is equal to the second version, the first version is lower than the second version, and the first version is not comparable to the second version.
  • an embodiment of the present invention further provides a server.
  • the server includes:
  • the obtaining module 610 is configured to obtain data to be written, a data identifier of the data to be written, version information of the data to be written, and a version comparison condition corresponding to the data to be written;
  • a determining module 620 configured to determine, in a pre-stored comparison sub-condition, at least one comparison sub-condition, wherein the determined union of the comparison sub-conditions is a version comparison condition;
  • the sending module 630 is configured to send, to the storage device, a data write request that carries the sub-condition information of the at least one comparison sub-condition, the data to be written, the data identifier of the data to be written, and the version information of the data to be written.
  • the comparison sub-conditions are: the first version is higher than the second version, the first version is equal to the second version, the first version is lower than the second version, and the first version is not comparable to the second version.
  • the storage device receives a data write request sent by the server that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written, and acquires data writing.
  • the comparison sub-condition corresponding to each sub-condition information carried in the request determines the union of the obtained comparison sub-conditions as a version comparison condition, and compares the version information of the data to be written with the version information of the local data corresponding to the data identifier.
  • the write operation is performed on the write data, so that even if the process of writing the data adds a new version comparison condition, the storage device may not need to be correspondingly set, that is, Can be completed to storage The purpose of writing data in the device, thereby improving the flexibility of the storage device to store data.
  • the device for writing data provided by the foregoing embodiment is only illustrated by dividing the foregoing functional modules when writing data.
  • the functions may be allocated by different functional modules according to requirements. Completion, that is, the internal structure of the server or storage device is divided into different functional modules to complete all or part of the functions described above.
  • the device for writing data and the method for writing data provided by the foregoing embodiments are in the same concept, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
  • an embodiment of the present invention further provides a system for writing data, characterized in that the system comprises a storage device and a server, wherein:
  • a storage device configured to receive, by the server, a data write request that carries at least one sub-condition information, a data to be written, a data identifier of the data to be written, and version information of the data to be written; and the acquired data write request carries The comparison sub-condition corresponding to each sub-condition information determines the union of the acquired comparison sub-conditions as a version comparison condition; compares the version information of the data to be written with the version information of the local data corresponding to the data identifier, if the version information The comparison result satisfies the version comparison condition, and the write operation is performed on the write data;
  • a server configured to obtain data to be written, a data identifier of the data to be written, version information of the data to be written, and a version comparison condition corresponding to the data to be written; determining, in the pre-stored comparison sub-condition, at least one contrast a condition, the determined union of the comparison sub-conditions is a version comparison condition; sending the sub-condition information carrying the at least one comparison sub-condition, the data to be written, the data identifier of the data to be written, and the data to be written to the storage device Data write request for version information.
  • the storage device receives a data write request sent by the server that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written, and acquires data writing.
  • the comparison sub-condition corresponding to each sub-condition information carried in the request determines the union of the obtained comparison sub-conditions as a version comparison condition, and compares the version information of the data to be written with the version information of the local data corresponding to the data identifier.
  • the write operation is performed on the write data, so that even if the process of writing the data adds a new version comparison condition, the storage device may not need to be correspondingly set, that is, The purpose of writing data to the storage device can be completed, thereby improving the flexibility of the storage device to store data.
  • FIG. 7 is a schematic structural diagram of a storage device according to an embodiment of the present invention.
  • the storage device may be used to implement the method for writing data provided in the foregoing embodiment. Specifically:
  • Storage device 1000 can include a memory 120 having one or more computer readable storage media, a processor 180 including one or more processing cores, and a power supply 190 and the like. It will be understood by those skilled in the art that the storage device structure shown in the figures does not constitute a limitation of the storage device, and may include more or less components than those illustrated, or a combination of certain components, or different component arrangements. among them:
  • the memory 120 can be used to store software programs and modules, and the processor 180 executes various functional applications and data processing by running software programs and modules stored in the memory 120.
  • the memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may be stored according to Data (such as audio data, etc.) created by the use of the storage device 1000.
  • memory 120 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 120 also includes a memory controller to provide access to memory 120 by processor 180.
  • Storage device 1000 may also include at least one type of sensor 150, such as a motion sensor and other sensors.
  • the gravity acceleration sensor can detect the magnitude of acceleration in all directions (usually three axes). When it is stationary, it can detect the magnitude and direction of gravity. It can be used to identify the attitude of the storage device (such as magnetometer attitude calibration). ), vibration recognition related functions (such as tapping), etc.; other sensors such as a barometer, a hygrometer, a thermometer, an infrared sensor, and the like that the storage device 1000 can also be configured are not described herein.
  • a wireless communication unit is shown in the drawings, it can be understood that it does not belong to the essential configuration of the storage device 1000, and may be omitted as needed within the scope of not changing the essence of the disclosure.
  • the processor 180 is a control center of the storage device 1000 that connects various portions of the entire handset with various interfaces and lines, by running or executing software programs and/or modules stored in the memory 120, and recalling data stored in the memory 120.
  • the various functions and processing data of the storage device 1000 are executed to perform overall monitoring of the storage device.
  • processor 180 may include one or more processing cores.
  • the storage device 1000 also includes a power source 190 (such as a battery) that supplies power to the various components, preferably, The power supply can be logically coupled to the processor 180 through the power management system to manage functions such as charging, discharging, and power management through the power management system.
  • Power supply 190 may also include any one or more of a DC or AC power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
  • the storage device further includes a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to execute the one or more by one or more processors
  • the program includes instructions for performing the methods provided by embodiments of the present disclosure:
  • a data writing request carrying at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written;
  • the version information of the data to be written is compared with the version information of the local data corresponding to the data identifier. If the comparison result of the version information satisfies the version comparison condition, the write operation is performed on the data to be written.
  • the comparison sub-condition corresponding to each sub-condition information carried in the data write request is obtained, and the obtained union of the comparison sub-conditions is determined as a version comparison condition, including:
  • the comparison sub-conditions corresponding to each sub-condition information carried in the data write request are respectively obtained according to the corresponding relationship between the pre-stored comparison sub-conditions and the sub-condition information, and the obtained union of the comparison sub-conditions is determined as a version comparison condition.
  • the comparison sub-condition is: One version is higher than the second version, the first version is equal to the second version, the first version is lower than the second version, and the first version is not comparable to the second version.
  • the storage device receives a data write request sent by the server that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written, and acquires data writing.
  • the comparison sub-condition corresponding to each sub-condition information carried in the request determines the union of the obtained comparison sub-conditions as a version comparison condition, and compares the version information of the data to be written with the version information of the local data corresponding to the data identifier.
  • the write operation is performed on the write data, so that even if the process of writing the data adds a new version comparison condition, the storage device may not need to be correspondingly set, that is, Can be completed to storage The purpose of writing data in the device, thereby improving the flexibility of the storage device to store data.
  • FIG. 8 is a schematic structural diagram of a server according to an embodiment of the present invention.
  • the server may be used to implement the method for writing data provided in the foregoing embodiment. Specifically:
  • Server 1100 may vary considerably depending on configuration or performance, and may include one or more central processing units (CPUs) 1122 (eg, one or more processors) and memory 1132, one or more A storage medium 1130 storing storage application 1142 or data 1144 (eg, one or one storage device in Shanghai).
  • the memory 1132 and the storage medium 1130 may be short-term storage or persistent storage.
  • the program stored on the storage medium 1130 may include one or more modules (not shown), each of which may include a series of instruction operations in the server.
  • central processor 1122 can be configured to communicate with storage medium 1130, executing a series of instruction operations in storage medium 1130 on server 1100.
  • Server 1100 can also include one or more power sources 1126, one or more wired or wireless network interfaces 1150, one or more input and output interfaces 1158, one or more keyboards 1156, and/or one or more operating systems 1141 For example, Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
  • the server includes a memory, and one or more programs, wherein one or more programs are stored in the memory, and one or more programs may include one or more modules, and each module may Included with a series of instruction operations in a server, and configured to be executed by one or more processors.
  • the one or more programs include instructions for:
  • determining at least one comparison sub-condition, and determining the union of the comparison sub-conditions is a version comparison condition
  • a data write request is sent to the storage device carrying sub-condition information of at least one comparison sub-condition, data to be written, data identification of the data to be written, and version information of the data to be written.
  • the comparison sub-condition is: the first version is higher than the second version, the first version is equal to the second version, the first version is lower than the second version, or the first version cannot be compared with the second version, wherein the first version For the version corresponding to the version information of the data to be written, the second version is a version corresponding to the version information of the local data having the same data identifier as the data to be written stored in the storage device.
  • the storage device receives a data write request sent by the server that carries at least one sub-condition information, data to be written, data identifier of data to be written, and version information of data to be written, and acquires data writing.
  • the comparison sub-condition corresponding to each sub-condition information carried in the request determines the union of the obtained comparison sub-conditions as a version comparison condition, and compares the version information of the data to be written with the version information of the local data corresponding to the data identifier.
  • the write operation is performed on the write data, so that even if the process of writing the data adds a new version comparison condition, the storage device may not need to be correspondingly set, that is, The purpose of writing data to the storage device can be completed, thereby improving the flexibility of the storage device to store data.
  • a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
  • the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种写入数据的方法和装置,属于计算机技术领域。所述方法应用于存储设备中,该存储设备中预先存储有不同数据标识对应的数据,所述方法包括:存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求,存储设备获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,存储设备将待写入数据的版本信息与待写入数据的数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作。采用本发明,可以提高存储设备存储数据的灵活性。

Description

写入数据的方法和装置技术领域 技术领域
本发明涉及计算机技术领域,特别涉及一种写入数据的方法和装置。
背景技术
随着计算机技术的发展,需要存储的数据量越来越大,通常将数据存储在存储设备中,用户可以通过终端写入新的数据,也可以读取和/或修改存储设备中的数据。
通常,在弱一致性或最终一致性的分布式存储系统中,向存储设备中写入数据时,包括多种写场景,例如普通写场景、修复写场景、冲突写场景等,不同的写场景设置有不同的版本对比条件,例如普通写场景下的版本对比条件为:如果待写入数据的版本高于存储设备中已存储的与待写入数据具有相同数据标识的数据的版本,则写入待写入数据。在向存储设备中写入数据的过程中,服务器获取某数据(可称为待写入数据),并获取场景参数、待写入数据的版本信息(如版本号)、待写入数据的数据标识,其中,待写入数据的获取过程是由用户通过终端发送的数据,或者服务器从存储设备中提取,场景参数是服务器在进行写入数据时判定,版本信息可以由服务器设置或者提取。然后,将携带有待写入数据、该数据标识、数据版本标识和场景参数的数据写入请求发送给存储设备,存储设备接收到数据写入请求时,确定场景参数对应的写场景的版本对比条件,并将与待写入数据具有相同数据标识的本地数据的版本与待写入数据的版本进行比较,如果两者的比较结果满足场景参数对应的写场景下的版本对比条件,则将待写入数据存储到存储设备中,并将本地数据删除。
现有技术至少存在以下问题:
向存储设备中写入数据的过程中,需要对不同的写场景设置不同的数据写入条件,当需要增加某写场景时,需要对存储设备进行相应的设置,例如设置该写场景下的数据写入条件等,否则在该写场景下存储设备将无法将待写入数据存储到该存储设备中,从而,使得存储设备存储数据的灵活性较差。
发明内容
本发明实施例提供了一种写入数据的方法和装置,该方法和装置可以用于解决现有技术中数据库存储数据的灵活性的问题,所述技术方案如下:
第一方面,提供了一种写入数据的方法,所述方法应用于存储设备中,所述存储设备中存储有不同数据标识对应的数据,所述方法包括:
所述存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求;
所述存储设备获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;
所述存储设备将所述待写入数据的版本信息与所述数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足所述版本对比条件,则对所述待写入数据进行写入操作。
结合第一方面,在第一方面的第一种可能实现方式中,所述存储设备获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,包括:
所述存储设备根据预先存储的对比子条件与子条件信息的对应关系,分别获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
结合第一方面,在第一方面的第二种可能实现方式中,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则所述对比子条件为:所述第一版本高于所述第二版本、所述第一版本等于所述第二版本、所述第一版本低于所述第二版本、所述第一版本与所述第二版本无法比较中的一个。
第二方面,提供了一种写入数据的方法,所述方法应用于服务器中,所述服务器中预先存储有多个版本对比条件和多个对比子条件,所述方法包括:
服务器获取待写入数据、所述待写入数据的数据标识、所述待写入数据的版本信息和所述待写入数据对应的版本对比条件;
所述服务器在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为所述版本对比条件;
所述服务器向存储设备发送携带有所述至少一个对比子条件的子条件信息、所述待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求。
结合第二方面,在第二方面的第一种可能实现方式中,如果第一版本为待 写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则所述对比子条件为:所述第一版本高于所述第二版本、所述第一版本等于所述第二版本、所述第一版本低于所述第二版本、所述第一版本与所述第二版本无法比较中的一个。
第三方面,提供了一种存储设备,所述存储设备包括:
接收模块,用于接收服务器发送的携带有至少一个子条件信息、待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求;
确定模块,用于获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;
写入模块,用于将所述待写入数据的版本信息与所述数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足所述版本对比条件,则对所述待写入数据进行写入操作。
结合第三方面,在第三方面的第一种可能实现方式中,所述确定模块,用于:
根据预先存储的对比子条件与子条件信息的对应关系,分别获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
结合第三方面,在第三方面的第二种可能实现方式中,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则所述对比子条件为:所述第一版本高于所述第二版本、所述第一版本等于所述第二版本、所述第一版本低于所述第二版本、所述第一版本与所述第二版本无法比较中的一个。
第四方面,提供了一种服务器,所述服务器包括:
获取模块,用于获取待写入数据、所述待写入数据的数据标识、所述待写入数据的版本信息和所述待写入数据对应的版本对比条件;
确定模块,用于在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为所述版本对比条件;
发送模块,用于向存储设备发送携带有所述至少一个对比子条件的子条件信息、所述待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求。
结合第四方面,在第四方面的第一种可能实现方式中,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则所述对比子条件为:所述第一版本高于所述第二版本、所述第一版本等于所述第二版本、所述第一版本低于所述第二版本、所述第一版本与所述第二版本无法比较中的一个。
第五方面,提供了一种写入数据的系统,所述系统包括存储设备和服务器,其中:
所述存储设备,用于接收服务器发送的携带有至少一个子条件信息、待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求;获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;将所述待写入数据的版本信息与所述数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足所述版本对比条件,则对所述待写入数据进行写入操作;
所述服务器,用于获取待写入数据、所述待写入数据的数据标识、所述待写入数据的版本信息和所述待写入数据对应的版本对比条件;在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为所述版本对比条件;向存储设备发送携带有所述至少一个对比子条件的子条件信息、所述待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求。
本发明实施例提供的技术方案带来的有益效果是:
本发明实施例中,接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求,获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作,这样,即使写入数据的过程增加了新的版本对比条件,也可以不需要对存储设备进行相应的设置,即可完成向存储设备中写入数据的目的,从而,可以提高存储设备存储数据的灵活性。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本发明实施例提供的一种写入数据的方法流程图;
图2是本发明实施例提供的一种写入数据的方法流程图;
图3是本发明实施例提供的一种写入数据的方法流程图;
图4是本发明实施例提供的一种系统的结构示意图;
图5是本发明实施例提供的一种存储设备结构示意图;
图6是本发明实施例提供的一种服务器结构示意图;
图7是本发明实施例提供的一种存储设备结构示意图;
图8是本发明实施例提供的一种服务器结构示意图。
具体实施方式
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。
由于不同的写场景,执行写入操作的执行条件各不相同,描述执行条件的信息称为版本对比条件。服务器需要把版本对比条件发送给存储设备,以便存储设备依据版本对比条件确定是否执行写入操作。
例如在修复写这种写场景中,执行写入操作的版本对比条件是:待写入数据的版本高于本地已经有数据的版本,或者待写数据的版本等于本地已经有数据的版本。如果满足版本对比条件,则执行写入操作;否则不执行。而普通写这种写场景中,版本对比条件是:待写数据的版本高于本地已经有数据的版本,会执行写入操作。而在任意版本写这种写场景中,版本对比条件是:无论版本哪个版本更新,甚至版本无法比较,都会执行写入操作。其中,本地已经有数据的数据标识与待写入数据的数据标识相同。
由于不同写场景的版本对比条件往往也不相同。现有技术中,根据不同的写场景,需要进行比较复杂的逻辑判断才能得出是否执行写入操作的结论。此外,现有技术还存在如下问题。
(1)如果使用不同的写命令,则接口较多,管理复杂度提高;
(2)如果使用相同的命令,需要使用场景参数表明写场景,也存在分布式存储设备和业务处理层逻辑强耦合的问题,即存储设备需要理解不同写场景 的意义,根据不同的写场景使用不同原则进行相应的处理,不利于使用第三方存储设备。
(3)一旦新增写场景,就不得不新增加接口,或者修改存储设备的设置,增加对该写场景的处理复杂度。
本发明实施例提出一种新的思路,服务器把版本对比条件。例如,把修复写的版本对比条件拆分成对比子条件A和子条件B。其中,对比子条件A是:待写数据的版本高于本地已经有数据的版本;对比子条件B是:待写数据的版本等于本地已经有数据的版本。
存储设备收到这两条对比子条件后,对二者进行合并。相当于重新生成了拆分前的版本对比条件。
使用本发明实施例所提供的方案后,不论是任何写场景,服务器仅需要发送下面4个对比子条件中的任意一个即可:(1)待写数据的版本高于本地已经有数据的版本;(2)或者待写数据的版本等于本地已经有数据的版本;(3)或者待写数据的版本低于本地已经有数据的版本;(4)或者待写数据的版本和本地已经有数据的版本无法比较。因此本发明实施例简化了流程。解决了上面提到的现有技术中的问题。
本发明实施例中,版本更高是版本更加新的意思,可以通过版本号的比较来执行这个判断。
实施例一
本发明实施例提供了一种写入数据的方法,该方法可以由服务器和存储设备共同实现。
如图1所示,该方法中存储设备的处理流程可以包括如下的步骤:
步骤101,存储设备接收终端发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求。
步骤102,存储设备获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
步骤103,存储设备将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作。
如图2所示,该方法中服务器的处理流程可以包括如下的步骤:
步骤201,服务器获取待写入数据、待写入数据的数据标识、待写入数据 的版本信息和待写入数据对应的版本对比条件。
步骤202,服务器在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为版本对比条件。
步骤203,服务器向存储设备发送携带有至少一个对比子条件的子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求。
本发明实施例中,存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求,获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作,这样,即使写入数据的过程增加了新的版本对比条件,也可以不需要对存储设备进行相应的设置,即可完成向存储设备中写入数据的目的,从而,可以提高存储设备存储数据的灵活性。
实施例二
本发明实施例提供了一种写入数据的方法,该方法可以由服务器和存储设备共同实现。其中的服务器可以是用于向存储设备中写入数据的任意服务器,该服务器中可以预先存储有多个版本对比条件和多个对比子条件,存储设备中可以预先存储有不同数据标识对应的数据。
如图3所示,该方法的处理流程可以包括如下的步骤:
步骤301,服务器获取待写入数据、待写入数据的数据标识、待写入数据的版本信息和待写入数据对应的版本对比条件。
其中,数据标识可以是数据的名称等,版本信息可以是版本号、版本名称等。
在实施中,可以通过多种方式通过服务器向存储设备中写入数据,例如,用户通过服务器向存储设备中写入数据,或者,服务器检测到存储设备中某数据出现错误,可以对存储设备中的该数据进行修复。其中,存储设备可以是一个独立的数据存储设备,也可以是由多个存储设备组成的存储系统,例如分布式存储系统等,存储设备中存储的数据通常包括多个副本,例如三个副本,从而保证数据的可靠性,存储设备可以设置多个存储节点分别存储上述多个副本。如图4所示,对于用户通过服务器向存储设备中写入数据的情况,用户可 以编写某数据(即待写入数据),待写入数据可以是用户编写的新数据,也可以是对存储设备中的某数据进行修改后的数据,编写待写入数据完成后,可以将待写入数据发送给服务器,服务器接收到待写入数据后,可以提取该待写入数据的数据标识,然后可以为待写入数据设置版本信息,由于待写入数据是由用户通过终端提供给服务器,服务器可以确定写入数据的写场景为普通写场景,进而,服务器确定普通写场景对应的版本对比条件。其中,写入数据的写场景包括多种,例如普通写场景、修复写场景、冲突写场景等,不同的写场景设置有不同的版本对比条件。版本信息可以是由服务器设置,例如,用户通过终端编写了一个新的数据发送给如图4所示的服务器中的服务器X,服务器X可以将该数据的版本信息设置为(X,1),如果用户读取存储设备中的某数据,并对该数据进行修改,修改完成后,可以将修改的数据发送给服务器,服务器提取该数据修改前的版本信息,若为(X,1),该服务器为服务器X,则服务器X可以设置修改后的数据的版本信息为(X,2),若该数据修改前的版本信息为(X,1),该服务器为服务器Y,则服务器Y可以设置修改后的数据的版本信息为(X,1)(Y,1),若该数据修改前的版本信息为(X,1),该服务器为服务器Z,则服务器Z可以设置修改后的数据的版本信息为(X,1)(Z,1)。通过上述版本信息可以确定版本信息为(X,2)、(X,1)(Y,1)或(X,1)(Z,1)的数据,都是基于版本信息为(X,1)的数据进行修改,因此,版本信息(X,2)、(X,1)(Y,1)和(X,1)(Z,1)都高于版本信息(X,1),而版本信息(X,2)、(X,1)(Y,1)和(X,1)(Z,1)之间无法比较。
对于服务器检测到存储设备中某数据出现错误,可以对存储设备中的该数据进行修复的情况,如图4所示,当用户通过终端向服务器请求读某数据时,如果终端读取数据的过程中,数据出现错误,终端可以向服务器发送错误消息,服务器接收到错误消息后,可以提取该数据的数据标识,然后可以向存储设备发送获取该数据标识对应的数据,作为待写入数据,然后可以提起待写入数据的版本信息,此时服务器可以确定需要进行的写入数据的写场景为修复写场景,服务器获取修复写场景对应的版本比较条件。对于其它情况,如冲突写场景、非等版本写场景的情况等,与上述过程类似,具体过程可以参见上述内容,在此不再赘述。其中,冲突写可以为两个相同数据标识的数据的版本无法比较,非等版本写可以为存储设备中存储有同一数据标识的数据的副本中包括多个不同版本的副本。对于冲突写场景、非等版本写场景的情况,需要用户选择一 个版本或者用户使用的终端根据数据写入的时间确定一个版本,作为存储设备中该数据的版本,并将不同版本的数据使用该版本的数据进行覆写。
步骤302,服务器在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为版本对比条件。
在实施中,服务器中可以预先存储有多个对比子条件,服务器可以通过多个对比子条件,将获取到的版本对比条件进行拆分,得到至少一个对比子条件,可见,如果计算得到的对比子条件的并集,则得到的计算结果为版本对比条件。
可选地,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则对比子条件为:第一版本高于第二版本、第一版本等于第二版本、第一版本低于第二版本、第一版本与第二版本无法比较中的一个。其中,待写入数据可以为任意数据。
服务器中的多个对比子条件可以是通过对比子条件与子条件信息的对应关系的方式存储,其中,子条件信息可以是子条件标识等。对比子条件与子条件信息的对应关系可以表格的形式存储,以B1表示第一版本,B2表示第一版本,子条件信息为子条件标识,则上述步骤301中不同的写场景设置有不同的版本对比条件,可以如表1所示。
表1
写场景 版本对比条件
普通写场景 B1>B2:写入待写入数据
修复写场景 B1≥B2:写入待写入数据
冲突写场景 用户确定的版本的数据写入存储设备
相应的,上述对比子条件与子条件信息的对应关系可以如表2所示。
表2
子条件信息 对比子条件
A1 B1>B2
A2 B1=B2
A3 B1<B2
A4 B1与B2无法比较
如果版本对比条件为:B1≥B2,写入待写入数据,则通过上述表2可以 确定,对应的对比子条件为B1>B2和B1=B2,子条件信息分别为A1、A2。
子条件信息可以二进制数值表示,如0和1,可以为待写入数据设置一个二进制数值,具体的,一个字节通常有8位二进制数值,如表3所示。
表3
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
可以使用其中的bit 0、bit 1、bit 2和bit 3表示上述多个对比子条件,例如,如果bit 0中为1,则表示第一版本低于第二版本,如果bit 1中为1,则表示第一版本等于第二版本,如果bit 2中为1,则表示第一版本高于第二版本,如果bit 3中为1,则表示第一版本与第二版本无法比较,通过上述方法,如果版本对比条件为“B1≥B2:写入待写入数据”,则通过上述表2可以确定,对应的对比子条件为B1>B2和B1=B2,因此,可以确定bit 1和bit 2中都为1,其它位置都为0,从而得到二进制数值为00000110,转换为十进制数值为6,服务器可以将数值6作为确定出的对比子条件的子条件信息。
步骤303,服务器向存储设备发送携带有至少一个对比子条件的子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求。
在实施中,服务器可以通过确定出的对比子条件,通过上述表2,得到每个对比子条件对应的子条件信息,该子条件信息也可以是上述如表3的方式确定出的二进制数值或十进制数值,子条件信息还可以是相应的对比子条件。服务器可以通过该子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息,生成数据写入请求,发送给存储设备。
数据写入请求可以是某种形式的命令,以子条件信息可以二进制数值为例,数据写入请求可以为Write(data,version,mask),其中,Write可以表示命令关键字,data可以表示待写入数据,version可以表示待写入数据的版本信息,mask可以表示上述二进制数值或十进制数值等。
步骤304,存储设备接收终端发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求。
步骤305,存储设备获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
在实施中,子条件信息可以是相应的对比子条件,存储设备接收到数据写入请求后,可以提取其中的子条件信息,即对比子条件,存储设备可以计算得 到的对比子条件的并集,并将得到的计算结果确定为版本对比条件。
可选地,子条件信息可以是子条件标识或一个数值。如果子条件信息为子条件标识,则上述步骤305的处理过程可以包括以下内容:根据预先存储的对比子条件与子条件信息的对应关系,分别获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
在实施中,存储设备中预先存储有对比子条件与子条件信息的对应关系,该对应关系可以如表2所示,存储设备接收到数据写入请求后,可以提取其中的子条件信息,然后,可以在如表2的对比子条件与子条件信息的对应关系中查找,得到提取出的每个子条件信息对应的对比子条件,可以将得到的对比子条件的并集确定为版本对比条件。
如果子条件信息为一个数值,相应的处理过程可以为:以数值6为例,存储设备可以将数值6转换成二进制数值,得到00000110,可以通过上述表3,得到bit 1和bit 2中都为1,对应的对比子条件为B1>B2和B1=B2,存储设备计算上述对比子条件的并集,得到B1≥B2,从而,得到版本对比条件,即如果B1≥B2,则写入待写入数据。如果是非等版本写的情况,可以确定多个版本信息中,数目最多的版本信息对应的数据作为待写入数据,由于该待写入数据的版本可能大于或小于本地数据的版本,或者两者或者无法比较,因此,mask可以为00001101,该情况的处理过程可以参见上述内容,在此不再赘述。
步骤306,存储设备将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作。
在实施中,存储设备可以通过待写入数据的版本信息、数据标识对应的本地数据的版本信息和版本对比条件,判断待写入数据的版本信息和数据标识对应的本地数据的版本信息是否满足版本对比条件,如果满足,则存储设备可以向服务器发送写入成功的通知消息,如果不满足,则服务器可以向服务器发送写入失败的通知消息或错误消息。
例如,版本对比条件为:如果B1≥B2,则写入待写入数据。存储设备将待写入数据的版本信息和本地数据的版本信息进行对比,如果待写入数据的版本高于本地数据的版本,或者待写入数据的版本等于本地数据的版本,则将待写入数据写入到存储设备中,并将该本地数据删除,如果待写入数据的版本低于本地数据的版本,则可以取消将待写入数据写入到存储设备中。
通过上述内容可以得到,在对待写入数据进行写入操作的过程中,首先可以通过待写入数据对应的写场景,确定版本对比条件,然后可以将该版本对比条件拆分成一个或多个对比子条件,发送给存储设备,存储设备可以求取上述一个或多个对比子条件的并集,得到上述版本对比条件,最后,可以将待写入数据的版本信息和本地数据的版本信息进行对比,如果两者的对比结果满足版本对比条件,则对待写入数据进行写入操作,这样,存储设备中可以不需要设置各种写场景对应的版本对比条件,而只需要得到相应的对比子条件即可完成对待写入数据的写入操作,一定程度上提高了存储设备存储数据的灵活性。本发明实施例中,存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求,获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作,这样,即使写入数据的过程增加了新的版本对比条件,也可以不需要对存储设备进行相应的设置,即可完成向存储设备中写入数据的目的,从而,可以提高存储设备存储数据的灵活性。
需要特别说明的是,本实施例及其他实施例中存储设备可以是存储控制器(Storage Controller)和存储介质的组合,例如存储控制器和硬盘。也可以是具有运算功能的存储介质,类似于集成了部分控制器功能的硬盘,例如IP(Internet Protocol,网络之间互连的协议)盘。之所以需要有运算能力,是因为需要执行待写入数据的版本信息与待写入数据的数据标识对应的本地数据的版本信息进行对比的操作,以及发出写入操作的指令。换句话说,只要具有完成这样功能的并且具有存储功能的设备,就是本申请中所谓的存储设备。
实施例三
基于相同的技术构思,本发明实施例还提供了一种存储设备,如图5所示,该存储设备包括:
接收模块510,用于接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求;
确定模块520,用于获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;
写入模块530,用于将待写入数据的版本信息与数据标识对应的本地数据 的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作。
可选地,确定模块520,用于:
根据预先存储的对比子条件与子条件信息的对应关系,分别获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
可选地,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则对比子条件为:第一版本高于第二版本、第一版本等于第二版本、第一版本低于第二版本、第一版本与第二版本无法比较中的一个。
基于相同的技术构思,本发明实施例还提供了一种服务器,如图6所示,该服务器包括:
获取模块610,用于获取待写入数据、待写入数据的数据标识、待写入数据的版本信息和待写入数据对应的版本对比条件;
确定模块620,用于在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为版本对比条件;
发送模块630,用于向存储设备发送携带有至少一个对比子条件的子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求。
可选地,如果第一版本为待写入数据的版本信息对应的版本,第二版本为存储设备中存储的、与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则对比子条件为:第一版本高于第二版本、第一版本等于第二版本、第一版本低于第二版本、第一版本与第二版本无法比较中的一个。
本发明实施例中,存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求,获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作,这样,即使写入数据的过程增加了新的版本对比条件,也可以不需要对存储设备进行相应的设置,即可完成向存储 设备中写入数据的目的,从而,可以提高存储设备存储数据的灵活性。
需要说明的是:上述实施例提供的写入数据的装置在写入数据时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将服务器或存储设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的写入数据的装置与写入数据的方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
实施例四
基于相同的技术构思,本发明实施例还提供的一种写入数据的系统,其特征在于,该系统包括存储设备和服务器,其中:
存储设备,用于接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求;获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作;
服务器,用于获取待写入数据、待写入数据的数据标识、待写入数据的版本信息和待写入数据对应的版本对比条件;在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为版本对比条件;向存储设备发送携带有至少一个对比子条件的子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求。
本发明实施例中,存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求,获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作,这样,即使写入数据的过程增加了新的版本对比条件,也可以不需要对存储设备进行相应的设置,即可完成向存储设备中写入数据的目的,从而,可以提高存储设备存储数据的灵活性。
实施例五
请参考图7,其示出了本发明实施例所涉及的存储设备结构示意图,该存储设备可以用于实施上述实施例中提供的写入数据的方法。具体来讲:
存储设备1000可以包括有一个或一个以上计算机可读存储介质的存储器120、包括有一个或者一个以上处理核心的处理器180、以及电源190等部件。本领域技术人员可以理解,图中示出的存储设备结构并不构成对存储设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。其中:
存储器120可用于存储软件程序以及模块,处理器180通过运行存储在存储器120的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器120可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据存储设备1000的使用所创建的数据(比如音频数据等)等。此外,存储器120可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器120还包括存储器控制器,以提供处理器180对存储器120的访问。
存储设备1000还可包括至少一种传感器150,比如运动传感器以及其他传感器。作为运动传感器的一种,重力加速度传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别存储设备姿态的应用(比如磁力计姿态校准)、振动识别相关功能(比如敲击)等;至于存储设备1000还可配置的气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。
虽然图中示出了无线通信单元,但是可以理解的是,其并不属于存储设备1000的必须构成,完全可以根据需要在不改变公开的本质的范围内而省略。
处理器180是存储设备1000的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器120内的软件程序和/或模块,以及调用存储在存储器120内的数据,执行存储设备1000的各种功能和处理数据,从而对存储设备进行整体监控。可选的,处理器180可包括一个或多个处理核心。
存储设备1000还包括给各个部件供电的电源190(比如电池),优选的, 电源可以通过电源管理系统与处理器180逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。电源190还可以包括一个或一个以上的直流或交流电源、再充电系统、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。
在本实施例中,存储设备还包括有存储器,以及一个或者一个以上的程序,其中一个或者一个以上程序存储于存储器中,且经配置以由一个或者一个以上处理器执行所述一个或者一个以上程序包含用于进行本公开实施例提供的方法的指令:
接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求;
获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;
将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作。
可选地,获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,包括:
根据预先存储的对比子条件与子条件信息的对应关系,分别获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
可选地,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则对比子条件为:第一版本高于第二版本、第一版本等于第二版本、第一版本低于第二版本、第一版本与第二版本无法比较中的一个。
本发明实施例中,存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求,获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作,这样,即使写入数据的过程增加了新的版本对比条件,也可以不需要对存储设备进行相应的设置,即可完成向存储 设备中写入数据的目的,从而,可以提高存储设备存储数据的灵活性。
实施例六
请参考图8,其示出了本发明实施例所涉及的服务器结构示意图,该服务器可以用于实施上述实施例中提供的写入数据的方法。具体来讲:
服务器1100可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(central processing units,CPU)1122(例如,一个或一个以上处理器)和存储器1132,一个或一个以上存储应用程序1142或数据1144的存储介质1130(例如一个或一个以上海量存储设备)。其中,存储器1132和存储介质1130可以是短暂存储或持久存储。存储在存储介质1130的程序可以包括一个或一个以上模块(图示未示出),每个模块可以包括对服务器中的一系列指令操作。更进一步地,中央处理器1122可以设置为与存储介质1130通信,在服务器1100上执行存储介质1130中的一系列指令操作。服务器1100还可以包括一个或一个以上电源1126,一个或一个以上有线或无线网络接口1150,一个或一个以上输入输出接口1158,一个或一个以上键盘1156,和/或,一个或一个以上操作系统1141,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。具体在本实施例中,服务器包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上程序可以包括一个或一个以上模块,且每个模块可以包括对服务器中的一系列指令操作,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下操作的指令:
获取待写入数据、待写入数据的数据标识、待写入数据的版本信息和待写入数据对应的版本对比条件;
在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为版本对比条件;
向存储设备发送携带有至少一个对比子条件的子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求。
可选地,对比子条件为:第一版本高于第二版本、第一版本等于第二版本、第一版本低于第二版本或者第一版本与第二版本无法比较,其中,第一版本为待写入数据的版本信息对应的版本,第二版本为存储设备中存储的、与待写入数据具有相同数据标识的本地数据的版本信息对应的版本。
本发明实施例中,存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、待写入数据的数据标识和待写入数据的版本信息的数据写入请求,获取数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,将待写入数据的版本信息与数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足版本对比条件,则对待写入数据进行写入操作,这样,即使写入数据的过程增加了新的版本对比条件,也可以不需要对存储设备进行相应的设置,即可完成向存储设备中写入数据的目的,从而,可以提高存储设备存储数据的灵活性。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (11)

  1. 一种写入数据的方法,其特征在于,所述方法应用于存储设备中,所述存储设备中预先存储有不同数据标识对应的数据,所述方法包括:
    所述存储设备接收服务器发送的携带有至少一个子条件信息、待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求;
    所述存储设备获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;
    所述存储设备将所述待写入数据的版本信息与所述待写入数据的数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足所述版本对比条件,则对所述待写入数据进行写入操作。
  2. 根据权利要求1所述的方法,其特征在于,所述存储设备获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件,包括:
    所述存储设备根据预先存储的对比子条件与子条件信息的对应关系,分别获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
  3. 根据权利要求1所述的方法,其特征在于,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则所述对比子条件为:所述第一版本高于所述第二版本、所述第一版本等于所述第二版本、所述第一版本低于所述第二版本、所述第一版本与所述第二版本无法比较中的一个。
  4. 一种写入数据的方法,其特征在于,所述方法应用于服务器中,所述服务器中预先存储有多个版本对比条件和多个对比子条件,所述方法包括:
    服务器获取待写入数据、所述待写入数据的数据标识、所述待写入数据的版本信息和所述待写入数据对应的版本对比条件;
    在预先存储的对比子条件中,所述服务器确定至少一个对比子条件,确定出的对比子条件的并集为所述版本对比条件;
    所述服务器向存储设备发送携带有所述至少一个对比子条件的子条件 信息、所述待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求。
  5. 根据权利要求4所述的方法,其特征在于,如果第一版本为待写入数据的版本信息对应的版本,第二版本为所述存储设备中存储的、与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则所述对比子条件为:所述第一版本高于所述第二版本、所述第一版本等于所述第二版本、所述第一版本低于所述第二版本、所述第一版本与所述第二版本无法比较中的一个。
  6. 一种存储设备,其特征在于,所述存储设备包括:
    接收模块,用于接收服务器发送的携带有至少一个子条件信息、待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求;
    确定模块,用于获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;
    写入模块,用于将所述待写入数据的版本信息与所述数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足所述版本对比条件,则对所述待写入数据进行写入操作。
  7. 根据权利要求6所述的存储设备,其特征在于,所述确定模块,用于:
    根据预先存储的对比子条件与子条件信息的对应关系,分别获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件。
  8. 根据权利要求6所述的存储设备,其特征在于,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则所述对比子条件为:所述第一版本高于所述第二版本、所述第一版本等于所述第二版本、所述第一版本低于所述第二版本、所述第一版本与所述第二版本无法比较中的一个。
  9. 一种服务器,其特征在于,所述服务器包括:
    获取模块,用于获取待写入数据、所述待写入数据的数据标识、所述待写入数据的版本信息和所述待写入数据对应的版本对比条件;
    确定模块,用于在预先存储的对比子条件中,确定至少一个对比子条 件,确定出的对比子条件的并集为所述版本对比条件;
    发送模块,用于向存储设备发送携带有所述至少一个对比子条件的子条件信息、所述待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求。
  10. 根据权利要求11所述的服务器,其特征在于,如果第一版本为待写入数据的版本信息对应的版本,第二版本为与待写入数据具有相同数据标识的本地数据的版本信息对应的版本,则所述对比子条件为:所述第一版本高于第二版本、所述第一版本等于所述第二版本、所述第一版本低于所述第二版本、所述第一版本与所述第二版本无法比较中的一个。
  11. 一种写入数据的系统,其特征在于,所述系统包括存储设备和服务器,其中:
    所述存储设备,用于接收服务器发送的携带有至少一个子条件信息、待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求;获取所述数据写入请求中携带的每个子条件信息对应的对比子条件,将获取的对比子条件的并集确定为版本对比条件;将所述待写入数据的版本信息与所述数据标识对应的本地数据的版本信息进行对比,如果版本信息的比较结果满足所述版本对比条件,则对所述待写入数据进行写入操作;
    所述服务器,用于获取待写入数据、所述待写入数据的数据标识、所述待写入数据的版本信息和所述待写入数据对应的版本对比条件;在预先存储的对比子条件中,确定至少一个对比子条件,确定出的对比子条件的并集为所述版本对比条件;向存储设备发送携带有所述至少一个对比子条件的子条件信息、所述待写入数据、所述待写入数据的数据标识和所述待写入数据的版本信息的数据写入请求。
PCT/CN2015/092945 2014-10-31 2015-10-27 写入数据的方法和装置技术领域 WO2016066081A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410605966.8A CN104407808B (zh) 2014-10-31 2014-10-31 写入数据的方法和装置
CN201410605966.8 2014-10-31

Publications (1)

Publication Number Publication Date
WO2016066081A1 true WO2016066081A1 (zh) 2016-05-06

Family

ID=52645441

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/092945 WO2016066081A1 (zh) 2014-10-31 2015-10-27 写入数据的方法和装置技术领域

Country Status (2)

Country Link
CN (1) CN104407808B (zh)
WO (1) WO2016066081A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104407808B (zh) * 2014-10-31 2017-10-10 华为技术有限公司 写入数据的方法和装置
CN105117489B (zh) * 2015-09-21 2018-10-19 北京金山安全软件有限公司 一种数据库管理方法、装置及电子设备
CN106708651B (zh) * 2016-11-16 2020-09-11 北京三快在线科技有限公司 基于纠删码的部分写入方法及装置、存储介质、设备
CN112035378A (zh) * 2020-09-03 2020-12-04 北京百瑞互联技术有限公司 一种数据快速写入flash闪存的方法及系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020052888A1 (en) * 2000-10-31 2002-05-02 Hewlett-Packard Co. Electronic record storage
CN1570866A (zh) * 2004-05-10 2005-01-26 杭州斯达康通讯有限公司 将计算机数据下载至手机时进行版本比较的方法
CN1664805A (zh) * 2004-03-01 2005-09-07 联想(北京)有限公司 一种实现机群环境中数据有效性的方法
US20090260004A1 (en) * 2008-04-10 2009-10-15 Palm, Inc. Computer program updates for mobile computing device
CN101610449A (zh) * 2009-07-07 2009-12-23 中兴通讯股份有限公司 配置数据升级与回退的方法和系统
CN104407808A (zh) * 2014-10-31 2015-03-11 华为技术有限公司 写入数据的方法和装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6047357A (en) * 1995-01-27 2000-04-04 Digital Equipment Corporation High speed method for maintaining cache coherency in a multi-level, set associative cache hierarchy
EP1293981A1 (en) * 2001-09-18 2003-03-19 Deutsche Thomson-Brandt Gmbh Method for processing information parts of recorded data
US9245011B2 (en) * 2011-03-04 2016-01-26 Red Hat, Inc. Data model versioning for document databases
CN102929600B (zh) * 2012-06-13 2016-06-29 许继电气股份有限公司 基于elf的监控系统版本识别方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020052888A1 (en) * 2000-10-31 2002-05-02 Hewlett-Packard Co. Electronic record storage
CN1664805A (zh) * 2004-03-01 2005-09-07 联想(北京)有限公司 一种实现机群环境中数据有效性的方法
CN1570866A (zh) * 2004-05-10 2005-01-26 杭州斯达康通讯有限公司 将计算机数据下载至手机时进行版本比较的方法
US20090260004A1 (en) * 2008-04-10 2009-10-15 Palm, Inc. Computer program updates for mobile computing device
CN101610449A (zh) * 2009-07-07 2009-12-23 中兴通讯股份有限公司 配置数据升级与回退的方法和系统
CN104407808A (zh) * 2014-10-31 2015-03-11 华为技术有限公司 写入数据的方法和装置

Also Published As

Publication number Publication date
CN104407808A (zh) 2015-03-11
CN104407808B (zh) 2017-10-10

Similar Documents

Publication Publication Date Title
US9600393B2 (en) Testing of application service versions on live data
EP3255527A1 (en) Remote keyboard-video-mouse technologies
US9003142B2 (en) Volume swapping of point-in-time read-only target volumes
US10642606B2 (en) Re-use of code
JP6325001B2 (ja) 階層データ構造のノードにおいて再帰的イベントリスナを用いる方法およびシステム
WO2016066081A1 (zh) 写入数据的方法和装置技术领域
US9197503B2 (en) Enhanced remote presence
US20130138934A1 (en) Loading configuration information
US11272012B2 (en) Action processing associated with a cloud device
WO2018192478A1 (zh) 云管理平台、虚拟机管理方法及其系统
US11099828B2 (en) Updating a metadata structure for a firmware update
US9940224B2 (en) Automatic remote execution of an application
US11940992B2 (en) Model file management method and terminal device
WO2019134565A1 (zh) 基于窄带物联网的终端验证方法及装置
CN110633046A (zh) 一种分布式系统的存储方法、装置、存储设备及存储介质
US20110270602A1 (en) Opening A Message Catalog File For a Language That Is Not Installed
WO2019194394A1 (ko) 전자 장치 및 그의 제어방법
TW201705015A (zh) 遠端系統配置管理方法、遠端系統配置管理系統及非暫態電腦可讀式儲存多媒體
US8738816B2 (en) Management of detected devices coupled to a host machine
US11662927B2 (en) Redirecting access requests between access engines of respective disk management devices
WO2022252322A1 (zh) 基于特征标记的电网监控系统内存库关系库同步方法
CN112261072B (zh) 一种服务调用方法、装置、设备和存储介质
CN210166772U (zh) 计算系统
US11893391B2 (en) Processing computing jobs via an acceleration device
WO2020052092A1 (zh) 代码自动发布方法、装置、计算机设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15855268

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15855268

Country of ref document: EP

Kind code of ref document: A1