LimeWire Consolidated API

com.limegroup.gnutella
Class QueryUnicaster

java.lang.Object
  extended by com.limegroup.gnutella.QueryUnicaster
All Implemented Interfaces:
Service

public final class QueryUnicaster
extends Object
implements Service

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.
 
Constructor Summary
QueryUnicaster(NetworkManager networkManager, QueryRequestFactory queryRequestFactory, ScheduledExecutorService backgroundExecutor, com.google.inject.Provider<MessageRouter> messageRouter, com.google.inject.Provider<UDPService> udpService, PingRequestFactory pingRequestFactory)
           
 
Method Summary
 boolean addQuery(QueryRequest query, ReplyHandler reference)
           
 void addUnicastEndpoint(InetAddress address, int port)
          Just feed me ExtendedEndpoints - I'll check if I could use them or not.
 String getServiceName()
           
 GUESSEndpoint getUnicastEndpoint()
          Returns a GUESSEndpoint from the current cache of GUESS endpoints.
 List<GUESSEndpoint> getUnicastEndpoints()
          Returns a List of unicast Endpoints.
 void handleQueryKeyPong(PingReply pr)
          Feed me AddressSecurityToken pongs so I can query people....
 void handleQueryReply(QueryReply qr)
          Feed me QRs so I can keep track of stuff.
 void initialize()
           
 void start()
          Starts the query unicaster thread.
 void stop()
           
 
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
Constructor Detail

QueryUnicaster

@Inject
public QueryUnicaster(NetworkManager networkManager,
                             QueryRequestFactory queryRequestFactory,
                             ScheduledExecutorService backgroundExecutor,
                             com.google.inject.Provider<MessageRouter> messageRouter,
                             com.google.inject.Provider<UDPService> udpService,
                             PingRequestFactory pingRequestFactory)
Method Detail

getUnicastEndpoints

public List<GUESSEndpoint> 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.

Specified by:
start in interface Service

getServiceName

public String getServiceName()
Specified by:
getServiceName in interface Service

initialize

public void initialize()
Specified by:
initialize in interface Service

stop

public void stop()
Specified by:
stop in interface Service

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(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 AddressSecurityToken pongs so I can query people.... pre: pr.getQueryKey() != null


LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.