CSE 4510: Lab Assignment #8

Due: Friday March 5, 1999

The Task

This task builds upon lab assignment #7. The input to the one ancestor database may come from different files files as well as the standard input stream.
java AncestorDB file
java AncestorDB -
java AncestorDB file1 - file2
The argument '-' stands for the standard input stream. For each source of input use a separate thread to process the commands. You have to insure that each database update is executed atomically (i.e., without interference from other thread also trying to update the database.) The queries in each file of transactions generate output (on the standard output stream). The output of individual queries must not be interleaved with the output of other queries. But the order in which queries are processed may vary depending on which thread gets to a query first.

A semicolon as a command line argument means the the preceeding input must all be processed first before any subsequent input is processed. This means the output for all the queries of the first input set must come before the output of any queries in the subsequent input. The command line may contain several semicolons; this breaks the processing up into several sets of input. In each set, all the files are processed in parallel.

Here is a simple example of how the program could be invoked:

java AncestorDB file1 - file2 ";" file3 file4 file5
(The quotes around the semicolon are necessary in those command line environments in which the semicolon ends the command line. The quotes are not part of the argument. Experiment with Args.java to how command arguments may be interpreted in your command line environment.) In this example, the standard input, file1, and file2 are processed concurrently. Afterwards file3, file4, and file4 are processed concurrently.

Here is a more complex example:

java AncestorDB file1 file2 ";" file3 ";" file4 file5 file6 file7 file8 ";" file9
You may assume that no more than 10 input streams will ever need to be processed at the same time.

Problematic Cases

It does not make sense to use the argument '-' (standing for the standard input stream) more than once. If it appears again in the command line, it is ignored and the following message is printed on the standard error output stream.

The command line argument n is ignored,
because a previous "-" argument has been found.
n should be replaced by the actual number of the argument. The first argument has n equal 1 (not 0).

It is also meaningless to use the semicolon argument without having at least one source of inputs. This example has three empty sets of input.

java AncestorDB ";" ";" ";"
For each emtpy set, print the following message.
The command line argument n is ignored,
because it ends an empty set of inputs.

java AncestorDB
is legal and does nothing (no error messages).

Helpful stuff

Turning it in

Use the following command on maelstrom.cs.fit.edu or zach.cs.fit.edu

~ryan/bin/mfiles ryan@cs.fit.edu "cse4510/lab08" files ...

Your program must compile using the command javac AncestorDB.java. Be sure your name is in comments somewhere at the beginning of each Java file you submit. Try to avoid putting tabs in your files as tabs are rarely interpreted the same by different applications. With luck a summary of the submissions for this lab exercise will be found in the file lab08-sub.txt.


Ryan Stansifer <ryan@cs.fit.edu>
Last modified: Mon Mar 15 09:00:02 EST 1999