Communication%20between%20distributed%20objects - PowerPoint PPT Presentation

View by Category
About This Presentation



extension of local method invocation in OO model ... different passivate strategies. at the end of a transaction. when the program exit ... – PowerPoint PPT presentation

Number of Views:1246
Avg rating:3.0/5.0
Slides: 50
Provided by: HH7
Learn more at:


Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Communication%20between%20distributed%20objects

Chapter 5 Distributed objects and remote
  • Introduction
  • Communication between distributed objects
  • Remote procedure call
  • Events and notifications
  • Java RMI case study
  • Summary

  • Layers of Middleware
  • Provide a programming model
  • Provide transparence
  • Location
  • Communication protocols
  • Computer hardware
  • Operating systems
  • Programming languages

Distributed programming model
  • Remote procedure call (RPC)
  • call procedure in separate process
  • Remote method invocation (RMI)
  • extension of local method invocation in OO model
  • invoke the methods of an object of another
  • Event-based model
  • Register interested events of other objects
  • Receive notification of the events at other

  • Interface
  • Specifies accessible procedures and variables
  • Inner alteration wont affect the user of the
  • Interface in distributed system
  • Cant access variables directly
  • Input argument and output argument
  • Pointers cant be passed as arguments or returned

Interface cases
  • RPCs Service interface
  • specification of the procedures of the server
  • input and output arguments of each procedure
  • RMIs Remote interface
  • Specification of the methods of an object that
    are available for objects in other processes
  • may pass objects or remote object references as
    arguments or returned result
  • Interface definition languages
  • program language, e.g. Java RMI
  • Interface definition language (IDL), e.g. CORBA

Chapter 5 Distributed objects and remote
  • Introduction
  • Communication between distributed objects
  • Remote procedure call
  • Events and notifications
  • Java RMI case study
  • Summary

Discuss RMI under following headings
  • The object model
  • Distributed objects
  • The distributed object model
  • Design issues
  • semantics of remote invocations
  • Implementation
  • RMI above the request-reply protocol
  • Distributed garbage collections

The object model
  • Object references
  • Objects can be accessed via object references
  • First-class values
  • Interfaces
  • A definition of the signatures of a set of
  • No constructers
  • A class can implement several interfaces, e.g.
  • Actions
  • Initiated by an object invoking a method in
    another object
  • Two affects
  • Change the state of the receiver
  • Further invocations on methods in other objects

The object model continued
  • Exceptions mechanism
  • A clean way to deal with error conditions
  • List exceptions at the method head
  • throw user know exceptions
  • Catch exceptions
  • Garbage collection
  • Freeing the space occupied by cancelled objects
  • C collected by programmers
  • Java collected by JVM

Distributed objects
  • Natural extension
  • physical distribution of objects into different
    processes or computers in a distributed system
  • Benefits of distributed objects
  • Enforce encapsulation
  • cant access variables directly
  • Support heterogeneous systems
  • Local object cache
  • Assume other architectural models
  • Replicated objects
  • Migrated objects

The distributed objects model
  • Remote object reference
  • An unique identifier in a distributed system
  • May be passed as arguments and results of remote
    method invocation
  • Remote interface
  • remote object class implements the methods of its
    remote interface
  • Actions in a distributed system
  • may incur a chain of invocations on different
  • Garbage collection
  • Usually based on reference counting
  • Exception
  • notify the client and the client handle exceptions

Design Issues Invocation semantics
  • Choices for different delivery guarantees
  • retry request message
  • duplicate filtering
  • retransmission of results
  • Three different semantics

Different invocation semantics
  • Maybe
  • For invoker executed once, or not at all ???
  • Suffer from (1) message lost (2) server crash
  • Useful for app. in which occasional failed
    invocation are acceptable
  • At least once
  • For invoker execute at least once, or an
  • Suffer from (1) server crash (2) arbitrary
    failures for non-idempotent method
  • At most once
  • For invoker receives result, or an exception
  • Prevent omission failures by retrying, arbitrary

Design Issues - Transparency
  • What can be made transparent
  • marshal
  • message passing
  • object locating and contacting
  • What cant be made transparent
  • vulnerable to failure
  • latency
  • Current consensus
  • transparent in syntax
  • different in expression

Implementation of RMI
  • The inner scene of RMI
  • Communication module
  • Request/reply between client and server
  • Select dispatcher at server side
  • Remote reference module
  • Translate between local and remote object
  • Create remote object reference
  • Remote object table
  • entries for remote objects held by the process
  • entries for local proxies

