Unit3 DistributedObjects RemoteCommunication
Unit3 DistributedObjects RemoteCommunication
1
Middleware layers
Slides for Chapter 5:
Distributed objects and remote invocation
Applications
Distributed Systems:
Middleware
Request reply protocol layers
Concepts and Design External data representation
Edition 4, © Addison-Wesley 2005 Operating System
1 2
5.1 Introduction
3 4
5.1.1 Interfaces
An explicit interface is defined for each programming module in order to Interfaces in distributed systems:
control the possible interactions between modules. In a distributed program, the modules can run in separate processes.
The interface of a module specifies the procedures and the variables that It is not possible for a module running in one process to access the
can be accessed from other modules. variables in a module in another process – thus, the interface of a module
that is intended for RPC or RMI cannot specify direct access to variables.
Modules are implemented so as to hide all information about them except The specification of a procedure or method in the interface of a module in a
that which is available through its interface. distributed program describes the parameters as input or output.
Input parameters are passed to the remote module by sending the values of
the arguments in the request message and then supplying them as
arguments to the operation to be executed in the server.
Output parameters are returned in the reply message.
When a parameter is used for both input and output, the value must be
transmitted in both the request and reply messages.
Another different between local and remote modules is that pointers in one
process are not valid in another remote one.
5 6
Remote interfaces:
In the distributed object model, a remote interface specifies the
methods of an object that are available for invocation by objects in
other processes, defining the types of the input and output arguments
of each of them.
The difference is that the methods in remote interfaces can pass
object as arguments and results of methods.
Reference to remote objects may also be passed.
7 8
Figure 5.2
CORBA IDL example 5.2 Communication between distributed objects
9 10
11 12
Exceptions: Garbage collection
Programs can encounter many sorts of errors and unexpected Necessary to provide a means of freeing the space occupied by
conditions of varying seriousness. objects when they are no longer needed.
Exceptions provide a clean way to deal with error conditions without This process is called garbage collection.
complicating the code. When a language does not support garbage collection, the
A block of code may be defined to throw an exception whenever programmer has to cope with the freeing of space allocated to objects.
particular unexpected conditions or error arise.
This means that control passes to another block of code that catches
the exception.
Control does not return to the place where the exception was thrown.
13 14
Figure 5.3
5.2.2 Distributed objects Remote and local method invocations
15 16
5.2.3 The distributed object model
17 18
Figure 5.4
A remote object and its remote interface
19 20
Figure 5.5 Instantiation of remote objects
21 22
Figure 5.6
5.2.4 Design issues for RMI Invocation semantics
23 24
Maybe invocation semantics: At-least-once invocation semantics:
the remote method may be executed once or not at all. The invoker receives either a result or an exception informing it that no
Maybe semantics arises when none of the fault tolerance measures is result was received.
applied. Can suffer from the following types of failure:
Can suffer from the following types of failure: ⌧Crash failures when the server containing the remote object fails.
⌧Omission failure, if the invocation or result message is lost: ⌧Arbitrary failures. In cases when the invocation message is retransmitted,
⌧Crash failure, when the server containing the remote object fails. the remote object may receive it and execute the method more than once,
possibly cause wrong values to be stored or returned.
Maybe semantics is useful only for applications in which occasional
failed invocations are acceptable.
At-most-once invocation semantics:
The invoker receives either a result or an exception informing it that no
result was received, in which case the method will have been
executed either once or not at all.
25 26
Figure 5.7
The role of proxy and skeleton in remote method invocation
Transparency
Remote invocations should be made transparent in the sense that the server
syntax of a remote invocation is the same as that of a local invocation, client
remote
but that the difference between local and remote objects should be object A proxy for B skeleton object B
Request & dispatcher
expressed in their interfaces.
for B’s class
Reply
servant
Remote Communication Communication Remote reference
reference module module module module
27 28
5.2.5 Implementation of RMI
29 30
31 32
Generation of the classes for proxies, dispatchers, and The binder:
skeletons --- are generated automatically by an interface A binder in a distributed system is a separate service that maintains a
compiler. table containing mappings from texture names to remote object
references.
Server and client programs
It is used by servers to register their remote objects by name and by
The server program contains the classes for the dispatchers and clients to look them up.
skeletons, together with the implementations of the classes of all of
the servants that it supports. Server threads:
In addition, the server program contains an initialization section – for Whenever an object executes a remote invocation, that execution may
creating and initializing at least one of the servants to be hosted by the lead to further invocations of methods in other remote objects – which
server. may take some time to return.
The client program will contain the classes of the proxies for all of the To avoid the execution of one remote invocation delaying the
remote objects that it will invoke. execution of another, servers generally allocate a separate thread for
the execution of each remote invocation.
33 34
35 36
5.2.6 Distributed garbage collection
Object location Aim: to ensure that if a local or remote reference to an object is still held
A location service helps clients to locate remote objects from their anywhere in a set of distributed objects, then the object itself will continue
remote object references. to exist, but as soon as no object any longer holds a reference to it, the
Use a database that maps remote object references to their probable object will be collected and the memory it uses recovered.
current locations – the location are probable because an object may
have migrated again since it was last heard of.
37 38
Figure 5.8 Role of client and server stub procedures in RPC in the context of
a procedural language 5.3 Remote procedure call
39 40
Figure 5.10
Dealing room system
The client that accesses a service includes one stub procedure for each Dealer’s computer External Dealer’s computer
source
procedure in the service interface. It behaves like a local procedure to the
client, but instead of executing the call, it marshals the procedure identifier and Dealer Notification Notification Dealer
the arguments into a request message – which it sends via its communication
Information
module to the server. Notification
provider Notification
The dispatcher selects one of the server stub procedures according to the Information
provider
procedure identifier in the request message. Notification
Dealer Notification
A server stub procedure is like a skeleton method in that it unmarshals the Dealer
arguments in the request message, calls the corresponding service procedure, External
source
and marshals the return values for the reply message.
41 42
The idea behind the use of events is that one object can react to a Use the publish-subscribe paradigm
change occurring in another object. An object that generates events publishes the types of events that are of
interest to them.
Notifications of events are essentially asynchronous and determined by Different event types may refer to the different methods executed by the
their receivers. object of interest.
Distributed event-based systems extend the local event model by allowing Objects that represent events are called notifications.
multiple objects at different locations to be notified of events taking place When a publisher experiences an event, subscribes that expressed an
at an object. interest in that type of event will receive notifications.
Subscribing to a particular type of event is called registering interest in that
type of event.
43 44
Distributed event-based systems have two main characteristics Event types:
Heterogeneous: An event source can generate events of one or more different types.
⌧When event notifications are used as a means of communication between Each event has attributes that specify information about that event, such as
distributed objects, components in a distributed system that were not the name or identifier of the object that generated it, the operations, its
designed to interoperate can be made to work together. All that is parameters, and the time.
required is that event-generating objects publish the types of events they Types and attributes are used both in subscribing to events and in
offer, and that other objects subscribe to events and provide an interface notifications.
for receiving notifications.
Asynchronous:
⌧Notification are sent asynchronously by event-generating objects to all the
objects that have subscribed to them to prevent publishers needing to
synchronize with subscribers.
45 46
Figure 5.11
Architecture for distributed event notification 5.4.1 The participants in distributed event notification
2. notification notification
3. notification
47 48
The roles of the participating objects are as follows: Figure 5.11 shows three cases:
The object of interest: an object that experiences changes of state, as a An object of interest inside the event service without an observer. It sends
result of its operations being invoked and is considered as part of the event notifications directly to the subscribers.
service if it transmits notifications. An object of interest inside the event service with an observer. The object of
Event: an event occurs at an object of interest as the result of the interest sends notifications via the observer to the subscribers.
completion of a method execution. An object of interest outside the event service. In this case, an observer
Notification: is an object that contains information about an event. Typically, queries the object of interest in order to discover when events occur. The
it contains the type of the event and its attributes. observer sends notifications to the subscribers.
Subscriber: is an object that has subscribed to some type of events in
another object. Delivery semantics:
Observer objects: to decouple an object of interest from its subscribers. A variety of different delivery guarantees can be provided for notifications –
Publisher: an object that declares that it will generate notifications of the chosen one should depend on the requirements of applications.
particular types of event. A publisher may be an object of interest or an
observer.
49 50
51