Chapter 8 Distributed Objects and Components Distributed Systems

Chapter 8: Distributed Objects and Components Distributed Systems : Concepts and Design Dr. Ir. H. Sumijan, M. Sc Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 1 Distributed objects 2 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 2 IDL interfaces Shape and Shape. List struct Rectangle{ long width; long height; long x; long y; }; interface Shape { long get. Version() ; Graphical. Object get. All. State() ; }; 1 struct Graphical. Object { string type; Rectangle enclosing; boolean is. Filled; }; 2 3 // returns state of the Graphical. Object typedef sequence <Shape, 100> All; interface Shape. List { exception Full. Exception{ }; Shape new. Shape(in Graphical. Object g) raises (Full. Exception); All all. Shapes(); // returns sequence of remote object references long get. Version() ; }; 4 5 6 7 8 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 3 IDL module Whiteboard { struct Rectangle{. . . } ; struct Graphical. Object {. . . }; interface Shape {. . . }; typedef sequence <Shape, 100> All; interface Shape. List {. . . }; }; Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 4 IDL constructed types – 1 Type Examples Use sequence typedef sequence <Shape, 100> All; typedef sequence <Shape> All bounded and unbounded sequences of Shapes Defines a type for a variable-length sequence of elements of a specified IDL type. An upper bound on the length may be specified. string String name; typedef string<8> Small. String; unbounded and bounded sequences of characters Defines a sequences of characters, terminated by the null character. An upper bound on the length may be specified. array typedef octet unique. Id[12]; typedef Graphical. Object GO[10][8] Defines a type for a multi-dimensional fixed-length sequence of elements of a specified IDL type. this figure continues on the next slide Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 4 IDL constructed types – 2 Type Examples Use record struct Graphical. Object { string type; Rectangle enclosing; boolean is. Filled; }; Defines a type for a record containing a group of related entities. Structs are passed by value in arguments and results. enumerated enum Rand (Exp, Number, Name); The enumerated type in IDL maps a type name onto a small set of integer values. union Exp switch (Rand) { case Exp: string vote; case Number: long n; case Name: string s; }; The IDL discriminated union allows one of a given set of types to be passed as an argument. The header is parameterized by an enum, which specifies which member is in use. Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 5 The main components of the CORBA architecture client proxy program for A implementation repository ORB core or dynamic invocation Request Reply server interface repository object skeleton adapter ORB core Servant A or dynamic skeleton Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 6 CORBA Services (1) this figure continues on the next slide 8 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 6 CORBA Services (continued) 9 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 7 Java interfaces generated by idlj from CORBA interface Shape. List public interface Shape. List. Operations { Shape new. Shape(Graphical. Object g) throws Shape. List. Package. Full. Exception; Shape[] all. Shapes(); int get. Version(); } public interface Shape. List extends Shape. List. Operations, org. omg. CORBA. Object, org. omg. CORBA. portable. IDLEntity { } Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 8 Shape. List. Servant class of the Java server program for CORBA interface Shape. List import org. omg. CORBA. *; import org. omg. Portable. Server. POA; class Shape. List. Servant extends Shape. List. POA { private POA the. Rootpoa; private Shape the. List[]; private int version; private static int n=0; public Shape. List. Servant(POA rootpoa){ the. Rootpoa = rootpoa; // initialize the other instance variables } // continued on the next slide Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 8 continued public Shape new. Shape(Graphical. Object g) throws Shape. List. Package. Full. Exception { version++; Shape s = null; Shape. Servant shape. Ref = new Shape. Servant( g, version); try { org. omg. CORBA. Object ref = the. Roopoa. servant_to_reference(shape. Ref); s = Shape. Helper. narrow(ref); } catch (Exception e) {} if(n >=100) throw new Shape. List. Package. Full. Exception(); the. List[n++] = s; return s; } public Shape[] all. Shapes(){. . . } public int get. Version() {. . . } } 1 2 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 9 Java class Shape. List. Server import org. omg. Cos. Naming. *; import org. omg. Cos. Naming. Context. Package. *; import org. omg. CORBA. *; import org. omg. Portable. Server. *; public class Shape. List. Server { public static void main(String args[]) { try{ ORB orb = ORB. init(args, null); 1 POA rootpoa = POAHelper. narrow(orb. resolve_initial_references("Root. POA")); 2 rootpoa. the_POAManager(). activate(); 3 Shape. List. Servant SLSRef = new Shape. List. Servant(rootpoa); 4 org. omg. CORBA. Object ref = rootpoa. servant_to_reference(SLSRef); 5 Shape. List SLRef = Shape. List. Helper. narrow(ref); org. omg. CORBA. Object obj. Ref =orb. resolve_initial_references("Name. Service"); Naming. Context nc. Ref = Naming. Context. Helper. narrow(obj. Ref); 6 Name. Component nc = new Name. Component("Shape. List", ""); 7 Name. Component path[] = {nc}; 8 nc. Ref. rebind(path, SLRef); 9 orb. run(); 10 } catch (Exception e) {. . . } }} Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 10 Java client program for CORBA interfaces Shape and Shape. List import org. omg. Cos. Naming. *; import org. omg. Cos. Naming. Context. Package. *; import org. omg. CORBA. *; public class Shape. List. Client{ public static void main(String args[]) { try{ ORB orb = ORB. init(args, null); org. omg. CORBA. Object obj. Ref = orb. resolve_initial_references("Name. Service"); Naming. Context nc. Ref = Naming. Context. Helper. narrow(obj. Ref); Name. Component nc = new Name. Component("Shape. List", ""); Name. Component path [] = { nc }; Shape. List shape. List. Ref = Shape. List. Helper. narrow(nc. Ref. resolve(path)); Shape[] s. List = shape. List. Ref. all. Shapes(); Graphical. Object g = s. List[0]. get. All. State(); } catch(org. omg. CORBA. System. Exception e) {. . . } } 1 2 3 4 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 11 An example software architecture 15 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 12 The structure of a container 16 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 13 Application servers 17 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 14 Transaction attributes in EJB. 18 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 15 Invocation contexts in EJB 19 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 16 An example component configuration in Fractal 20 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 17 The structure of a Fractal component 21 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012

Figure 8. 18 Component and Content. Controller Interfaces in Fractal 22 Coulouris G. et al, 2012 : Distributed Systems: Concepts and Design (5 th Edition) 5 th Edition, Edition 5, © Addison-Wesley 2012
- Slides: 22