|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.limegroup.gnutella.HostCatcher
public class HostCatcher
The host catcher collects the addresses of Gnutella and DHT hosts from ping replies and bootstrap servers. Collected addresses are stored in a file between sessions. The servent may attempt to connect to these addresses as necessary to maintain full connectivity. Hosts that are known to be ultrapeers are preferred when caching and returning addresses.
| Nested Class Summary | |
|---|---|
static interface |
HostCatcher.EndpointObserver
Simple callback for having an endpoint added. |
| Field Summary | |
|---|---|
protected static int |
EXPIRED_HOSTS_SIZE
|
protected static int |
PROBATION_HOSTS_SIZE
|
| Constructor Summary | |
|---|---|
protected |
HostCatcher(ScheduledExecutorService backgroundExecutor,
ConnectionServices connectionServices,
com.google.inject.Provider<ConnectionManager> connectionManager,
com.google.inject.Provider<UDPService> udpService,
com.google.inject.Provider<DHTManager> dhtManager,
com.google.inject.Provider<QueryUnicaster> queryUnicaster,
com.google.inject.Provider<IPFilter> ipFilter,
UniqueHostPinger uniqueHostPinger,
NetworkInstanceUtils networkInstanceUtils,
Bootstrapper bootstrapper)
|
| Method Summary | |
|---|---|
int |
add(Collection<? extends Endpoint> endpoints)
Adds a collection of hosts to the catcher. |
boolean |
add(Endpoint e,
boolean forceHighPriority)
Adds a host, possibly ejecting others from the cache. |
boolean |
add(Endpoint e,
boolean forceHighPriority,
String locale)
Adds a host with known locale. |
boolean |
add(PingReply pr)
Adds hosts from a ping reply, possibly ejecting others from the cache. |
void |
connect()
Informs the host catcher that we have (re)connected to the network; reads the host file and starts pinging. |
void |
doneWithConnect(Endpoint e,
boolean success)
Notifies the catcher that a connection fetcher has finished attempting a connection to the given host. |
void |
expireHost(Endpoint host)
Adds the specified host to the group of expired hosts. |
protected Endpoint |
getAnEndpoint()
Removes and returns a host, blocking if one is not immediately available. |
void |
getAnEndpoint(HostCatcher.EndpointObserver observer)
Passes the next available host to the given EndpointObserver. |
Endpoint |
getAnEndpointImmediate(HostCatcher.EndpointObserver observer)
Returns a host immediately if one is available. |
protected ExtendedEndpoint |
getAnEndpointInternal()
Removes and returns the best available host, or null if no hosts are available. |
List<ExtendedEndpoint> |
getDHTSupportEndpoint(int minVersion)
Gets a (possibly empty) list of hosts that support the DHT. |
int |
getNumHosts()
Returns the number of hosts the catcher knows about. |
protected int |
getNumUltrapeerHosts()
Returns the number of hosts that are known to be ultrapeers. |
protected Iterator<ExtendedEndpoint> |
getPermanentHosts()
Returns an iterator of the set of permanent hosts. |
String |
getServiceName()
|
Collection<IpPort> |
getUltrapeersWithFreeLeafSlots(String locale,
int num)
Returns a collection containing up to the specified number of hosts that have advertised free leaf slots, matching the specified locale if possible. |
Collection<IpPort> |
getUltrapeersWithFreeUltrapeerSlots(String locale,
int num)
Returns a collection containing up to the specified number of hosts that have advertised free ultrapeer slots, matching the specified locale if possible. |
int |
handleHosts(Collection<? extends Endpoint> hosts)
Receives hosts from the bootstrapper, returning the number used. |
void |
initialize()
|
boolean |
isHostTLSCapable(IpPort ipp)
Returns true if the given host is known to be TLS-capable. |
boolean |
isValidHost(Endpoint host)
Determines whether a host is valid for adding to the catcher. |
boolean |
needsHosts()
Returns true if the host catcher needs hosts from the bootstrapper. |
void |
noInternetConnection()
Resets all recorded failures on the assumption that they were caused by having no internet connection |
void |
putHostOnProbation(Endpoint host)
Adds the specified host to the group of hosts currently on "probation." These are hosts that are on the network but that have rejected a connection attempt. |
void |
removeEndpointObserver(HostCatcher.EndpointObserver observer)
Removes an observer that is waiting for an endpoint. |
void |
reset()
Resets the state of the host catcher (only for testing). |
void |
sendMessageToAllHosts(Message m,
MessageListener listener,
Cancellable c)
Sends a ping to every host the catcher knows about (used for discovering DHT-capable hosts). |
void |
start()
Schedules background threads. |
void |
stop()
Shuts down background threads and saves the host file. |
protected void |
write()
Writes the host file to the default location. |
protected void |
write(File hostFile)
Writes hosts to the specified file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int EXPIRED_HOSTS_SIZE
protected static final int PROBATION_HOSTS_SIZE
| Constructor Detail |
|---|
@Inject
protected HostCatcher(ScheduledExecutorService backgroundExecutor,
ConnectionServices connectionServices,
com.google.inject.Provider<ConnectionManager> connectionManager,
com.google.inject.Provider<UDPService> udpService,
com.google.inject.Provider<DHTManager> dhtManager,
com.google.inject.Provider<QueryUnicaster> queryUnicaster,
com.google.inject.Provider<IPFilter> ipFilter,
UniqueHostPinger uniqueHostPinger,
NetworkInstanceUtils networkInstanceUtils,
Bootstrapper bootstrapper)
| Method Detail |
|---|
public void start()
start in interface Servicepublic String getServiceName()
getServiceName in interface Servicepublic void initialize()
initialize in interface Servicepublic void stop()
stop in interface Servicepublic void connect()
public void sendMessageToAllHosts(Message m,
MessageListener listener,
Cancellable c)
public List<ExtendedEndpoint> getDHTSupportEndpoint(int minVersion)
minVersion - the minimum DHT version, 0 to return all versions.protected void write()
protected void write(File hostFile)
throws IOException
IOExceptionpublic boolean add(PingReply pr)
public int add(Collection<? extends Endpoint> endpoints)
public boolean add(Endpoint e,
boolean forceHighPriority)
e - the host to addforceHighPriority - true if the host should have high priority
public boolean add(Endpoint e,
boolean forceHighPriority,
String locale)
public boolean isValidHost(Endpoint host)
public boolean isHostTLSCapable(IpPort ipp)
public void getAnEndpoint(HostCatcher.EndpointObserver observer)
public Endpoint getAnEndpointImmediate(HostCatcher.EndpointObserver observer)
public void removeEndpointObserver(HostCatcher.EndpointObserver observer)
protected Endpoint getAnEndpoint()
throws InterruptedException
InterruptedException - if the calling thread is interrupted
public void doneWithConnect(Endpoint e,
boolean success)
protected ExtendedEndpoint getAnEndpointInternal()
public int getNumHosts()
protected int getNumUltrapeerHosts()
protected Iterator<ExtendedEndpoint> getPermanentHosts()
public Collection<IpPort> getUltrapeersWithFreeUltrapeerSlots(String locale,
int num)
public Collection<IpPort> getUltrapeersWithFreeLeafSlots(String locale,
int num)
public void noInternetConnection()
public void reset()
public void putHostOnProbation(Endpoint host)
public void expireHost(Endpoint host)
public boolean needsHosts()
needsHosts in interface Bootstrapper.Listenerpublic int handleHosts(Collection<? extends Endpoint> hosts)
handleHosts in interface Bootstrapper.Listener
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||