I'm really really lost right now in class. I understand the basic concept of the Supervisor/worker pattern of developing a program, but have no idea how to design the following program. My professor isn't much help, as I have asked him numerous questions with no results. The problem is that I haven't had any networking/internet socket whatever you want to call it kind of class yet. So the following program to be designed is a nightmare for me. Please Help! I must...
Develop a supervisor-worker system that will retrieve information from several web sites in parallel. The supervisor should provide a function to the outside world:
public void getSites( int num_workers, ArrayList sitelist, ArrayList sitedata )
The caller will provide a list of URL's in sitelist. The entries will be structured as follows: element i will be a computer name and element i+1 will be the item to retrieve. So, for example, if the user wants to retrieve these three web pages:
The sitelist list will contain these strings:
When the getSites() function returns, the array sitedata should have the results from each site (as strings), in order (so sitedata.get(0) would return the data from cnn.com; sitedata.get(1) returns the data from wired, and so forth).
After sending this data, the server responds with the contents of the site, including a few headers. You can include these in your sitedata ArrayList along with the rest of the site's response. HTTP requests are made to port 80.
How you structure your supervisor and workers is up to you, but each one should be its own object. The caller may want several workers to work simultaneously, so your program should work correctly for any number requested (it will be at least one, but your code should not impose an upper limit, in case the user has a really fast computer and wants to stress-test it).
You will probably want to create some test program that will call the supervisor with a list of sites to check. If you want to get fancy (which I don't), you can make a GUI interface with progress reporting, thermometers, and whatever else you like.