CSE 40771 - Distributed Systems - Fall 2024

View the Project on GitHub

A2 - Remote Procedure Call

Overview

Please review the general instructions for preparing assignments.

In this assignment, you will build a simple RPC server that supports access to an in-memory spreadsheet running on a single machine. This will provide the basic capability that we will build upon over several assignments to work up to a fully distributed, scalable spreadsheet. The focus of this assignment will be on the remote procedure call (RPC) interface to the system.

For this first assignment, the server will simply keep a spreadsheet in memory and need only support a single client at a time. You will be adding more complexity in later assignments, one at a time.

Spreadsheet RPC Interface

Your spreadsheet server should support the following five operations:

insert( row, col, value ) -> Inserts the given value at a numeric row and column, overriding any existing value.
lookup( row, col ) -> Returns the value stored at that row and column.
remove( row, col ) -> Removes the value from that location.
size() -> Returns the maximum row and column values currently in use.
query( row, col, width, height ) -> Returns a rectangular subset of the spreadsheet.

Across the calls, rows and columns are integers, and values can be any Python values convertible to JSON. (e.g. strings, integers, booleans, dictionaries, lists)

You should design an appropriate set of JSON messages to represent a request and response for each operation. You can define this however you like, as long as it is consistent and works correctly. For example, a request to insert an item might look like this:

{
"method" : "insert",
"row" : 5,
"column" : 16, 
"value" : { "weight":100, "animal":"zebra" }
}

In a similar way, the server should return a brief JSON message to indicate the result of the operation. Keep in mind that both the client and server should be able to distinguish between a successful operation, a failed operation, and a completely invalid request. You should have return messages to corresponding to each of these cases.

Take care: Each of the RPC operations may fail under normal use. For example, the user might attempt to remove a cell that is not present in the table. If that happens, the server should not crash with an exception, but rather should return a suitable message to the client, so that the client can return an appropriate value or raise an exception to its caller. There should be no way in which the client can cause the server to crash.

General Code Structure

To ensure some degree of consistency across the projects, please break your project down into several files with the following names. (It’s ok if you have additional files as well.)

Invocation

SpreadSheetServer.py should be started by giving a single argument – a port number – on the command line. The server should attempt to listen on the port (if available) and fail otherwise. If the port number zero is given, then the server should listen on any available port. Either way, it should display the port it is listening on:

python3 SpreadSheetServer.py 9328
Listening on port 9328
python3 SpreadSheetServer.py 0
Listening on port 10475

Then, each of the test programs should accept a host name and port number that they will connect to. For example:

python3 TestBasics.py student10.cse.nd.edu 10475

Testing and Measurement

Write two test programs to exercise your service:

What to Turn In

Please review the general instructions for submitting assignments.

Turn in all of your source code, along with a lab report titled REPORT that describes the following in detail: