Computer Science 328 Distributed Systems - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Computer Science 328 Distributed Systems

Description:

Activation of remote objects ... Activation creates a new instance of the class of a passive object and ... server processes and activating remote objects in ... – PowerPoint PPT presentation

Number of Views:12
Avg rating:3.0/5.0
Slides: 30
Provided by: mehdith
Category:

less

Transcript and Presenter's Notes

Title: Computer Science 328 Distributed Systems


1
Computer Science 328Distributed Systems
  • Lecture 9
  • Inter-process Communication Distributed Objects

2
Middleware Layers
3
Distributed Objects
  • Object
  • consists of a set of data and a set of methods.
  • Object reference
  • an identifier via which objects can be accessed.
  • In Java a variable that appears to hold an object
    actually holds a reference to that object.
  • Interface
  • provides a definition of the signatures of a set
    of methods (i.e., the types of their arguments,
    return values, and exceptions) without specifying
    their implementation.
  • Remote method invocation
  • method invocations between objects in different
    processes.
  • Remote objects
  • objects that can receive remote invocations.
  • Remote object reference
  • an identifier that can be used throughout a
    distributed system to refer to a particular
    unique remote object.
  • Remote interface
  • Every remote object has a remote interface that
    specifies which of its methods can be invoked
    remotely.

4
Remote and Local Method Invocations
5
A Remote Object and Its Remote Interface
6
RMI Failure Modes

Request

Execute
lost request
correct function
Reply
Channel fails during reply
Execute
Request
Execute, Crash
crash before reply
Reply
Client machine fails before receiving reply
Request
Execute
Crash
crash before execution
Reply
7
RMI Invocation Semantics
whether to keep a history of result messages to
enable lost results to be retransmitted
without re-executing the operations
Whether or not to retransmit the request message
until either a reply is received or the server is
assumed to be failed
when retransmissions are used, whether to fliter
out duplicate requests at the server.
8
Proxy and Skeleton in Remote Method Invocation
9
Remote Reference Module
  • Is responsible for translating between local and
    remote object references and for creating remote
    object references.
  • Has a remote object table
  • An entry for each remote object held by the
    process.
  • An entry for each local proxy.
  • When a remote object is to be passed as argument
    for the first time, the remote reference module
    creates a remote object reference and adds it to
    the table.
  • When a remote object reference arrives in a
    request or reply message, the remote reference
    module is asked for the corresponding local
    object reference, which may refer either to a
    proxy or to a remote object.
  • In the case that the remote object reference is
    not in the table, the RMI software creates a new
    proxy and asks the remote reference module to add
    it to the table.

10
Proxy
  • Is responsible of making RMI transparent to
    clients by behaving like a local object to the
    invoker.
  • The proxy implements the methods in the remote
    interface of the remote object it represents.
  • Instead of executing an invocation, the proxy
    forwards it to a remote object.
  • Each method of the proxy marshals (i) a reference
    to the target object, (ii) its own method Id and
    (iii) its arguments into a request message and
    sends it to the target, awaits the reply message,
    un-marshals it and returns the results to the
    invoker.

11
Marshalling Unmarshalling
  • External data representation an agreed standard
    for the representation of data structures and
    primitive values.
  • CORBA Common Data Representation (CDR)
  • Javas object serialization.
  • Marshalling the process of taking a collection
    of data items and assembling them into a form
    suitable for transmission.
  • Translation of non-portable representations.
  • Assembly of data items into an external data
    rep.
  • Unmarshalling the process of disassembling
    transmitted data at the destination.
  • generation of primitive values
  • reconstruction of structured data

12
Dispatcher and Skeleton
  • A server has one dispatcher and skeleton for each
    class representing a remote object.
  • The dispatcher receives the request message from
    the communicating module.
  • It uses the method Id to select the appropriate
    method in the skeleton, passing on the request
    message.
  • Skeleton implements the methods in the remote
    interface.
  • A skeleton method un-marshals the arguments in
    the request message and invokes the corresponding
    method in the remote object.
  • It waits for the invocation to complete and
    marshals the result, together with any
    exceptions, in a reply message.

