Almost everyone had a very difficult time with Project 3, the software pipe and filter architecture that was implemented using many threads. To help in understanding how that project is supposed to work, you will re-implement each part of that project in a sequence, building up the entire project from its constituent parts. In the end, the project will have the identical functionality of Project 3, so see the specification of that project for the details of the overall system architecture. For this project, you will implement the parts of Project 3 in 5 steps:
Here's the additional info on testing parts 4 & 5. Testing for each of the text and sieve filters is described in this text file, with the Java driver code in this file. For the text filters, you have to supply input text. The drivers for running the filters in combination are still Text.java and Erast.java . The only change from above is that you should also run Erast with an input of 500, to test if your code works properly when it generates a large number of threads.
Test code for each of the five parts of the project is given above, and that will be exactly the code that will be used to grade your project. You should test the parts of your project in the sequence described above, making sure that your code works properly for each part before moving on to the next part. Each of the 5 parts is worth 20 points (no commentary for this project), and you can only get credit for a part of the project if all previous parts work (e.g., if parts 1 and 2 work, but part 3 doesn't, you can't get credit for parts 4 and 5).
Here again are the interfaces for the Filter and FilterBuffer interfaces, with corresponding FilterImpl and FilterBufferImpl classes, that you must write:
public interface Filter {
void setConnection(java.io.Reader in, java.io.Writer out);
java.io.Reader getInputConnection();
java.io.Writer getOutputConnection();
FilterBuffer getInputBuffer();
FilterBuffer getOutputBuffer();
void startFilter(); // start computing
}
public class FilterImpl implements Filter {
FilterImpl(java.io.Reader in, java.io.Writer out, int maxReadBufSize, int maxWriteBufSize, Runnable compute);
}
public interface FilterBuffer {
char[] read (); // returns current contents of buffer and clears it. Returns a zero-length array if its internal buffer is empty and the FilterBuffer has been closed
void write(char[] str) throws bufTooSmallException; // write str to buffer if str.length is less than maxBufferSize, otherwise throws exception
int getMaxBufferSize();
void close(); // informs the FilterBuffer that no more data will be written to it
void flush(); // doesn't return until the buffer is empty
}
public class FilterBufferImpl implements FilterBuffer {
FilterBufferImpl(int maxSize);
}
You do not have to implement logging of thread start and exit events as in Project 3. However, that code may be useful for debugging your classes, so use it as needed. But do not include any logging code in your submissions (comment it out in the files you submit).