5. Java RMI
17/02/23
RPC and RMI Summary
- RPC paradigm is the concept that porgrammers should be able to invoke remote operations in the same way as local procedure calls
- RMI extends this concept to distributed objects
- A remote reference represents a remote object
- Remote invocations differ from local ones because:
- Memory is not shared between the caller and the procedure body
- They are much slower than local calls
- They are subject to network and server failures
Defining a remote interface
- What is the service? -> each service = 1 remote interface
- What distinct requests can a client make? -> each request = 1 method
- How can each request be concisely described? -> = method name
- What information does the client have that the server needs to perform the request? -> = arguments - types (and names)
- What might be anticipated to go wrong? -> =exceptions
- If it works, what information does the client need back? -> = return type
RMI argument/return types
- Passed by value (primitive values, Serialisable objects)
- Methods called on the Serialisable copy run only on the copy; changes to copy's fields are not visible elsewhere
- => Keeping and using the copy may be more efficient
- Passed by reference/proxy (Remote objects)
- Methods called on remote proxies run on the server object
- => Making repeated remote method calls should be more consistent or up to date
Implementing a Remote Object
- Each remote interface needs an implementation that will be run in the server process
- Encapsulates state, implements methods
- Class names here are Servant also called Impl or Implementation