The requirement document for the entire system is described in English. A Simple 2-Phase Commit System The company ABC provides its customers wire transfer service. for example, it can withdraw $1000 from John's account in Bank of China and deposit the money to John's another account in China Construction Bank. also, it shocould report this transaction to China Banking Regulatory Commission (CBRC) for auditing purpose. the following dimo-strates the system architecture.This is a typical example of distributed transaction. 1. There is no direct communication among Bank of China (BoC), China Construction Bank (CCB), and CBRC's application server. They Only interact with ABC's transaction manager. 2. A wire transfer like this is a transaction (so ACID). All operations of the transaction (BoC substracts $1000 from John's account, CCB Adds $1000 to John's account, and CBRC records this transaction) must be all-done or none-done. Please write 5 small programs: 1. A client program that can talk to ABC Transaction Manager to require a wire transfer. This is a command line program (e.g. cli john 1000 boc ccb 127.0.0.1 8888 means sending a wire transfer request to ABC transaction manager that runs on 127.0.0.1 and listens on The port 8888. The request requires a wire transfer of $1000 from John's bank account to John's CCB account) 2. ABC transaction manager-it waits for requests from the client, initiates the distributed transaction among Boc, CCB, and CBRC, then Send the client the wire transfer result (succeed or fail) 3. BoC Application Server-it uses a MySQL db to store account information, and waits for requests from ABC's transaction manager. 4. CCB Application Server-same as BoC Application Server (you can combine 3 and 4 as one program) 5. CBRC Application Server-it uses a MySQL db to store all transactions, and waits for requests from ABC's transaction manager. Your system shoshould be able to handle all kinds of failures that can be handled by the classical 2 PC algorithm. After receiving the requirements of this project, first understand the requirements, analyze the 2 PC principle, and then design the entire system. Because the system is a similar Simulated Project and completed in a week's spare time, the author has made the following basic objectives: vGlob Description:This is a demo system of wire transfer between banks, the system mainly focus on the 2 phase communication. vFeature1. user interface is simply and easy to use. the company use web server to receive the concurrent requests from users, Even we provide a command client (line) tools for user, Actually, if provide a simple web page, user can use browser to access our server. 2. extendibility: All the data's format between the servers is json format, the communicate protocol is HTTP. this is a simply and frequently-used data format and protocol, it is self-reading and easy to add new function. 3. high concurrency: both the company and the bank servers use one thread to hold all the concurrent requests, but the company server use multi-threads to support concurrent access to the banks server, the bank servers use multi-connection to support concurrent execution of mul-SQL request. 4. support crashed recovery: both the company and bank server record all phases logs in disk to support crashed recovery. 5. reliability: fully support 2 pc. Therefore, the main design goal is high concurrency processing and 2 PC Fault Tolerance protocol design. The following figure shows the overall system deployment.The company Transaction WEB Server of the entire system targets all users, achieves high concurrency, holds user connections, and isolates the back-end data system. In this part, it simply uses backup to implement HA. The company WEB Server maintains the entire 2 PC protocol. The three backend database systems have a high-concurrency server. Although these servers are not directly oriented to users, the concurrency is small because they may be oriented to more than one Company server, in addition, each user connection is processed asynchronously. The concurrency is not small. The backend database is a mysql database. To implement atomic data operations, the row lock method is used. The following figure shows the process architecture of the entire system. 1. Concurrent requests from the client. Solution: Use a WEB server to Hold all connections, construct all requests into a queue, use a multi-threaded concurrent request database, and return all replies to the reply queue. The number of working threads should not be too large to prevent the backend database server from being too busy and hanging up. 2. after receiving a request, the threads in each thread pool perform a 2 PC process with the backend. Each stage sends a blocking request to the backend and uses the poll method to hold the three connections. If the connection times out, timeout. |