Advanced Topics in Distributed Systems Dr. Ayman A. Abdel-Hamid Computer Science Department Virginia Tech Communication (Based on Ch2 in Distributed Systems: Principles and Paradigms, 1/E or Ch4 in 2/E) Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 1 Outline Interprocess Communication in distributed systems Communication Models Remote Procedure Call (RPC) Remote Method Invocation (RMI) Message-Oriented Middleware Streams Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 2 1
RPC: Conventional Procedure Call count = read (fd, buf, nbytes); a) Parameter passing in a local procedure call: the stack before the call to read b) The stack while the called procedure is active Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 3 Client and Server Stubs Principle of RPC between a client and server program. Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 4 2
Steps of a Remote Procedure Call 1. Client procedure calls client stub in normal way 2. Client stub builds message, calls local OS 3. Client's OS sends message to remote OS 4. Remote OS gives message to server stub 5. Server stub unpacks parameters, calls server 6. Server does work, returns result to the stub 7. Server stub packs it in message, calls local OS 8. Server's OS sends message to client's OS 9. Client's OS gives message to client stub 10. Stub unpacks result, returns to client Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 5 Passing Value Parameters Steps involved in doing remote computation through RPC 2-8 Steps involved in doing remote computation through RPC Passing reference parameters? Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 6 3
Parameter Specification and Stub Generation Both sides follow the same protocol Message format (parameter marshalling) Representation of simple data structures Actual exchange of messages Implementation of client and server stubs Interfaces specified by an Interface Definition Language (IDL) Interface compiled into a client stub and a server stub (with compile-time and run-time interfaces) Through an IDL compiler Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 7 Asynchronous RPC 1/2 2-12 a) The interconnection between client and server in a traditional RPC b) The interaction using asynchronous RPC Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 8 4
Asynchronous RPC 2/2 A client and server interacting through two asynchronous RPCs Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 9 Distributed Objects Common organization of a remote object with client-side proxy. Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 10 5
Binding a Client to an Object Distr_object* obj_ref; obj_ref = ; obj_ref-> do_something(); Distr_object objpref; Local_object* obj_ptr; obj_ref = ; obj_ptr = bind(obj_ref); obj_ptr -> do_something(); (a) (b) //Declare a systemwide object reference // Initialize the reference to a distributed object // Implicitly bind and invoke a method //Declare a systemwide object reference //Declare a pointer to local objects //Initialize the reference to a distributed object //Explicitly bind and obtain a pointer to the local proxy //Invoke a method on the local proxy (a) Example with implicit binding using only global references (b) Example with explicit binding using global and local references Implementation of object references? Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 11 Static versus Dynamic RMI 1/2 Client bound to an object Invoke object s methods through proxy (RMI) RMI supports system-wide object references Object-specific stubs Object interface provided through IDL Use an object-based language (such as Java) to handle stub generation automatically Static invocation use predefined interface definitions Object s interface known when client application developed If interface changes, client application recompiled Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 12 6
Static versus Dynamic RMI 2/2 Dynamic invocation Compose a method invocation at runtime Application selects at runtime which method it will invoke at a remote object invoke (object, method, input_parameters, output_parameters) Static: fobject.append(int) Dynamic: invoke(fobject,id(append),int) Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 13 RMI: Parameter Passing The situation when passing an object by reference or by value. Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 14 7
Message-Oriented Communication Inherent synchronous nature of RPC and RMI Messaging Synchronous Sender blocked until message stored in a local buffer at receiving host or actually delivered to receiver (could block until message processed) Asynchronous Sender continues immediately after message submitted for transmission Message stored in communication system Persistent (email) Message stored by communication system as long as it takes to deliver to receiver Transient (store-and-forward routers, sockets) Message stored by communication system only as long as the sending and receiving application are executed Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 15 Persistence and Synchronicity in Communication 1/4 2-20 General organization of a communication system in which hosts are connected through a network Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 16 8
Persistence and Synchronicity in Communication 2/4 2-22.1 a) Persistent asynchronous communication b) Persistent synchronous communication Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 17 Persistence and Synchronicity in Communication 3/4 2-22.2 c) Transient asynchronous communication d) Receipt-based transient synchronous communication Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 18 9
Persistence and Synchronicity in Communication 4/4 e) Delivery-based transient synchronous communication at message delivery f) Response-based transient synchronous communication Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 19 General Architecture of a Message-Queuing System 1/2 The relationship between queue-level addressing and network-level addressing. Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 20 10
General Architecture of a Message-Queuing System 2/2 2-29 The general organization of a message-queuing system with routers. Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 21 Message Brokers 2-30 The general organization of a message broker in a message-queuing system. Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 22 11
Stream-Oriented Communication Timing is a problem Support for continuous media (temporal relationships between different data items are important to correctly interpret what the data means) Data streams transmission modes Asynchronous Synchronous (maximum end-to-end delay for each unit in a data stream) Isochronous (on-time, maximum and minimum end-to-end delay, bounded jitter) Need for QoS Communication Dr. Ayman Abdel-Hamid, CS6204, Sp08 23 12