CSEP545 - Final Project for Java

Unpackage and Install

Required Software


Download the project template. http://www.cs.washington.edu/education/courses/csep545/12wi/csep545-java.zip

Unzip it.

We assume that your working directory is csep545-project.

Modifying Code

The project use Java RMI as RPC mechanism. We provide most of the API as well as implementation so that you do not need to deal with RMI directly. To learn more about RMI, please refer following documentation.

All required interface are defined in the package tp. We expect you to modify tp.TM to implement two-phase commit. Other than that, please try to keep the interfaces intact.

We expect you to implement all the APIs in tp.WC class. All transactions are serializable by default. Weaker isolation is extra-credit.

Please put your implementation under tp.impl package. You will need to update all the tp.impl.My* classes.

For your convenience, we provide a single-threaded version of implementation and bootstrapping of the managers. If you find any problem, please contact TA.

We also provide a command line client tp.client.CommandLineClient for your convenience. Please feel free to extend the client. If you write another client, please put the new client under the tp.client package.

Please refer following documentation for the interface and provided API. [local] [online]

Building Project

Under the project root directory,

To compile and build csep545.jar,

% ant or ant jar
Or, in Eclipse, double click csep545.jardesc then click Finish in the dialogue window.

To compile and build csep545-client.jar,

% ant jar-client
Or, in Eclipse, double click csep545-client.jardesc then click Finish in the dialogue window.

To clean the project,

% ant clean

Running Project

We assume you are under the project root directory. If you are running in Win32 cmd.exe, prefix start to each command line so that each command run in new console.

Step 1. Run RMI registry

% rmiregistry
If you want the registry listen on different port, specify the port number as argument.

% rmiregistry 9999

Step 2. Run HTTP server

Now run a web server (included in the project template) that serves the jar file for RMI.

% java -jar webserver.jar

By default, the web server listens on port 8080.

Command line arguments of the Web server
Argument Description Default
-p port or --port port port number 8080
-d dir or --root dir document root directory current working directory
-l or --local listen only on loopback device ( false

Notes: This step is due to a known bug introduced in JDKu29 (Release notes). We have not tested this with file URI in different JDK but for simplicity, please follow this step since it works for all versions.

Step X. Intermission

From Step 3 to Step 5, you will run the managers that you implemented for the project. All managers (MyTM, MyRM, MyWC) inherit tp.impl.CSEP545ServiceObject.

The managers accept the following command line arguments in common.
Common command line arguments of managers
Argument Description Default
-n name or --name name the name of service. For example, flight would be a good name as a RM dedicated to flight resource The type of manager (TM, RM, WC)
-p port or --port port The port number to bind the manager 0 (randomly choose available port number)
-d dir or --dir dir directory to store persistent data (logs, database files) './' serviceid + '-data'
--init force initialization. Existing data directory will be wiped out and initialized do not force initialization
--rmiHost host host name of RMI registry service in Step 1.
--rmiPort port port number of RMI registry service in Step 1. 1099
-c URL or --code URL RMI server code base (java.rmi.server.codebase property). The web server information in Step 2 with your jar file name.

For more detail, please refer the javadoc of CSEP545ServiceObject.

Step 3. Run Transaction Manager

Run Transaction Manager.

Note that java.rmi.server.codebase expect a URL to your jar file. Please make sure you specify the right host name and port number of web server in step 2.

The security policy by default grants all permissions to your server RMI application. If you feel uncomfortable, please update security.policy file to restrict permission.

If you use all default values, your command line should look like below:

% java -Djava.security.policy=security.policy -jar csep545.jar TM ...

Step 4. Run Resource Managers

Now run Resource Managers. Repeat this step as many times as you need.

If you use all default values, your command line should look like below:

% java -Djava.security.policy=security.policy -jar csep545.jar RM ...

Later, if you want to use separate RMs for flight, room, and car, use -n or --name option to assign unique identifier per RM

The Resource Manager accept the following command line arguments in addition to the common arguments. For the detail, please refer MyRM class.

Command line arguments of Resource Manager
Argument Description Default
-x numio or --selfdestruct numio Set self-destruction counter to numio 0 (Do not self-destruct)
-t to or --timeout to Set deadlock detection timeout to to seconds 10

Step 5. Run Workflow Controller

Now run Resource Managers. Repeat this step as many times as you need.

If you use all default values, your command line should look like below:

% java -Djava.security.policy=security.policy -jar csep545.jar WC 

WC will not need further arguments.

Step 6. Run Client

Now run your own client or test program. java.security.policy as well as java.rmi.server.codebase are now required.

% java -Djava.security.policy=security.policy \
-Djava.rmi.server.codebase= \
-cp csep545.jar your.client.class ...

To run the default command line client with default arguments as above steps, your command line should look like below:

% java -Djava.security.policy=security.policy -jar csep545-client.jar

The command line client is interactive. It will take one line from the console and execute until exit or quit commands. Please refer the javadoc and the code for more detail.