org.apache.manifoldcf.crawler.system
Class DocumentQueue

java.lang.Object
  extended by org.apache.manifoldcf.crawler.system.DocumentQueue

public class DocumentQueue
extends java.lang.Object

This class describes a document queue, which has a "stuffer" thread and many "reader" threads. The queue manages thread synchronization so that (a) the "stuffer" thread blocks until queue is empty, and (b) the "reader" threads block if queue is empty. The objects being queued are all QueuedDocumentSet objects.


Field Summary
static java.lang.String _rcsid
           
protected  java.util.ArrayList queue
           
protected  boolean resetFlag
           
 
Constructor Summary
DocumentQueue()
          Constructor.
 
Method Summary
 void addDocument(QueuedDocumentSet dd)
          Add a document to the queue.
 boolean checkIfEmpty(int n)
          Check if "empty".
 void clear()
          Clear the queue.
 QueuedDocumentSet getDocument(QueueTracker overlapCalculator)
          Pull the best-rated document set off the queue, but wait if there is nothing there.
 void reset()
          Wake up all threads waiting on this queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rcsid

public static final java.lang.String _rcsid
See Also:
Constant Field Values

queue

protected java.util.ArrayList queue

resetFlag

protected boolean resetFlag
Constructor Detail

DocumentQueue

public DocumentQueue()
Constructor.

Method Detail

reset

public void reset()
Wake up all threads waiting on this queue. This happens at the beginning of a reset.


clear

public void clear()
Clear the queue. This happens during a reset.


checkIfEmpty

public boolean checkIfEmpty(int n)
Check if "empty".

Parameters:
n - is the low-water mark; if the number falls below this, then this method will return true.

addDocument

public void addDocument(QueuedDocumentSet dd)
Add a document to the queue.

Parameters:
dd - is the document description.

getDocument

public QueuedDocumentSet getDocument(QueueTracker overlapCalculator)
                              throws java.lang.InterruptedException
Pull the best-rated document set off the queue, but wait if there is nothing there.

Parameters:
overlapCalculator - performs analysis of the document sets on the queue so that we can pick the best one.
Returns:
the document set.
Throws:
java.lang.InterruptedException