Distributed Obj and Remote Invocation
Distributed Obj and Remote Invocation
Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary
Middleware
Layers of Middleware Provide a programming model Provide transparence
Location Communication protocols Computer hardware Operating systems Programming languages
Event-based model
Register interested events of other objects Receive notification of the events at other objects
Interfaces Interface
Specifies accessible procedures and variables Inner alteration wont affect the user of the interface
Remote interface:
specifies the methods of an object available for remote invocation an interface definition language (or IDL) is used to specify remote interfaces. E.g. the above in CORBA IDL. Java RMI would have a class for Person, but CORBA has a struct
Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary
each process contains objects, some of which can receive remote invocations, others only local invocations those that can receive remote invocations are called remote objects objects need to know the remote object reference of an object in another process in order to invoke its methods. the remote interface specifies which methods can be invoked remotely
Duplicate Filtering
Determines if the same request received multiple times should be filtered down to one request, or if all requests should be reexecuted
Retransmission of Results
Determines if the results from requests should be saved and resent instead of re-executing a request
Invocation Semantics
Maybe Invocation Semantics
Remote method requests may be executed once or not at all Used when request messages are not resent when a fault occurs Requesting system cannot tell if the server executed the request before the fault occurred
Invocation semantics
Local invocations are executed exactly once Remote invocations cannot achieve this. Why not? the Request-reply protocol can apply fault-tolerance measures
Fault tolerance measures Retransmit request message No Yes Yes Duplicate filtering Re-execute procedure or retransmit reply Maybe Invocation semantics
At-least-once - the client gets a result (and the method was executed at least once) or an exception (no result)
arbitrary failures. If the invocation message is retransmitted, the remote object may execute the method more than once, possibly causing wrong values to be stored or returned. if idempotent operations are used, arbitrary failures will not occur
At-most-once - the client gets a result (and the method was executed exactly once) or an exception (instead of a result, in which case, the method was executed once or not at all)
Reply
Proxy - makes RMI transparent carries out Requestto client. Class implements remote interface. Marshals requests and reply protocol unmarshals results. Forwards request. translates between local and remote Skeleton - implements methods in remote interface. object references and creates remote Dispatcher - gets request and marshals results. Invokes Unmarshals requests from communication module and object references. Uses remote object invokes method in skeleton (using methodID in message). method in remote object. table
RMI software - between application level objects and communication and remote reference modules
Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary
server process
Reply
Authentication
Each request contains the credentials of the user, e.g. uid and gid of the user Access control according to the credential information
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 object
Event examples
modification of a document an electronically tagged book being at a new location
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
Heterogeneous: components in a DS that were not designed to interoperate can be made to work together Asynchronous: prevent publishers needing to synchronize with subscribers
System components
Information provider
receive new trading information publish stocks prices event stock price update notification
Dealer process
subscribe stocks prices event
System architecture
Dealer
Dealer
Notification
Information provider
Notification
Information provider
Notification Dealer
Notification Dealer External source
Event service
object of interest 1. object of interest 2. object of interest 3. notification observer notification observer notification subscriber notification subscriber
subscriber
Event
An event occurs at an object of interest as the completion of a method execution
Notification
an object that contains information about an event
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. Avoid over-complicating the object of interest.
Publisher
an object that declares that it will generate notifications of particular types of event. May be an object of interest or an observer.
RemoteEventListener interface
Provide notify method subscriber implement it receive notifications when the notify method is invoked
RemoteEvent
a notification that is passed as argument to the notify method
Third-party agents
interpose between an object of interest and a subscriber equivalent of observer
Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary
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 event 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
RemoteServer
Activatable UnicastRemoteObject <servant class>
Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary
Summary
Two paradigms for distributed programming
RMI(RPC)/Event notification: sync./async.
RMI
Distributed object model
Remote interface, remote exception, naming service
Middleware layers
Applications RMI, RPC and events Request reply protocol Middleware layers
remote object
remote interface
Data
m4 m5 m6
m1
m2 m3
implementation of methods
remote
local
C local
E remote invocation
invocation B
invocation
struct readargs { FileIdentifier f; FilePointer position; Length length; }; program FILEREADWRITE { version VERSION { void WRITE(writeargs)=1; Data READ(readargs)=2; }=2; } = 9999;
1 2
Dealer
Dealer
Notification
Information provider
Notification
Information provider
Notification Dealer
Notification Dealer External source
public interface ShapeList extends Remote { Shape newShape(GraphicalObject g) throws RemoteException; 2 Vector allShapes() throws RemoteException; int getVersion() throws RemoteException; }
1 2
1 2