Distributed Database System-Implementation of business travel booking system (10)

Source: Internet
Author: User
Transaction Storage

With the unified specification and encoding of transactions, you need to consider how to store a transaction in the next step. First, an operation has its unique encoding, which stores the ID encoding value through the string type. Second, you need to store the parameter list. Because each operation requires different parameters, using list <string> is the preferred solution.

Code implementation:

/// <Summary> /// list of all method numbers and parameters of a method during an operation // </Summary> [serializable ()] public class transactionentity {public transactionentity () {transactionid = new list <string> (); transactionparam = new list <object []> (); success = new list <bool> () ;}/// <summary> /// clear the internal information /// </Summary> Public void clear () {transactionid. clear (); transactionparam. clear (); success. clear () ;}// the number of each method, which is equivalent to the key private list <string> m_transactionid; public list <string> transactionid {Get; set;} In hashtable ;} // The parameter list corresponding to the Method number, which is equivalent to the value private list <object []> m_transactionparam; public list <object []> transactionparam {Get; set;} In hashtable ;} // whether the corresponding method is successfully executed private list <Boolean> m_success; public list <Boolean> success {Get; Set ;}}

Structure entity class of a transaction

 

Structure of a transaction entity

 

A transaction contains many atomic operations. Each atomic operation corresponds to its own parameter list. In addition, each atomic operation is followed by a successful representation. After a transaction is executed, the program automatically checks whether each operation is successful. If not, the entire operation will be rolled back and the transaction is completed.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.