Summary of the invention
For solving the problems of the technologies described above, the embodiment of the present application provides a kind of method and system of canceling node data relationship in graphic database online transaction, can effectively cancel the node data relation that needs are cancelled in transaction process in graphic data base.
Technical scheme is as follows:
A method for canceling node data relationship in graphic database online transaction, comprising:
Receive the affairs cancellation operational order that client sends, described operational order comprises: affairs numbering and node data relation to be cancelled;
The affairs corresponding with it are searched according to described affairs numbering;
Effective when described affairs and service data in described affairs is not locked by other affairs time, open issued transaction mark, node data relation cancelled to treating in described affairs and cancels.
Above-mentioned method, preferably, also comprises: when described affairs are invalid, terminates to operate the cancellation of described transaction nodes data relationship.
Above-mentioned method, preferably, also comprise: when the service data in described affairs is locked by other affairs, the cancellation of described transaction nodes data relationship operation is in waiting status, and judge that whether described affairs are overtime, when described affairs time-out, terminate to operate the cancellation of described transaction nodes data relationship, otherwise, whether effectively rejudge described affairs.
Above-mentioned method, preferably, described affairs are waited that cancelling the process that node data relation cancels is specially:
Judge whether the relation record of described node data relation exists, when described relation record does not exist, upgrade the timestamp of affairs;
Otherwise, judge whether described relation record is dirty data; When described relation record is dirty data, deletes described relation record and upgrade the timestamp of affairs;
When described relation record is not dirty data, relation record described in tag delete also upgrades the timestamp of affairs.
Above-mentioned method, preferably, also comprises: when a transaction commits, for the processing procedure of the node data relation of described cancellation;
Be specially:
Receive the affairs numbering that client sends;
Search the affairs corresponding to described affairs numbering;
When described affairs are effective, mark the submit state of described affairs;
Remove the locking of the relation record of described affairs;
Delete the relation record of described affairs, complete the submission of affairs.
Above-mentioned method, preferably, also comprises: when transaction rollback, for the processing procedure of the node data relation of described cancellation;
Be specially:
Receive the affairs numbering that client sends;
Search the affairs corresponding to described affairs numbering;
When described affairs are effective, mark the rollback state of described affairs;
Remove the locking of the relation record of described affairs;
Delete described transaction journal, complete the submission of affairs.
A system for canceling node data relationship in graphic database online transaction, comprising:
Receiving element, the affairs sent for receiving client cancel operational order, and described operational order comprises: affairs numbering and node data relation to be cancelled;
Search unit, for the affairs numbering received according to described receiving element, search and number corresponding affairs with described affairs;
Cancel unit, for when described in search affairs that unit searches effective and service data in described affairs lock by other affairs time, open issued transaction and mark, described affairs are treated that cancellation node data relation is cancelled.
Above-mentioned system, preferably, described cancellation unit comprises:
First judgment sub-unit and the second judgment sub-unit;
Whether described first judgment sub-unit lost efficacy for the affairs of searching unit described in judging and searching;
Whether described second judgment sub-unit is locked by other affairs for the service data in the affairs of searching unit described in judging and searching.
Above-mentioned system, preferably, also comprises: the first processing unit;
Described first processing unit is used for when a transaction commits, processes the data relationship of the node of described cancellation.
Above-mentioned system, preferably, also comprises: the second processing unit;
Described second processing unit is used for when transaction rollback, processes the data relationship of the node of described cancellation.
The technical scheme provided from above the embodiment of the present application, the method and system of canceling node data relationship in graphic database online transaction provided by the invention, after the affairs receiving client transmission cancel operational order, respective transaction is searched according to described operational order, when the service data of described affairs effectively and in affairs is not locked by other affairs, according to the operational order of client, node data relation is cancelled to treating in described affairs and cancels.The method and system of cancellation node data relation provided by the invention, under the prerequisite that and service data in affairs effective in affairs is not locked by other affairs, can cancel and other operation accordingly the cancellation node data relation for the treatment of in each stage in transaction operation process, filled up in prior art, temporarily not relevant effective technology is to the vacancy of canceling node data relationship in graphic database online transaction.
Embodiment
The application's scheme is understood better in order to make those skilled in the art person.Below in conjunction with the accompanying drawing in the embodiment of the present application, be clearly and completely described the technical scheme in the embodiment of the present application, obviously, described embodiment is only some embodiments of the present application, instead of whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not making the every other embodiment obtained under creative work prerequisite, all should belong to the scope of the application's protection.
The method flow diagram that the graphic database online transaction that the embodiment of the present application provides recovers, comprising:
Step S101: receive the affairs cancellation operational order that client sends, described operational order comprises: affairs numbering and node data relation to be cancelled;
Step S102: search the affairs corresponding with it according to described affairs numbering;
Step S103: effective when described affairs and service data in described affairs is not locked by other affairs time, open issued transaction mark, node data relation cancelled to treating in described affairs and cancels.
In order to being described said method clearly, the embodiment of the present application provides the structural drawing of online transaction Gradation processing as shown in Figure 2, and the Transaction Processing that the embodiment of the present application provides is divided into three layers from top to bottom:
The superiors are the API being exposed to external call program;
Middle layer is the affair logic key-course, synchronization zone and asynchronous district is divided into by class of operation, synchronization zone means can only have an operation to carry out at one time, and other operate in enter between synchronization zone and all process waiting status, and this mechanism utilizes the thread synchronization lockout feature of Java language to realize.The operation in asynchronous district is then unrestricted, all can carry out at any time;
Orlop is that the DataSet storing data operates level of abstraction, in DataSet, preserves the status information of online transaction self, and the transaction status attribute information of data.
In graphic data base, the status data of online transaction is stored in name and is called in the DataSet of graphic_db_tx_def, and the data structure of this DataSet is as shown in table 1:
Table 1
In graphic data base, each Node all has a corresponding DataSet of the same name, and the Relation information between data is kept at name and is called in the DataSet of graphic_db_relation_record_def.All default built-in following two row in these DataSet, as shown in table 2:
Table 2
After the basic layer having understood the online transaction in graphic database process that the embodiment of the present application provides, the embodiment of the present application provides an a kind of method detailed process flow diagram of canceling node data relationship in graphic database online transaction as shown in Figure 3, on the basis of Fig. 3, be described in conjunction with the process of a basic example to the cancellation node data relation that the embodiment of the present application provides;
Create a new transactional instance:
When receiving client and creating the API Calls of affairs, treatment step is as follows:
(1) an overall unique transaction ID is generated; The affairs ID of hypotheses creation is: 123abc;
(2) present system time is obtained; Suppose that present system time is: 1291739790803;
(3) be called the record that in the DataSet of graphic_db_tx_def, insertion one is new in name, its record value is as shown in table 3;
Table 3
Fig. 3, in affairs, specific as follows for the processing logic cancelling node data relation:
Step S201: cancellation process starts;
Step S202: client program calls API, affairs numbering is passed to graphic data base with data relationship to be cancelled.The parameter that API imports into is as follows:
Relation_name, specifies the title that will increase node relationships;
Source_rid, the RID of source node data;
Target_rid, the RID of destination node data;
Step S203: the synchronization zone of Transaction Processing; Synchronization zone utilizes the synchronized thread synchronization locking of Java language to realize, and at synchronization, only has an operation to enter synchronization zone;
Step S204: judge that whether affairs to be processed are effective, if described affairs are invalid, perform step S216, call end; Otherwise, perform step S205;
Judgment mechanism is: inquiry graphic_db_tx_def, and retrieve using affairs numbering as filtercondition, if there is following situation, then affairs are invalid:
Record does not find;
In record, the value of is_commit is 1, illustrates that affairs are submitted to;
In record, the value of is_rollback is 1, and affairs rollback is described;
In record, the value of is_timeout is 1, illustrates that affairs are expired;
If affairs are invalid, this calls end, and returns error message;
Step S205: judged whether that data are locked by other affairs; If described affairs are locked, perform step S207; Otherwise, perform step S206;
Call according to CLIENT PROGRAM source_rid and the target_rid parameter that API imports into, inquire about corresponding DataSet, obtain source node data record and destination node data record respectively, these two data are checked; If the value having any record row _ dirty is-1, and the value of row _ tx_no is neither for sky is also not equal to Current transaction numbering; Then mean that these data are locked by other affairs;
Step S206: open issued transaction mark, then perform step S209;
Inquiry graphic_db_tx_def, assuming that attribute affairs are numbered 123abc, is set to 1 by the value of this record processing row, as shown in table 4:
Table 4
Step S207: wait for 10 milliseconds; The thread dormancy of call operation logic 10 milliseconds;
Step S208: whether overtimely judge whether, if affairs are overtime, then perform step S216, call end, otherwise return step S203;
Inquiry graphic_db_tx_def, follows the record obtaining Current transaction according to affairs numbering.The value of transaction journal start_time row is deducted, if value is greater than 30000 (30 seconds) with the time of current system.Then show that affairs are overtime, exit actuating logic.Otherwise again enter synchronization zone;
Step S209: judge whether relation record exists, if existed, performs step S210; Otherwise, perform step S213;
Inquiry graphic_db_relation_record_def, the value of filtering row source_record equals the value of API parameter s ource_rid and the value of target_record equals the value of API parametric t arget_rid; If the above-mentioned condition of Data Matching, then illustrate that relation record exists;
Step S210: judge whether described relation record is dirty data; If so, step S211 is performed; Otherwise, perform step S212;
Value according to row _ dirty judges, if value is 1, is then dirty data;
Step S211: delete relation record; Perform step S213;
This record is deleted from DataSet;
Step S212: tag delete relation record; The value of this record _ tx_no row is set to Current transaction numbering;
Step S213: upgrade transaction time stamp;
Up-to-date system time is updated in the start_time row of affiliated transaction journal.That supposes Current transaction is numbered 123abc, and current system time is 1291739798888, then data are as shown in table 5:
Table 5
Step S214: close issued transaction mark; Inquiry graphic_db_tx_def, assuming that attribute affairs are numbered 123abc, is set to-1 by the value of this record processing row, as shown in table 6:
Table 6
Step S215: exit synchronization zone;
Jump out the synchronized method of thread locked;
Step S216: invoked procedure terminates.
On the basis of the cancellation node data relation described in Fig. 3, when a transaction commits, for the dealing with relationship of node of cancelling, its treatment scheme as shown in Figure 4:
Step S301: processing procedure starts;
Step S302: CLIENT PROGRAM calls API, passes to graphic data base by affairs numbering;
Step S303: judge that whether affairs are effective, if effectively, perform step S304; Otherwise, perform step S307;
The mechanism judged is, inquiry graphic_db_tx_def, and retrieve using affairs numbering as filtercondition, if there is following situation, then affairs are invalid:
Record does not find;
In record, the value of is_commit is 1, illustrates that affairs are submitted to;
In record, the value of is_rollback is 1, and affairs rollback is described;
In record, the value of is_timeout is 1, illustrates that affairs are out of date;
If affairs are invalid, then this calls end, and returns error message;
Step S304: mark affairs submit state;
Inquiry graphic_db_tx_def, assuming that affiliated affairs are numbered 123abc, is set to 1 by the value of this record is_commit row, as shown in table 7:
Table 7
Step S305: the relation record of deleting locking;
Inquiry graphic_db_relation_record_def, the value of searching all _ tx_no equals Current transaction numbering and the value of _ dirty is the data of-1, these data is deleted;
Step S306: delete transaction journal;
This submitted to the record of affairs to be called the DataSet of graphic_db_tx_def from name to delete, complete the submit operation of affairs;
Step S307: the affairs terminated in submission process are called.
On the basis of the cancellation node data relation described in Fig. 3, when transaction rollback, for the dealing with relationship of node of cancelling, its treatment scheme as shown in Figure 5:
Step S401: processing procedure starts;
Step S402: CLIENT PROGRAM calls API, passes to graphic data base by affairs numbering;
Step S403: judge that whether affairs are effective, when affairs are effective, perform step S404; Otherwise, perform step S407;
The mechanism judged is, inquiry graphic_db_tx_def, and retrieve using affairs numbering as filtercondition, if there is following situation, then affairs are invalid:
Record does not find;
In record, the value of is_commit is 1, illustrates that affairs are submitted to;
In record, the value of is_rollback is 1, and affairs rollback is described;
In record, the value of is_timeout is 1, illustrates that affairs are out of date;
If affairs are invalid, then this calls end, and returns error message;
Step S404: mark transaction rollback state;
Inquiry graphic_db_tx_def, assuming that affiliated affairs are numbered 123abc, is set to 1 by the value of this record is_rollback row, as shown in table 8:
Table 8
Step S405: remove relation record locking;
Inquiry graphic_db_relation_record_def, the value obtaining all _ tx_no equals Current transaction numbering and the value of _ dirty is the data of-1, by these data _ value of tx_no row is set to null;
Step S406: delete transaction journal;
The data record of these rollback affairs is called the DataSet of graphic_db_tx_def from name and deletes, complete the rolling back action of affairs;
Step S407: the affairs terminated in rollback process are called.
More than be discussed as the control method cancelling node data relation in the online transaction in graphic database that the embodiment of the present application provides, affairs submit to and rollback time to the processing logic cancelling node data relation.
Aforesaid embodiment of the method, in order to simple description, therefore is all expressed as a series of combination of actions by it, but those skilled in the art should know, the present invention is not by the restriction of described sequence of movement, because according to the present invention, some step can adopt other orders or carry out simultaneously.Secondly, those skilled in the art also should know, the embodiment described in instructions all belongs to preferred embodiment, and involved action and module might not be that the present invention is necessary.
For above embodiment of the method, the embodiment of the present application additionally provides a kind of system of canceling node data relationship in graphic database online transaction, and its structural representation as shown in Figure 6, comprising:
Receiving element 501, the affairs sent for receiving client cancel operational order, and described operational order comprises: affairs numbering and node data relation to be cancelled;
Search unit 502, for the affairs numbering received according to described receiving element 501, search and number corresponding affairs with described affairs;
Cancel unit 503, for when described in search affairs that unit 502 searches effective and service data in described affairs lock by other affairs time, open issued transaction and mark, described affairs are treated that cancellation node data relation is cancelled.
On the basis of Fig. 6, the embodiment of the present application provides a detailed construction schematic diagram of the system of canceling node data relationship in graphic database online transaction, as shown in Figure 7:
Cancel unit 503 to comprise:
First judgment sub-unit 504 and the second judgment sub-unit 505;
Whether the first judgment sub-unit 504 lost efficacy for the affairs of searching unit described in judging and searching;
Whether the second judgment sub-unit 505 is locked by other affairs for the service data in the affairs of searching unit described in judging and searching;
It should be noted that, the arbitration functions of above first judgment sub-unit 504 and the second judgment sub-unit 505 is only its main arbitration functions realized, in online transaction, cancel other deterministic process of node data relation, also performed by the first judgment sub-unit 504 or the second judgment sub-unit 505.
As can be seen from figures 8 and 9, the system of canceling node data relationship in graphic database online transaction that the embodiment of the present application provides also comprises the first processing unit 506 and the second processing unit 507 respectively; .
First processing unit 506, for when a transaction commits, processes the data relationship of the node of described cancellation.
Second processing unit 507, for when transaction rollback, processes the data relationship of the node of described cancellation.
For system embodiment, because it is substantially corresponding to embodiment of the method, so description is fairly simple, relevant part illustrates see the part of embodiment of the method.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, between each embodiment identical similar part mutually see, what each embodiment stressed is the difference with other embodiments.The above is only the embodiment of the application; it should be pointed out that for those skilled in the art, under the prerequisite not departing from the application's principle; can also make some improvements and modifications, these improvements and modifications also should be considered as the protection domain of the application.