Data processing method and apparatus, computer device, and computer-readable storage medium
Example data processing methods and apparatuses, example computer devices, and example computer-readable storage medium are provided. An example data processing method is applied to a storage system in which storage and computing are decoupled. The storage system includes a computing cluster and a storage cluster. The example method is performed by a computing node in the computing cluster. The example method includes receiving a data processing request, where the data processing request indicates to process a file. A first gateway device is determined from a plurality of gateway devices in the storage cluster. The data processing request is sent to the first gateway device, where the first gateway device forwards the data processing request to a storage node in the storage cluster to complete the processing of the file.
1 . A data processing method, wherein the method is applied to a storage system in which storage and computing are decoupled, the storage system comprises a computing cluster and a storage cluster, the computing cluster includes a plurality of computing nodes, and the method comprises:
receiving, by a computing node in the plurality of computing nodes, a data processing request, wherein the data processing request indicates to process a file, and each computing node in the plurality of computing nodes has a function of selecting a gateway device and a function of accessing the storage cluster by using the selected gateway device;
determining, by the computing node, a first gateway device from a plurality of gateway devices in the storage cluster based on a target index that is obtained by performing a modulo operation on a hash value of the file and a quantity of the plurality of gateway devices; and
sending, by the computing node, the data processing request to the first gateway device, wherein the first gateway device forwards the data processing request to a storage node in the storage cluster to complete the processing of the file.
2 . The method according to claim 1 , wherein correspondences between the plurality of gateway devices and indexes are recorded in the computing node, and each gateway device in the plurality of gateway devices corresponds to one index, and wherein the determining a first gateway device from a plurality of gateway devices in the storage cluster comprises:
performing hash calculation on an identifier of the file carried in the data processing request, to obtain the hash value of the file;
obtaining the target index based on the hash value and the quantity of the plurality of gateway devices; and
determining, based on the correspondences between the plurality of gateway devices and the indexes, a gateway device that is in the plurality of gateway devices and that corresponds to the target index as the first gateway device.
3 . The method according to claim 2 , wherein the correspondences between the plurality of gateway devices and the indexes comprise an identifier of each gateway device in the plurality of gateway devices and an index corresponding to each gateway device in the plurality of gateway devices, and the identifier of each gateway device comprises an internet protocol (IP) address of each gateway device.
4 . The method according to claim 2 , wherein the target index is a remainder of the hash value and a quantity of the plurality of gateway devices.
5 . The method according to claim 2 , further comprising:
storing a gateway mapping table, wherein the correspondences between the plurality of gateway devices and the indexes are recorded in the gateway mapping table.
6 . The method according to claim 1 , wherein before the determining a first gateway device from a plurality of gateway devices in the storage cluster, the method further comprises:
obtaining, from a monitoring node in the storage cluster, a status of each gateway device in the storage cluster, wherein the status comprises any one of an idle state, a busy state, or a faulty state; and
determining, based on the status of each gateway device in the storage cluster, the plurality of gateway devices in the idle state.
7 . The method according to claim 1 , wherein the sending comprises:
in response to the first gateway device being in a busy state or a faulty state, determining, based on recorded statuses of the plurality of gateway devices, a second gateway device from the plurality of gateway devices, wherein the second gateway device is any one gateway device that is in the plurality of gateway devices and that is in an idle state; and
sending the data processing request to the second gateway device, wherein the second gateway device forwards the data processing request to the storage node in the storage cluster to complete the processing of the file.
8 . A computer device, comprising:
at least one processor;
one or more memories coupled to the at least one processor and storing programming instructions for execution by the at least one processor to perform operations comprising:
receiving a data processing request, wherein the data processing request indicates to process a file, the computer device is one of a plurality of computing nodes in a computing cluster, and each computing node in the plurality of computing nodes has a function of selecting a gateway device and a function of accessing a storage cluster by using the selected gateway device;
determining a first gateway device from a plurality of gateway devices in the storage cluster based on a target index that is obtained by performing a modulo operation on a hash value of the file and a quantity of the plurality of gateway devices; and
sending the data processing request to the first gateway device, wherein the first gateway device forwards the data processing request to a storage node in the storage cluster to complete the processing of the file.
9 . The computer device according to claim 8 , wherein correspondences between the plurality of gateway devices and indexes are recorded in a computing node, and each gateway device in the plurality of gateway devices corresponds to one index, and wherein the determining a first gateway device from the plurality of gateway devices in the storage cluster comprises:
performing hash calculation on an identifier of the file carried in the data processing request, to obtain the hash value of the file;
obtaining the target index based on the hash value and the quantity of the plurality of gateway devices; and
determining, based on the correspondences between the plurality of gateway devices and the indexes, a gateway device that is in the plurality of gateway devices and that corresponds to the target index as the first gateway device.
10 . The computer device according to claim 9 , wherein the correspondences between the plurality of gateway devices and the indexes comprise an identifier of each gateway device in the plurality of gateway devices and an index corresponding to each gateway device in the plurality of gateway devices, and the identifier of each gateway device comprises an internet protocol (IP) address of each gateway device.
11 . The computer device according to claim 9 , wherein the target index is a remainder of the hash value and a quantity of the plurality of gateway devices.
12 . The computer device according to claim 9 , wherein the operations further comprise:
storing a gateway mapping table, wherein the correspondences between the plurality of gateway devices and the indexes are recorded in the gateway mapping table.
13 . The computer device according to claim 8 , wherein before the determining a first gateway device from a plurality of gateway devices in the storage cluster, the operations comprise:
obtaining, from a monitoring node in the storage cluster, a status of each gateway device in the storage cluster, wherein the status comprises any one of an idle state, a busy state, or a faulty state; and
determining, based on the status of each gateway device in the storage cluster, the plurality of gateway devices in the idle state.
14 . The computer device according to claim 8 , wherein the sending the data processing request to the first gateway device comprises:
in response to the first gateway device being in a busy state or a faulty state, determining, based on recorded statuses of the plurality of gateway devices, a second gateway device from the plurality of gateway devices, wherein the second gateway device is any one gateway device that is in the plurality of gateway devices and that is in an idle state; and
sending the data processing request to the second gateway device, wherein the second gateway device forwards the data processing request to the storage node in the storage cluster to complete the processing of the file.
15 . A non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores at least one piece of program code, and the at least one piece of program code is read by one or more processor, to enable a computer device to:
receive a data processing request, wherein the data processing request indicates to process a file, the computer device is one of a plurality of computing nodes in a computing cluster, and each computing node in the plurality of computing nodes has a function of selecting a gateway device and a function of accessing a storage cluster by using the selected gateway device;
determine a first gateway device from a plurality of gateway devices in the storage cluster based on a target index that is obtained by performing a modulo operation on a hash value of the file and a quantity of the plurality of gateway devices; and
send the data processing request to the first gateway device, wherein the first gateway device forwards the data processing request to a storage node in the storage cluster to complete the processing of the file.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein correspondences between the plurality of gateway devices and indexes are recorded in a computing node, and each gateway device in the plurality of gateway devices corresponds to one index, and determining the first gateway device from the plurality of gateway devices in the storage cluster comprises:
performing hash calculation on an identifier of the file carried in the data processing request, to obtain the hash value of the file;
obtaining the target index based on the hash value and the quantity of the plurality of gateway devices; and
determining, based on the correspondences between the plurality of gateway devices and the indexes, a gateway device that is in the plurality of gateway devices and that corresponds to the target index as the first gateway device.
17 . The non-transitory computer-readable storage medium according to claim 16 , wherein the correspondences between the plurality of gateway devices and the indexes comprise an identifier of each gateway device in the plurality of gateway devices and an index corresponding to each gateway device in the plurality of gateway devices, and the identifier of each gateway device comprises an internet protocol (IP) address of each gateway device.
18 . The non-transitory computer-readable storage medium according to claim 16 , wherein the target index is a remainder of the hash value and a quantity of the plurality of gateway devices.
19 . The non-transitory computer-readable storage medium according to claim 16 , wherein the at least one piece of program code further comprises program code to:
store a gateway mapping table, wherein the correspondences between the plurality of gateway devices and the indexes are recorded in the gateway mapping table.
20 . The non-transitory computer-readable storage medium according to claim 15 , wherein before the determining a first gateway device from a plurality of gateway devices in the storage cluster, the at least one piece of program code further comprises program code to:
obtain, from a monitoring node in the storage cluster, a status of each gateway device in the storage cluster, wherein the status comprises any one of an idle state, a busy state, or a faulty state; and
determine, based on the status of each gateway device in the storage cluster, the plurality of gateway devices in the idle state.