Distributed objects and remote invocation Pages 165 - 187 1 Objectives • Models (RPC, RMI, ……) • Interface – remote and service. • Communications between objects - Remote method invocation. 3 General models • Remote procedure call model (RPC) • allows client programs to call procedures in server programs running in separate processes and computers • Remote method invocation (RMI) • allows an object living in one process to invoke methods of an object living in another process • Middelware • software that provides a programming model above the basic building blocks of processes and message passing 4 Middleware layers Applications RMI, RPC and events Request reply protocol External data representation Middleware layers Operating System local remote invocation A B C E invocation local invocation local invocation D Remote and local method invocations remote invocation F 5 Middleware • Location transparency • Communication protocols • Computer hardware • O.S. 6 Interface remoteobject remote interface { Data m1 m2 m3 implementation of methods m4 m5 m6 • Interface - module (data, procedure) in general • Interface – module in D.S. (input, output) 7 Remote interface and Service interface • Objects - each object has a remote object reference and a remote interface • Service interface - client- server model. • remoteobject remote interface { Data m1 m2 m3 implementation of methods m4 m5 m6 8 Communications between D. objects • Object model – reference, interface, actions, exception, garbage collection. • Distributed object – program is partitioned, objects are logically partitionedī Distribution, 9 Distributed object model local remote E invocation local invocation invocation A C B remote invocation F local invocation D • reference, interface, actions, exception, garbage collection. 10 Design issues for RMI • Invocation semantics Fault tolerance measures Retransmit request message Duplicate filtering Invocation semantics Re-execute procedure or retransmit reply No Not applicable Not applicable Maybe Yes No Re-execute procedure At-least-once Yes Yes Retransmit reply At-most-once 11 Design issues for RMI (cont’d) • Exactly once semantics • every method is executed exactly once • At-least-once semantics • the invoker receives: either a result (method executed at least once) or an exception (no result received) • Transparency • remote calls look like local ones 12 Home work Figure 5.6 server client object Aproxy for B Request skeleton & dispatcher for B’s class remote object B Reply Remote Communication reference module module servant CommunicationRemote reference module module 13 Implementation of RMI • Communication module • Request-Reply protocol, client-server model • Remote reference module • Responsible for translating between local and remote object references and creating remote object references 14 Implementation for RMI • The RMI software (self study) • Proxy: makes remote method invocation transparent to the invoker by behaving like a local object, forwards a message to a remote object • Dispatcher: receives the Request message, chooses the appropriate method in the skeleton and passes on the Request message • Skeleton: the class of a remote object has a skeleton which implements the methods in the remote interfaces. Unmarshals the arguments in the Request message, invokes the corresponding method in the remote object. Then waits for invocation to complete and marshals the result in a Reply message 15 Remote procedure call client process server process Request client stub procedure client program Communication module Reply server stub procedure Communication dispatcher module service procedure 16