EEC-681/781 Distributed Computing Systems
-
Upload
gareth-giles -
Category
Documents
-
view
23 -
download
1
description
Transcript of EEC-681/781 Distributed Computing Systems
EEC-681/781EEC-681/781Distributed Computing SystemsDistributed Computing Systems
Lecture 6Lecture 6
Wenbing ZhaoWenbing ZhaoDepartment of Electrical and Computer EngineeringDepartment of Electrical and Computer Engineering
Cleveland State UniversityCleveland State University
[email protected]@ieee.org
22
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Message-Oriented CommunicationMessage-Oriented Communication
• Persistence and Synchronicity in Communication• Message-oriented transient communication
– Berkeley sockets– Message-passing interface
• Message-oriented persistent communication– Message-queuing system– Message brokers (publish/subscribe)
• Java message service– A copy of JMS tutorial is available at DCS server
/software/activemq/jms-tutorial.pdf
33
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Synchronous CommunicationSynchronous Communication
• Client/Server computing is generally based on a model of synchronous communication:– Client and server have to be active at the time of
communication– Client issues request and blocks until it receives
reply– Server essentially waits only for incoming
requests, and subsequently processes them
44
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Synchronous CommunicationSynchronous Communication
• Drawbacks of synchronous communication:– Client cannot do any other work while waiting
for reply– Failures have to be dealt with immediately (the
client is waiting)– In many cases the model is simply not
appropriate (mail, news)
55
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Asynchronous CommunicationAsynchronous Communication
• Message-oriented middleware: Aims at high-level asynchronous communication:– Processes send each other messages, which
are queued– Sender need not wait for immediate reply, but
can do other things– Middleware often facilitates fault tolerance
66
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Persistent CommunicationPersistent Communication• Persistent Communication – A message that
has been submitted for transmission is stored by the communication system as long as it takes to deliver it to the receiver– E.g. from postal mail to e-mail
77
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Transient CommunicationTransient Communication
• Transient Communication – A message is stored by the communication system only as long as the sending and receiving application are executing– All transport-level communication services
offer only transient communication– RPC/RMI
88
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Message-Oriented Message-Oriented Transient CommunicationTransient Communication
• Berkeley Sockets
• Message-Passing Interface
99
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Berkeley SocketsBerkeley Sockets
Primitive Meaning
Socket Create a new communication endpoint
Bind Attach a local address to a socket
Listen Announce willingness to accept connections
Accept Block caller until a connection request arrives
Connect Actively attempt to establish a connection
Send Send some data over the connection
Receive Receive some data over the connection
Close Release the connection
1010
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Berkeley SocketsBerkeley Sockets
Connection-oriented communication pattern using sockets
1111
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
The Message-Passing Interface (MPI)The Message-Passing Interface (MPI)
• MPI is used to do high performance computing on multicomputers – Use high-speed interconnection networks– Come with proprietary communication
libraries
• Need message-passing primitives at a convenient level of abstraction– Standard APIs, hardware-independent
1212
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Message-Oriented Message-Oriented Persistent CommunicationPersistent Communication
Message-Oriented
Middleware
Application A
Messaging API
Messaging Clients
Application B
Messaging API
Messaging Clients
Message-Oriented Middleware (MOM)
1313
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Characteristics of MOMCharacteristics of MOM
• Loosely-coupled communication: They offer intermediate storage capacity for messages, without requiring either sender or receiver to be active during message transmission
• Encompasses message queuing and publish/subscribe communications
Sender Receiver
MOM
Messages
1414
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Message QueuingMessage Queuing
Producer Queue Consumer
send(m1)
send(m2)
receive()m1
Put message into queue
Consume message
A message queue offers point-to-point communication: each message produced has one consumer
1515
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Publish/SubscribePublish/Subscribe
Producer Broker Consumer Consumer
publish(m1)send(m1)Pass message to
brokersend(m1)
send(m2)
send(m2)
Dispatch message to all consumers
publish(m2)
publish(m3)
Publish/subscribe offers one-to-many communication: each message published can have many subscribers
1616
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Message Queuing ApplicationMessage Queuing Application
1717
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Publish/Subscribe ApplicationPublish/Subscribe Application
subscribe (“EEC681”);subscribe (“EEC681”);subscribe (“EEC693”);
subscribe (“EEC681”);subscribe (“EEC693”);
publish(“EEC681”, Lab1);publish(“EEC681”, Lab2);
publish(“EEC693”, HW1);publish(“EEC693”, HW2);
1818
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Java Message ServiceJava Message Service
• Standard Java API
• Message delivery models
• Two messaging models
1919
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
JMS Messaging DomainsJMS Messaging Domains
• Publish and subscribe (topic)– Many consumers per message
• Point-to-point (queue)– One consumer per message
2020
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
JMS ComponentsJMS Components
Message Server
Message MessageDestination
JMS Client
Connection
Session
Producer
JMS Client
Connection
Session
Consumer
2121
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Connections and SessionsConnections and Sessions
• A connection connects to a message server
• You can create one or more sessions within a connection
JMS Client
Connection
Session
Session
Session
2222
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Creating Connections and SessionsCreating Connections and Sessions
Message Server
JNDI Store
JMS Client
Connection
Session
Session
Session
ConnectionFactory
create
ConnectionFactoriesDestinations
2323
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
JMS Message TypesJMS Message Types
Message type Message body
Message No body
TextMessage A standard Java string
ObjectMessage A serializable Java object
MapMessageA set of name/value pairs where values are Java primitives
StreamMessage A stream of Java primitives
BytesMessage A stream of uninterpreted bytes
2424
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Creating a MessageCreating a Message
createStreamMessage( )
StreamMessage
TopicSession
createTextMessage( )
TextMessage
QueueSession
2525
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
JMS Message HeadersJMS Message Headers
• Automatically assigned headers– JMSDestination– JMSDeliveryMode– JMSMessageID– JMSTimestamp– JMSExpiration– JMSRedelivered– JMSPriority
• Developer-assigned headers– JMSReplyTo– JMSCorrelationID– JMSType
2626
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Producers, Consumers, and Producers, Consumers, and DestinationsDestinations
Message ServerSend
messageConsumemessage
Destination
Producer
Bind todestination
Consumer
Read message
Bind todestination
2727
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Creating DestinationsCreating Destinations
Message Server
JNDI StoreJMS Client
Topic
Queue
ConnectionFactoriesDestinations lookup
2828
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Producing a MessageProducing a Message
create message
produce message
Session
MessageProducer
Message Destinationcreate
2929
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Consuming MessagesConsuming MessagesIncoming messages
MessageListener
onMessage(message)
Message Server
acknowledge
MessageConsumer
Message receive()
Incoming messages
acknowledge
Asynchronous Message Delivery
Synchronous Message Delivery
3030
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Filtering with Message SelectorFiltering with Message Selector
Message Server
Publisher
Departments.Sales
SubscriberDepartments.SalesPipeline > 15000
JMSPriority = 2Pipeline = 20000
delivered
SubscriberDepartments.SalesJMSPriority > 5
not delivered
SubscriberDepartments.SalesJMSPriority >= 2 AND Pipeline > 10000
delivered
SubscriberDepartments.SalesPipeline > 20000
notdelivered
3131
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Browsing a QueueBrowsing a Queue
nextElement()
QueueBrowser
getEnumeration()
Message1
Message2
Message3
Message4
Enumeration
3232
Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao
Accessing Message ContentAccessing Message Content
Message
TextMessageMapMessage ObjectMessage StreamMessage BytesMessage
getText() getObject()
get<type>(Name)
read<type>()