You can implement this program in C, or Java, or Python, or whatever you prefer.
We want to replicate a "store". This is normally done so that
We need to execute the write requests in the same order at all the stores otherwise the results could be different.
We will assume that the store is a single file store.txt, say, containing initially the characters 0123456789 repeated 100 times. This file is replicated at 3 sites. Clients perform at random write operations consisting of choosing at random a value x equal to 0,1,..,9 and then writing starting at position x*100 the character x repeated 100 times.
Each copy of the file is managed by a process called Agent. One of these agents is designated as a Primary [and we assume clients and other agents know which it is].
A write operation goes as follows:
A client process executes a loop
loop
generate a write request at random
print value of x [0,1,..,9]
execute the write
display the result (success/failure)
delay
forever
A few client processes should run at the same time.
An agent with very small probability (say ~1%) will print a termination message and terminate without completing a write request. As you can imagine, agents start as being 3, then as they terminate, they become fewer, but the program should still work. The clients should contact only the agents that are active. The program terminates when all agents terminate, at that time all stores should have the same content.
In a more realistic program we would worry about the primary failing and what to do when agents fail.
Network communications are in TCP. Choose ports and timeouts as you think best.
Submit your homework to the TA including a good README file explaining your program..