Interprocess Communication and Middleware Information Management NTU Sockets and Ports Node 1 Source: G. Coulouris et al., Distributed Systems: Concepts and Design Node 2 Information Management NTU Crossing Hosts/Platforms Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Purposes of Middleware Higher-level abstractions (RPC, RMI, …) Location transparency Independent of communication protocols Independent of hardware/operating systems Use of several programming languages Information Management NTU 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. Information Management NTU The Middleware layer * The operating system includes common network protocols (TCP/IP, …). Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Marshalling (Serialization) in CORBA CDR Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Request-Reply Communication Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU 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 the transport of other request-reply protocols. Source of figures: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Distributed Objects Client/Server: two-tier, three-tier, … Interfaces and Interface Definition Languages (IDLs) Object References (or Identifiers) and Remote Method Invocation (RMI) Object Activations and Persistency Exceptions: timeouts, … Synchronization, Replication, Migration, Garbage Collection, … Information Management NTU Interactions among Distributed Objects Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU A Remote Object and Its Interface Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU A CORBA IDL Example Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Client Proxy and Server Skeleton 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: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU 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. Information Management NTU 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 designe have to deal with. Source of the table: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Event-Based Systems The publish-subscribe paradigm publisher event and event type subscriber notification Heterogeneity Asynchrony Information Management NTU A Dealing Room System Dealer’s computer Dealer Dealer’s computer External source Notification Notification Notification Information provider Notification Notification Dealer Notification Notification Dealer’s computer Dealer’s computer Notification Information provider Notification Notification Dealer Dealer External source Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU An Architecture for Event Notification Event service subscriber object of interest 1. notification object of interest 2. object of interest observer notification subscriber notification observer 3. Source: G. Coulouris et al., Distributed Systems: Concepts and Design subscriber notification Information Management NTU The Roles for Observers/Agents Forwarding Filtering Patterns of Events Notification Mailboxes Information Management NTU Java Remote Interfaces Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU 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 For parameters of serializable types, including primitive types and classes that implement the serializable interface Information Management NTU A Java Server Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU A Java Server (cont.) Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU A Java Client Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU 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. Information Management NTU The CORBA Architecture * ** * The implementation repository allows server objects to be activated on dema ** The interface repository gives run-time type information, mainly for dynamic invocations. Source of the figure: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU 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 Information Management NTU 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. Information Management NTU 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. Information Management NTU Shape and Shapelist in CORBA IDL Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Java Interface Generated from ShapeList Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Java Implementation of Shapelist Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Java Implementation of ShapeList (cont.) Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU Java Implementation of a ShapeList Client Source: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU 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 Persistent Object Service Information Management NTU 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. Information Management NTU CORBA Naming Graph initial naming context ShapeList initial naming context B initial naming context XX P V C D E R Q Source: G. Coulouris et al., Distributed Systems: Concepts and Design S T U Information Management NTU 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: G. Coulouris et al., Distributed Systems: Concepts and Design Information Management NTU 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. Information Management NTU 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. Information Management NTU 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. Information Management NTU