Implementation of RMI RMI software
  • Proxy
  • forward invocation to remote object
  • one remote object one proxy
  • Skeleton
  • implement the method in the remote interface
  • unmarshal the arguments in the request
  • invoke the corresponding method in the remote
  • wait for the invocation complete
  • marshal the result in the reply message
  • Dispatcher
  • select appropriate method in the skeleton
  • one dispatcher and skeleton for one remote object

Implementation of RMI - execution
  • The classes for proxies, dispatchers and
  • generated automatically by an interface compiler,
    e.g. rmic
  • Server program
  • create and initialize at least one of the remote
  • register
  • Client program
  • look up the remote object references
  • invoke
  • The binder
  • Maintain mapping information of textual names to
    remote object references

Implementation of RMI - Object state
  • Activation of remote objects
  • to avoid resource waste, the servers can be
    started whenever they are needed
  • a remote object could be active or passive
  • Persistent object stores
  • Persistent object
  • an object that is guaranteed to live between
    activations of processes
  • different passivate strategies
  • at the end of a transaction
  • when the program exit
  • E.g., Persistent Java, PerDiS

Distributed garbage collection
  • The aim of a distributed garbage collector
  • Retain the object (localremote) when it is still
    be referenced
  • Collect the object when none holds reference to
  • Java distributed garbage collection algorithm
  • based on reference counting
  • server maintain processes set that hold remote
    object references to it
  • client notify server to modify the process set
  • when the process set becomes empty, server local
    garbage collector reclaims the space
  • Leases in Jini
  • lease the granting of the use of a resource for
    a period of time
  • avoid to discover whether the resource users are
    still interested or their programs have not exited

Chapter 5 Distributed objects and remote
  • Introduction
  • Communication between distributed objects
  • Remote procedure call
  • Events and notifications
  • Java RMI case study
  • Summary

RPC is very similar to RMI
  • Service interface the procedures that are
    available for remote calling
  • Invocation semantics choice at-least-once or
  • Generally implemented over request-reply protocol
  • Building blocks
  • Communication module
  • Client stub procedure (as proxy in RMI)
    marshalling, sending, unmarshalling
  • Dispatcher select one of the server stub
  • Server stub procedure (as skeleton in RMI)
    unmarshalling, calling, marshalling

Sun RPC case study
  • Designed for NFS
  • at-least-once semantics
  • XDR - Interface definition language
  • Interface name Program number, version number
  • Procedure identifier procedure number
  • Rpcgen generator of RPC components
  • client stub procedure
  • server main procedure
  • Dispatcher
  • server stub procedure
  • marshalling and unmarshalling procedure

Sun RPC case study continued
  • Binding portmapper
  • Server register ((program number, version
    number), port number)
  • Client request port number by (program number,
    version number)
  • Authentication
  • Each request contains the credentials of the
    user, e.g. uid and gid of the user
  • Access control according to the credential

Chapter 5 Distributed objects and remote
  • Introduction
  • Communication between distributed objects
  • Remote procedure call
  • Events and notifications
  • Java RMI case study
  • Summary

Event-notification model
  • Idea
  • one object react to a change occurring in another
  • Event examples
  • modification of a document
  • an electronically tagged book being at a new
  • Publish/subscribe paradigm
  • event generator publish the type of events
  • event receiver subscribe to the types of events
    that are interest to them
  • When event occur, notify the receiver
  • Distributed event-based system two
  • Heterogeneous
  • asynchronous

Example - dealing room system
  • Requirements
  • allow dealers to see the latest market price
  • System components
  • Information provider
  • receive new trading information
  • publish stocks prices event
  • stock price update notification
  • Dealer process
  • subscribe stocks prices event
  • System architecture

Architecture for distributed event notification
  • Event service maintain a database of published
    events and of subscribers interests
  • decouple the publishers from the subscribers

The roles of the participating objects
  • The object of interest
  • its changes of state might be of interest to
    other objects
  • Event
  • the completion of a method execution
  • Notification
  • an object that contains information about an
  • Subscriber
  • an object that has subscribed to some type of
    events in another object
  • Observer objects
  • the main purpose is to decouple an object of
    interest from its subscribers
  • Publisher
  • an object that declares that it will generate
    notifications of particular types of event

Notification delivery
  • Delivery semantics
  • Unreliable
  • Reliable
  • real-time
  • Roles for observers
  • Forwarding
  • send notifications to subscribers on behalf of
    one or more objects of interests
  • Filtering of notifications
  • Patterns of events
  • Notification mailboxes
  • notification be delayed until subscriber being
    ready to receive

Jini distributed event specification
  • EventGenerator interface
  • Provide register method
  • Event generator implement it
  • Subscriber invoke it to subscribe to the
    interested events
  • RemoteEventListener interface
  • Provide notify method
  • subscriber implement it
  • receive notifications when the notify method is
  • RemoteEvent
  • a notification that is passed as argument to the
    notify method
  • Third-party agents
  • interpose between an object of interest and a
  • equivalent of observer

