com.limegroup.gnutella.downloader
Class AbstractSourceRanker
java.lang.Object
com.limegroup.gnutella.downloader.AbstractSourceRanker
- All Implemented Interfaces:
- SourceRanker
- Direct Known Subclasses:
- FriendsFirstSourceRanker, LegacyRanker, PingRanker
public abstract class AbstractSourceRanker
- extends Object
- implements SourceRanker
A class that ranks sources for a download.
It uses a factory pattern to provide the best ranker based on system
conditions.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
meshHandler
protected MeshHandler meshHandler
- The mesh handler to inform when altlocs fail
AbstractSourceRanker
public AbstractSourceRanker()
addToPool
public boolean addToPool(Collection<? extends RemoteFileDescContext> hosts)
- Specified by:
addToPool in interface SourceRanker
- Parameters:
hosts - a collection of remote hosts to rank
- Returns:
- if we didn't know about at least one of the hosts
addToPool
public abstract boolean addToPool(RemoteFileDescContext host)
- Specified by:
addToPool in interface SourceRanker
- Parameters:
host - the host that the ranker should consider
- Returns:
- if we did not already know about this host
hasMore
public abstract boolean hasMore()
- Specified by:
hasMore in interface SourceRanker
- Returns:
- whether the ranker has any more potential sources
getBest
public abstract RemoteFileDescContext getBest()
- Specified by:
getBest in interface SourceRanker
- Returns:
- the source that should be tried next or
null
if there is none
getShareableHosts
public abstract Collection<RemoteFileDescContext> getShareableHosts()
- Specified by:
getShareableHosts in interface SourceRanker
- Returns:
- the collection of hosts that can be shared with other rankers
getNumKnownHosts
public abstract int getNumKnownHosts()
- Specified by:
getNumKnownHosts in interface SourceRanker
- Returns:
- the number of hosts this ranker knows about
hasNonBusy
public boolean hasNonBusy()
- Specified by:
hasNonBusy in interface SourceRanker
- Returns:
- the ranker knows about at least one potential source that is
not currently busy
getNumBusyHosts
public int getNumBusyHosts()
- Specified by:
getNumBusyHosts in interface SourceRanker
- Returns:
- the number of busy hosts the ranker knows about
calculateWaitTime
public int calculateWaitTime()
- Specified by:
calculateWaitTime in interface SourceRanker
- Returns:
- how much time we should wait before at least one host
will become non-busy
getPotentiallyBusyHosts
protected abstract Collection<RemoteFileDescContext> getPotentiallyBusyHosts()
stop
public void stop()
- Description copied from interface:
SourceRanker
- stops the ranker, clearing any state
- Specified by:
stop in interface SourceRanker
clearState
protected void clearState()
setMeshHandler
public void setMeshHandler(MeshHandler handler)
- Description copied from interface:
SourceRanker
- sets the Mesh handler if any
- Specified by:
setMeshHandler in interface SourceRanker
getMeshHandler
public MeshHandler getMeshHandler()
- Specified by:
getMeshHandler in interface SourceRanker
- Returns:
- the Mesh Handler, if any
Copyright © 2009. All Rights Reserved.