All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Webcrawler.Crawler.Readers

java.lang.Object
   |
   +----java.util.Observable
           |
           +----Webcrawler.Crawler.Readers

public class Readers
extends Observable
implements Observer
This is the class that organizes all the Reader-Threads. If a new node is available in the todo-pool, it takes it and creates a new Reader for it if the maximum number of Readers isn't reached yet. This object is Observable itself, because it notifies all attached Observers (usually the one Crawler) when a node is done reading (sends out a ReadersMessage).

See Also:
Reader, Crawler, ReadersMessage

Variable Index

 o currentlyRunning
 o currentReaders
 o maxThreadNum
 o todoPool

Constructor Index

 o Readers(FIFOQueue)
Prepares a new ThreadGroup for the Readers.

Method Index

 o getCounter()
 o getReadingNodes()
 o nodeDone(Reader, LoadableNode)
 o setMaxThreadNum(int)
Sets the maximum number of allowd threads.
 o startThread()
Starts a new Thread that downloads the next node from the todo-pool (if available).
 o stopAll()
Stops all the Reader-threads.
 o update(Observable, Object)
Called when a node was added to the todo-pool

Variables

 o todoPool
 private FIFOQueue todoPool
 o maxThreadNum
 private int maxThreadNum
 o currentlyRunning
 private int currentlyRunning
 o currentReaders
 private Vector currentReaders

Constructors

 o Readers
 public Readers(FIFOQueue todoPool)
Prepares a new ThreadGroup for the Readers. To set the maximum number of threads, use the method setMaxThreadNum(num)

Parameters:
todoPool - the todo-pool where this object takes the nodes from

Methods

 o setMaxThreadNum
 public void setMaxThreadNum(int maxThreadNum)
Sets the maximum number of allowd threads. Since no computer-system can have an infinite number of threads this is important. The default number is 1 (set by the constructor)

 o startThread
 public synchronized void startThread()
Starts a new Thread that downloads the next node from the todo-pool (if available).

 o update
 public synchronized void update(Observable o,
                                 Object message)
Called when a node was added to the todo-pool

 o nodeDone
 protected synchronized void nodeDone(Reader r,
                                      LoadableNode n)
 o getCounter
 public int getCounter()
Returns:
The number of currently running Reader-threads.
 o getReadingNodes
 public Vector getReadingNodes()
Returns:
a Vector filled with the nodes that are currently read by the Reader-threads
 o stopAll
 public void stopAll()
Stops all the Reader-threads. e.g. called when the user presses the Stop-button.


All Packages  Class Hierarchy  This Package  Previous  Next  Index