Slides for Chapter 5 Communication between distributed objects

Slides for Chapter 5: Communication between distributed objects From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley 2001

Figure 5. 1 Middleware layers Applications RMI, RPC and events Request reply protocol External data representation Operating System Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 Middleware layers

Figure 5. 2 CORBA IDL example // In file Person. idl struct Person { string name; string place; long year; }; interface Person. List { readonly attribute string listname; void add. Person(in Person p) ; void get. Person(in string name, out Person p); long number(); }; Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5. 3 Remote and local method invocations local remote invocation A B C local E invocation local invocation D Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 remote invocation F

Figure 5. 4 A remote object and its remote interface remoteobject remote interface { Data m 1 m 2 m 3 implementation of methods m 4 m 5 m 6 Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5. 5 Invocation semantics Fault tolerance measures Retransmit request message Duplicate filtering Invocation semantics Re-execute procedure or retransmit reply No Not applicable Yes No Re-execute procedure At-least-once Yes Retransmit reply At-most-once Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 Maybe

Figure 5. 6 The role of proxy and skeleton in remote method invocation server client object A proxy for B Request skeleton & dispatcher for B’s class remote object B Reply Communication Remote reference module Communication module Remote reference module Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5. 7 Role of client and server stub procedures in RPC client process server process Request client program Reply client stub procedure Communication module server stub procedure Communication dispatcher module Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 service procedure

Figure 5. 8 Files interface in Sun XDR const MAX = 1000; typedef int File. Identifier; typedef int File. Pointer; typedef int Length; struct Data { int length; char buffer[MAX]; }; struct writeargs { File. Identifier f; File. Pointer position; Data data; }; struct readargs { File. Identifier f; File. Pointer position; Length length; }; program FILEREADWRITE { version VERSION { void WRITE(writeargs)=1; Data READ(readargs)=2; } = 9999; Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 1 2

Figure 5. 9 Dealing room system External source Dealer’s computer Notification Information provider Notification Dealer’s computer Notification Information provider Notification Dealer External source Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5. 10 Architecture for distributed event notification Event service subscriber object of interest 1. notification object of interest 2. object of interest 3. notification observer subscriber notification Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5. 11 Java Remote interfaces Shape and Shape. List import java. rmi. *; import java. util. Vector; public interface Shape extends Remote { int get. Version() throws Remote. Exception; Graphical. Object get. All. State() throws Remote. Exception; 1 } public interface Shape. List extends Remote { Shape new. Shape(Graphical. Object g) throws Remote. Exception; 2 Vector all. Shapes() throws Remote. Exception; int get. Version() throws Remote. Exception; } Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5. 12 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. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5. 13 Java class Shape. List. Server with main method import java. rmi. *; public class Shape. List. Server{ public static void main(String args[]){ System. set. Security. Manager(new RMISecurity. Manager()); try{ Shape. List a. Shape. List = new Shape. List. Servant(); Naming. rebind("Shape List", a. Shape. List ); System. out. println("Shape. List server ready"); }catch(Exception e) { System. out. println("Shape. List server main " + e. get. Message()); } } } Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 1 2

Figure 5. 14 Java class Shape. List. Servant implements interface Shape. List import java. rmi. *; import java. rmi. server. Unicast. Remote. Object; import java. util. Vector; public class Shape. List. Servant extends Unicast. Remote. Object implements Shape. List { private Vector the. List; // contains the list of Shapes 1 private int version; public Shape. List. Servant()throws Remote. Exception{. . . } public Shape new. Shape(Graphical. Object g) throws Remote. Exception { 2 version++; Shape s = new Shape. Servant( g, version); 3 the. List. add. Element(s); return s; } public Vector all. Shapes()throws Remote. Exception{. . . } public int get. Version() throws Remote. Exception {. . . } } Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5. 15 Java client of Shape. List import java. rmi. *; import java. rmi. server. *; import java. util. Vector; public class Shape. List. Client{ public static void main(String args[]){ System. set. Security. Manager(new RMISecurity. Manager()); Shape. List a. Shape. List = null; try{ a. Shape. List = (Shape. List) Naming. lookup("//bruno. Shape. List") ; Vector s. List = a. Shape. List. all. Shapes(); } catch(Remote. Exception e) {System. out. println(e. get. Message()); }catch(Exception e) {System. out. println("Client: " + e. get. Message()); } } } Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 1 2

Figure 5. 16 Classes supporting Java RMI Remote. Object Remote. Server Activatable Unicast. Remote. Object <servant class> Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000
- Slides: 17