Threaded Query Server due Fri 10 Feb 11:00

\begin{purpose}
In completing this assignment the student will:
\begin{itemize...
...rent threads to query a non-standard
database
\end{itemize}\par
\end{purpose}

Overview

This assignment explores a possible use of threads in the implementation of a simple query server. You may find it useful to play around with Java threads prior to attempting this assignment. There is a good bit of code provided in a repository as a starting point. Most of the provided code should be considered immutable (should not be changed). Documentation for the existing code is available at

http://josephus.hsutx.edu/classes/os/source/bookdb-documentation/

Using git for Homework

This semester the CSCI department is moving forward with plans to standardize on the use of git as the version control system of choice for managing and turning in homework. For this and several future assignments I am providing starter code in the form of a git repository hosted on bitbucket.org.

You will clone the starter code and create a private repository of your own that you will share with me. I will grade your work by cloning your homework repository. All of the homework assignments will reside in a single repository so there will be times you will update from the original (base) repository and other times you will update from your own bitbucket repository.

To get properly setup you will read and follow the instructions in the first three sections of Using git for Homework. The sections you should work through are titled: ``Background'', ``Setting up Your Workspace'', and ``Setting Up a Hosted Repository''. The URL for the base homework repository for this course is:

https://tsergeant@bitbucket.org/tsergeant/os_homework.git

NOTE: Since you may already have some experience with git or with bitbucket.org you may not need to perform every step listed.

Provided Code

You will do your work in the hw02 directory of your os_homework working repository. Take some time to compile and run the starter program. Then study the source code to see how it works. The link to the online documentation provided above will likely prove helpful. Once you have a decent understanding of the existing code you will be ready to start the assignment.

IMPORTANT: DO NOT CHANGE ANY CODE IN THESE FILES: Book.java, BookDatabase.java, and SearchRequest.java. You will not receive full credit for this assignment if git indicates any of these files are modified.

Program Behavior

The final program will load the database and prompt the user to enter a search string. The program will search for the specified value in each of the five fields that exist in the database. Once the results have been displayed the user will be prompted to enter another search string. This continues until the user simply pressed <Enter> to indicate they are done searching. A transcript of the results of running my version of the program against the database is given at the end of this assignment.

In the provided hw02 directory you will find a file named bookdb.out that contains a transcript of my program for a variety of search values. This will give you an indication of how the program should function. Notice that in some search results the output from different threads is interleaved.

What About Threads?

Here's how I would like you to use threads. When the user enters a search string create five separate threads to perform the search. You will assign one thread for each field. Thus, the database will be searched ``simultaneously'' on each field. Although you will have five threads, they should all be of the same type and upon creation you should designate the field upon which the thread should search. The actual search performed by the thread will be accomplished by calling the appropriate method of the BookDatabase object.

In the case that a thread finds a match, it should display the matching entry together with the field upon which the match was found. Then it should continue searching that field for additional matches.

In the driver program the threads should all be started prior to issuing any joins. Once the threads have finished you will prompt the user to enter another search string.

Turning in the Program

As part of these instructions you will have created and shared a private repository with me that was initially created by cloning the provided os_homework repository. I will grade the source code found in that shared repository according the following criteria:

Correctness/Completeness 22 pts
Documentation 2 pts
Java Conventions 2 pts
Setup and use of git 4 pts
Total 30 pts

Quick Links