![]() |
![]() |
|
02152 Concurrent Systems Fall 2008 |
NP Lab 3: Java RMI |
Home | Plan | Material |
This lab should give you a basic experience with the use of Remote Method Invocation (RMI) in Java.
Assistance for this programming lab will be available in the G-databar, Building 308, Rooms 15 + 16, Monday, November 10, 10.00-12.00.
This describes the third set of practical exercises for the Network Programming part of the course in Concurrent Systems. The exercises assume that you have read at least Sections 1 to 10 of ``The Poor Man's Guide to Computer Networks and their Applications'' [PMG].
import java.rmi.*; import java.rmi.server.*; public interface RemoteSysinfo extends Remote { public String getSysinfo(String systemProperty) throws java.rmi.RemoteException; }The implementation of this remote interface is to use the System.getProperty() method to find the value of the property whose name is given by the systemProperty argument to the getSysinfo method.
You will need to write the following pieces of software:
Then follow the instructions given in [PMG 10], pages 75-78 in order to start the rmiregistry, activate the remote object and finally activate the client.
Since the rmiregistry will use port 1099 by default, only the first group to start it will succeed. Therefore, each group should chose an arbitrary port (> 1024) and pass that as a parameter to the registry. E.g.
rmiregistry 39192
Correspondingly, the client should use that port in the URI used for the Naming.bind and Naming.lookup.
Test out your program in two ways:
Look in the documentation of method System.getProperties() to see what properties are available.
To get an accurate measurement, you are advised to modify your client so that it can make the same remote call a large number of times in succession.
IMPORTANT: When you have finished, make sure that you kill the process in which the RMI registry that you started is running. Otherwise, subsequent users may not be able to start their RMI programs. Use ps | fgrep rmi to see if you have any registries running and if so, kill them with kill -9 <processid>.
If you are going deploy your client and server programs in a truly distributed setting, ie. running on different machines, you are likely to experience issues with security policies and firewalls.
For a more comprehensive discussion, see the page on RMI details
[Originally by Robin Sharp, 2002-2003. Modified by Hans Henrik Løvengreen 2004-2007.]
Hans Henrik Løvengreen, Nov 7, 2008 |