CN109740027B - Data exchange method, device, server and storage medium - Google Patents

Data exchange method, device, server and storage medium Download PDF

Info

Publication number
CN109740027B
CN109740027B CN201910080274.9A CN201910080274A CN109740027B CN 109740027 B CN109740027 B CN 109740027B CN 201910080274 A CN201910080274 A CN 201910080274A CN 109740027 B CN109740027 B CN 109740027B
Authority
CN
China
Prior art keywords
directory name
data
original
directory
temporary
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910080274.9A
Other languages
Chinese (zh)
Other versions
CN109740027A (en
Inventor
王攀
郭琰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Dameng Database Co Ltd
Original Assignee
Shanghai Dameng Database Co Ltd
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 Shanghai Dameng Database Co Ltd filed Critical Shanghai Dameng Database Co Ltd
Priority to CN201910080274.9A priority Critical patent/CN109740027B/en
Publication of CN109740027A publication Critical patent/CN109740027A/en
Application granted granted Critical
Publication of CN109740027B publication Critical patent/CN109740027B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a data exchange method, a device, a server and a storage medium, wherein the method comprises the following steps: receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data; searching a first original directory name of the first data according to the identifier of the first data, and searching a second original directory name of the second data according to the identifier of the second data; and exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data. When the embodiment of the invention exchanges data, the data exchange can be rapidly completed by exchanging the directory name of the data to be exchanged, the read-write operation of the data to be exchanged is avoided, the server resource is occupied, and the data exchange efficiency is improved.

Description

Data exchange method, device, server and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a data exchange method, a data exchange device, a server and a storage medium.
Background
In a database and data management software, it is a common method to store data of different objects by using data files in different directories, and there is a need to exchange data of different objects in the database.
In a column storage table in a database, for data in different columns, one existing storage method is to store the data in different columns in respective independent data files, and the column data files in the same table are stored in the same directory. For example, there are two columns in the column storage table T in the database: c1 and C2, the DATA of this table may be stored in the directory DATA _ T, the DATA of the two columns being the files DATA _ C1.dta and DATA _ C2.dta under this directory, respectively.
The database has a data exchange operation, such as a partition table exchange partition operation, and needs to exchange sub-table data of the partition table with data of other tables. At present, a data exchange method which is commonly used for data adopting a file storage mode is data replication. However, due to the existence of read-write operations and occupation of server resources, the method for data replication may affect the performance of normal services of the database, such as database read-write file operations, other service operations forced to be queued due to resource occupation, and the like.
Disclosure of Invention
The embodiment of the invention provides a data exchange method, a data exchange device, a server and a storage medium, which can solve the technical problem of low efficiency in the prior art.
In a first aspect, an embodiment of the present invention provides a data exchange method, including:
receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data;
searching a first original directory name of the first data according to the identifier of the first data, and searching a second original directory name of the second data according to the identifier of the second data;
and exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data.
In a second aspect, an embodiment of the present invention further provides a data exchanging apparatus, where the apparatus includes:
the request module is used for receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data;
the directory module is used for searching a first original directory name of the first data according to the identifier of the first data and searching a second original directory name of the second data according to the identifier of the second data;
and the exchange module is used for exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data.
Further, the switching module is specifically configured to:
modifying the first original directory name into a first temporary directory name, modifying the second original directory name into the first original directory name, and taking the first original directory name as a second new directory name;
and modifying the first temporary directory name into a second original directory name, wherein the second original directory name is used as a first new directory name.
Further, the apparatus further includes a temporary file module, where the temporary file module is specifically configured to: prior to said swapping said first original directory name and said second original directory name,
and acquiring an exchange transaction number, the directory information of the first data and the directory information of the second data, and storing the exchange transaction number, the directory information of the first data and the directory information of the second data in a temporary file, wherein the directory information of the first data comprises a directory identifier of the first data and a directory path of the first data, and the directory information of the second data comprises a directory identifier of the second data and a directory path of the second data.
Further, the apparatus further includes a first rollback module, where the first rollback module is specifically configured to: after said swapping of said first original directory name and said second original directory name,
detecting a rollback request;
if the first temporary directory name is found and the second new directory name is lost, modifying the first temporary directory name into the first original directory name according to the rollback request;
if the first temporary directory name is found and the second new directory name is found, modifying the second new directory name into the second original directory name according to the rollback request, and then modifying the first temporary directory name into the first original directory name.
Further, the apparatus further includes a second rollback module, where the second rollback module is specifically configured to: after said swapping of said first original directory name and said second original directory name,
detecting a rollback request;
if the first temporary directory name, the undo transaction number and the exchange transaction number in the temporary file cannot be found, and the directory identification in the rollback log is different from the directory identification of the first data or the directory identification of the second data in the temporary file, modifying the first new directory name into a second temporary directory name, modifying the second new directory name into the first new directory name, and modifying the second temporary directory name into the second new directory name.
Further, the apparatus further includes a third rollback module, where the third rollback module is specifically configured to: after said swapping of said first original directory name and said second original directory name,
detecting a rollback request;
and if the first temporary directory name cannot be found and the first new directory name cannot be found, modifying the second temporary directory name into the second new directory name.
After the directory name and the second original directory name,
further, the apparatus further includes a fourth rollback module, where the fourth rollback module is specifically configured to: after said swapping of said first original directory name and said second original directory name,
detecting a rollback request;
and if the first temporary directory name cannot be found and the first new directory name cannot be found, modifying the second new directory name into the first new directory name, and then modifying the second temporary directory name into the second new directory name.
In a third aspect, an embodiment of the present invention further provides a server, where the server includes:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a data exchange method as described above.
In a fourth aspect, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the data exchange method as described above.
According to the embodiment of the invention, a data exchange request is received, a first original directory name of first data is searched according to an identifier of the first data, a second original directory name of second data is searched according to an identifier of the second data, and the first original directory name and the second original directory name are exchanged to obtain a first new directory name of the first data and a second new directory name of the second data. When the embodiment of the invention exchanges data, the data exchange can be rapidly completed by exchanging the directory name of the data to be exchanged, the read-write operation of the data to be exchanged is avoided, the server resource is occupied, and the data exchange efficiency is improved.
Drawings
Fig. 1 is a flow chart of a data exchange method according to a first embodiment of the present invention;
FIG. 2 is a diagram illustrating a data exchange method according to a first embodiment of the present invention;
FIG. 3 is a flow chart of a data exchange method according to a second embodiment of the present invention;
FIG. 4 is a flow chart of a data exchange method according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of a data exchange device according to a fourth embodiment of the present invention;
fig. 6 is a schematic structural diagram of a server in the fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a data exchange method in a first embodiment of the present invention, where the present embodiment is applicable to a case of implementing data exchange, the method may be executed by a data exchange device, and the device may be implemented in a software and/or hardware manner, for example, the device may be configured in a server.
The data exchange method according to the embodiment of the present invention is generally illustrated by a schematic diagram, and specifically refer to fig. 2. Fig. 2 is a schematic diagram of a data exchange method in the first embodiment of the present invention, where directory names of files corresponding to two pieces of data to be exchanged are a and B on the left side in the diagram, respectively, data exchange is implemented by exchanging directory names of files corresponding to the two pieces of data, and directory names of files corresponding to the two pieces of data after data exchange are B and a on the right side in the diagram, respectively, so that simple and fast data exchange is implemented.
As shown in fig. 1, the method may specifically include:
s110, receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data.
The data exchange is carried out on the data under different catalogues in the database, the data under different catalogues in the database correspond to different objects and also refer to the data of different objects to be exchanged, and the data exchange operation is carried out in the database according to the actual situation.
Specifically, the data exchange device may receive a data exchange request sent by a user, and may also receive a data exchange request sent when performing other operations in the database, and a source of the data exchange request is not limited in this embodiment. Further, the data exchange request includes an identifier of the first data to be exchanged and an identifier of the second data, where the identifiers are used to distinguish the data to be exchanged, and a specific form of the identifiers may be set as needed, and may be represented by a number, for example.
S120, searching a first original directory name of the first data according to the identification of the first data, and searching a second original directory name of the second data according to the identification of the second data.
In this embodiment, the data to be exchanged is stored in the directories corresponding to the different directory names, for example, the first data is stored in the first directory, the second data is stored in the second directory, and the like.
Specifically, after the identifier of the first data and the identifier of the second data are obtained, the directory name of the first data can be found according to the identifier of the first data through a search program or algorithm preset in the data exchange device, and the directory name of the second data is found according to the identifier of the second data.
S130, exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data.
Specifically, exchanging the first original directory name and the second original directory name may include: modifying the first original directory name into a first temporary directory name, modifying the second original directory name into the first original directory name, and taking the first original directory name as a second new directory name; and modifying the first temporary directory name into a second original directory name, wherein the second original directory name is used as a first new directory name.
The first new directory name and the second new directory name are used for distinguishing the directory names before data exchange from those after data exchange, and are not used for renaming the directory name corresponding to the first data and the directory name corresponding to the second data. For example, if a first original directory name of the first data is a and a second original directory name of the second data is B, after data exchange, a first new directory name of the first data is B and a second new directory name of the second data is a, it can be seen that only the directory names of the first data and the second data are exchanged, and no new directory name is generated.
According to the technical scheme of the embodiment, a data exchange request is received, a first original directory name of first data is searched according to an identifier of the first data, a second original directory name of second data is searched according to an identifier of the second data, and the first original directory name and the second original directory name are exchanged to obtain a first new directory name of the first data and a second new directory name of the second data. When data exchange is performed, the directory name of the data to be exchanged is exchanged, so that the data exchange can be completed quickly, read-write operation of the data to be exchanged is avoided, server resources are occupied, and the data exchange efficiency is improved.
Example two
Fig. 3 is a flowchart of a data exchange method according to a second embodiment of the present invention. The present embodiment further optimizes the data exchange method based on the above embodiments. Correspondingly, as shown in fig. 3, the method of the embodiment specifically includes:
s210, receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data.
S220, searching a first original directory name of the first data according to the identification of the first data, and searching a second original directory name of the second data according to the identification of the second data.
S230, acquiring the exchange transaction number, the directory information of the first data and the directory information of the second data, and storing the exchange transaction number, the directory information of the first data and the directory information of the second data in a temporary file.
The exchange transaction number is an Identification (ID) of a corresponding current transaction during data exchange. The directory information includes a directory identifier and a directory path, the directory information of the first data includes the directory identifier of the first data and the directory path of the first data, and the directory information of the second data includes the directory identifier of the second data and the directory path of the second data. For example, the directory identification for the first data may be id1, the directory path may be name1, the directory identification for the second data may be id2, and the directory path may be name 2.
Specifically, directory information of the first data is acquired according to the identifier of the first data, directory information of the second data is acquired according to the identifier of the second data, an exchange transaction number is acquired, and the exchange transaction number, the directory information of the first data and the directory information of the second data are stored in the temporary file. The temporary file is a newly-built file for data exchange, and after the temporary file is built, the temporary file is stored in a directory corresponding to the first data and a directory corresponding to the second data.
The temporary file in this embodiment is used to ensure atomicity of data exchange, and ensure that the data exchange can be restored to a correct state when an exception occurs at any time point during data exchange or when rollback is subsequently required.
S240, exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data.
Specifically, exchanging the first original directory name and the second original directory name may include: modifying the first original directory name into a first temporary directory name, modifying the second original directory name into the first original directory name, and taking the first original directory name as a second new directory name; and modifying the first temporary directory name into a second original directory name, wherein the second original directory name is used as a first new directory name.
Further, exchanging the first original directory name and the second original directory name may include: a rollback log of the data exchange is generated, which may include a log type, an exchange transaction number, directory information of the first data, and directory information of the second data. The rollback log is used for performing rollback operation on the data exchange if any error occurs after the data exchange.
And S250, detecting a rollback request.
Wherein, Rollback (Rollback) refers to an operation of restoring a program or data to a last correct state when the program or data in the database has an error.
Specifically, the data exchange device detects a rollback request sent by a user, or a rollback request sent when subsequent operations of the transaction after data exchange are abnormal, or a rollback request sent when an abnormality occurs in the data exchange process, which may be specifically a rollback request sent when an abnormality occurs in any one of steps S210 to S240, and a source of the specific rollback request is not limited in this embodiment. Further, the specific execution sequence of S250 may be executed after any step of S210-S240, not only after S240, but also when any step of S210-S240 is abnormal.
S260, if the first temporary directory name is found and the second new directory name is lost, modifying the first temporary directory name into the first original directory name according to the rollback request.
Specifically, if the first temporary directory name is found, it is indicated that an exception occurs in the data exchange process, and data exchange is not completed, and at this time, if the second new directory name (i.e., the first original directory name) after data exchange does not exist, it is indicated that only the first original directory name is modified into the first temporary directory name in the data exchange process, and the modification of the second original directory name into the first original directory name (i.e., the second new directory name) is not performed. At this time, the first temporary directory name is directly modified into the first original directory name according to the rollback request, and thus rollback is realized.
S270, if the first temporary directory name is found and the second new directory name is found, the second new directory name is modified into the second original directory name according to the rollback request, and then the first temporary directory name is modified into the first original directory name.
Specifically, if the first temporary directory name is found and the second new directory name is found, after the first original directory name is modified into the first temporary directory name in the data exchange process, the modification of the second original directory name into the first original directory name (i.e., the second new directory name) is also performed. At this time, after the second new directory name is modified into the second original directory name according to the rollback request, the first temporary directory name is modified into the first original directory name, and rollback is achieved.
Optionally, after S240, S251-S252 (not shown in the figure) may be further included, specifically:
s251, a rollback request is detected.
S252, if the first temporary directory name, the undo transaction number and the exchange transaction number in the temporary file cannot be found, and the directory identifier in the rollback log is different from the directory identifier of the first data or the directory identifier of the second data in the temporary file, modifying the first new directory name into the second temporary directory name, modifying the second new directory name into the first new directory name, and modifying the second temporary directory name into the second new directory name.
The revocation transaction number is an Identification (ID) of a corresponding current transaction when rollback is performed.
If the first temporary directory name cannot be found, the data exchange process is completed, and the first temporary directory name does not exist. At this time, whether the undo transaction number is the same as the exchange transaction number in the temporary file is determined, that is, whether the temporary file is generated by the transaction number corresponding to the undo transaction number and whether the transactions corresponding to the undo transaction number and the exchange transaction number are the same transaction are determined. And judging whether the directory identification of the first data in the rollback log is the same as the directory identification of the first data in the temporary file or whether the directory identification of the second data in the rollback log is the same as the directory identification of the second data in the temporary file.
Specifically, if the first temporary directory name, the undo transaction number and the exchange transaction number in the temporary file cannot be found, and the directory identifier in the rollback log is different from the directory identifier of the first data or the directory identifier of the second data in the temporary file, the rollback operation is executed on the basis of completion of data exchange, the first new directory name is modified into the second temporary directory name, the second new directory name is modified into the first new directory name, and the second temporary directory name is modified into the second new directory name. And if the data exchange is finished, executing rollback operation, wherein the temporary directory name is different from the temporary directory name during the data exchange, and distinguishing so as to process when the subsequent rollback process is abnormal.
If the first temporary directory name cannot be found, the undo transaction number is different from the exchange transaction number in the temporary file, which indicates that the temporary file is not generated by the transaction corresponding to the undo transaction number, and the data exchange in the transaction corresponding to the undo transaction number is not executed, so that the rollback operation is not directly executed. If the directory identifier of the first data in the rollback log is the same as the directory identifier of the first data in the temporary file, or the directory identifier of the second data in the rollback log is the same as the directory identifier of the second data in the temporary file, it indicates that the data exchange is not performed, and the rollback operation is not performed directly.
Optionally, after S240, S261-S262 (not shown in the figure) may be further included, specifically:
s261, a rollback request is detected.
S262, if the first temporary directory name cannot be found and the first new directory name is found, the second temporary directory name is modified to be the second new directory name.
Specifically, if the first temporary directory name cannot be found, it is described that the data exchange process is completed, and the first temporary directory name does not exist. If the first new directory name is found, it indicates that other operations after data exchange in the transaction have been rolled back, and an exception occurs in the rolling back process, and the previous rolling back is not successfully executed. And the previous rollback operation has completed the operation of modifying the first new directory name into the second temporary directory name, and then modifying the second new directory name into the first new directory name, at this time, the previous rollback operation modifies the second temporary directory name into the second new directory name, and the rollback operation is realized.
Optionally, after S240, S271-S272 (not shown in the figure) may be further included, specifically:
s271, detecting a rollback request;
s272, if the first temporary directory name cannot be found and the first new directory name cannot be found, modifying the second new directory name into the first new directory name, and then modifying the second temporary directory name into the second new directory name.
Specifically, if the first temporary directory name cannot be found, it is described that the data exchange process is completed, and the first temporary directory name does not exist. If the first new directory name cannot be found, the previous rollback operation is completed and the first new directory name is modified into the second temporary directory name, and the subsequent rollback operation is not performed. At this time, after the previous rollback operation modifies the second new directory name into the first new directory name, the second temporary directory name is modified into the second new directory name, and the rollback operation is realized.
According to the technical scheme of the embodiment, a data exchange request is received, a first original directory name of first data is searched according to an identifier of the first data, a second original directory name of second data is searched according to an identifier of the second data, and the first original directory name and the second original directory name are exchanged to obtain a first new directory name of the first data and a second new directory name of the second data; and, a rollback request is detected, and a rollback operation is implemented according to the rollback request. When data exchange is carried out, the embodiment can quickly complete data exchange by exchanging the directory name of the data to be exchanged, avoids read-write operation of the data to be exchanged and occupation of server resources, and improves the efficiency of data exchange; in addition, by establishing the temporary file and setting different temporary directory names in the rollback process after the data exchange and the data exchange are successful, the rollback operation of the data exchange under different abnormal conditions can be realized, and the atomicity of the data exchange is further ensured.
EXAMPLE III
Fig. 4 is a flowchart of a data exchange method in the third embodiment of the present invention. The present embodiment may further embody a rollback operation in the data exchange method by an example based on the above-described embodiment. The method specifically comprises the following steps:
s301, start.
Specifically, after detecting the rollback request, the rollback operation is started to be executed.
S302, information in the rollback log is obtained.
And acquiring information of a rollback log stored during data exchange, wherein the rollback log can comprise a log type, an exchange transaction number, directory information of the first data and directory information of the second data.
S303, whether the first temporary directory name exists or not.
Because the first temporary directory name is generated in the data exchange process, whether the first temporary directory name exists is judged, if yes, the abnormal condition occurs in the data exchange process is described, S311 is executed, and if not, the data exchange process is executed completely, S304 is executed.
S304, whether a second temporary directory name exists or not.
In this embodiment, a second temporary directory name is generated in the rollback process after the data exchange is completed, and at this time, it is determined whether the second temporary directory name exists, if so, it indicates that an abnormal condition occurs in the rollback process, S310 is executed, and if not, it indicates that the rollback process has not been performed, so S305 is executed. If the second temporary directory name does not exist, it may be further described that the rollback is already executed, but if the rollback is already executed, the rollback is not performed again in S301.
S305, whether the undo transaction number is the same as the exchange transaction number in the temporary file or not.
And judging whether the withdrawn transaction number is the same as the exchange transaction number in the temporary file, namely judging whether the temporary file is generated by the transaction number corresponding to the withdrawn transaction number and whether the transactions of which the withdrawn transaction number and the exchange transaction number are the same. If the two are the same, S306 is executed, and if the two are different, it indicates that the temporary file is not generated by the transaction corresponding to the undo transaction number, and the data exchange in the transaction corresponding to the undo transaction number is not executed, S314 is executed.
S306, whether the directory identification in the rollback log is the same as the directory identification in the temporary file or not is judged.
And judging whether the directory identification of the first data in the rollback log is the same as the directory identification of the first data in the temporary file or not, or whether the directory identification of the second data in the rollback log is the same as the directory identification of the second data in the temporary file or not. If the same indicates that the data exchange is not performed, S314 is performed, and if not, S307 is performed.
S307, the first new directory name is modified into a second temporary directory name.
S308, the second new directory name is modified into the first new directory name.
S309, the second temporary directory name is modified into a second new directory name.
After the second temporary directory name is modified to the second new directory name, the rollback is completed, and S314 is executed.
S310, whether a first new directory name exists or not.
Specifically, if the second temporary directory name exists, it indicates that an abnormal condition occurs in the rollback process, and if the first new directory name exists, the previous rollback operation has completed the operation of modifying the first new directory name into the second temporary directory name, and then the operation of modifying the second new directory name into the first new directory name, at this time, S309 is executed. If the first new directory name does not exist, it indicates that the previous rollback operation has been completed to modify the first new directory name into the second temporary directory name, and the subsequent rollback operation has not been performed, and S308 is executed.
S311, whether a second new directory name exists.
Specifically, a first temporary directory name exists, which indicates that an abnormal condition occurs in the data exchange process, and at this time, it is determined whether a second new directory name exists, and if so, after the first original directory name is modified into the first temporary directory name in the data exchange process, the modification of the second original directory name into the first original directory name (i.e., the second new directory name) is further performed, and then S312 is performed. If the directory name does not exist, it is stated that only the first original directory name is modified into the first temporary directory name in the data exchange process, and the modification of the second original directory name into the first original directory name (i.e., the second new directory name) has not been performed, then S313 is performed.
And S312, modifying the second new directory name into a second original directory name.
S313, the first temporary directory name is modified into the first original directory name.
After the first temporary directory name is modified to the first original directory name, the rollback is completed, and S314 is executed.
And S314, ending.
According to the technical scheme of the embodiment, after data exchange, a rollback request is detected, and rollback operations under different abnormal conditions can be executed according to the rollback request. When data exchange is carried out, the embodiment can quickly complete data exchange by exchanging the directory name of the data to be exchanged, avoids read-write operation of the data to be exchanged and occupation of server resources, and improves the efficiency of data exchange; in addition, by establishing the temporary file and setting different temporary directory names in the rollback process after the data exchange and the data exchange are successful, the rollback operation of the data exchange under different abnormal conditions can be realized, and the atomicity of the data exchange is further ensured.
Example four
Fig. 5 is a schematic structural diagram of a data exchange device in a fourth embodiment of the present invention, which is applicable to a case of implementing data exchange. The data exchange device provided by the embodiment of the invention can execute the data exchange method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. The device specifically comprises a request module 410, a directory module 420 and an exchange module 430, wherein:
a request module 410, configured to receive a data exchange request, where the data exchange request includes an identifier of first data to be exchanged and an identifier of second data;
the directory module 420 is configured to search for a first original directory name of the first data according to the identifier of the first data, and search for a second original directory name of the second data according to the identifier of the second data;
the exchanging module 430 is configured to exchange the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data.
The embodiment of the invention obtains a first new directory name of the first data and a second new directory name of the second data by receiving a data exchange request, searching a first original directory name of the first data according to the identifier of the first data, searching a second original directory name of the second data according to the identifier of the second data, and exchanging the first original directory name and the second original directory name. When the embodiment of the invention exchanges data, the data exchange can be rapidly completed by exchanging the directory name of the data to be exchanged, the read-write operation of the data to be exchanged is avoided, the server resource is occupied, and the data exchange efficiency is improved.
Further, the switching module 430 is specifically configured to:
modifying the first original directory name into a first temporary directory name, modifying the second original directory name into the first original directory name, and taking the first original directory name as a second new directory name;
and modifying the first temporary directory name into a second original directory name, wherein the second original directory name is used as a first new directory name.
Further, the device further comprises a temporary file module, and the temporary file module is specifically configured to: prior to exchanging the first original directory name and the second original directory name,
the method comprises the steps of obtaining an exchange transaction number, directory information of first data and directory information of second data, storing the exchange transaction number, the directory information of the first data and the directory information of the second data in a temporary file, wherein the directory information of the first data comprises a directory identifier of the first data and a directory path of the first data, and the directory information of the second data comprises a directory identifier of the second data and a directory path of the second data.
Further, the device further comprises a first rollback module, and the first rollback module is specifically configured to: after exchanging the first original directory name and the second original directory name,
detecting a rollback request;
if the first temporary directory name is found and the second new directory name is lost, modifying the first temporary directory name into a first original directory name according to the rollback request;
if the first temporary directory name is found and the second new directory name is found, the first temporary directory name is modified into the first original directory name after the second new directory name is modified into the second original directory name according to the rollback request.
Further, the device further comprises a second rollback module, and the second rollback module is specifically configured to: after exchanging the first original directory name and the second original directory name,
detecting a rollback request;
if the first temporary directory name, the undo transaction number and the exchange transaction number in the temporary file cannot be found, and the directory identifier in the rollback log is different from the directory identifier of the first data or the directory identifier of the second data in the temporary file, the first new directory name is modified into a second temporary directory name, the second new directory name is modified into the first new directory name, and the second temporary directory name is modified into the second new directory name.
Further, the device further includes a third rollback module, where the third rollback module is specifically configured to: after exchanging the first original directory name and the second original directory name,
detecting a rollback request;
if the first temporary directory name cannot be found and the first new directory name is found, the second temporary directory name is modified into the second new directory name.
After the directory name and the second original directory name,
further, the apparatus further includes a fourth rollback module, where the fourth rollback module is specifically configured to: after exchanging the first original directory name and the second original directory name,
detecting a rollback request;
if the first temporary directory name cannot be found and the first new directory name cannot be found, the second new directory name is modified into the first new directory name, and then the second temporary directory name is modified into the second new directory name.
The data exchange device provided by the embodiment of the invention can execute the data exchange method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
Fig. 6 is a schematic structural diagram of a server in the fifth embodiment of the present invention. FIG. 6 illustrates a block diagram of an exemplary server 512 suitable for use in implementing embodiments of the present invention. The server 512 shown in fig. 6 is only an example and should not bring any limitations to the function and scope of the use of the embodiments of the present invention.
As shown in FIG. 6, the server 512 is in the form of a general purpose server. Components of server 512 may include, but are not limited to: one or more processors 516, a storage device 528, and a bus 518 that couples the various system components including the storage device 528 and the processors 516.
Bus 518 represents one or more of any of several types of bus structures, including a memory device bus or memory device controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
The server 512 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by server 512 and includes both volatile and nonvolatile media, removable and non-removable media.
Storage 528 may include computer system readable media in the form of volatile Memory, such as Random Access Memory (RAM) 530 and/or cache Memory 532. The server 512 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 534 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 6, and commonly referred to as a "hard drive"). Although not shown in FIG. 6, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk such as a Compact disk Read-Only Memory (CD-ROM), Digital Video disk Read-Only Memory (DVD-ROM) or other optical media may be provided. In these cases, each drive may be connected to bus 518 through one or more data media interfaces. Storage 528 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 540 having a set (at least one) of program modules 542 may be stored, for example, in storage 528, such program modules 542 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may include an implementation of a network environment. The program modules 542 generally perform the functions and/or methods of the described embodiments of the invention.
The server 512 may also communicate with one or more external devices 514 (e.g., keyboard, pointing terminal, display 524, etc.), with one or more terminals that enable a user to interact with the server 512, and/or with any terminals (e.g., network card, modem, etc.) that enable the server 512 to communicate with one or more other computing terminals. Such communication may occur via input/output (I/O) interfaces 522. Further, server 512 may communicate with one or more networks (e.g., a Local Area Network (LAN), Wide Area Network (WAN), and/or a public Network such as the internet) via Network adapter 520. As shown in FIG. 6, the network adapter 520 communicates with the other modules of the server 512 via the bus 518. It should be appreciated that although not shown, other hardware and/or software modules may be used in conjunction with the server 512, including but not limited to: microcode, end drives, Redundant processors, external disk drive Arrays, RAID (Redundant Arrays of Independent Disks) systems, tape drives, and data backup storage systems, among others.
The processor 516 executes various functional applications and data processing by running programs stored in the storage device 528, for example, implementing a data exchange method provided by the embodiment of the present invention, the method includes:
receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data;
searching a first original directory name of the first data according to the identifier of the first data, and searching a second original directory name of the second data according to the identifier of the second data;
and exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data.
EXAMPLE six
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a data exchange method provided in an embodiment of the present invention, where the method includes:
receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data;
searching a first original directory name of the first data according to the identifier of the first data, and searching a second original directory name of the second data according to the identifier of the second data;
and exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or terminal. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A method of data exchange, comprising:
receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data;
searching a first original directory name of the first data according to the identifier of the first data, and searching a second original directory name of the second data according to the identifier of the second data;
exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data;
the data exchange method further comprises the following steps:
during and after the data exchange is completed, detecting a rollback request triggered by a user or generated by a data exchange device when an anomaly is detected, and performing a rollback operation based on the rollback request to restore the first data and the second data to a state before the data exchange.
2. The method of claim 1, wherein exchanging the first original directory name and the second original directory name comprises:
modifying the first original directory name into a first temporary directory name, modifying the second original directory name into the first original directory name, and taking the first original directory name as a second new directory name;
and modifying the first temporary directory name into a second original directory name, wherein the second original directory name is used as a first new directory name.
3. The method of claim 2, wherein prior to said exchanging said first original directory name and said second original directory name, further comprising:
and acquiring an exchange transaction number, the directory information of the first data and the directory information of the second data, and storing the exchange transaction number, the directory information of the first data and the directory information of the second data in a temporary file, wherein the directory information of the first data comprises a directory identifier of the first data and a directory path of the first data, and the directory information of the second data comprises a directory identifier of the second data and a directory path of the second data.
4. The method of claim 3, wherein after the exchanging the first original directory name and the second original directory name, further comprising:
detecting the rollback request;
if the first temporary directory name is found and the second new directory name is lost, modifying the first temporary directory name into the first original directory name according to the rollback request;
if the first temporary directory name is found and the second new directory name is found, modifying the second new directory name into the second original directory name according to the rollback request, and then modifying the first temporary directory name into the first original directory name.
5. The method of claim 3, wherein after the exchanging the first original directory name and the second original directory name, further comprising:
detecting the rollback request;
if the first temporary directory name, the undo transaction number and the exchange transaction number in the temporary file cannot be found, and the directory identification in the rollback log is different from the directory identification of the first data or the directory identification of the second data in the temporary file, modifying the first new directory name into a second temporary directory name, modifying the second new directory name into the first new directory name, and modifying the second temporary directory name into the second new directory name.
6. The method of claim 3, wherein after the exchanging the first original directory name and the second original directory name, further comprising:
detecting the rollback request;
and if the first temporary directory name cannot be found and the first new directory name cannot be found, modifying the second temporary directory name into the second new directory name.
7. The method of claim 3, wherein after the exchanging the first original directory name and the second original directory name, further comprising:
detecting the rollback request;
and if the first temporary directory name cannot be found and the first new directory name cannot be found, modifying the second new directory name into the first new directory name, and then modifying the second temporary directory name into the second new directory name.
8. A data exchange device, comprising:
the request module is used for receiving a data exchange request, wherein the data exchange request comprises an identifier of first data to be exchanged and an identifier of second data;
the directory module is used for searching a first original directory name of the first data according to the identifier of the first data and searching a second original directory name of the second data according to the identifier of the second data;
the exchange module is used for exchanging the first original directory name and the second original directory name to obtain a first new directory name of the first data and a second new directory name of the second data;
the apparatus is for:
during and after the data exchange is completed, detecting a rollback request triggered by a user or generated by a data exchange device when an anomaly is detected, and performing a rollback operation based on the rollback request to restore the first data and the second data to a state before the data exchange.
9. A server, characterized in that the server comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a data exchange method as claimed in any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the data exchange method according to any one of claims 1 to 7.
CN201910080274.9A 2019-01-28 2019-01-28 Data exchange method, device, server and storage medium Active CN109740027B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910080274.9A CN109740027B (en) 2019-01-28 2019-01-28 Data exchange method, device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910080274.9A CN109740027B (en) 2019-01-28 2019-01-28 Data exchange method, device, server and storage medium

