420 likes | 553 Views
Interprocess Communication and Middleware. Sockets and Ports. Node 2. Node 1. Source: G. Coulouris et al., Distributed Systems: Concepts and Design. Crossing Hosts/Platforms. Source: G. Coulouris et al., Distributed Systems: Concepts and Design. Purposes of Middleware.
E N D
Sockets and Ports Node 2 Node 1 Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
Crossing Hosts/Platforms Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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, …). Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
Marshalling (Serialization) in CORBA CDR Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
Request-Reply Communication Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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. Information Management NTU Source of figures: G. Coulouris et al., Distributed Systems: Concepts and Design
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 Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
A Remote Object and Its Interface Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
A CORBA IDL Example Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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. Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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 designers have to deal with. Information Management NTU Source of the table: G. Coulouris et al., Distributed Systems: Concepts and Design
Event-Based Systems • The publish-subscribe paradigm • publisher • event and event type • subscriber • notification • Heterogeneity • Asynchrony Information Management NTU
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 Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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 Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
The Roles for Observers/Agents • Forwarding • Filtering • Patterns of Events • Notification Mailboxes Information Management NTU
Java Remote Interfaces Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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 Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
A Java Server (cont.) Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
A Java Client Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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 demand. ** The interface repository gives run-time type information, mainly for dynamic invocations. Information Management NTU Source of the figure: G. Coulouris et al., Distributed Systems: Concepts and Design
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 Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
Java Interface Generated from ShapeList Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
Java Implementation of Shapelist Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
Java Implementation of ShapeList (cont.) Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
Java Implementation of a ShapeList Client Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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 initial naming context initial naming context XX ShapeList B V P C T D E S R Q U Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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. }; Information Management NTU Source: G. Coulouris et al., Distributed Systems: Concepts and Design
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