1 / 50

Interprocess Communication and Middleware

Interprocess Communication and Middleware. Yih-Kuen Tsay Dept. of Information Management National Taiwan University. Sockets and Ports. Node 2. Node 1. Source: Coulouris et al., Distributed Systems: Concepts and Design. Sockets and Ports (cont.).

gaura
Télécharger la présentation

Interprocess Communication and Middleware

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interprocess Communication and Middleware Yih-Kuen Tsay Dept. of Information Management National Taiwan University Interprocess Communication and Middleware -- 1

  2. Sockets and Ports Node 2 Node 1 Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 2

  3. Sockets and Ports (cont.) Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 3

  4. Purposes of Middleware • Higher-level abstractions (RPC, RMI, …) • Location transparency • Independent of communication protocols • Independent of hardware/operating systems • Use of several programming languages Interprocess Communication and Middleware -- 4

  5. Local vs. Remote Modules • Variables • Variables of a remote module cannot be directly accessed. • Parameter-passing Mechanisms • Call by reference, for input parameters, is not feasible for a remote procedure/method. • Pointers • Pointers of a remote module are not very useful for the local module. * For a module in some process, any other module in a different process, not necessarily a different computer, is a remote module. Interprocess Communication and Middleware -- 5

  6. The Middleware layer * The operating system includes common network protocols (TCP/IP, …). Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 6

  7. Marshalling (Serialization) in CORBA CDR Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 7

  8. Request-Reply Communication Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 8

  9. Dealing with Communication Failures • What causes a timeout for doOperation? • What should doOperation do after a timeout? • How should duplicate request messages be handled? • What should the server do if a reply message has been lost? • Idempotent operation • History • Some of the above problems still exist even if one uses TCP. Interprocess Communication and Middleware -- 9

  10. Request-Reply Communication Using HTTP An HTTP request message: An HTTP reply message: HTTP is not only a request-reply protocol but also has been used as the transport of other request-reply protocols. Source of figures: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 10

  11. The Distributed Object Model • Client/Server: two-tier, three-tier, etc. • Interfaces and Interface Definition Languages (IDLs) • Object References (or Identifiers) • Remote Method Invocation (RMI) • Garbage Collection • Exceptions (in particular, timeouts) Interprocess Communication and Middleware -- 11

  12. Interactions among Distributed Objects Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 12

  13. Interactions among Distributed Objects (cont.) Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 13

  14. A Remote Object and Its Interface A client proxy is also known as a client stub and server skeleton as server stub. The remote reference module is mainly for translating between local and remote object references. Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 14

  15. The RMI Software • Proxy: the local representative of the remote object. • Dispatcher: relays a request to the appropriate skeleton method. • Skeleton: unmarshals the request and invokes the corresponding method in the remote object. • These RMI components are generated automatically by an interface compiler. Interprocess Communication and Middleware -- 15

  16. RMI/RPC Semantics and Transparency Remote invocations may be made syntactically identical to local invocations, but they have far more implications that both the client and the server designers have to deal with. Source of the table: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 16

  17. A CORBA IDL Example Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 17

  18. Issues for RMI • Object Activations • Active vs. passive objects • Persistent Objects • Passivation, permanent deletion, … • Object Location • Garbage Collection • Cooperation between a local proxy and its server • Leases • Synchronization, Replication, Migration, … Interprocess Communication and Middleware -- 18

  19. Events • An event is an action performed that may cause changes to the state of an object. • For instance, pushing a button or entering a piece of text is an event. • The state change of an object may trigger state changes of other objects. • Objects responsible for state changes are notified of the event. Interprocess Communication and Middleware -- 19

  20. Event-Based Systems • The publish-subscribe paradigm • An object that generates events publishes the type of events. • Other objects subscribe to the type of events of interest. • A publisher sends subscribers a notification ---- an object representing a subscribed event, when the represented event occurs. • Two main characteristics: • Heterogeneous: with suitable RMI interfaces for receiving notifications • Asynchronous: decoupling publishers and subscribers Interprocess Communication and Middleware -- 20

  21. External Dealer’s computer Dealer’s computer source Dealer Notification Notification Dealer Information Notification Notification provider Notification Notification Notification Dealer’s computer Dealer’s computer Notification Information provider Notification Notification Dealer Dealer External source A Dealing Room System Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 21

  22. Event service subscriber object of interest 1. notification object of interest observer subscriber 2. notification notification object of interest observer subscriber 3. notification An Architecture for Event Notification NNote: Java-based event system (specification) Jini has a similar architecture. Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 22

  23. The Roles for Observers/Agents An observer decouples an object of interest from its subscribers. The roles it plays include: • Forwarding • Filtering • Allowing patterns of events to be subscribed • Notification mailboxes: a subscriber may check notifications intended for it later. Interprocess Communication and Middleware -- 23

  24. Java Remote Interfaces NNote: GraphicalObject must implement the Serializable interface. Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 24

  25. Parameter Passing in Java • By reference (passed as remote object references) • For parameters whose type is defined as a remote interface, one that extends Remote • By value (new objects created at local site) • For parameters of serializable types, including primitive types and classes that implement the serializable interface • Classes for arguments and results are downloaded automatically to the recipient. Interprocess Communication and Middleware -- 25

  26. The Naming Class of RMIRegistry Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 26

  27. A Java Server Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 27

  28. A Java Server (cont.) Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 28

  29. A Java Client Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 29

  30. CORBA • Defined by OMG to facilitate the development of distributed object-oriented systems. • Language-independency is achieved through the use of a standard interface definition language---the CORBA IDL. • An ORB (Object Request Broker) receives invocations from a client and deliver them to a target object. • The main communication protocol is GIOP (General Inter-ORB Protocol), known as IIOP when implemented over the Internet. Interprocess Communication and Middleware -- 30

  31. The CORBA Architecture * ** • * The implementation repository allows server objects to be activated on • demand. ** The interface repository gives run-time type information, mainly for dynamic invocations. Source of the figure: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 31

  32. The Object Adapter • Creates remote object references for CORBA objects • Maps the names of CORBA objects to their servants • Dispatches each remote invocation via a skeleton to the appropriate server object • Activate objects Interprocess Communication and Middleware -- 32

  33. CORBA Object Interfaces • Each object has an interface defined in IDL. • An interface defines the operations that can be called by the clients. • An interface can be implemented in one language and called from by another. • The CORBA IDL includes features such as inheritance of interfaces, exceptions, and compound data types. Interprocess Communication and Middleware -- 33

  34. CORBA Programming with Java • Define the interfaces using IDL and compile them into Java interfaces. • Implement the interfaces with Java classes. • Write a server main function that creates instances of these classes and then inform the underlying CORBA implementation. • Register the server. • Write a client main function to connect to the server and to use server’s objects. Interprocess Communication and Middleware -- 34

  35. Shape and Shapelist in CORBA IDL Interprocess Communication and Middleware -- 35 Source: Coulouris et al., Distributed Systems: Concepts and Design

  36. Java Interface Generated from ShapeList Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 36

  37. Java Implementation of Shapelist Interprocess Communication and Middleware -- 37 Source: Coulouris et al., Distributed Systems: Concepts and Design

  38. Java Implementation of ShapeList (cont.) Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 38

  39. Java Implementation of ShapeList (cont.) Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 39

  40. CORBA Services • Naming Service • locate objects by their names • Trading Service • locate objects by their attributes • Event Service and Notification Service • Security Service • Transaction Service and Concurrency Control Service • Persistent Object Service Interprocess Communication and Middleware -- 40

  41. The CORBA Naming Service • Allows (1) a name to be bound to an object and (2) that object to be found subsequently by resolving that name. • A name is a sequence of name components and is resolved within a given naming context. • The IDL interface NamingContext defines the core of the naming service. • A NamingContext object acts much like a directory in a filing system. Interprocess Communication and Middleware -- 41

  42. CORBA Naming Graph initial naming context initial naming context initial naming context XX ShapeList B V P C T D E S R Q U Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 42

  43. The NamingContext Interface (partial) struct NameComponent { string id; string kind; }; typedef sequence <NameComponent> Name; interface NamingContext { void bind (in Name n, in Object obj); binds the given name and remote object reference in my context. void unbind (in Name n); removes an existing binding with the given name. void bind_new_context(in Name n); creates a new naming context and binds it to a given name in my context. Object resolve (in Name n); looks up the name in my context and returns its remote object reference. void list (in unsigned long how_many, out BindingList bl, out BindingIterator bi); returns the names in the bindings in my context. }; Source: Coulouris et al., Distributed Systems: Concepts and Design Interprocess Communication and Middleware -- 43

  44. COM/DCOM • COM stands for Component Object Model. Its distributed version is referred to as DCOM. • It is a programming model for binary components reuse and a foundation of OLE (Object Linking and Embedding) and ActiveX controls. • COM interfaces are defined in the interface definition language IDL and compiled by MIDL.EXE. Interprocess Communication and Middleware -- 44

  45. COM Objects • All COM objects implement the IUnknown interface (defined in unknwn.idl) or one of its extended interfaces. • Methods of IUnknown: • QueryInterface: checks if the named interface is supported and, if so, returns the corresponding interface reference • AddRef • Release • A COM object may implement multiple interfaces. Interprocess Communication and Middleware -- 45

  46. How a COM Interface Works Source: Microsoft, The COM Specification. Interprocess Communication and Middleware -- 46

  47. Creation of a COM Object Source: Microsoft, The COM Specification. Interprocess Communication and Middleware -- 47

  48. Location Transparency in COM Source: Microsoft, The COM Specification. Interprocess Communication and Middleware -- 48

  49. GUIDS • To eliminate name collisions, all COM interfaces are assigned a unique binary name at design time that is the physical name of the interface. • These physical names are called Globally Unique Identifiers (GUIDs). • GUIDs are 128-bit extremely large numbers that are guaranteed to be unique in both time and space. Interprocess Communication and Middleware -- 49

  50. The IUnknown Interface [ object, uuid(00000000-0000-0000-C000-000000000046), pointer_default(unique) ] interface IUnknown { HRESULT QueryInterface([in] REFIID iid, [out] void **ppv) ; ULONG AddRef(void) ; ULONG Release(void); } Interprocess Communication and Middleware -- 50

More Related