eec-681/781 distributed computing systems

32
EEC-681/781 EEC-681/781 Distributed Computing Distributed Computing Systems Systems Lecture 6 Lecture 6 Wenbing Zhao Wenbing Zhao Department of Electrical and Computer Department of Electrical and Computer Engineering Engineering Cleveland State University Cleveland State University [email protected] [email protected]

Upload: gareth-giles

Post on 03-Jan-2016

21 views

Category:

Documents


1 download

DESCRIPTION

EEC-681/781 Distributed Computing Systems. Lecture 6 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University [email protected]. Message-Oriented Communication. Persistence and Synchronicity in Communication Message-oriented transient communication - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 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

Page 2: EEC-681/781 Distributed Computing Systems

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

Page 3: EEC-681/781 Distributed Computing Systems

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

Page 4: EEC-681/781 Distributed Computing Systems

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)

Page 5: EEC-681/781 Distributed Computing Systems

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

Page 6: EEC-681/781 Distributed Computing Systems

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

Page 7: EEC-681/781 Distributed Computing Systems

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

Page 8: EEC-681/781 Distributed Computing Systems

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

Page 9: EEC-681/781 Distributed Computing Systems

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

Page 10: EEC-681/781 Distributed Computing Systems

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

Page 11: EEC-681/781 Distributed Computing Systems

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

Page 12: EEC-681/781 Distributed Computing Systems

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)

Page 13: EEC-681/781 Distributed Computing Systems

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

Page 14: EEC-681/781 Distributed Computing Systems

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

Page 15: EEC-681/781 Distributed Computing Systems

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

Page 16: EEC-681/781 Distributed Computing Systems

1616

Fall Semester 2008Fall Semester 2008 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

Message Queuing ApplicationMessage Queuing Application

Page 17: EEC-681/781 Distributed Computing Systems

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);

Page 18: EEC-681/781 Distributed Computing Systems

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

Page 19: EEC-681/781 Distributed Computing Systems

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

Page 20: EEC-681/781 Distributed Computing Systems

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

Page 21: EEC-681/781 Distributed Computing Systems

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

Page 22: EEC-681/781 Distributed Computing Systems

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

Page 23: EEC-681/781 Distributed Computing Systems

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

Page 24: EEC-681/781 Distributed Computing Systems

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

Page 25: EEC-681/781 Distributed Computing Systems

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

Page 26: EEC-681/781 Distributed Computing Systems

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

Page 27: EEC-681/781 Distributed Computing Systems

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

Page 28: EEC-681/781 Distributed Computing Systems

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

Page 29: EEC-681/781 Distributed Computing Systems

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

Page 30: EEC-681/781 Distributed Computing Systems

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

Page 31: EEC-681/781 Distributed Computing Systems

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

Page 32: EEC-681/781 Distributed Computing Systems

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>()