CIS4307 - Homeworks 4: Transactionality

Given: November 10, 2009
Due Date 1: November 23, by 10pm - Detailed Design Document (10 points)
Due Date: December 9, 2009, by 10pm - Completed Project (20 points)

This assignment can be done in groups of 2. The names of both participans must be on all documents. Both will receive the same grade for the design (from 0 to 10 points) and for the program (from 0 to 20 points). Send your team's composition to the instructor by November 12 at 10pm.

We want to develop a distributed program where operations are transactional. We will simplify all sort of issues so that we can focus on transactionality. You can write the program in C, or Java, or Python.

The transactions will involve trivial operations. You should try, within the available time, to come up with reasonably general solutions.

We will assume that there are 10 accounts, numbered from 0 to 9, 5 on machine A, 5 on machine B. Their initial balance is 1000.0. You can keep each balance stored in its own separate file, balance0, .., balance4 at machine A, balance 5, .., balance 9 at machine B. You will decide if to keep the balances stored as binary or text.
Clients in a loop will execute the code

    loop
	Select at random accounts j and k, j != k;
	Select at random an amount x, 0 < x <= 300;
	Transfer atomically x dollars from the j to the k account;
	Sleep a random time;
    until terminated by a signal;
Of course if the amount x exceeds the balance at j, the transaction will be aborted.
You should have at least two clients running at the same time. Also, it is possible that two transactions submitted by the same client are active at the same time.
At machine A a server waits for requests from the clients and carries them out, possibly in collaboration with a server at machine B.
I recommend that you use the UDP protocol, recommend, not order.

Transfers are transactions and must satisfy the ACID properties: Atomicity, Consistency, Isolation, and Persistence. Each transaction must have a unique identifier. Logs must be maintained at A and at B so that we can later see which transactions were initiated and carried out.

Systems A and B may crash at any moment. You may simulate that by having an exit call executed at random moments or, if you have your own computers, by unplugging them. When the crashed systems are restarted the system should recover as if nothing had happened.

Note that you will have to worry about:

You can assume that servers will be restarted within a reasonable time. Also, clients submit their request for a transaction, wait for an acknowledgement in the form of a transaction id + the request [if the server decides that the operation cannot be done it will close the connection without sending any response], and then close the connection (i.e. they do not wait for completion or care about results).

If you would like to modify these instructions, discuss your suggestions with the instructor and ask for approval.

Submit the homework at the specified dates to the blackboard dropbox.