CS 441 - Fall 2004

MP 1 - Socket Connections to a Simple Database Server

Due: Tuesday, September 21, Thursday, September 23, 2004 by 11:59 pm

For this assignment, you are to create a client/server program pair that will communicate via sockets. The server will maintain a simple database that is to allow multiple clients to access it simultaneously. When a client wishes to access the database, it must first establish a connection with the server. The server must use different threads to listen for connection requests and to communicate with the clients.

The server is is maintain a read lock and write lock for each record in the database. It is the server's responsibility to properly use the locks. A client will make a read or write request to the server, but the server will determine if the request can be honored. If the request cannot be honored, the server is to immediately return a message to the client stating the request could not be completed. The requests are NOT to be queued and then completed later when the locks become available. The database is to use both read locks and write locks to determine if a client can access a record in the database. When a record has a read lock, other processes can "share" the read lock. Thus multiple processes can read simultaneously. When a record has a write lock, no other process can use the record.

To use the database, the client will send a command across the client socket. The proper thread of the server will retrieve this command and attempt to perform the desired action. If the action is successful, the server's thread will send either the resulting information across the client socket or a confirmation that the command was successfully performed to the client. If the action is unsuccessful, the server's thread will send a message stating the action was unable to be performed. The reasons for the unsuccessful action is because of conflicting locks set on the desired record(s). Your program is not to block the process, but simply to report the unsuccessful action.

The database is to have at least 5 records numbered from 1 to 5 (you may create more records if you wish, such as a sixth record with number 0). These records should just be strings. Note that the records do not have to be remembered from one execution of the server to the next and each record can have any value you wish when the server begins execution.

The server class must have the name of Dbs, and the client class must have the name of Dbc. The client must take on optional command line argument. If no argument is given, it will assume the current machine contains the server socket. If an argument is given, it will assume that the argument is the name of the machine that contains the server socket. The port number used by your program is to be 1XXXX, where XXXX is the last 4 digits of your UIN.

The server and each client is to have a graphical user interface.

Your program should have any remaining clients "gracefully" exit after the server exits.

Your program is to be submitted electronically via the turnin command on the LINUX machines. The project name for this is mp1. All programs are expected to be written in good programming style using the java programming language.

How to turn in your work

Turnin your program electronically using the "turnin" command from your CS account as follows:

turnin -c cs441 -p mp1  [your project directory]
where the [your project directory] is the directory name under which you have all your files related to this programming problem. The turnin command will automatically compress the data under your directory, so there is no need to do the compression by yourself.

Notice you can only invoke turnin command on the Linux machines in the lab or after logging into the server machine oscar.cs.uic.edu.


If you want to verify that your project was turned in, look in the turnin directory for a file with your userid. For instance for this project, from your CS account you would type:
  

    turnin -c cs441 -v

Note that you can execute turnin as many times as you would like, up until the program deadline when turnin will be disabled for this project. Each time you execute turnin for a project, you overwrite all of what you had turned in previously for that project.It does not work in an incremental way.

Grading criteria

  Here is a grading criteria for this programming project, subject to some minor adjustment in the future.

1 If you finish your project, submit it on time and your java code can compile ( TA might try to recompile your source code on Linux machines in CS lab, so you had better try to compile and test your work in lab to avoid any potential incompatibility problem), you get 40 base points.

2 If your client can talk to server process to read/write records, you get 15 more points.

3 More than one clients can connect to the same server and they see the same set of record values,10 more points


4 Server has a GUI showing the current values of records,5 more points

5 Implement the read lock, 4 more points

6 Implement the write lock, 4 more points 

7 Server can unlock all the locks, 2 more points

8 Client program can handle the command line argument correctly, 3 more points. 

9 Client program can gracefully exit. 2 more points.

10 Have good coding style and provide a understandable readme description file for the project, 10 more points. What you put in the readme file is an overview description of your program's internal structure, steps to compile and run your program. 

11 Don't have any other unexpected issues (5 points).