Download presentation
Presentation is loading. Please wait.
Published byLester Golden Modified over 9 years ago
1
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 1 Franco Gasperoni gasperon@act-europe.frhttp://libre.act-europe.fr
2
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 2 Copyright Notice © ACT Europe under the GNU Free Documentation License© ACT Europe under the GNU Free Documentation License Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; provided its original author is mentioned and the link to http://libre.act-europe.fr/ is kept at the bottom of every non-title slide. A copy of the license is available at:Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; provided its original author is mentioned and the link to http://libre.act-europe.fr/ is kept at the bottom of every non-title slide. A copy of the license is available at: http://www.fsf.org/licenses/fdl.htmlhttp://www.fsf.org/licenses/fdl.html
3
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 3
4
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 4 IntroductionIntroduction Distributed Prog. ParadigmsDistributed Prog. Paradigms Distributed Object TechnologiesDistributed Object Technologies ConclusionConclusion
5
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 5 Non-distributed application = single processNon-distributed application = single process –running on a single computer Distributed application = several communicating processesDistributed application = several communicating processes –processes often run on different computers –computers are connected through a network
6
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 6 process Single Process Application body spec main body spec body spec
7
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 7 Distributed Application body spec body spec body spec main process body spec body spec body spec main process body spec body spec body spec main process Application
8
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 8 All Processes Can Run on the Same Computer body spec body spec body spec main process body spec body spec body spec main process body spec body spec body spec main process
9
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 9 Or They can run on Different Computers body spec body spec body spec main process body spec body spec body spec main process body spec body spec body spec main process
10
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 10 In All Cases This Requires Inter-Process Communication body spec body spec body spec main process body spec body spec body spec main process body spec body spec body spec main process
11
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 11 body spec body spec body spec main process body spec body spec body spec main process body spec body spec body spec main process ? ?
12
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 12 The Main Topic of this Lecture How distributed processes communicate at the programming levelHow distributed processes communicate at the programming level How the “software chunks” of a distributed app can interact.How the “software chunks” of a distributed app can interact. This lecture will NOT teach you how they communicate at theThis lecture will NOT teach you how they communicate at the –physical level –or protocol level
13
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 13 Remember OSI Layers ? Application Presentation Transport Network Data Link Physical Session Application Presentation Transport Network Data Link Physical Session }{ This is what we will look at
14
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 14 Application Presentation Transport Network Data Link Physical Session Telnet, ftp, … Sending data in platform indep. manner Establish communication bw processes TCP, UDP,... IP, X.25,... Network drivers The wire
15
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 15 Why Distributed Apps ? Multiuser apps (e.g. e-mail, ftp)Multiuser apps (e.g. e-mail, ftp) Sharing data (e.g. www, airline reservation)Sharing data (e.g. www, airline reservation) Sharing resources (e.g. printers)Sharing resources (e.g. printers) Fault toleranceFault tolerance App may be inherently distributed (cell phones, ATM machines, …)App may be inherently distributed (cell phones, ATM machines, …)
16
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 16 Distributed Prog. Is Hard Multiple failure modesMultiple failure modes –each individual process can fail (bugs, machine crash..) –the network can go ashtray Security issuesSecurity issues –is someone else listening Testing & debuggingTesting & debugging Distributed prog. technologies not fully matureDistributed prog. technologies not fully mature –interoperability is still an issue
17
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 17 IntroductionIntroduction Distributed Prog. ParadigmsDistributed Prog. Paradigms –Message Sending (Sockets) –Remote Procedure Calls –Distributed Objects
18
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 18 body process spec process ? How to Formalize the Notion of an Interface in a Distributed Environment ?
19
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 19 How to Formalize the Notion of an Interface in a Distributed Environment ? Answer 1: don’t formalize it, send a messageAnswer 1: don’t formalize it, send a message –e.g. sockets Answer 2: Remote Procedure Call (RPC)Answer 2: Remote Procedure Call (RPC) Answer 3: RPCs + Distributed ObjectsAnswer 3: RPCs + Distributed Objects –Language dependent: Ada 95, Java RMI –Language independent: CORBA, COM/DCOM
20
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 20 A Simple Comparison Object-OrientedProgramming Programming with GOTOs StructuredProgramming Distributed Objects Message Sending (sockets) RPCs
21
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 21 Some Terminology body spec Client: the code that made the request for service Server: the code that answered the request
22
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 22 Answer 1: Don’t Formalize It Send a Message (e.g. Sockets) Send (…, Bytes); Receive(…, & Bytes [ ]); Receive (…, & Bytes [ ]);
23
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 23 Client Process time Server Process time Wait for connection Compute Send bytes Close socket Open socket Get bytes Open socket Compute Send bytes Wait for reply Close socket Get bytes raw bytes
24
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 24 What are the problems with this approach ?
25
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 25 Problems with Sockets/Message Sending No interfaces - very low-level programmingNo interfaces - very low-level programming –does not scale up Sockets exchange bytesSockets exchange bytes –How do you exchange more complex data structures ? –How do you handle heterogeneous systems ?
26
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 26 ClientClient time ServerServer Answer request Compute Wait for reply Compute Get response Send request data Send response data Doesn’t this look familiar ? Wait for request
27
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 27 Answer 2: Remote Procedure Calls R := Foo (123); function Foo (X : Integer) (X : Integer) return Float; return Float;
28
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 28 ClientClient time ServerServer function Foo (X: Integer) return Float return Floatis …begin … return …; end Foo; Wait for reply Compute Get result R := Foo (123); send parameters send result or modified parameters RPC
29
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 29 RPCs Remote procedure call completely handled by the systemRemote procedure call completely handled by the system Parameters and results passed across the network without programmer interventionParameters and results passed across the network without programmer intervention Heterogeneity handled transparentlyHeterogeneity handled transparently
30
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 30 Where is the Magic ? R := Foo (123); function Foo (X : Integer) (X : Integer) return Float; return Float;
31
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 31 Client Stub & Server Skeleton From the server spec the system generates a client stub:From the server spec the system generates a client stub: –Marshals the parameters –Sends the request over the network –Waits for the response and unmarshals the result From the server spec (and server body) the system generates a server skeletonFrom the server spec (and server body) the system generates a server skeleton –Receives the RPC request –unmarshals the parameters –Selects and calls the appropriate subprogram –Marshals the result and sends the response
32
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 32 SpecialCompiler SpecialCompiler Stubs & Skeletons function Foo (X : Integer) (X : Integer) return Float; return Float; Client Stub Server Skeleton function Foo (X: Integer) return Float return Floatis … end Foo;
33
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 33 R := Foo (123); function Foo (X : Integer) (X : Integer) return Float; return Float; Client Stub ServerSkeleton function Foo (X: Integer) return Float return Floatis … end Foo;
34
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 34 network ClientClientServerServer function Foo (X : Integer) return Float is... ClientClientServerServer function Foo network call return call return parametermarshalling call return resultunmarshalling resultmarshalling resultunmarshalling Client Stub Server Skeleton
35
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 35 Enhancing RPCs ExceptionsExceptions –exceptions raised in the callee canbe transmitted to the caller over the network Asynchronous callsAsynchronous calls –the caller does not need to wait for the result from the callee (one way procedure calls) Pointers on remote proceduresPointers on remote procedures –RPC through a pointer. At the point of call the spec of the callee is known but not its location or identity
36
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 36 Service Related to RPCs: Naming Records the location of the various processesRecords the location of the various processes –location of client stubs and server skeletons This service is called via RPCThis service is called via RPC To solve the circularity problem the naming service is at a known machine addressTo solve the circularity problem the naming service is at a known machine address
37
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 37 Answer 3: Distributed Objects A: Alert’Class := Get_Alert; … Handle (A); type Alert is tagged record…; procedure Handle (A : in out Alert); DynamicBinding type Medium_Alert is new Alert...; procedure Handle (A : in out Medium_Alert); ?
38
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 38 IntroductionIntroduction Distributed Prog. ParadigmsDistributed Prog. Paradigms Distributed Object TechnologiesDistributed Object Technologies –Language Dependent: Ada 95 –Language Independent: CORBA
39
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 39 Language Dependent Distributed Objects Paradigm body spec The same programming language is used to write the spec of the distributed services the spec of the distributed services the implementation of the server code the implementation of the server code the implementation of the client code the implementation of the client code
40
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 40 Language Independent Distributed Objects Paradigm Client language A Server language B spec Different languages are used to write: the spec of the distributed services the spec of the distributed services the implementation of the server code the implementation of the server code the implementation of the client code the implementation of the client code language indep. spec
41
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 41 IntroductionIntroduction Distributed Prog. ParadigmsDistributed Prog. Paradigms Distributed Object TechnologiesDistributed Object Technologies –Language Dependent: Ada 95 –Language Independent: CORBA
42
42 Ada 95 Distributed Systems Annex
43
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 43 Ada 95 Distributed Programming Ada 95 partition(process) multi-partitions Core Annex E A partition comprises one or more Ada packages
44
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 44 Supported Paradigms Client/Server Paradigm (RPC)Client/Server Paradigm (RPC) –Synchronous / Asynchronous –Static / Dynamic Distributed ObjectsDistributed Objects Shared MemoryShared Memory
45
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 45 Ada Distributed Application No need for a separate interfacing language as in CORBA (IDL)No need for a separate interfacing language as in CORBA (IDL) –Ada is the IDL Some packages categorized using pragmasSome packages categorized using pragmas –Remote_Call_Interface (RCI) –Remote_Types –Shared_Passive (SP) All packages except RCI & SP duplicated on partitions using themAll packages except RCI & SP duplicated on partitions using them
46
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 46 Remote_Call_Interface (RCI) Allows subprograms to be called remotelyAllows subprograms to be called remotely –Statically bound RPCs –Dynamically bound RPCs (remote access to subprogram)
47
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 47 Remote_Types Allows the definition of a remote access typesAllows the definition of a remote access types –Remote access to subprogram –Remote reference to objects (ability to do dynamically dispatching calls across the network)
48
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 48 Shared_Passive A Shared_Passive package contains variables that can be accessed from distinct partitionsA Shared_Passive package contains variables that can be accessed from distinct partitions Allows support of shared distributed memoryAllows support of shared distributed memory Allows persistence on some implementationsAllows persistence on some implementations
49
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 49 1. Write app as if non distributed. 2. Identify remote procedures, shared variables, and distributed objects & categorize packages. 3. Build & test non-distributed application. 4. Write a configuration file for partitionning your app. 5. Build partitions & test distributed app. pack age P is. package P is. package P is. package P is. pack age P is. package P is. pack age P is. package P is. pac kag e P is. package P is. Building a Distributed App in Ada 95
50
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 50 Remote_Call_Interface An Example
51
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 51 package Types is type Device is ( Furnace, Boiler,…); type Device is ( Furnace, Boiler,…); type Pressure is …; type Pressure is …; type Temperature is …; type Temperature is …; end Types ; with Types ; use Types ; package Sensors is function Get_P ( D: Device ) return Pressure ; function Get_P ( D: Device ) return Pressure ; function Get_T ( D: Device ) return Temperature ; function Get_T ( D: Device ) return Temperature ; end Sensors ; with Types ; use Types ; package Sensors is function Get_P ( D: Device ) return Pressure ; function Get_P ( D: Device ) return Pressure ; function Get_T ( D: Device ) return Temperature ; function Get_T ( D: Device ) return Temperature ; end Sensors ; with Types ; use Types ; with Sensors ; procedure Client_1 is P := Sensors.Get_P (Boiler); P := Sensors.Get_P (Boiler); with Types ; use Types ; with Sensors ; procedure Client_2 is T := Sensors.Get_T (Furnace); T := Sensors.Get_T (Furnace); Write App
52
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 52 package Types is pragma Pure; pragma Pure; type Device is ( Furnace, Boiler,…); type Device is ( Furnace, Boiler,…); type Pressure is …; type Pressure is …; type Temperature is …; type Temperature is …; end Types ; with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P (D:Device) return Pressure ; function Get_P (D:Device) return Pressure ; function Get_T (D:Device) return Temperature ; function Get_T (D:Device) return Temperature ; end Sensors ; with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P (D:Device) return Pressure ; function Get_P (D:Device) return Pressure ; function Get_T (D:Device) return Temperature ; function Get_T (D:Device) return Temperature ; end Sensors ; with Types ; use Types ; with Sensors ; procedure Client_1 is P := Sensors.Get_P (Boiler); P := Sensors.Get_P (Boiler); with Types ; use Types ; with Sensors ; procedure Client_2 is T := Sensors.Get_T (Furnace); T := Sensors.Get_T (Furnace); Categorize
53
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 53 Build & Test package Types is pragma Pure; pragma Pure; type Device is ( Furnace, Boiler,…); type Device is ( Furnace, Boiler,…); type Pressure is …; type Pressure is …; type Temperature is …; type Temperature is …; end Types ; with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P (D:Device) return Pressure ; function Get_P (D:Device) return Pressure ; function Get_T (D:Device) return Temperature ; function Get_T (D:Device) return Temperature ; end Sensors ; with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P (D:Device) return Pressure ; function Get_P (D:Device) return Pressure ; function Get_T (D:Device) return Temperature ; function Get_T (D:Device) return Temperature ; end Sensors ; with Types ; use Types ; with Sensors ; procedure Client_1 is P := Sensors.Get_P (Boiler); P := Sensors.Get_P (Boiler);
54
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 54 Build & Test package Types is pragma Pure; pragma Pure; type Device is ( Furnace, Boiler,…); type Device is ( Furnace, Boiler,…); type Pressure is …; type Pressure is …; type Temperature is …; type Temperature is …; end Types ; with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P (D:Device) return Pressure ; function Get_P (D:Device) return Pressure ; function Get_T (D:Device) return Temperature ; function Get_T (D:Device) return Temperature ; end Sensors ; with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P (D:Device) return Pressure ; function Get_P (D:Device) return Pressure ; function Get_T (D:Device) return Temperature ; function Get_T (D:Device) return Temperature ; end Sensors ; with Types ; use Types ; with Sensors ; procedure Client_2 is T := Sensors.Get_T (Furnace); T := Sensors.Get_T (Furnace);
55
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 55 configuration Config_1 is Node_A : Partition := ( Sensors ); Node_A : Partition := ( Sensors ); Node_B : Partition := ( Client_1 ); Node_B : Partition := ( Client_1 ); Node_C : Partition := ( Client_2 ); Node_C : Partition := ( Client_2 ); end Config_1 ; Partition
56
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 56 Partition Node_A Node_B Node_C
57
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 57 package Types is pragma Pure; pragma Pure; type Device is …; type Device is …; type Pressure is …; type Pressure is …; type Temperature is …; type Temperature is …; end Types ; DUPLICATED Node_A Node_B Node_C
58
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 58 with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P(…) return Pressure ; function Get_P(…) return Pressure ; function Get_T(…) return Temperature ; function Get_T(…) return Temperature ; end Sensors ; with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P(…) return Pressure ; function Get_P(…) return Pressure ; function Get_T(…) return Temperature ; function Get_T(…) return Temperature ; end Sensors ; STUBS Node_A Node_B Node_C
59
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 59 with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P(…) return Pressure ; function Get_P(…) return Pressure ; function Get_T(…) return Temperature ; function Get_T(…) return Temperature ; end Sensors ; with Types ; use Types ; package Sensors is pragma Remote_Call_Interface; pragma Remote_Call_Interface; function Get_P(…) return Pressure ; function Get_P(…) return Pressure ; function Get_T(…) return Temperature ; function Get_T(…) return Temperature ; end Sensors ; SKELETON + BODY Node_A Node_B Node_C
60
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 60 ….:= Sensors.Get_P (Boiler); Sensors.Get_P Stub Marshal Arguments SendReceive Sensors.Get_P body Unmarshal Arguments Skeleton Select body Node_BNode_A
61
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 61 with Types; use Types; package Sensors is Remote_Call_Interface pragma Remote_Call_Interface; … procedure Log (D : Device; P : Pressure); Asynchronous pragma Asynchronous (Log); end Bank; Asynchronous Calls + returns immediately + exceptions are lost + parameters must be in
62
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 62 Remote_Types An Example
63
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 63 package Alerts is type Alert is abstract tagged private; type Alert is abstract tagged private; type Alert_Ref is access all Alert’Class; type Alert_Ref is access all Alert’Class; procedure Handle (A : access Alert); procedure Handle (A : access Alert); procedure Log (A : access Alert) is abstract ; procedure Log (A : access Alert) is abstract ; private private...... end Alerts; package Alerts.Pool is procedure Register (A : Alert_Ref); procedure Register (A : Alert_Ref); function Get_Alert return Alert_Ref; function Get_Alert return Alert_Ref; end Medium; with Alerts, Alerts.Pool; use Alerts; procedure Process_Alerts is begin loop loop Handle (Pool.Get_Alert); Handle (Pool.Get_Alert); end loop; end loop; end Process_Alerts; Write App
64
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 64 package Alerts.Low is type Low_Alert is new Alert with private; type Low_Alert is new Alert with private; procedure Log (A : access Low_Alert); procedure Log (A : access Low_Alert);private...... end Alerts.Low; with Alerts.Pool; use Alerts.Pool; package body Alerts.Low is......begin Register ( new Low_Alert); Register ( new Low_Alert); end Alerts. Low;
65
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 65 package Alerts.Medium is type Medium_Alert is new Alert with private; type Medium_Alert is new Alert with private; procedure Handle (A : access Medium_Alert); procedure Handle (A : access Medium_Alert); procedure Log (A : access Medium_Alert); procedure Log (A : access Medium_Alert);private...... end Alerts. Medium; with Alerts.Pool; use Alerts.Pool; package body Alerts.Medium is......begin Register ( new Medium_Alert); Register ( new Medium_Alert); end Alerts. Medium;
66
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 66 package Alerts is pragmaRemote_Types pragma Remote_Types; type Alert is abstract tagged private; type Alert is abstract tagged private; type Alert_Ref is access all Alert’Class; type Alert_Ref is access all Alert’Class; procedure Handle (A : access Alert); procedure Handle (A : access Alert); procedure Log (A : access Alert) is abstract ; procedure Log (A : access Alert) is abstract ; private private...... end Alerts; package Alerts.Pool is pragma Remote_Call_Interface; pragma Remote_Call_Interface; procedure Register (A : Alert_Ref); procedure Register (A : Alert_Ref); function Get_Alert return Alert_Ref; function Get_Alert return Alert_Ref; end Medium; with Alerts, Alerts.Pool; use Alerts; procedure Process_Alerts is begin loop loop Handle (Pool.Get_Alert); Handle (Pool.Get_Alert); end loop; end loop; end Process_Alerts; Categorize
67
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 67 package Alerts.Low is pragmaRemote_Types pragma Remote_Types; type Low_Alert is new Alert with private; type Low_Alert is new Alert with private; procedure Log (A : access Low_Alert); procedure Log (A : access Low_Alert);private...... end Alerts.Low; package Alerts.Medium is pragmaRemote_Types pragma Remote_Types; type Medium_Alert is new Alert with private; type Medium_Alert is new Alert with private; procedure Handle (A : access Medium_Alert); procedure Handle (A : access Medium_Alert); procedure Log (A : access Medium_Alert); procedure Log (A : access Medium_Alert);private...... end Alerts. Medium;
68
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 68 package Alerts is pragmaRemote_Types pragma Remote_Types; type Alert is abstract tagged private; type Alert is abstract tagged private; type Alert_Ref is access all Alert’Class; type Alert_Ref is access all Alert’Class; procedure Handle (A : access Alert); procedure Handle (A : access Alert); procedure Log (A : access Alert) is abstract ; procedure Log (A : access Alert) is abstract ; private private...... end Alerts; package Alerts.Pool is pragma Remote_Call_Interface; pragma Remote_Call_Interface; procedure Register (A : Alert_Ref); procedure Register (A : Alert_Ref); function Get_Alert return Alert_Ref; function Get_Alert return Alert_Ref; end Medium; with Alerts, Alerts.Pool; use Alerts; procedure Process_Alerts is begin loop loop Handle (Pool.Get_Alert); Handle (Pool.Get_Alert); end loop; end loop; end Process_Alerts; Build & Test package Alerts.Low is pragmaRemote_Types pragma Remote_Types; type Low_Alert is new Alert with private; type Low_Alert is new Alert with private; procedure Log (A : access Low_Alert); procedure Log (A : access Low_Alert);private...... end Alerts.Low; package Alerts.Medium is pragmaRemote_Types pragma Remote_Types; type Medium_Alert is new Alert with private; type Medium_Alert is new Alert with private; procedure Handle (A : access Medium_Alert); procedure Handle (A : access Medium_Alert); procedure Log (A : access Medium_Alert); procedure Log (A : access Medium_Alert);private...... end Alerts. Medium;
69
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 69 configuration Config_2 is Node_AL : Partition := ( Alerts.Low ); Node_AL : Partition := ( Alerts.Low ); Node_AM : Partition := ( Alerts.Medium ); Node_AM : Partition := ( Alerts.Medium ); Node_B : Partition := ( Alerts.Pool ); Node_B : Partition := ( Alerts.Pool ); Node_C : Partition := ( Process_Alerts ); Node_C : Partition := ( Process_Alerts ); end Config_2 ; Partition
70
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 70 What Happens When Executing the Distributed Program ?
71
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 71 with Alerts, Alerts.Pool; use Alerts; procedure Process_Alerts is begin loop loop Handle (Pool.Get_Alert); Handle (Pool.Get_Alert); end loop; end loop; end Process_Alerts; package Alerts.Low is pragmaRemote_Types pragma Remote_Types; type Low_Alert is new Alert with private; type Low_Alert is new Alert with private; procedure Log (A : access Low_Alert); procedure Log (A : access Low_Alert);private...... end Alerts.Low; package Alerts.Pool is pragma Remote_Call_Interface; pragma Remote_Call_Interface; procedure Register (A : Alert_Ref); procedure Register (A : Alert_Ref); function Get_Alert return Alert_Ref; function Get_Alert return Alert_Ref; end Medium; package Alerts.Medium is pragmaRemote_Types pragma Remote_Types; type Medium_Alert is new Alert with private; type Medium_Alert is new Alert with private; procedure Handle (A : access Medium_Alert); procedure Handle (A : access Medium_Alert); procedure Log (A : access Medium_Alert); procedure Log (A : access Medium_Alert);private...... end Alerts. Medium; Node_AL Node_AM Node_BNode_C Step 1: A Low_Alert object in Node_AL registers itself with Node_B
72
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 72 with Alerts, Alerts.Pool; use Alerts; procedure Process_Alerts is begin loop loop Handle (Pool.Get_Alert); Handle (Pool.Get_Alert); end loop; end loop; end Process_Alerts; package Alerts.Low is pragmaRemote_Types pragma Remote_Types; type Low_Alert is new Alert with private; type Low_Alert is new Alert with private; procedure Log (A : access Low_Alert); procedure Log (A : access Low_Alert);private...... end Alerts.Low; package Alerts.Pool is pragma Remote_Call_Interface; pragma Remote_Call_Interface; procedure Register (A : Alert_Ref); procedure Register (A : Alert_Ref); function Get_Alert return Alert_Ref; function Get_Alert return Alert_Ref; end Medium; package Alerts.Medium is pragmaRemote_Types pragma Remote_Types; type Medium_Alert is new Alert with private; type Medium_Alert is new Alert with private; procedure Handle (A : access Medium_Alert); procedure Handle (A : access Medium_Alert); procedure Log (A : access Medium_Alert); procedure Log (A : access Medium_Alert);private...... end Alerts. Medium; Node_AL Node_AM Node_BNode_C Step 2: A Medium_Alert object in Node_AM registers itself with Node_B
73
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 73 with Alerts, Alerts.Pool; use Alerts; procedure Process_Alerts is begin loop loop Handle (Pool.Get_Alert); Handle (Pool.Get_Alert); end loop; end loop; end Process_Alerts; package Alerts.Low is pragmaRemote_Types pragma Remote_Types; type Low_Alert is new Alert with private; type Low_Alert is new Alert with private; procedure Log (A : access Low_Alert); procedure Log (A : access Low_Alert);private...... end Alerts.Low; package Alerts.Pool is pragma Remote_Call_Interface; pragma Remote_Call_Interface; procedure Register (A : Alert_Ref); procedure Register (A : Alert_Ref); function Get_Alert return Alert_Ref; function Get_Alert return Alert_Ref; end Medium; package Alerts.Medium is pragmaRemote_Types pragma Remote_Types; type Medium_Alert is new Alert with private; type Medium_Alert is new Alert with private; procedure Handle (A : access Medium_Alert); procedure Handle (A : access Medium_Alert); procedure Log (A : access Medium_Alert); procedure Log (A : access Medium_Alert);private...... end Alerts. Medium; Node_AL Node_AM Node_BNode_C Step 3: Process_Alerts in Node_C does an RPC to Get_Alert in Node_B
74
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 74 with Alerts, Alerts.Pool; use Alerts; procedure Process_Alerts is begin loop loop Handle (Pool.Get_Alert); Handle (Pool.Get_Alert); end loop; end loop; end Process_Alerts; package Alerts.Low is pragmaRemote_Types pragma Remote_Types; type Low_Alert is new Alert with private; type Low_Alert is new Alert with private; procedure Log (A : access Low_Alert); procedure Log (A : access Low_Alert);private...... end Alerts.Low; package Alerts.Pool is pragma Remote_Call_Interface; pragma Remote_Call_Interface; procedure Register (A : Alert_Ref); procedure Register (A : Alert_Ref); function Get_Alert return Alert_Ref; function Get_Alert return Alert_Ref; end Medium; package Alerts.Medium is pragmaRemote_Types pragma Remote_Types; type Medium_Alert is new Alert with private; type Medium_Alert is new Alert with private; procedure Handle (A : access Medium_Alert); procedure Handle (A : access Medium_Alert); procedure Log (A : access Medium_Alert); procedure Log (A : access Medium_Alert);private...... end Alerts. Medium; Node_AL Node_AM Node_BNode_C Step 4: Get_Alert returns a pointer to an Alert object (Low_Alert or Medium_Alert)
75
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 75 with Alerts, Alerts.Pool; use Alerts; procedure Process_Alerts is begin loop loop Handle (Pool.Get_Alert); Handle (Pool.Get_Alert); end loop; end loop; end Process_Alerts; package Alerts.Low is pragmaRemote_Types pragma Remote_Types; type Low_Alert is new Alert with private; type Low_Alert is new Alert with private; procedure Log (A : access Low_Alert); procedure Log (A : access Low_Alert);private...... end Alerts.Low; package Alerts.Pool is pragma Remote_Call_Interface; pragma Remote_Call_Interface; procedure Register (A : Alert_Ref); procedure Register (A : Alert_Ref); function Get_Alert return Alert_Ref; function Get_Alert return Alert_Ref; end Medium; package Alerts.Medium is pragmaRemote_Types pragma Remote_Types; type Medium_Alert is new Alert with private; type Medium_Alert is new Alert with private; procedure Handle (A : access Medium_Alert); procedure Handle (A : access Medium_Alert); procedure Log (A : access Medium_Alert); procedure Log (A : access Medium_Alert);private...... end Alerts. Medium; Node_AL Node_AM Node_BNode_C Step 5: Node_C performs a dispatching RPC. It calls Handle in Node_AL or Node_AM ?
76
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 76 What Does Get_Alert Return ? Pointer Machine Address of Alert object on the Machine Get_Alert
77
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 77 Remote Access to Class Wide Type At compile time:At compile time: –You do not know what operation you’ll dispatch to –On what node that operations will be executed on
78
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 78 IntroductionIntroduction Distributed Prog. ParadigmsDistributed Prog. Paradigms Distributed Object TechnologiesDistributed Object Technologies –Language Dependent: Ada 95 –Language Independent: CORBA
79
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 79 Language Independent Distributed Objects Paradigm Client language A Server language B spec Different languages are used to write: the spec of the distributed services the spec of the distributed services the implementation of the server code the implementation of the server code the implementation of the client code the implementation of the client code language indep. Spec (IDL)
80
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 80 CORBA Interfaces In Corba interfaces are described in IDLIn Corba interfaces are described in IDL –(Interface Description Language) The IDL is independent of programming languagesThe IDL is independent of programming languages Each interface is translated inEach interface is translated in –Language A used for the client (client stub) –Language B used for the server (server skeleton) To implement the server the programmer completes the skeleton in language BTo implement the server the programmer completes the skeleton in language B To implement the client the programmer uses the services provided by th estub in language ATo implement the client the programmer uses the services provided by th estub in language A
81
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 81 The CORBA Architecture RPC go through the ORBRPC go through the ORB –(Object Request Broker) The ORB is a software busThe ORB is a software bus ORBs communicate with a set of standardised protocolsORBs communicate with a set of standardised protocols –IIOP, GIOP
82
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 82 The IDL Syntax similar to C++ with some Ada additionsSyntax similar to C++ with some Ada additions IDL must be translatable in various prog. LanguagesIDL must be translatable in various prog. Languages – Ada, C, C++, Java, … There are limitations in what you can write in the IDLThere are limitations in what you can write in the IDL Programmer must understand how the IDL is translated in the host languageProgrammer must understand how the IDL is translated in the host language –to complete the server skeleton –to use the client stub
83
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 83 Example package M is pragma Remote_Types; pragma Remote_Types; type T is tagged …; type T is tagged …; procedure P (O : in access T); procedure P (O : in access T); end M; module M { interface T { interface T { void P (); void P (); }; };};
84
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 84 Exemple module Echo { echoString string echoString (in string mesg); }; Module foo { interface Buffer { exception Empty; void put (in string content); string get() raises (Empty); } };
85
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 85 Example of IDL translation in Ada with Corba.Object; package Echo is type Ref is new Corba.Object.Ref with null record; function To_Echo (Self : in Corba.Object.Ref’Class) return Ref’Class; function To_Ref (From : in Corba.Any) return Ref; function To_Any (From : in Ref) return Corba.Any; echoString function echoString (Self : in Ref; msg : in Corba.String) return Corba.String; Null_Ref : constant Ref := (Corba.Object.Null_Ref with null record); Echo_R_Id : constant Corba.RepositoryId := Corba.To_Unbounded_String («IDL:Echo:1.0»); end Echo;
86
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 86 CORBA Services The CORBA core services are very fewThe CORBA core services are very few Lot ’s of external servicesLot ’s of external services –Naming (distributed and hierarchical) –Persistance –Transaction –Security –...
87
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 87 ApplicationObjects Object Services CommonFacilities O R B Code you write Domain Independent Domain Specific
88
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 88 IntroductionIntroduction Distributed Prog. ParadigmsDistributed Prog. Paradigms Distributed Object TechnologiesDistributed Object Technologies ConclusionConclusion
89
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 89 Developing a Distributed App Using network services directlyUsing network services directly –Sockets Using middlewareUsing middleware –CORBA –COM/DCOM Using a distributed languageUsing a distributed language –Ada 95 DSA –Java RMI Similar issues with Tasking
90
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 90 Impact on Development Phases GeneralDesign DistributedDesign Coding Testing
91
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 91 Sockets GeneralDesign DistributedDesign Coding Testing Ad Hoc Very low level Distributed mode only
92
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 92 Coding Very low level Everything must be done with socketsEverything must be done with sockets Data marshaling/unmarshallingData marshaling/unmarshalling Handle heterogeneous systems directlyHandle heterogeneous systems directly
93
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 93 CORBA GeneralDesign DistributedDesign Coding Testing IDL Must invoke high-level services directly Distributed mode only
94
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 94 Ada 95 DSA GeneralDesign DistributedDesign Coding Testing Ada 95 distributed & non-distributed Regular Ada Coding
95
http://libre.act-europe.fr © ACT Europe under the GNU Free Documentation License 95 Ada 95 DSA & CORBA: Benefits Save developer’s time, in socket programming:Save developer’s time, in socket programming: –Defining a client/server protocol –Defining a message format –Marshalling of data –Unmarshalling data Raise the level of abstractionRaise the level of abstraction
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.