Distributed Systems Lab: Java Remote Method Invocation



In this lab, we will try out Java RMI.

1. Hello World

Here are the files that make up our RMI version of the Hello World Example: HelloInterface, Hello, HelloServer, and HelloClient.

Compile the code with the Java compiler and the RMI compiler, then run it.

2. Hello World over the Network

Adapt the code so that the client and the server run on two different machines.

3. Print Server

Write a client and a server so that the client can send a string to the server
and the server prints the string to standard output.

4. Echo Server

Write a client and a server so that the client can send a string to the server,
the server modifies the string (e.g., attaches a prefix to it) and returns it to the client,
and the client prints the string to standard output.

5. Broadcast Server

Write a server that accepts registrations from clients.
When a client sends a string to the server,
the server calls all registered clients and lets them print the string it received.
Hint: For this to work, you need to use the callback mechanism discussed in the lecture.

6. Echo Server

Here are the files for the RMI generic echo server example that we discussed in the lecture:
EchoInterface, Echo, EchoServer, EchoClientString, MyString and EchoClientMyString.

Install the server in such a way that an EchoClientString can dynamically download stubs
from the server's codebase on the file system and compile and run client that does this.

Run an EchoClientMyString so that it makes it's codebase available to the server.

For these two exercises you will have to create files with security policies, like the
Permit All Policy or a the Permit All For Codebase Policy.

Hint: You can simplify your work if you do not always type the javac and java commands,
but use a shell script. If so, do not forgot to make the script executable.

Modify the setup so that the server and the clients make their codebase available over your home page
and the client retrieves code via HTTP.

Hint 1: Everyone having a MAC can do this easily, since a Web server is already built-into your computer.
Switch on: System Preferences > Sharing > Services > Web Sharing.

Hint 2: For all students registered for the Database course, some file space has been set up that can be accessed
using the webdavs protocol.
To connect to that space, you need the konqueror browser, which you can call by typing konqueror
into a shell. Once the browser is running, you type into the input field

webdavs://archimedes.inf.unibz.it/teaching2010/idb/username_dav

and you can start to put files into that space. The content becomes accessible under

http://archimedes.inf.unibz.it/teaching2010/idb/username.

Of course, you have to replace username with your own user name.




BACK Back to the labs page