0% found this document useful (0 votes)
47 views6 pages

Assignment 4: Implementing RPC/RMI: Operating Systems

This document describes an assignment to implement RPC and RMI. For RPC, students must create a communication module, client and server stubs, and modify an existing client and server to work with the stubs. For RMI, students must create a communication module, client stub class, server skeleton class, generic server, dispatcher, and remote reference module to map remote objects to local references. The roles of proxies, skeletons, and various modules in RPC and RMI are outlined. Notes provide guidance on using protocols, serialization, and reflection to implement the projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views6 pages

Assignment 4: Implementing RPC/RMI: Operating Systems

This document describes an assignment to implement RPC and RMI. For RPC, students must create a communication module, client and server stubs, and modify an existing client and server to work with the stubs. For RMI, students must create a communication module, client stub class, server skeleton class, generic server, dispatcher, and remote reference module to map remote objects to local references. The roles of proxies, skeletons, and various modules in RPC and RMI are outlined. Notes provide guidance on using protocols, serialization, and reflection to implement the projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment 4: Implementing RPC/RMI

Operating Systems

Goal

❒ Implement RPC/RMI software to obtain a better


understanding of the underlying issues
❒ RPC
❍ C/C++
❍ Communication module + client-side & server-side stubs +
dispatcher
❒ RMI
❍ Your implementation of Java RMI
❍ Communication module + client-side & server-side stubs +
dispatcher + Remote Reference module

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

Role of client and server stub procedures in RPC

client process server process

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

Example: using select() for timeouts


#include <sys/time.h>
/* use select to test whether there is any input on descriptor s */

int anyThingThere(int s) {
unsigned long read_mask;
struct timeval timeout;
int n;

timeout.tv_sec = 10; /*seconds wait*/


timeout.tv_usec = 0; /* micro seconds*/
read_mask = (1<<s);
if((n = select(32, (fd_set *)&read_mask, 0, 0, &timeout))<0)
perror("Select fail:\n");
else printf("n = %d\n");
return n;
}
6

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

The role of proxy and skeleton in RMI

client server
remote
object A proxy for B skeleton
object B
Request & dispatcher
for B’s class

Reply

Remote Communication Communication Remote reference


reference module module module module

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

Generic Server (yourRMI)

❒ Pass name of class implementing remote object


(“servant”) as command line argument
❒ Creates classes corresponding to servant and
skeleton
❒ Creates instance of servant, creates ROR, adds
object to RORtable, registers ROR with registry
❒ Code for communication module & generic
dispatcher

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

You might also like