
1
Java RMI
Different Approaches to
Distributed Computation
• High-performance, parallel scientific apps
– e.g MPI
• Connecting via sockets
– custom protocols for each application
– text or binary protocol
• RPC/DCOM/CORBA/RMI
– make what looks like a normal function call
– function is actually invoked on another machine
– Arguments are marshalled for transport
– return value is marshelled as well
Remote Method Invocation
• Easy way to get distributed computation
• Have stub for remote object
– calls to stub get translated into network call
• Arguments can be passed over network
Remote Objects and Interfaces
• Remote Objects are those that can be
referenced remotely
– extends java.rmi.UnicastRemoteObject
– constructor throws java.rmi.RemoteException
• Remote interfaces describe services that can
be provided remotely
– extends java.rmi .Remote interface
– all methods throw java.rmi.RemoteException
RMIC - RMI Compiler
• Generates stub code for a class
– For 1.1, also generates skeleton class
– skeleton not needed for 1.2+
• Generates stubs for all methods declared in
remote interfaces
– other methods don’t get a stub
Passing arguments
• Can pass arbitrary values as arguments
• Can return arbitrary values as results
• To pass a value, it must either be
– Serializable, or
– Remote
• Passing the same Serializable object in
different calls
– will materialize different objects at receiver