Chapter 5 Distributed objects and remote
  • Introduction
  • Communication between distributed objects
  • Remote procedure call
  • Events and notifications
  • Java RMI case study
  • Summary

Java RMI introduction
  • Remote object
  • Must implement the remote interface
  • must handle remote exceptions
  • Arguments and return results of remote method
  • Must be serializable
  • All primitive types serializable
  • remote objects are serializable
  • File handles are unserializable
  • Remote objects are passed as remote object
    reference, non-remote serializable objects are
    copied and passed by value
  • RMIregistry
  • access by the Naming class

Example shared whiteboard
  • Remote Interface
  • Server program and Client program
  • Callbacks
  • A servers action of notifying clients about an
  • Implementation
  • Client create a remote object
  • Client pass the remote object reference to server
  • Whenever an event occurs, server call client via
    the remote object
  • Advantage
  • Improve performance by avoid constant polling
  • Delivery information in a timely manner

Design and implementation of Java RMI
  • Java classes supporting RMI

Chapter 5 Distributed objects and remote
  • Introduction
  • Communication between distributed objects
  • Remote procedure call
  • Events and notifications
  • Java RMI case study
  • Summary

  • Two paradigms for distributed programming
  • RMI(RPC)/Event notification sync./async.
  • RMI
  • Distributed object model
  • Remote interface, remote exception, naming
  • Remote invocation semantics
  • Once, at-least-once, at-most-once
  • Example whiteboard based on Java RMI
  • Sun RPC
  • Event-notification
  • Publish/subscribe
  • Event service
  • Example dealing room

Middleware layers
CORBA IDL example
// In file Person.idl struct Person string
name string place long year interface
PersonList readonly attribute string
listname void addPerson(in Person p) void
getPerson(in string name, out Person p) long
A remote object and its remote interface
Remote and local method invocations
The role of proxy and skeleton in remote method
Files interface in Sun XDR
Dealing room system
The Naming class of Java RMIregistry
void rebind (String name, Remote obj) This
method is used by a server to register the
identifier of a remote object by name, as shown
in Figure 15.13, line 3. void bind (String
name, Remote obj) This method can alternatively
be used by a server to register a remote object
by name, but if the name is already bound to a
remote object reference an exception is
thrown. void unbind (String name, Remote obj)
This method removes a binding. Remote
lookup(String name) This method is used by
clients to look up a remote object by name, as
shown in Figure 15.15 line 1. A remote object
reference is returned. String list() This
method returns an array of Strings containing the
names bound in the registry.
Java Remote interfaces Shape and ShapeList
import java.rmi. import java.util.Vector publi
c interface Shape extends Remote int
getVersion() throws RemoteException GraphicalObj
ect getAllState() throws RemoteException 1 pu
blic interface ShapeList extends Remote Shape
newShape(GraphicalObject g) throws
RemoteException 2 Vector allShapes() throws
RemoteException int getVersion() throws
Java class ShapeListServant implements interface
import java.rmi. import java.rmi.server.UnicastR
emoteObject import java.util.Vector public
class ShapeListServant extends UnicastRemoteObject
implements ShapeList private Vector
theList // contains the list of Shapes 1
private int version public ShapeListServant()thr
ows RemoteException... public Shape
newShape(GraphicalObject g) throws
RemoteException 2 version Shape s
new ShapeServant( g, version) 3
return s public Vector allShapes()throws
RemoteException... public int getVersion()
throws RemoteException ...
Java class ShapeListServer with main method
import java.rmi. public class
ShapeListServer public static void main(String
args) System.setSecurityManager(new
RMISecurityManager()) try ShapeList
aShapeList new ShapeListServant() 1
Naming.rebind("Shape List", aShapeList
) 2 System.out.println("ShapeList server
ready") catch(Exception e)
System.out.println("ShapeList server main "
Java client of ShapeList
import java.rmi. import java.rmi.server. impor
t java.util.Vector public class
ShapeListClient public static void
main(String args) System.setSecurityManager(ne
w RMISecurityManager()) ShapeList aShapeList
null try aShapeList (ShapeList)
Naming.lookup("//bruno.ShapeList") 1 Vector
sList aShapeList.allShapes() 2
catch(RemoteException e) System.out.println(e.get
Message()) catch(Exception e)
System.out.println("Client "
Callback mechanism in the whiteboard system
Client created remote object Public interface
WhiteboardCallback implements Remote void
callback(int version) throws RemoteException M
ethods added in Shapelist interface Int
register(WhiteboardCallback callback) throws
RemoteException Void deregister(int callbackID)
throws RemoteException