Publications (2)

Publication Number Publication Date
CN109740027A CN109740027A (en) 2019-05-10
CN109740027B true CN109740027B (en) 2020-01-10

Family

ID=66366258

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910080274.9A Active CN109740027B (en) 2019-01-28 2019-01-28 Data exchange method, device, server and storage medium

Country Status (1)

Country Link
CN (1) CN109740027B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110888717A (en) * 2019-11-05 2020-03-17 中盈优创资讯科技有限公司 Transaction control method and device for directory operation of HDFS (Hadoop distributed File System)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105787065A (en) * 2016-03-01 2016-07-20 浪潮通用软件有限公司 Implementation method for integrated exchange platform
CN107403012A (en) * 2017-08-01 2017-11-28 山东浪潮通软信息科技有限公司 A kind of method for interchanging data and device
CN108829767A (en) * 2018-05-29 2018-11-16 吉贝克信息技术(北京)有限公司 Data exchange system and its method, apparatus and computer storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080027899A1 (en) * 2005-08-09 2008-01-31 Quark, Inc. Systems and Methods for Integrating from Data Sources to Data Target Locations
US8281053B2 (en) * 2008-07-21 2012-10-02 International Business Machines Corporation Performing an all-to-all data exchange on a plurality of data buffers by performing swap operations
CN104486448B (en) * 2014-12-29 2018-09-11 成都极驰科技有限公司 A kind of data processing method and device
CN104702441B (en) * 2015-03-17 2018-01-12 四川天邑康和通信股份有限公司 The method for interchanging data of network intelligent management terminal and the network facilities
CN107248984B (en) * 2017-06-06 2020-06-05 北京京东尚科信息技术有限公司 Data exchange system, method and device
CN107734034B (en) * 2017-10-17 2021-01-26 泰康保险集团股份有限公司 Server docking system, method, computer-readable storage medium and front-end processor

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105787065A (en) * 2016-03-01 2016-07-20 浪潮通用软件有限公司 Implementation method for integrated exchange platform
CN107403012A (en) * 2017-08-01 2017-11-28 山东浪潮通软信息科技有限公司 A kind of method for interchanging data and device
CN108829767A (en) * 2018-05-29 2018-11-16 吉贝克信息技术(北京)有限公司 Data exchange system and its method, apparatus and computer storage medium

