06/16/22 Distributed Systems - Com p 655 1 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 – (skip) Streams
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 (skip) Streams. Communication patterns. Producer. Consumer. query. response. - PowerPoint PPT Presentation
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
04/22/23 Distributed Systems - Comp 655 1
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– (skip) Streams
04/22/23 Distributed Systems - Comp 655 2
Communication patterns
Producer Consumer
query
response
04/22/23 Distributed Systems - Comp 655 3
Communication patterns with broker
Producer 2
query
response
Producer 1Consumer 2
Consumer 1
Consumer 3
Subscriptionservice
Client 2
Client 1Server 2
Server 1
Server 3
Requestbroker
queryresponse
04/22/23 Distributed Systems - Comp 655 4
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
04/22/23 Distributed Systems - Comp 655 5
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
04/22/23 Distributed Systems - Comp 655 6
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
Where does http fit?• Originally, it looked like an
application-level 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
04/22/23 Distributed Systems - Comp 655 10
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
04/22/23 Distributed Systems - Comp 655 11
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)
04/22/23 Distributed Systems - Comp 655 12
Ordinary procedure callprocess
caller
callee(callee is atanh)
0.98 2.3
04/22/23 Distributed Systems - Comp 655 13
RPC: call the procedure across a network
clientprocess
serverprocess
network
caller callee
clientstub
serverstub
0.98
Atanh, 0.98message
0.98
04/22/23 Distributed Systems - Comp 655 14
RPC: call the procedure across a network
clientprocess
serverprocess
network
caller callee
clientstub
serverstub
2.3
OK, 2.3message
2.3
04/22/23 Distributed Systems - Comp 655 15
RPC Summaryclient
processserver
process
network
caller
clientstub
callee
serverstub
•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)
04/22/23 Distributed Systems - Comp 655 16
Warning: passing parameters and results
can be tricky
04/22/23 Distributed Systems - Comp 655 17
Passing Value Parameters (1)
04/22/23 Distributed Systems - Comp 655 18
Passing Value Parameters (2)
a) Original message (JILL, 5) on the Pentium (little endian)b) The message after receipt on the SPARC (big endian)c) The message after being inverted. The little numbers in
boxes indicate the address of each byte
Number is backwards String is backwards
04/22/23 Distributed Systems - Comp 655 19
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.
04/22/23 Distributed Systems - Comp 655 20
Interface definitionInterface definitions are critical
factors in • Openness• Flexibility• Access transparency• Enabling proxy construction in
middleware
04/22/23 Distributed Systems - Comp 655 21
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 BNetwork
04/22/23 Distributed Systems - Comp 655 22
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
04/22/23 Distributed Systems - Comp 655 23
Activity – what could you do about it?
Brainstorm approaches to dealing with the top three failure modes
A BNetwork
04/22/23 Distributed Systems - Comp 655 24
Communication patterns -reminder
Parameters:• Query-response or producer-consumer• Blocking or non-blocking• Connection-based or connection-less• Persistent or transientExamples:• blocking transient query-response == RPC• non-blocking persistent
producer/consumer == message queuing
04/22/23 Distributed Systems - Comp 655 25
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
04/22/23 Distributed Systems - Comp 655 26
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
04/22/23 Distributed Systems - Comp 655 27
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
04/22/23 Distributed Systems - Comp 655 28
Distributed Objects
• Common organization of a remote object with client-side proxy.
2-16
04/22/23 Distributed Systems - Comp 655 29
Basic Java RMI
rmiregistry**
Server
Client1. Server registers its name
and remote object2. Client gets reference to
remote object from rmiregistry
3. Client calls server
Interface.class_Stub.class *
1.
2.
3.
Interface.class_Skel.class *
* = 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.
04/22/23 Distributed Systems - Comp 655 30
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?
04/22/23 Distributed Systems - Comp 655 31
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
04/22/23 Distributed Systems - Comp 655 32
Parameter Passing in RMI
04/22/23 Distributed Systems - Comp 655 33
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
• Network-unfriendly code• Lots of clients can mean lots of
configuration management
04/22/23 Distributed Systems - Comp 655 42
Network-unfriendly code …• In OO, there are usually lots of fine-grained
classes, and lots of getters and setters
• Performance is not good if you do this over a network
Person person = new Person();person.setFirstName(fname);person.setMiddleInitial(initial);person.setLastName(lname);Address address = new Address();address.setStreet(street);address.setCity(city);address.setState(state);person.setAddress(address);…
04/22/23 Distributed Systems - Comp 655 43
Network-unfriendlyclient server
domainobject
domainobject
04/22/23 Distributed Systems - Comp 655 44
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 fine-grained 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