Presentation Points Chapter 5

Remote Invocation

Objectives

To study communication between distributed objects and the integration of remote method invocation into a programming language.

To be able to use Java RMI to program applications with distributed objects and how to use some aspects of reflection

To study the extension of the event-based programming model to apply to distributed event-based programs.

The performance of invocations and asynchronous invocations are left to Section 7.5.

Points to emphasize

A `remote interface’ specifies the methods of an object that are available for invocation by remote objects in other processes. Interface definition languages (or IDLs) are designed to allow objects in different languages to invoke one another. The semantics of parameter passing are adjusted to suit the separation of client and remote object. In particular input and output parameters are used, and pointers cannot be passed.

A remote object is one that can be invoked from another process. A remote object reference is an identifier for a remote object which is used to refer to it as the target of a remote invocation and can be passed as an argument or result of a remote invocation. Clients need remote object references in order to invoke remote objects. Remote object references may be obtained from a binder or as the result of an RMI.

Call semantics cannot be `exactly once’. The semantics achieved (e.g. `at-most-once’) depends on the approach to dealing with failures of processes and communication.

An RMI system runs over a Request-Reply protocol and can be integrated relatively transparently with a programming language by means of a middleware layer which provides clients with proxies for remote objects and conceals the details of remote object references, marshalling and message passing. However, programmers of clients and servers must handle exceptions due to distribution.

A distributed garbage collector extends the concept of local garbage collection to apply to distributed objects. It generally works in cooperation with a local garbage collector.

Distributed event-based systems use the publish-subscribe paradigm in which an event-generating object publishes the type of events that will be available for other objects. These systems are useful for communication between heterogeneous components and their asynchronous nature allows publishers and subscribers to be decoupled.

The Java case study illustrates a single-language RMI system. Remote objects are passed by reference and non-remote objects by value. Classes may be downloaded from one JVM to another.

Possible difficulties

In our experience, students find it hard to appreciate the variety of call semantics and how to achieve each one.

The relationship between local and remote object references may cause problems, but needs to be understood because application programs use the former whereas remote interfaces are defined in terms of the latter.

Teaching hints

The integration of RMI into a programming language is illustrated by Java RMI in this chapter and by CORBA RMI in Section 8.3.

The approach taken is to build a model for distributed objects as an extension of the local object model. If necessary revise the following topics which should have been covered in earlier courses on programming. (i) the semantics of local method invocation and the use of local object references in invocation and as parameters and results; (ii) the concept of interface; (iii) the handling of exceptions.

The students could be asked to consider the measures taken to deal with failures in the Request-Reply protocol.

Practical work involving either (i) the use of an RMI system (e.g. Java RMI or CORBA) or (ii) the implementation of a simple RMI system over UDP would help to reinforce this chapter. (See Exercises 5.8-11, some of which also require reflection to be used).