Also Published As

Publication number Publication date
CN109740027A (en) 2019-05-10

Similar Documents

Publication Publication Date Title
CN110442560B (en) Log replay method, device, server and storage medium
US9778998B2 (en) Data restoration method and system
CN109597640B (en) Account management method, device, equipment and medium for application program
CN110196759B (en) Distributed transaction processing method and device, storage medium and electronic device
EP3786802A1 (en) Method and device for failover in hbase system
US20200034042A1 (en) Method for writing data in a distributed storage system
CN111880967A (en) File backup method, device, medium and electronic equipment in cloud scene
CN111324441A (en) Operating environment switching method and device, computer equipment and storage medium
CN110413413A (en) A kind of method for writing data, device, equipment and storage medium
CN110688111A (en) Configuration method, device, server and storage medium of business process
CN111061740A (en) Data synchronization method, equipment and storage medium
CN111818145A (en) File transmission method, device, system, equipment and storage medium
US11157456B2 (en) Replication of data in a distributed file system using an arbiter
CN109033456B (en) Condition query method and device, electronic equipment and storage medium
CN112835885A (en) Processing method, device and system for distributed table storage
CN109740027B (en) Data exchange method, device, server and storage medium
CN108228611B (en) Document information copying method and device
CN110688305B (en) Test environment synchronization method, device, medium and electronic equipment
CN110941658A (en) Data export method, device, server and storage medium
CN114077518A (en) Data snapshot method, device, equipment and storage medium
CN109542860B (en) Service data management method based on HDFS and terminal equipment
CN111240810B (en) Transaction management method, device, equipment and storage medium
CN112866979B (en) User information association method, device, equipment and medium based on 5G service interface
CN109918231B (en) Data reforming abnormity repairing method, device, equipment and storage medium
CN114090514A (en) Log retrieval method and device for distributed system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant