Wednesday 7 October 2015

Answers to Exercises - Distributed Systems - Chapter 5




Skipping Chapters 2-4. Didn't really do good in first exam. So might as well start studying chapters 5-8 covered for the 2nd exam.




5.1 - The Election interface provides two remote methods:
 

vote: with two parameters through which the client supplies the name of a candidate (a string) and the ‘voter’s number’ (an integer used to ensure each user votes once only).  The voter’s numbers are allocated sparsely from the range of integers to make them hard to guess.
 

result: with two parameters through which the server supplies the client with the name of a candidate and the number of votes for that candidate.
 

Which of the parameters of these two procedures are input and which are output parameters?

5.1 Ans.

vote: input parameters: name of candidate, voter’s number;
result: output parameters: name of candidate, number of votes




5.2 - Discuss the invocation semantics that can be achieved when the request-reply protocol is implemented over a TCP/IP connection, which guarantees that data is delivered in the order sent, without loss or duplication. Take into account all of the conditions causing a connection to be broken.

5.2 Ans.

A process is informed that a connection is broken:
  • when one of the processes exits or closes the connection.
  • when the network is congested or fails altogether

Therefore a client process cannot distinguish between network failure and failure of the server.
 


Provided that the connection continues to exist, no messages are lost, therefore, every request will receive a corresponding reply, in which case the client knows that the method was executed exactly once.

However, if the server process crashes, the client will be informed that the connection is broken and the client will know that the method was executed either once (if the server crashed after executing it) or not at all (if the server crashed before executing it).
 

But, if the network fails the client will also be informed that the connection is broken. This may have happened either during the transmission of the request message or during the transmission of the reply message. As before the method was executed either once or not at all.
 


Therefore we have at-most-once call semantics.




5.3 - Define the interface to the Election service in CORBA IDL and Java RMI. Note that CORBA IDL provides the type long for 32 bit integers. Compare the methods in the two languages for specifying input and output arguments.



5.3 Ans.
 

CORBA IDL:

interface Election {
         void vote(in string name, in long number);
         void result(out string name, out long votes);
};




Java RMI
      We need to define a class for the result e.g.
 

class Result {
         String name;
         int votes;
}



The interface is:
import java.rmi.*;
public interface Election extends Remote {
        void vote(String name, int number) throws RemoteException;
        Result result () throws RemoteException;
};



This example shows that the specification of input arguments is similar in CORBA IDL and Java RMI.
        This example shows that if a method returns more than one result, Java RMI is less convenient than CORBA IDL because all output arguments must be packed together into an instance of a class.





5.4 - The Election service must ensure that a vote is recorded whenever any user thinks they have cast a vote.
Discuss the effect of maybe call semantics on the Election service.
Would at-least-once call semantics be acceptable for the Election service or would you
recommend at-most-once call semantics?



5.4 Ans.
Maybe call semantics is obviously inadequate for vote ! Ex 5.1 specifies that the voter’s number is used to ensure that the user only votes once. This means that the server keeps a record of who has voted. Therefore at-least-once semantics is alright, because any repeated attempts to vote are foiled by the server.