COMP 310
Fall 2010

Lab08: Java RMI

Home  Info  Owlspace  Resources

Remote Method Invocation

As the name implies, Java RMI is a mechanism to invoke methods on a remote machine and receive the results. A typical RMI application consists of a server, which makes remote objects available, and a client, which invokes methods on those remote objects.

In order for this to work, the client must be able to locate remote objects.  This is accomplished using the RMI registry.  Remote objects are registered in the registry by the server.  The client can then look up these objects in the registry.

Once the client has a reference to the remote object from the registry (called a stub), it must be able to communicate with it.  In Java RMI, this communication is handled seemlessly, and to the client, everything looks exactly as if a method were being invoked on a local object.

Getting the Example Code

The "hello world RMI" program is available in subversion.  You should create a new project and use the svn:externals property to add the following provided code into your project: https://svn.rice.edu/r/comp310/course/RMIHelloWorld/provided.

Networking and Firewalls

As discussed above, RMI works by having a server register available remote objects.  Clients can then look up and access those remote objects.  This requires the client to know two things about the server.

The first is the IP address of the server.  An IP address is a 32-bit number (usually written in dotted decimal notation, i.e., 192.168.1.1) that uniquely identifies hosts in the Internet.

The second is the port on the server that corresponds to the RMI registry. A network server may be running several services at once (i.e., a web server, an e-mail server, a Java RMI server, etc.). Each service is associated with a unique 16-bit port number on that machine.  Common services use "well known port numbers." For instance, most all web servers listen on port 80. But, a service can associate itself with any port.

The combination of an IP address and a port number provides an unambiguous address of a particular service on a server. Clients can then use that address/port combination to access that service.

As you well know, Windows is susceptible to a large number of malicious attacks over the network. So, all Windows machines typically run firewall software that blocks access to almost all network ports. This prevents attackers from gaining entrance to the machine to access services that you may not even know are running.  In order to allow others to access your Java RMI server, we must tell the firewall to allow access to the ports we will be using.  For this class we will be using ports in the range of 2099-2102.

If you are using Windows Firewall (you probably are), then you need to open it.  Type "windows firewall" in the Start menu search box.  Click the "allow a program or feature" option on the left. Choose "change settings" and then "allow another program".  You will want to allow all four ports (2099-2102) for TCP access.  If you are using a different firewall program, you will need to figure out how to allow TCP access to those four ports.

Using the RMI Hello World Program

We will walk through the code of both the client and server and discuss how they work.  Then you will run both programs on your machine.  Finally, you will access a server running on someone else's machine.

More details on running the code can be found on Friday's lecture page.

 

Compute Engine Project

If we have time, we will try to get the demo of the HW07 Compute Engine project operational.

 

 


© 2010 by Stephen Wong and Scott Rixner