com.limegroup.gnutella.search
Class QueryDispatcher

java.lang.Object
  extended bycom.limegroup.gnutella.search.QueryDispatcher
All Implemented Interfaces:
java.lang.Runnable

public final class QueryDispatcher
extends java.lang.Object
implements java.lang.Runnable

This class handles the thread that dispatches dynamic queries for Ultrapeers. This maintains the data for all active queries for this Ultrapeer and any of its leaves, also providing an interface for removing active queries. Queries may be removed, for example, when a leaf node with an active query disconnects from the Ultrapeer.


Method Summary
 void addQuery(QueryHandler handler)
          Adds the specified QueryHandler to the list of queries to process.
static QueryDispatcher instance()
          Instance accessor for the QueryDispatcher.
 void removeReplyHandler(ReplyHandler handler)
          This method removes all queries for the given ReplyHandler instance.
 void run()
          Starts the thread that processes queries.
 void start()
          Schudules the processing of queries for execution.
 void updateLeafResultsForQuery(GUID queryGUID, int numResults)
          Updates the relevant QueryHandler with result stats from the leaf.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static QueryDispatcher instance()
Instance accessor for the QueryDispatcher.

Returns:
the QueryDispatcher instance

start

public void start()
Schudules the processing of queries for execution.


addQuery

public void addQuery(QueryHandler handler)
Adds the specified QueryHandler to the list of queries to process.

Parameters:
handler - the QueryHandler instance to add

removeReplyHandler

public void removeReplyHandler(ReplyHandler handler)
This method removes all queries for the given ReplyHandler instance.

Parameters:
handler - the handler that should have it's queries removed

updateLeafResultsForQuery

public void updateLeafResultsForQuery(GUID queryGUID,
                                      int numResults)
Updates the relevant QueryHandler with result stats from the leaf.


run

public void run()
Starts the thread that processes queries.

Specified by:
run in interface java.lang.Runnable