Assignment 4: Implementing RPC/RMI: Operating Systems
Assignment 4: Implementing RPC/RMI: Operating Systems
Operating Systems
Goal
1
RPC
❒ You have to implement
1. Communication module
❒ Implements protocol for providing at most once RPC semantics
❒ API used by client & server stubs & dispatcher
doOperation(InetAddress serverhost, int serverport,
int methodId, byte[] arguments)
byte[] getRequest();
void sendReply(byte[] reply, InetAddress clienthost,
int clientport)
2. Client & server stubs
❒ Handcrafted for arithmetic server of Assignment 3
❒ Marshall/Unmarshall arguments & results
3. Client & server
❒ Already implemented by you for Assignment 3 but you will have
to modify your code to work with your client & server stubs
Request
Reply
client stub server stub
procedure procedure
client service
program Communication Communication procedure
module module dispatcher
2
RPC project notes
❒ Communication module
❍ Use Request-Reply-Ack protocol for implementing at
most once semantics
❍ Use select system call for implementing timeouts
❍ Your code should “drop messages” to demonstrate the
correct working of your RRA protocol
• Print enough debug messages so that grader can see your
protocol at work
❒ Stubs
❍ Convert data types into cannonical format and vice versa
• htonl() & ntohl() for integers
• Flat array of bytes containing arguments
❒ Client
❍ Server hostname & port are command-line arguments,
I.e. no need for a binder/registry
int anyThingThere(int s) {
unsigned long read_mask;
struct timeval timeout;
int n;
3
RMI project
❒ You have to implement
1. Communication module
❒ Use TCP streams as transport
2. Client stub class
3. Server skeleton class
4. Generic server & Dispatcher
5. Remote Reference Module
❒ Maps Remote Object References to local references
6. Client
❒ Already implemented for Assignment 3, but will need
to be changed slightly to work with Registry
(provided to you) and your RMI implementation
Outline of code for classes implementing items 4
and 5 are given to you
7
client server
remote
object A proxy for B skeleton
object B
Request & dispatcher
for B’s class
Reply
4
Remote Reference Module
❒ Class RemoteObjRef
❍ Implement Remote Object References (ROR)
❍ Two methods
• Constructor
• localise()
– Called by client to create a proxy for remote object whose
reference was obtained from Registry
❒ Class RORtable
❍ maintains a mapping between RORs and objects
in the server process
10
5
RMI project notes
❒ Marshalling/Unmarshalling
❍ Can use Java serialization for flattening
arguments
❍ Use Java serialization API
❒ Generic server
❍ Use classes in java.lang package for generic
server & dispatcher (see code outline provided
to you)
❍ Can use Java reflection for creating generic
skeleton (but don’t need to do this, I.e. you can
have a specific skeleton)
11