courses:cs334-201503:pproject.docx (14.6 KB)

advertisement
cmpu-334
fall, 2015
Programming Project
For this project you will write a Tweeter-Producer-Consumer application. It is a threaded
producer/consumer framework that will have a producer read from a file (input.txt) a "Tweet Container"
object and put it on the queue for consumer(s) to process. The Tweet Container class
has three fields: a request field (READ or WRITE request), a name field and a tweet field, which is a
(possibly null) character string that has a maximum of 140 characters. Assume there are no white spaces
in the Twitter name. I will supply an input.txt starter file. Feel free to add additional tweet requests!
An example of an entry in the input.txt input file:
WRITE @VASSAR Hear Dr. Rita Charon discuss the role of writing as a
healing art (11/19, 6:00pm) http://goo.gl/k9WeKk
The consumer work
For a WRITE request: the consumer will create a file using the name field, and write the tweet to file.
For a READ request: the consumer will open the file using the name, and print the tweet to the java
console. The tweet field will not be checked and should be null, but it does not have to be.
Given the input example above, the consumer will create a file called “@VASSAR” or “VASSAR” that
contains the associated text. Tweet.
The file cache
The consumer(s) will have a cache available to them so that when a WRITE request is processed, the file
is written to cache and to file. When a read request is processed, the consumer will check the cache to
see if it is there before reading from file. The tweet will be read from cache if it is there, otherwise the
tweet will be read from file.
Accounting
Your program should provide valuable statistics regarding the performance of your program. This can be
printed on the output screen at the end of the run or put into a separate file:





The number of records read in from input.txt
The number of files created
Total number of READ and WRITE requests
The number of cache hits and cache misses
Producer & Consumer Thread information – number of tasks processed, average time to process
a request, total processing time.
Date Due: The last day of class, but I will accept submissions through December 15. You should have
enough information as of 11/19/15 to do everything except the file cache.
Grading
This project is worth 25% of your final grade and will be graded on a 25 point scale:
1. The program works. That is, I should be able to unzip the project and run it in netbeans, or
another IDE. Read requests will display a message on the output screen and write requests will
create a new file for all requests in the input.txt file: 10 points
2. Using threads: 2 points. Using thread pools and an executor service: 3 points
3. Utilizing a cache: 5 points
4. Creating Accounting information: 5 points
Total: 25 points
Download