13
Generation of Proxies, Dispatchers and Skeletons
  • In CORBA, interfaces of remote objects are
    defined in CORBA IDL, and the interface compiler
    is used to generate the classes for proxies,
    dispatchers and skeletons.
  • In Java RMI
  • the set of methods offered by a remote object is
    defined as a Java interface that is implemented
    in the remote object.
  • The Java RMI compiler generates the proxy,
    dispatcher and skeleton classes from the class of
    the remote object.

14
Java Remote Interfaces Shape and ShapeList
import java.rmi. import java.util.Vector public
interface Shape extends Remote int
getVersion() throws RemoteException GraphicalObj
ect getAllState() throws RemoteException 1 pub
lic interface ShapeList extends Remote Shape
newShape(GraphicalObject g) throws
RemoteException 2 Vector allShapes() throws
RemoteException int getVersion() throws
RemoteException
15
Remote Method Invocation (RMI)

Proxy object is a hollow container of Method
names. Remote Reference Module translates between
local and remote object references.
CLIENT
Proxy Object B
Object A
Remote Reference Module
Comm. Module
Dispatcher sends the request to Skeleton
Object Skeleton unmarshals parameters, sends it
to the object, marshals the results for return
SERVER
Comm. Module
Dispatcher
Object B
Skeleton for Bs Class
16
Binder and Activator
  • A separate service that maintains a table
    containing mappings from textual names to remote
    object references.
  • Used by servers to register their remote objects
    by name and by clients to look them up.
  • Activation of remote objects
  • A remote object is active when it is available
    for invocation within a running process.
  • A passive object consists of (i) implementation
    of its methods and (ii) its state in the
    marshalled form.
  • Activation creates a new instance of the class of
    a passive object and initializing its instance
    variables.
  • An activator is responsible for
  • Registering passive objects (recording the names
    of the servers against the URLs of the passive
    objects)
  • Starting named server processes and activating
    remote objects in them.

17
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 5.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 5.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.
18
Remote Procedure Call (RPC)
  • Uniform, reusable, user-friendly, and action
    based.
  • Provide a familiar interface for the application
    developer
  • Implement the request-reply primitive
  • Format of the message is standard
  • Supports code reuse
  • Client calls for invocation of a procedure at
    the server machine.
  • Semantics are similar to procedure calls in
    local programs
  • Standard interface, independent of applications
  • A library of reusable procedures, distributed
    over all sites.

19
Client and Server Stub Procedures in RPC
20
Stubs
  • Stubs are generated automatically from interface
    specifications.
  • Stubs hide details of (un)marshalling from
    application programmer library code developer.
  • Client Stubs perform marshalling
  • Server Stubs perform unmarshalling
  • Stubs also take care of communication
    invocation

21
The Stub Generation Process

Compiler / Linker
Server Program
Server Stub
Server Source
Interface Specification
Common Header
RPC LIBRARY
RPC LIBRARY
Stub Generator
Client Stub
Client Source
Client Program
Compiler / Linker
22
Files Interface in Sun XDR
const MAX 1000 typedef int FileIdentifier type
def int FilePointer typedef int Length struct
Data int length char bufferMAX struct
writeargs FileIdentifier f FilePointer
position Data data
struct readargs FileIdentifier f FilePointer
position Length length program
FILEREADWRITE version VERSION void
WRITE(writeargs)1 1 Data READ(readargs)2 2
2 9999
23
Finding RPCs

Finding An RPC RPCs live on specific hosts at
specific ports. Port mapper on the host maps from
RPC name to port When a server is initialized,
it registers its RPCs with the port mapper
(handle) A client first connects to port mapper
to to get this handle The call to RPC is then
made by connecting to the corresponding port
CLIENT
Client Stub
Client Program
Comm. Module
SERVER
Comm. Module
Server procedure
Dispatcher
Server Stub
24
Dealing Room System
25
Architecture for Distributed Event Notification
26
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 "
e.getMessage())
27
Java class ShapeListServant Implements Interface
ShapeList
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
theList.addElement(s)
return s public Vector allShapes()throws
RemoteException... public int getVersion()
throws RemoteException ...
28
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 "
e.getMessage())
29
Classes Supporting Java RMI
Write a Comment
User Comments (0)
About PowerShow.com