CS 542: Distributed Database Systems, Spring 2020

Home Reading List Slides Homeworks Weekly Readings Project

CORBA Example

Purpose

From this example you will learn about:

Description

You will develop a client/server application with CORBA and Java. The server acts like a bank: it maintains two accounts X and Y, both having some nonzero initial values. The client may read X and Y from the server, and perform a transfer between the two accounts. The server is registered in the Implementation Repository for an Orbix daemon, and the client is supposed to be able to communicate with the server wherever the client is running.

The client should be implemented as an Java applet. It should have at least four text fields for displaying X, Y, their sum, and the amount for transfer. It should have labels indicating what each textfield is displaying. It should have at least three buttons: one is to read X and Y from the server, calculate their sum, and display them in the corresponding textfields; one is to send a request to the server for transferring the specified amount from account X to Y; the third one is for transferring from account Y to X. You are free to add more items, like the button for 'Quit', textfields and button letting the user specify the server name and its host name before making connections, etc.

The server should maintain two data items X and Y. Just to be simple, X, Y and the transfer amount can be always integer. It should provide methods which can be called remotely by the client to read X and Y and perform transfers. However, we want to introduce concurrency control problems into transfers, each of which is regarded as a transaction. In the server's method(s) for transfer, the server should not perform the transfer directly, instead, it must create a thread which handles the transfer as a transaction. The thread should get the amount to transfer from its parent when it is created, then it should perform the following operations on X and Y (if the transfer is from X to Y):

Read(X)
Read(Y)
X = X - transferAmount; Y = Y + transferAmount; Write(X)
Write(Y)

'

To allow the user to control the execution of the operations, the thread should generate a window which is a Java frame. In this window, there is a textfield displaying the next operation to be executed, and a button 'Next' for executing the next operation. So the execution of the thread should be as follows:

  1. Open up a frame
  2. display 'Read(X)' in the textfield
  3. wait for the user to click button 'Next'...
  4. read X from the server
  5. display 'Read(Y)'
  6. wait for the user to click button 'Next'...
  7. read Y from the server
  8. display 'Write(X)'
  9. wait for the user to click button 'Next'...
  10. compute X = X - transferAmount; Y = Y + transferAmount;
  11. write X to the server
  12. display 'Write(Y)'
  13. wait for the user to click button 'Next'...
  14. write Y to the server
  15. close the frame and exit

It is not necessary to display the read or written value of X or Y in the window.

The thread and its methods should NOT be synchronized. Clearly, while two clients are running at the same time, the transactions they execute may be interleaved if the user deliberately manages the execution of their operations. Thus inconsistency resulted from various violations of concurrency control may appear, which is reflected by the change of the sum of X and Y when a client performs another read after the execution of the transactions.

On-line Help

Guidelines


In order to avoid the conflicts of different students' work on the same machine, everyone should run his or her own Orbix daemon, but on a different port. This means that everyone should install some part of the software, which can be configured for running Orbix daemon on different ports. You should follow the following steps exactly in order:

The demo programs will be compiled, and at the end it will tell you how to use it. Basically, you should:

Before you register a server with the same name again, or terminate the orbixd daemon, you should get rid of the server:

You may use commands lsit, catit, and psit to know more about the server and the implementation repository. To learn more about these commands, you may visit OrbixWeb Reference Guide, or simply check its manual by typing man putit, for instance.

I recommend you to study the demo gridApplet thoroughly, take it as the basis for your project, and use similar directory structures and almost the same Makefile. The only things you may want to change in the Makefile are the server name and the package name.