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
-
currentlyRunning
-
-
currentReaders
-
-
maxThreadNum
-
-
todoPool
-
-
Readers(FIFOQueue)
- Prepares a new ThreadGroup for the Readers.
-
getCounter()
-
-
getReadingNodes()
-
-
nodeDone(Reader, LoadableNode)
-
-
setMaxThreadNum(int)
- Sets the maximum number of allowd threads.
-
startThread()
- Starts a new Thread that downloads the next node from the todo-pool (if available).
-
stopAll()
-
Stops all the Reader-threads.
-
update(Observable, Object)
- Called when a node was added to the todo-pool
todoPool
private FIFOQueue todoPool
maxThreadNum
private int maxThreadNum
currentlyRunning
private int currentlyRunning
currentReaders
private Vector currentReaders
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
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)
startThread
public synchronized void startThread()
- Starts a new Thread that downloads the next node from the todo-pool (if available).
update
public synchronized void update(Observable o,
Object message)
- Called when a node was added to the todo-pool
nodeDone
protected synchronized void nodeDone(Reader r,
LoadableNode n)
getCounter
public int getCounter()
- Returns:
- The number of currently running Reader-threads.
getReadingNodes
public Vector getReadingNodes()
- Returns:
- a Vector filled with the nodes that are currently read by the Reader-threads
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