Solutions by liuhongmeiyes


									COM873J2 – Distributed Data Systems - SOLUTIONS

Question 4 – Naming and Directory Services

   (a) What are the main requirements for an effective Name Service and what
       extensions need be made to create a Directory Service?
                                                                         (6 marks)

Ability to handle an arbitrary number of names
A long lifetime
High availability
Isolation of faults
Tolerance of mistrust (Coulouris and Dollimore)

A Directory service allows the objects associated with names to have
     attributes so that they can be found by means other than a pure
     name – e.g. by a Boolean condition.

   (b) The ARP protocol and the DNS system both offer name services to parts of
       the Internet. How do they differ and why?
                                                                       (6 marks)
   More difficult because it requires reflection…
   ARP translates IP addresses to machine addresses. The look-up
   depends on a broadcast of an IP address to all machines on a
   network which clearly would not scale-up to an internetwork.

   DNS translates human-readable names to machine names (plus
   other info) but must operate across the entire Internet. Hence it is a
   distributed system which solves the problem by using a set of DNS

(c) How does the DNS achieve a relatively short response time to queries?
                                                                            (6 marks)
In short, by partitioning, replication and caching.
The DNS delegates authority for names to authorities in various zones,
so that clients do not place an undue load on the resources of one
single authority.
The data is replicated, being stored in more than one location, using
master servers which have authoritative data and secondary servers
which download zone data periodically,
Finally, data is cached as it is retrieved by a server in the process of
resolving names on behalf of other entities. Heavily-accessed name-
address pairs are likely to be local to a user.

                                    Page 1 of 6
COM873J2 – Distributed Data Systems - SOLUTIONS

(d)     Briefly discuss the CORBA Naming Service. How could this service be used
to identify objects from different databases which can be located as services on the
Internet? The objective is to give each object a pathname which can be located in a
single name-space.
                                                                            (7 marks)

Corba naming service has a hierarchical name space so that the service
can map on to many existing services such as the DNS, file services in
UNIX, NFS. The user can create names as paths in the hierarchy and
then interrogate the service for the object reference corresponding to
the name. In this example the database name could be appended to an
Internet domain name and the object’s local pathname appended to the

Question 5 – Global States

      Let D be a distributed system in which N processes execute concurrently.
      Assume that events are of three types,
      1: changing the internal state of a process,
      2: sending a message m to another process,
      3: receiving a message m from another process.

(a)   Define the happened-before relation in terms of events and use your definition
      to give a definition of a consistent global state.
      Hence present the “snapshot” algorithm of Chandy and Lamport.

The event a is said to happen before the event b if
Either it occurred in the same process P as event b, and P observed it
     as happening before b
OR If a is the event of sending a message from process P to process Q
     and b is the event of receiving that message.
Furthermore, if a happens before b and b happens before c, then a
     happens before c. (transitivity).
                                                              (5 marks)

Assume that at any time a process can send a special marker message
    on any of its channels. There are two rules which govern the
    handling of markers: the marker receiving rule, and the marker
    sending rule. Any process may initiate the snapshot algorithm by
    following the marker receiving rule.

                                     Page 2 of 6
COM873J2 – Distributed Data Systems - SOLUTIONS

Initially set all processes as not having recorded state.
Marker Receiving Rule
When process P receives a marker message over channel c
     If (P has not yet recorded its state)
         P records its state
         P records the state of c as the empty set.
         P turns on recording of messages arriving over
               other incoming channels
         P records the state of c as the set of messages it
      has received over c since it saved its state

Marker Sending Rule
After P has recorded its state, then for each outgoing
    channel c P sends one marker message over c. (This is
    done before P sends any other messages.)

At each process the algorithm has completed when all
    incoming channels have been marked.
                                                 (7 marks)

(b)   Briefly describe how the TCP and IP protocols together allow two processes on
         machines connected by an internet to reliably send and receive messages.
                                                                            (7 marks)

This is a long story, but something like the following would suffice…
TCP is a reliable stream-oriented message protocol which allows
processes on different hosts to communicate. TCP packets are carried
inside IP packets. The IP protocol is responsible for ensuring that
messages travel across an internet from one IP address to another. IP
is unreliable and stateless: but part of the data inside the IP message
header is the TCP message header which does carry state information
such as the number of non-corrupted octets which have arrived at the
sender’s end and the location of the data packet in the current stream
of data.

