Communication essentials Communication patterns Communication structure OSI reference
- Slides: 75
Communication essentials • Communication patterns • Communication structure: OSI reference model and TCP/IP coverage • Major middleware communication services – – – 5/21/2021 RPC RMI http I hate to wait … Message passing (skip) Streams Distributed Systems - Comp 655 1
Communication patterns Producer Consumer query response 5/21/2021 Distributed Systems - Comp 655 2
Communication patterns with broker Producer 1 Producer 2 Client 1 Client 2 Consumer 1 Subscription service Consumer 2 Consumer 3 query response Request broker query response Server 1 Server 2 Server 3 5/21/2021 Distributed Systems - Comp 655 3
Communication patterns other variations • Blocking or non-blocking • Connection-based or connectionless • Transient or persistent Examples: • blocking transient query-response == RPC • non-blocking persistent producer/consumer == message queuing 5/21/2021 Distributed Systems - Comp 655 4
A note about blocking • Blocking communication blocks the thread that makes the call • Other work may continue in other threads in the same process • More about threads and processes next week 5/21/2021 Distributed Systems - Comp 655 5
Communication essentials • Communication patterns • Communication structure: OSI reference model and TCP/IP coverage • Major middleware communication services – – – 5/21/2021 RPC RMI http I hate to wait … Message passing Distributed Systems - Comp 655 6
OSI Reference Model TCP/IP 2 -1 HTTP, FTP, … not used TCP, UDP connectionless IP e. g. Ethernet sending bits 5/21/2021 Distributed Systems - Comp 655 7
Middleware Protocols 2 -5 RPC RMI 5/21/2021 Distributed Systems - Comp 655 8
Where does http fit? • Originally, it looked like an applicationlevel protocol, where the application was fetching and viewing HTML pages • As the Web has matured, it has been used increasingly as middleware. • It’s the foundation for – Web applications – Web services 5/21/2021 Distributed Systems - Comp 655 9
Communication essentials • Communication patterns • Communication structure: OSI reference model and TCP/IP coverage • Major middleware communication services – RPC – RMI – http – I hate to wait … – Message passing 5/21/2021 Distributed Systems - Comp 655 10
RPC is all about • Allowing a client to make a procedure call that is processed on a remote machine • Without the client’s having to care (much) 5/21/2021 Distributed Systems - Comp 655 11
Ordinary procedure call process caller 0. 98 callee 5/21/2021 2. 3 (callee is atanh) Distributed Systems - Comp 655 12
RPC: call the procedure across a network client process server process caller callee client stub 0. 98 message Atanh, 0. 98 5/21/2021 Distributed Systems - Comp 655 server stub network 13
RPC: call the procedure across a network client process server process caller callee client stub 2. 3 message OK, 2. 3 5/21/2021 Distributed Systems - Comp 655 server stub network 14
RPC Summary client process caller client stub • client stub pretends to be the callee • server stub pretends to be the caller • caller and callee are written as if they were on the same machine • location transparency!! (almost) server process callee server stub network 5/21/2021 Distributed Systems - Comp 655 15
Warning: passing parameters and results can be tricky 5/21/2021 Distributed Systems - Comp 655 16
Passing Value Parameters (1) 5/21/2021 Distributed Systems - Comp 655 17
Passing Value Parameters (2) Number is backwards a) b) c) String is backwards Original message (JILL, 5) on the Pentium (little endian) The message after receipt on the SPARC (big endian) The message after being inverted. The little numbers in boxes indicate the address of each byte 5/21/2021 Distributed Systems - Comp 655 18
Conclusion from the byte order problem • You have to explicitly define your interfaces. • This problem is one of the fundamental motivators for the use of Interface Definition Languages (IDL) • Passing value parameters is a key component of access transparency. 5/21/2021 Distributed Systems - Comp 655 19
Interface definitions are critical factors in • Openness • Flexibility • Access transparency • Enabling proxy construction in middleware 5/21/2021 Distributed Systems - Comp 655 20
Activity – what can go wrong? (with an RPC) Brainstorm things that can go wrong when a program on machine A tries to make an RPC to a server on machine B A 5/21/2021 Network Distributed Systems - Comp 655 B 21
Pick the top three • The instructor will pick some of the failures you brainstormed • Multi-vote on the ones in whose solutions you are most interested • You will use the top three vote-getters in the next activity 5/21/2021 Distributed Systems - Comp 655 22
Activity – what could you do about it? Brainstorm approaches to dealing with the top three failure modes A 5/21/2021 Network Distributed Systems - Comp 655 B 23
Communication patterns reminder Parameters: • Query-response or producer-consumer • Blocking or non-blocking • Connection-based or connection-less • Persistent or transient Examples: • blocking transient query-response == RPC • non-blocking persistent producer/consumer == message queuing 5/21/2021 Distributed Systems - Comp 655 24
Finding the server or peer • In all cases, the process that initiates a communication has to find the process it wants to communicate with • The address could be in – Source code (simplest, least flexible) – Configuration file – A network directory service (requires client to know a name for a server) (e. g. DNS) – A series of directories (e. g. LDAP, then RMI Registry) • Interaction with the directory is usually blocking request/response 5/21/2021 Distributed Systems - Comp 655 25
Communication essentials • Communication patterns • Communication structure: OSI reference model and TCP/IP coverage • Major middleware communication services – RPC – RMI – http – I hate to wait … – Message passing 5/21/2021 Distributed Systems - Comp 655 26
Focus on Remote Objects • Here, object == state + methods + interface • Usually, only the interface is distributed • “Remote objects” refers to approaches in which, for each object there is some server where all of it state resides 5/21/2021 Distributed Systems - Comp 655 27
Distributed Objects 2 -16 of a remote object with • Common organization client-side proxy. 5/21/2021 Distributed Systems - Comp 655 28
Basic Java RMI Interface. class _Stub. class * 1. Client 2. 3. rmiregistry** 3. 1. Server Interface. class _Skel. class * 5/21/2021 Server registers its name and remote object Client gets reference to remote object from rmiregistry Client calls server * = not needed if Client and Server are both Java 1. 5 or newer ** = RMI Registry can be a separate process or an object inside the Server process. If separate, must be on same machine. Distributed Systems - Comp 655 29
Passing objects around … • In RMI, parameters and return values can be object references – If the parameter refers to a local object, do you copy the object or pass only a reference? – If the parameter refers to a remote object, what do you pass? 5/21/2021 Distributed Systems - Comp 655 30
Local, remote objects in Java RMI • Local objects are passed by value • Remote objects by reference • Passing a remote object by reference means passing a proxy by value 5/21/2021 Distributed Systems - Comp 655 31
Parameter Passing in RMI 5/21/2021 Distributed Systems - Comp 655 32
http • Communication patterns: – Transient – Query/response • But, http does NOT simulate a procedure call – Non-blocking (officially) • Many clients choose to block • HTTP 1. 1 is defined in RFC 2616 • Depends on TCP for reliable communication 5/21/2021 Distributed Systems - Comp 655 33
Steps in an HTTP interaction 1. Client requests TCP connection 2. Client and server collaborate to create a TCP connection 3. Client sends an HTTP request 4. Server sends a response 5. TCP connection torn down • 5/21/2021 In HTTP 1. 1, connection can be kept alive Distributed Systems - Comp 655 34
Anatomy of an HTTP request method request URI protocol headers POST /don/demo HTTP/1. 1 accept: */* accept-language: en-us referer: http: //localhost: 8080/don/echoclient. htm content-type: application/x-www-form-urlencoded accept-encoding: gzip, deflate user-agent: Mozilla/4. 0 (compatible; MSIE 6. 0; Windows NT 5. 1; SV 1; Nova. Pacs Viewer 6. 0. 197. 0; . NET CLR 1. 1. 4322; . NET CLR 2. 0. 50727) host: localhost: 8080 content-length: 37 connection: Keep-Alive cache-control: no-cache name=007&mission=deep%20 dark%20 secret content 5/21/2021 Distributed Systems - Comp 655 35
Watch out for Norton (and others) POST /don/demo HTTP/1. 1 accept: */* accept-language: en-us -------: -----------content-type: application/x-www-form-urlencoded --------: ------user-agent: Mozilla/4. 0 (compatible; MSIE 6. 0; Windows NT 5. 1; SV 1; Nova. Pacs Viewer 6. 0. 197. 0; . NET CLR 1. 1. 4322; . NET CLR 2. 0. 50727) host: localhost: 8080 content-length: 37 connection: Keep-Alive cache-control: no-cache name=007&mission=deep%20 dark%20 secret 5/21/2021 Distributed Systems - Comp 655 36
Anatomy of an HTTP response protocol status code reason phrase headers HTTP/1. 1 200 OK X-Powered-By: Servlet/2. 5 Content-Type: text/xml; charset=utf-8 Content-Length: 57 Date: Sun, 16 Sep 2007 17: 55: 54 GMT Server: Sun Java System Application Server Platform Edition 9. 0_01 <greeting>Hello, 007. You made a POST request. </greeting> content 5/21/2021 Distributed Systems - Comp 655 37
Distributed Systems - Comp 655 38 Making an HTTP request in Java 5/21/2021
Server side: Http. Servlet 5/21/2021 Distributed Systems - Comp 655 39
Servlet container request client response Servlet base class your Servlet Container (Tomcat, Glassfish, Web. Logic, Web. Sphere, etc) DB 5/21/2021 Distributed Systems - Comp 655 whatever 40
Smudging the transparency … • Network-unfriendly code • Lots of clients can mean lots of configuration management 5/21/2021 Distributed Systems - Comp 655 41
Network-unfriendly code … • In OO, there are usually lots of fine-grained classes, and lots of getters and setters Person person = new Person(); person. set. First. Name(fname); person. set. Middle. Initial(initial); person. set. Last. Name(lname); Address address = new Address(); address. set. Street(street); address. set. City(city); address. set. State(state); person. set. Address(address); … • Performance is not good if you do this over a network 5/21/2021 Distributed Systems - Comp 655 42
Network-unfriendly client server domain object 5/21/2021 Distributed Systems - Comp 655 43
A more network-friendly way • This is a recurring problem in distributed systems • Remote façade and Data transfer object patterns provide the core of a solution – Define a façade class with methods that group multiple finegrained operations together – Define classes (DTOs) with nothing but getters and setters for moving groups of data items around – Keep the business logic in the original class(es) on the server side 5/21/2021 Distributed Systems - Comp 655 44
Using Remote Façade + DTO 1. 2. 3. 4. 5. 6. 7. 8. Client creates a DTO Client calls lots of setters on DTO Client calls façade with DTO as parameter Service calls lots of getters on DTO, setters (and other methods, as needed) on the domain object(s) Façade creates DTO 2 Façade calls setters on DTO 2 Façade returns DTO 2 to client Client calls lots of getters on DTO 2 5/21/2021 Distributed Systems - Comp 655 45
Using Remote Façade + DTO client DTO server DTO domain object DTO 2 domain object Façade 5/21/2021 Distributed Systems - Comp 655 46
Remote Façade + DTO code (flavor) Person. TO pto = new Person. TO(); pto. set. First. Name(fname); pto. set. Middle. Initial(initial); pto. set. Last. Name(lname); pto. set. Street(street); pto. set. City(city); pto. set. State(state); Facade facade = new Facade(); Result. TO rto = facade. add. Person(pto); … 5/21/2021 Distributed Systems - Comp 655 47
Remote Façade + DTO consequences • Reduced network traffic • Reduced coupling between client and domain model • Costs include – More classes to deal with – Getters and setters called multiple times (client DTO. get, server DTO. get + domain. set) • Risks include – Temptation to put business logic in DTO – Temptation to skip domain model development and build a DTO-processing system 5/21/2021 Distributed Systems - Comp 655 48
More about client/domain coupling • Refactoring is a good thing • Issues with refactoring a network service – Refactored client needs to be deployed in many places – Service administrators may not know where all the clients are – There may be clients the service developers know nothing about 5/21/2021 Distributed Systems - Comp 655 49
A more refactoring-friendly way • This is a recurring problem in distributed systems • Patterns include – Migrate code at runtime • e. g. applet • See Tanenbaum & van Steen, section 3. 5, if interested – Remote façade + DTO helps here, too 5/21/2021 Distributed Systems - Comp 655 50
Remote façade + DTO (again) before client Person. TO server Person. TO Person + name + addr Façade client after Person. TO server Person. TO Façade 5/21/2021 Distributed Systems - Comp 655 Person + name Address 51
I hate to wait … 5/21/2021 Distributed Systems - Comp 655 52
RMI is usually synchronous 5/21/2021 Distributed Systems - Comp 655 53
Asynchronous RPC (1) 2 -12 a) b) interconnection between client and server in a traditional RPC The interaction using asynchronous RPC 5/21/2021 Distributed Systems - Comp 655 54
Asynchronous RPC (2) 2 -13 5/21/2021 Distributed Systems - Comp 655 55
Communication essentials • Communication patterns • Communication structure: OSI reference model and TCP/IP coverage • Major middleware communication services – RPC – RMI – http – I hate to wait … – Message passing 5/21/2021 Distributed Systems - Comp 655 56
Looser coupling • In RPC and RMI, client and server must be running at the same time • This coupling makes them relatively sensitive to failures and remote-machine policies • Message queuing enables more looselycoupled communication 5/21/2021 Distributed Systems - Comp 655 57
General Architecture of a Message-Queuing System (1) 5/21/2021 Distributed Systems - Comp 655 58
Message-Queuing Primitives Primitive Meaning Put Append a message to a specified queue Get Block until the specified queue is nonempty, and remove the first message Poll Check a specified queue for messages, and remove the first. Never block. Notify Install a handler to be called when a message is put into the specified queue. 5/21/2021 Distributed Systems - Comp 655 59
Consumer message queuing: email sender’s machine host 5/21/2021 sender’s email server comm server receiver’s email server comm server Distributed Systems - Comp 655 receiver’s machine host 60
Example: IBM MQSeries • General organization of IBM's MQSeries message -queuing system. 2 -31 5/21/2021 Distributed Systems - Comp 655 61
Message Brokers 2 -30 • The general organization of a message broker in a message-queuing • system. 5/21/2021 Distributed Systems - Comp 655 62
Middleware communication summary Common name RPC Pattern Blocking, transient request/response RMI Blocking, transient request/response http (officially) non-blocking, transient request/response Asynchronous RPC Non-blocking, transient request/response Message queuing Non-blocking, persistent producer/consumer 5/21/2021 Distributed Systems - Comp 655 63
Bonus material 5/21/2021 Distributed Systems - Comp 655 64
Implementing a Java RMI server and client 1. 2. 3. 4. 5. Define the remote interface Write a class that implements it Include that class in an application Compile Generate stub and skeleton with rmic (not necessary with 1. 5) 6. Start rmiregistry, if necessary 5/21/2021 Distributed Systems - Comp 655 65
1. Define the Interface import java. rmi. Remote; import java. rmi. Remote. Exception; public interface Hello. Interface extends Remote { String say. Hello(String your. Name) throws Remote. Exception; String say. Goodbye(int how. Many) throws Remote. Exception; void ping() throws Remote. Exception; } 5/21/2021 Distributed Systems - Comp 655 66
2. Implement the interface public class Hello. Server extends Unicast. Remote. Object implements Hello. Interface { Hello. Server() throws Remote. Exception { super(Constants. server. Port); System. out. println(to. String()); // Register Registry reg = Locate. Registry. get. Registry(Constants. rmi. Port); reg. rebind(Constants. server. Name, this); } … 5/21/2021 Distributed Systems - Comp 655 67
2. Implement the interface, con’t public void ping() throws Remote. Exception { System. out. println("I've been pinged"); } public String say. Goodbye(int how. Many) throws Remote. Exception { String. Buffer sb = new String. Buffer(); for(int i=0; i<how. Many; i++) sb. append("goodbye "); return sb. to. String(); } public String say. Hello(String your. Name) throws Remote. Exception { return "Hello, " + your. Name; } 5/21/2021 Distributed Systems - Comp 655 68
3. Include in an application public static void main(String[] args) throws Remote. Exception { new Hello. Server(); } 5/21/2021 Distributed Systems - Comp 655 69
6. Start RMI Registry >> start rmiregistry 5/21/2021 Distributed Systems - Comp 655 70
Implementation continued 8. Assign the server a name 9. Run the server, using that name 10. Write a class that uses the remote interface (by name) 11. Compile 12. Run 13. Enjoy 5/21/2021 Distributed Systems - Comp 655 71
8, 9. Name the server public class Constants { public static final int rmi. Port = 5555; public static final int server. Port = 43215; public static final String server. Name = "whatever"; } 5/21/2021 Distributed Systems - Comp 655 72
10. Write a client public class Hello. Client { public static void main(String args[]) throws Remote. Exception, Not. Bound. Exception { Registry reg = Locate. Registry. get. Registry(Constants. rmi. Port); Hello. Interface hi = (Hello. Interface) reg. lookup(Constants. server. Name); for( String name : args ) { System. out. println(hi. say. Hello(name)); } System. out. println(hi. say. Goodbye(args. length)); hi. ping(); } } 5/21/2021 Distributed Systems - Comp 655 73
11. Run >> java Hello. Client Alice Bob Carol Dave Hello, Alice Hello, Bob Hello, Carol Hello, Dave goodbye >> 5/21/2021 Distributed Systems - Comp 655 74
RMI Resources • java. sun. com/j 2 se/1. 5. 0/docs/guide/rmi/faq. html (Java RMI and Object Serialization FAQ) • java. sun. com/j 2 se/1. 5. 0/docs/tooldocs/windows/ rmiregistry. html 5/21/2021 Distributed Systems - Comp 655 75
- Explain osi reference model
- They relay packets among multiple interconnected networks
- Define osi reference model
- Disadvantages of osi reference model
- Upiopi
- Osi reference model diagram
- Why and when osi reference model was invented?
- Reference node and non reference node
- Reference node and non reference node
- In traditional dating patterns dating behavior
- Mining frequent patterns associations and correlations
- Web essentials
- Essentials of technical communication
- Graphic design essentials
- Peer-to-peer communication in osi model
- Capital structure pattern
- Sequence/process text structure
- Sentence patterns
- Product management organization structure patterns
- Different patterns of organization in a text structure
- Order of importance text structure
- What is frame of reference in communication
- Patterns of group interaction and communication
- Chromatics nonverbal communication
- Dysfunctional family communication patterns
- Function of group dynamics
- Microsoft windows small business server 2011 essentials
- Windows small business server 2011 essentials
- Define tort law
- Google scholar
- Tres dias essentials
- Essentials of safe care
- 5 essentials of pay for performance
- Safeguarding and child protection the essentials
- Business cloud essentials
- Wedding cake model of criminal justice examples
- What are the essentials of valid tender
- Network security essentials 5th edition pdf
- Cisco it essentials virtual desktop
- Low power design essentials
- Barracuda essentials for office 365
- It essentials chapter 8
- Essential elements of partnership
- Essentials of sociology: a down-to-earth approach
- Essentials of migration management
- 5 essentials for a successful ffa chapter
- Parallelism in english
- It essentials chapter 9
- Data warehouse essentials
- Ite chapter 14
- It essentials chapter 12 quiz
- Chapter 11 quiz it essentials
- Business essentials 12th edition chapter 1
- Marketing essentials chapter 38
- Essentials of contemporary business
- Artistry
- Name and define the four narrative essentials of a play
- Purdue project management
- Covalent bond comic strip
- Essentials of business and online commerce law
- Essentials of health care marketing
- Online essentials
- Microsoft silver cloud partner
- Chapter 13 initiating the sale
- What are the economic utilities that relate to marketing?
- Windows server 2012 r2 essentials
- Network security essentials william stallings ppt
- Essentials of information systems
- It essential chapter 5
- It essentials chapter 3
- It essentials chapter 11
- Feedback essentials
- Etf trading essentials
- Essentials of migration management
- Essentials of investments 11th edition
- Essentials of social media marketing chapter 9 quiz