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

Source: Internet
Author: User
Atomic operation and Specification

The idea of this design is: the client only needs to send a small amount of data, that is, the operation set. The parameters of each operation are sent to the station server, and the station server quickly parses the requests sent by the server, perform each operation according to certain specifications. After each operation is successful, return it to the client.

The process passed during transaction execution

 

In this design, there are a total of five data tables with a total of 23 related data operations. These 23 data operations have fixed parameters and return values. We call these 23 Operations atomic operations. each transaction is composed of several of these 23 operations. In this way, we compile the numbers for these 23 Operations. Each number corresponds to an operation. When assembling the transaction, the client only needs to know which number method to perform the work, what are the parameters to be passed, and how can I receive the returned results.

During programming, we need to re-write every method in globalservice, so that the customer does not need to connect to the sub-server, as long as the number is known, and the user is thrown to globalservice, it will search for and execute for you, and finally return the result.

/// <Summary> /// No.: 2 /// search for the number of free rooms in a hotel in a certain place. /// table: hotel // </Summary> /// <Param name = "locationstring"> place name </param> /// <Param name = "remoteservice"> interface implementation class </ param> /// <returns> returned result </returns> private int search1_avail (string locationstring, ihotelremoteservice extends remoteservice) {return operation remoteservice. searchincluavail (locationstring );}

The method numbered 2 is rewritten in globalservice.

 

/// <Summary> /// No.: 8 /// return information of all customers /// table: customer // </Summary> /// <Param name = "customerremoteservice"> interface implementation class </param> /// <returns> </returns> private list <customer> retallcustomer (icustomerremoteservice customerremoteservice) {return customerremoteservice. retallcustomer ();}

For a method numbered 8, the interface implementation class must be passed. For each method, the interface implementation class must be passed.

 

/// <Summary> /// No.: 22 // verify the user // table: customer // </Summary> /// <Param name = "custname"> User Name </param> /// <Param name = "customerremoteservice"> interface implementation class </ param> // <returns> </returns> private Boolean validate (string custname, icustomerremoteservice customerremoteservice) {return customerremoteservice. validate (custname );}

The 22nd method is used to verify the customer's information.

 

With such a unified specification, you only need to pass some simple parameters to perform operations on the server. When performing each operation, we need to write the parameters sent from each user as they can be executed by the remote sub-server. In this way, A special process is required to add user parameters to the program.

/// <Summary> /// execute the corresponding method according to the method number, and return the required data /// </Summary> /// <Param name = "idstring"> execution method id </param> /// <Param name =" objparam "> parameter list </param> // <returns> result </returns> private object getdatabyid (string idstring, object [] objparam) {Switch (idstring) {Case "1": Return searchcaravail (objparam [0]. tostring (), (icarremoteservice) objparam [1]); Case "3": Return insertcar (objparam [0]. tostring (), (int32) objparam [1], (int32) objparam [2], (icarremoteservice) objparam [3]); Case "2 ": return search1_avail (objparam [0]. tostring (), (imo-remoteservice) objparam [1]); Case "4": Return inserthotel (objparam [0]. tostring (), (int32) objparam [1], (int32) objparam [2], (imo-remoteservice) objparam [3]); Case "5 ": return deletecar (objparam [0]. tostring (), (icarremoteservice) objparam [1]); Case "6": Return retallcar (icarremoteservice) objparam [0]);

Search for functions by uniform numbers and add them to them. Wait for a reply.

 

 

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.