(c)   Assume that a set of N client processes which carry out various tasks use
      TCP/IP channels in order to communicate. Suggest how the snapshot algorithm
      may be used to detect if all tasks have reached completion. (6 marks)

Each process can initiate the snapshot algorithm when it completes a
task. It sends the marker message on any output channels after all
task-related information has been processed. All marker messages
will be received on input channels after meaningful data from the
process. Eventually each process will have received N marker
messages which indicates completion.

                                    Page 3 of 6
COM873J2 – Distributed Data Systems - SOLUTIONS

Question 6

(i) Given that an arbitrary transaction Tj consists of a list of atomic operations
(t1j, t2j, …)
 explain how a possible schedule of a set of transactions
T1, T2, …, Tn
can arise.                                                                        (3 marks)
A schedule is an interleaving of the atomic operations of the set of
transactions, a list of these operations which preserves the ordering of
the operations within a transaction.

(ii) List the conditions under which two operations in a schedule can conflict.
Transactions S and T access data items X, Y and Z as follows:
    S: w(X); r(Y); r(Z); r(Y);
    T: r(Y); r(X)
    Which operations in the transactions S and T conflict?         (5 marks)

Operations in a schedule can conflict if:
  (i)    they refer to the same data item
  (ii)   one of the operations is a write to the item and one is a read
  (iii) both operations are writes to the item

Writing the operations in S as (s1, s2, s3, s4), and the operations in T
as (t1, t2) it is easy to see that the conflict-pair is:

(iii) When is a schedule conflict-serialisable? Explain why such a schedule is
generally regarded as correct?

A schedule is conflict-serialisable if all pairs of conflicting operations
from the participating transactions are executed in the same order at
all of the objects that they access. Such a schedule is equivalent to
some serial schedule – a schedule in which the operations of each
transaction are not interleaved with the operations of any other
transaction. A serial schedule is usually regarded as correct because
each transaction has a single view of the database, and its effects are
seen at the end of its execution.
                                                                 (4 marks)

(iv) Write down an algorithm which tests for conflict serialisability of a schedule
using a precedence graph.

Stage 1: Graph creation.
For each participating transaction Ti create a node in the precedence

                                       Page 4 of 6
COM873J2 – Distributed Data Systems - SOLUTIONS

For each pair of conflicting operations in the schedule draw a directed
arc from the transaction whose operation is first in the schedule to the
transaction whose operation is later in the schedule.
The schedule is serialisable if and only if the precedence graph has no

                        (s1, t2)

           S                               T

                                                                            (5 marks)

(v) Given the schedule E below which is a schedule relating to the transactions S and
T in part (b) of this question create the corresponding precedence graph and hence
determine if the schedule is serialisable.
    E = (s1, s2, t1, s3, s4, t2)                                          (3 marks)

   Precedence graph is above. It has no cycle, so schedule is

(b) Transactions S and T are executed on (client) sites A and B in a distributed system,
    and there are two data (server) sites, C and D. Data items X and Z are on C and Y
    is on D. Only primary copies of the data exist.
    Discuss how the system would recover in each case below, assuming that the
    following state has been reached:

   Transaction S has written its COMMIT record to its log, and is at the stage of
   informing the lock managers at C and D that it has completed. The message
   releasing locks at C has arrived at C.

   Case 1. The message from A to D does not arrive.

   Case 2. The message from A to D arrives at D but the computer at D fails due to a
   power failure, before releasing locks at D.

   Case 3. The computer at site A fails before S has had a chance to send a message
   to D.
                                                                         (5 marks)

Case 1: Depends on why. S can resend the message and see if an
ACK appears. If this does not work because the break is long-lived
then D has locked items which may or may not belong to a committed
transaction.   If correctness is vital then D must wait until
communications are restored before it can release the items. (In

                                      Page 5 of 6
COM873J2 – Distributed Data Systems - SOLUTIONS

extremis another communication channel could be used of course.)
Otherwise, the lock manager at D may release the locks held by S,
possibly causing inconsistencies.

Case 2. In this case A will not receive an ACK from D. It can simply
keep resending the message to D until D reboots. (Assuming that D
has a recovery protocol for its own data and local locks).

Case 3. As far as site D is concerned this situation corresponds to
case 1, because the message releasing the locks has failed to arrive.

                               Page 6 of 6

To top