Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.

Similar presentations


Presentation on theme: "Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products."— Presentation transcript:

1 Object Interaction: RMI and RPC 1

2 Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products - Java RMI,CORBA,DCOM - Sun RPC - JINI

3 Why Middleware? 3 Location transparency - client/server need not know their location Sits on top of OS, independent of: - communication protocols: use abstract request-reply protocols over UDP,TCP - computer hardware: use external data representation e.g. CORBA CDR - operating system: use e.g. socket abstraction available in most systems - programming language: e.g. CORBA supports Java, C++

4 Middleware Layer 4 Applications Request-reply protocol External data representation RMI, RPC and events Operating System Middleware layer

5 Objects 5 Objects = data + methods Interact via interfaces: - define types of arguments and exceptions of methods Data Implementation of methods object Data Implementation of methods object interface m1 m2 m3 m4 m5

6 The object model 6 Programs logically partitioned into objects - distributing objects natural and easy Interfaces - the only means to access data, make them remote? Actions - via method invocation -interaction, chains of invocations -may lead to exceptions, part of interface

7 --exceptions system as well as programmer-defined reactions on unexpected or error situations -Garbage collection -disposal of resources (memory) that are occupied by objects that are no longer referenced and will not be needed any more in the future - reduced effort, error-free (Java, not C++)

8

9 The distributed object model 9 Objects distributed (client-server models) Extend with - Remote object reference - Remote interfaces - Remote method invocation (RMI) A B C D E REMOTE INVOCATION LOCAL INVOCATION LOCAL INVOCATION LOCAL INVOCATION F REMOTE INVOCATION

10

11 Advantages of distributed objects 11 Data encapsulation gives better protection - concurrent processes, interference Method invocations - can be remote or local Objects - can act as clients, servers, etc - can be replicated for fault-tolerance and performance

12 Remote Object Reference 12 Object References - used to access objects which live in processes - can be passed as arguments, stored in variables,… Remote Object References - object identifiers in a distributed system - must be unique in space and time - error returned if accessing a deleted object - can allow relocation

13 Remote Object Reference 13 Constructing unique remote object reference - IP address, port, interface name - time of creation, local object number (new for each object) Use the same as for local object references If used as addresses - cannot support relocation Interface of remote object Object number timePort numberInternet address 32 bit 32 bit 32 bit 32 bit

14 Remote Object and its interfaces 14 CORBA: Interface Definition Language (IDL) Java RMI: as other interfaces, keyword remote m1 m2 m3 Data Implementation Of method Remote object m4 m5 m6 Local interface Remote interface

15  if implemented over UDP, then the following failures may occur: – message omission – messages not delivered in send order – message duplication  additionally, process failures are possible (crash)  consequence: cannot be guaranteed, that remote operations are executed exactly once (as it can be guaranteed for local operations)

16 RMI issues 16 Local invocations -executed exactly once Remote invocations - via Request-Reply - may suffer from communication failures! retransmission of request/reply message duplication, duplication filtering

17 Invocation semantics summary 17 Fault tolerance measures Invocation semantics Retransmit request Duplicate Re-execute procedure message filtering or retransmit reply No Not applicable Not applicable Maybe Yes No Re-execute procedure At-least-once Yes Yes Retransmit reply At-most-once Re-executing a method sometimes dangerous...

18 Invocation Semantics choices in the implementation – retransmit request message until reply or server presumed failed – filtering of duplicates at server if retransmit is used – when retransmitted request arrives: 1. result retransmission if retransmitted request arrives (requires keeping of history at server) or 2.repeated execution of procedure  leads to different invocation semantics

19 Maybe invocation 19 Remote method - may execute or not at all, invoker cannot tell - useful only if occasional failures Invocation message lost… - method not executed Result not received… - was method executed or not? Server crash… - before or after method executed? - if timeout, result could be received after timeout...

20 At-least-once invocation 20 Remote method - invoker receives result (executed exactly) or exception (no result, executed once or not at all) - retransmission of request message Invocation message retransmitted… - method may be executed more than once - arbitrary failure (wrong result possible) - method must be non-indempotent(repeated execution has the same effect as a single execution) Server crash… - dealt with timeouts, exceptions

21 At-most-once invocation 21 Remote method - invoker receives result (executed once) or exception (no result) - retransmission of reply & request messages - duplicate filtering Best fault-tolerance… - arbitrary failures prevented if method called at most once Used by CORBA and Java RMI

22 Implementation of RMI 22 Skeleton &dispatcher for B’s class Client object A proxy for B Request Reply Remote object B Remote reference module Communication module Communication module Remote reference module Server Object A invokes a method in a remote object B: communication module reference module,RMI software.

23 Communication modules 23

24 Remote reference module 24 Translates remote to local references (object table): – correspondence between remote and local object references (proxies) Directs requests to proxy (if exists) when marshalling / un marshalling

25 RMI Software architecture 25 Proxy – behaves like local object to client – forwards requests to remote object Dispatcher – receives request – selects method and passes on request to skeleton skeleton – implements methods in remote interface – unmarshals data, invokes remote object – Waits for result, marshals it and returns reply

26 Remote Procedure Call (RPC) 26 RPC – historically first,now little used – over Request-Reply protocol – usually at-least-once or at-most-once semantics – can be seen as a restricted form of RMI –sun RPC RPC software architecture – similar to RMI (communication,dispatcher and stub in place of proxy / skeleton)

27 RPC client and server 27 Client process Client stub procedure Client program Communication module Request Reply Communication module dispatcher Service procedure Server stub procedure Server process Implemented over Request-Reply protocol

28 Remote Procedure Call (cont.) Client procedure calls the client stub in a normal way Client stub builds a message and traps to the kernel Kernel sends the message to remote kernel Remote kernel gives the message to server stub Server stub unpacks parameters and calls the server Server computes results and returns it to server stub Server stub packs results in a message and traps to kernel Remote kernel sends message to client kernel Client kernel gives message to client stub Client stub unpacks results and returns to client

29

30 Summary 30 Distributed object model – capabilities for handling remote objects (remote references,etc) – RMI:maybe,at-least-once,at-most-once semantics – RMI implementation,software architecture Other distributed programming paradigms – RPC,restricted form of RMI, less often used – event notification (for heterogeneous,asynchronous systems)


Download ppt "Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products."

Similar presentations


Ads by Google