Safe Electronic Postcard Application with CORBA (part III)

Name

Short: Central Coordinator CORBA server
Long: Safe Electronic Postcard Application with CORBA (part III)

Objective

The purpose of this lab is to implement a safe way of using the Corba CardWriter server.

CardWriter Server Problem

The current implementation of the CardWriter class has a problem that potentially occurs when two clients access concurrently the CardWriter object.

Assume for example, that there are two clients that create two references to the CardWriter: c1 and c2.
Client1
c1.setCard(inputCardName1, x1,y1,width1,height1);
c1.setMesage("message1");
c1.writeCard(outputFileName1);

Client2
c2.setCard(inputCardName2, x2,y2,width2,height2);
c2.setMesage("message2");
c2.writeCard(outputFileName2);
Imagine that these operations are performed in the following order:
c1.setCard(inputCardName1, x1,y1,width1,height1);
c1.setMesage("message1");
c2.setCard(inputCardName2, x2,y2,width2,height2);
c2.setMesage("message2");
c1.writeCard(outputFileName1);
c2.writeCard(outputFileName2);

As a result, Client1 will get the card writen by Client2 (actually it can realize that something went wrong because the name returned by the CardWriter is not the one supplied by Client1). Client2 will not encounter any misbehavings.

Assumption

One solution would be to make the operations from the CardWriter that are involved in creating the picture atomic. However, this requires access to the CardWriter code. We assume that we can not modify the CardWriter class. Instead, your task is to design "polite" clients and a central coordinator that grants access to the clients that want to use the CardWriter object.

Time allocation

Four hours are allocated to complete this lab assignment.

Exercise

You will have to implement in (C++ or Java) the Coordinator server for the application written in the previous assignments and then modify the client to use the Coordinator for requesting and releasing the access to the CardWriter object. The IDL interface for the Coordinatoris given.

TO DO

  1. Make sure that you completed the first 2 steps in Assignment 3.
  2. Show an example of a possible misbehaviour of the CardWriter when is concurrently accessed by two clients
  3. Modify the "Hello world" example in order to implement the Coordinator object:

Reporting your work

The lab is reported by showing the assistant the working application. All members of the lab group should be present when reporting.

Appendices