Você está na página 1de 20

Second Semester 2014-2015

SS ZG 526: Distributed Computing


Lect 3: Communication models (Publish/Subscribe, Queuing
Models), Logical Clocks and Vector Clocks, Causal Order

BITS Pilani
Hyderabad Campus

Chittaranjan Hota, PhD


Dept. of Computer Sc. & Information Systems
hota@hyderabad.bits-pilani.ac.in

What is Publish/Subscribe?

Producer

publish(topic, msg)

Topic 1

Consumer

subscribe
Topic 2

Message

Topic 3

Publish subscribe
system

Consumer

Producer
Message

1/18/2015

SS ZG526, Distributed Computing

Publish-and-subscribe messaging

Oracle

IBM
http://publib.boulder.ibm.com/infocenter/ledoc/v6r2/index.jsp?topic=/co
m.ibm.rcp.tools.doc.appdev/ovr10040.html

1/18/2015

http://docs.oracle.com/cd/E19587-01/821-0028/6nl41ccqd/index.html

SS ZG526, Distributed Computing

Complex Publish/Subscribe Messaging - Oracle

Source: http://docs.oracle.com/cd/E19587-01/821-0028/6nl41ccqd/index.html
1/18/2015

SS ZG526, Distributed Computing

IBM MQ Series middleware


Runs on multiple platforms and enables applications to
send messages to other applications. The sending and
receiving applications do not have to be on the same
platform, and do not have to be executing at the same
time.

MQSeries takes care of all the storage, logging and


communications details required to guarantee delivery of
the message to the destination queue. All the
applications have to do is know the name of the Queue
and agree on the meaning of the message.

1/18/2015

SS ZG526, Distributed Computing

APIs: MQ Series
Connect to a Queue Manager
Open a queue
Put or get messages
Close a queue
Disconnect

1/18/2015

SS ZG526, Distributed Computing

Local Queuing

1/18/2015

SS ZG526, Distributed Computing

Distributed Queuing

1/18/2015

SS ZG526, Distributed Computing

Inherent Limitations of a Distributed


System
Absence of a global clock
Unpredictable message transmission delays
Drift from Physical time

Absence of a shared memory


Difficult to maintain coherent global state

Solution: Logical Clocks

Inherent limitations of a Distributed System


Absence of a global clock
Unpredictable message transmission delays
Drift from Physical time
Absence of a shared memory
Difficult to maintain coherent global state
Solution: Logical Clocks

1/18/2015

10

Logical Clocks: Scalar time and Vector time


Causality among events in a distributed system is a
powerful concept in reasoning, analysing, and drawing
inferences about a computation.
The knowledge of the causal precedence relation among
the events of processes helps solve a variety of problems
in distributed systems, such as distributed algorithms
design, tracking of dependent events, knowledge about
the progress of a computation, and concurrency
measures.

1/18/2015

11

Time-space diagram

Space

1/18/2015

12

A Framework for a System of Logical Clocks


Definition
A system of logical clocks consists of a time domain T and a
logical clock C. Elements of T form a partially ordered set over a
relation <.
Relation < is called the happened before or causal precedence.
Intuitively, this relation is analogous to the earlier relation provided
by the physical time.
The logical clock C is a function that maps an event e in a
distributed system to an element in the time domain T , denoted
as C(e ) and called the timestamp of e , and is defined as follows:
C:HT
such that the following property is satisfied:
for two events ei and ej,
1/18/2015

SS ZG526, Distributed Computing

13

Scalar Time
Proposed by Lamport in 1978 as an attempt to totally order
events in a distributed system.
Time domain is the set of non-negative integers.
The logical local clock of a process pi and its local view of
the global time are squashed into one integer variable Ci.
Rules R1 and R2 to update the clocks are as follows:
R1: Before executing an event (send, receive, or internal),
process pi executes the following:
Ci := Ci + d
(d > 0)
In general, every time R1 is executed, d can have a
different value; however, typically d is kept at 1.
1/18/2015

SS ZG526, Distributed Computing

14

Scalar Time Continued


R2: Each message piggybacks the clock value of its
sender at sending time. When a process pi receives a
message with timestamp Cmsg , it executes the following
actions:
Ci := max(Ci , Cmsg )
Execute R1.
Deliver the message.

1/18/2015

SS ZG526, Distributed Computing

15

Scalar Time Example

1/18/2015

SS ZG526, Distributed Computing

16

Basic Properties
Consistency Property
Scalar clocks satisfy the monotonicity and hence the
consistency property:
for two events ei and ej,
Total Ordering
Scalar clocks can be used to totally order events in a distributed
system.
The main problem in totally ordering events is that two or more
events at different processes may have identical timestamp.
For example in Figure 3.1, the third event of process P1 and the
second event of process P2 have identical scalar timestamp.

1/18/2015

17

Total Ordering
A tie-breaking mechanism is needed to order such events. A
tie is broken as follows:
Process identifiers are linearly ordered and tie among events with
identical scalar timestamp is broken on the basis of their process
identifiers.
The lower the process identifier in the ranking, the higher the
priority.
The timestamp of an event is denoted by a tuple (t, i) where t is its
time of occurrence and i is the identity of the process where it
occurred.
The total order relation on two events x and y with timestamps
(h,i) and (k,j), respectively, is defined as follows:

1/18/2015

18

Properties. . .
Event counting
If the increment value d is always 1, the scalar time has the
following interesting property: if event e has a timestamp h,
then h-1 represents the minimum logical duration, counted
in units of events, required before producing the event e;
We call it the height of the event e.
In other words, h-1 events have been produced
sequentially before the event e regardless of the processes
that produced these events.

1/18/2015

19

Properties. . .
No Strong Consistency
The system of scalar clocks is not strongly consistent; that
is, for two events ei and ej,
The reason that scalar clocks are not strongly consistent is
that the logical local clock and logical global clock of a
process are squashed into one, resulting in the loss causal
dependency information among events at different
processes.

1/18/2015

20

Você também pode gostar