com.limegroup.gnutella
Class QueryUnicaster

java.lang.Object
  extended bycom.limegroup.gnutella.QueryUnicaster

public final class QueryUnicaster
extends java.lang.Object

This class runs a single thread which sends unicast UDP queries to a master list of unicast-enabled hosts every n milliseconds. It interacts with HostCatcher to find unicast-enabled hosts. It also allows for stopping of individual queries by reply counts.


Field Summary
static int ITERATION_TIME
          The time in between successive unicast queries.
static int MAX_ENDPOINTS
          The max number of unicast pongs to store.
static int MIN_ENDPOINTS
          The number of Endpoints where you should start sending pings to them.
static long ONE_HOUR
          One hour in milliseconds.
 
Method Summary
 boolean addQuery(QueryRequest query, ReplyHandler reference)
           
 void addUnicastEndpoint(java.net.InetAddress address, int port)
          Just feed me ExtendedEndpoints - I'll check if I could use them or not.
 GUESSEndpoint getUnicastEndpoint()
          Returns a GUESSEndpoint from the current cache of GUESS endpoints.
 java.util.List getUnicastEndpoints()
          Returns a List of unicast Endpoints.
 void handleQueryKeyPong(PingReply pr)
          Feed me QueryKey pongs so I can query people....
 void handleQueryReply(QueryReply qr)
          Feed me QRs so I can keep track of stuff.
static QueryUnicaster instance()
          Need to call initialize() to make sure I'm running!
 void start()
          Starts the query unicaster thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ITERATION_TIME

public static final int ITERATION_TIME
The time in between successive unicast queries.

See Also:
Constant Field Values

MIN_ENDPOINTS

public static final int MIN_ENDPOINTS
The number of Endpoints where you should start sending pings to them.

See Also:
Constant Field Values

MAX_ENDPOINTS

public static final int MAX_ENDPOINTS
The max number of unicast pongs to store.

See Also:
Constant Field Values

ONE_HOUR

public static final long ONE_HOUR
One hour in milliseconds.

See Also:
Constant Field Values
Method Detail

instance

public static QueryUnicaster instance()
Need to call initialize() to make sure I'm running!


getUnicastEndpoints

public java.util.List getUnicastEndpoints()
Returns a List of unicast Endpoints. These Endpoints are the NEWEST we've seen.


getUnicastEndpoint

public GUESSEndpoint getUnicastEndpoint()
Returns a GUESSEndpoint from the current cache of GUESS endpoints.

Returns:
a GUESSEndpoint from the list of GUESS hosts to query, or null if there are no available hosts to return

start

public void start()
Starts the query unicaster thread.


addQuery

public boolean addQuery(QueryRequest query,
                        ReplyHandler reference)
Parameters:
query - The Query to add, to start unicasting.
reference - The originating connection. OK if NULL.
Returns:
true if the query was added (maybe false if it existed).

addUnicastEndpoint

public void addUnicastEndpoint(java.net.InetAddress address,
                               int port)
Just feed me ExtendedEndpoints - I'll check if I could use them or not.


handleQueryReply

public void handleQueryReply(QueryReply qr)
Feed me QRs so I can keep track of stuff.


handleQueryKeyPong

public void handleQueryKeyPong(PingReply pr)
Feed me QueryKey pongs so I can query people.... pre: pr.getQueryKey() != null