|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.limegroup.gnutella.DownloadManagerImpl
public class DownloadManagerImpl
| Constructor Summary | |
|---|---|
DownloadManagerImpl(DownloadCallback innetworkCallback,
com.google.inject.Provider<DownloadCallback> downloadCallback,
com.google.inject.Provider<MessageRouter> messageRouter,
ScheduledExecutorService backgroundExecutor,
com.google.inject.Provider<TorrentManager> torrentManager,
com.google.inject.Provider<PushDownloadManager> pushDownloadManager,
CoreDownloaderFactory coreDownloaderFactory,
DownloadSerializer downloaderSerializer,
IncompleteFileManager incompleteFileManager,
RemoteFileDescFactory remoteFileDescFactory,
BTMetaInfoFactory btMetaInfoFactory,
PushEndpointFactory pushEndpointFactory)
|
|
| Method Summary | |
|---|---|
boolean |
acceptPushedSocket(String file,
int index,
byte[] clientGUID,
Socket socket)
Accept the newly-connected push socket The given file, index & clientGUID were identified during the push. |
void |
addListener(EventListener<DownloadManagerEvent> listener)
Adds the listener. |
void |
addNewDownloader(CoreDownloader downloader)
Adds a new downloader to this manager. |
void |
bumpPriority(Downloader downl,
boolean up,
int amt)
Bumps the priority of an inactive download either up or down by an amount (if amt==0, bump to start/end of list). |
boolean |
conflicts(URN urn,
long fileSize,
File... fileName)
Returns true if there already is a download with the same urn. |
boolean |
contains(Downloader downloader)
Returns true if the given downloader is in either the waiting or active lists. |
Downloader |
download(DownloadInformation info,
long now)
Downloads an InNetwork update, using the info from the DownloadInformation. |
Downloader |
download(File incompleteFile)
Starts a resume download for the given incomplete file. |
Downloader |
download(MagnetOptions magnet,
boolean overwrite,
File saveDir,
String fileName)
Creates a new MAGNET downloader. |
Downloader |
download(RemoteFileDesc[] files,
List<? extends RemoteFileDesc> alts,
GUID queryGUID,
boolean overwrite,
File saveDir,
String fileName)
Tries to "smart download" any of the given files. |
Downloader |
downloadFromMozilla(MozillaDownload listener)
Creates a Downloader wrapping the MozillaDownloadListener. |
Downloader |
downloadFromStore(RemoteFileDesc rfd,
boolean overwrite,
File saveDir,
String fileName)
Creates a new LimeWire Store (LWS) download. |
int |
downloadsInProgress()
|
Downloader |
downloadTorrent(BTMetaInfo info,
boolean overwrite)
Downloads the given torrent specified by the meta info object. |
Downloader |
downloadTorrent(File torrentFile,
boolean overwrite)
Opens the torrent for the specified file, and begins the torrent download. |
Downloader |
downloadTorrent(URI torrentURI,
boolean overwrite)
Downloads the torrent file from the specified URI then begins the torrent download as a seperate item. |
Iterable<CoreDownloader> |
getAllDownloaders()
|
float |
getAverageBandwidth()
returns the summed average of the downloads |
Downloader |
getDownloaderForIncompleteFile(File file)
Returns the active or waiting downloader that uses or will use file as incomplete file. |
Downloader |
getDownloaderForURN(URN sha1)
|
Downloader |
getDownloaderForURNString(String urn)
|
IncompleteFileManager |
getIncompleteFileManager()
Returns the IncompleteFileManager used by this DownloadManager and all ManagedDownloaders. |
float |
getLastMeasuredBandwidth()
Returns the measured bandwidth as calculated from the last getMeasuredBandwidth() call. |
float |
getMeasuredBandwidth()
Returns the total upload throughput, i.e., the sum over all uploads. |
int |
getNumActiveDownloads()
Inner network traffic and downloads from the LWS don't count towards overall download activity. |
int |
getNumIndividualDownloaders()
|
int |
getNumWaitingDownloads()
|
String |
getServiceName()
|
void |
handleEvent(ManagedListStatusEvent evt)
Listens for events from FileManager |
void |
handleQueryReply(QueryReply qr,
Address address)
Adds all responses (and alternates) in qr to any downloaders, if
appropriate. |
boolean |
hasInNetworkDownload()
Determines if an 'In Network' download exists in either active or waiting. |
void |
initialize()
|
boolean |
isActivelyDownloading(URN urn)
Returns whether or not we are actively downloading this file. |
boolean |
isGuidForQueryDownloading(GUID guid)
|
boolean |
isIncomplete(URN urn)
Determines if the given URN has an incomplete file. |
boolean |
isSavedDownloadsLoaded()
True if saved downloads have been loaded from disk. |
boolean |
isSaveLocationTaken(File candidateFile)
Returns true if there already is a download that is or
will be saving to this file location. |
void |
killDownloadersNotListed(Collection<? extends DownloadInformation> updates)
Kills all in-network downloaders that are not present in the list of DownloadInformations |
void |
loadSavedDownloads()
|
void |
loadSavedDownloadsAndScheduleWriting()
Performs the slow, low-priority initialization tasks: reading in snapshots and scheduling snapshot checkpointing. |
void |
measureBandwidth()
Calls measureBandwidth on each uploader. |
CoreDownloader |
prepareMemento(DownloadMemento memento)
|
protected void |
pumpDownloads()
Pumps through each waiting download, either removing it because it was stopped, or adding it because there's an active slot and it requires attention. |
void |
register(PushedSocketHandlerRegistry registry)
|
void |
remove(CoreDownloader downloader,
boolean completed)
Removes downloader entirely from the list of current downloads. |
boolean |
removeListener(EventListener<DownloadManagerEvent> listener)
Returns true if the listener was removed. |
void |
scheduleSnapshots()
|
void |
scheduleWaitingPump()
|
void |
sendQuery(QueryRequest query)
Attempts to send the given requery to provide the given downloader with more sources to download. |
void |
start()
Initializes this manager. |
void |
stop()
|
void |
visitDownloads(Visitor<CoreDownloader> visitor)
|
void |
writeSnapshot()
Writes a snapshot of all downloaders in this and all incomplete files to the file named DOWNLOAD_SNAPSHOT_FILE. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
@Inject
public DownloadManagerImpl(DownloadCallback innetworkCallback,
com.google.inject.Provider<DownloadCallback> downloadCallback,
com.google.inject.Provider<MessageRouter> messageRouter,
ScheduledExecutorService backgroundExecutor,
com.google.inject.Provider<TorrentManager> torrentManager,
com.google.inject.Provider<PushDownloadManager> pushDownloadManager,
CoreDownloaderFactory coreDownloaderFactory,
DownloadSerializer downloaderSerializer,
IncompleteFileManager incompleteFileManager,
RemoteFileDescFactory remoteFileDescFactory,
BTMetaInfoFactory btMetaInfoFactory,
PushEndpointFactory pushEndpointFactory)
| Method Detail |
|---|
@Inject public void register(PushedSocketHandlerRegistry registry)
public void start()
DownloadManager
start in interface DownloadManagerstart in interface Servicepublic String getServiceName()
getServiceName in interface Servicepublic void initialize()
initialize in interface Servicepublic void stop()
stop in interface Servicepublic void addNewDownloader(CoreDownloader downloader)
addNewDownloader in interface DownloadManagerdownloader - the core downloaderpublic void loadSavedDownloadsAndScheduleWriting()
DownloadManager
loadSavedDownloadsAndScheduleWriting in interface DownloadManagerpublic void loadSavedDownloads()
public CoreDownloader prepareMemento(DownloadMemento memento)
public void scheduleSnapshots()
public void writeSnapshot()
DownloadManager
writeSnapshot in interface DownloadManagerpublic boolean isSavedDownloadsLoaded()
DownloadManager
isSavedDownloadsLoaded in interface DownloadManagerpublic boolean hasInNetworkDownload()
DownloadManager
hasInNetworkDownload in interface DownloadManagerpublic void killDownloadersNotListed(Collection<? extends DownloadInformation> updates)
DownloadManager
killDownloadersNotListed in interface DownloadManagerupdates - a current set of DownloadInformation that we are
downloading in-network.
public boolean acceptPushedSocket(String file,
int index,
byte[] clientGUID,
Socket socket)
PushedSocketHandler
acceptPushedSocket in interface PushedSocketHandleracceptPushedSocket in interface DownloadManagerpublic void scheduleWaitingPump()
protected void pumpDownloads()
public boolean isIncomplete(URN urn)
DownloadManager
isIncomplete in interface DownloadManagerpublic boolean isActivelyDownloading(URN urn)
DownloadManager
isActivelyDownloading in interface DownloadManagerpublic IncompleteFileManager getIncompleteFileManager()
DownloadManager
getIncompleteFileManager in interface DownloadManagerpublic int downloadsInProgress()
downloadsInProgress in interface DownloadManagerpublic int getNumIndividualDownloaders()
getNumIndividualDownloaders in interface DownloadManagerpublic int getNumActiveDownloads()
DownloadManager
getNumActiveDownloads in interface DownloadManagerpublic int getNumWaitingDownloads()
getNumWaitingDownloads in interface DownloadManagerpublic Downloader getDownloaderForURN(URN sha1)
getDownloaderForURN in interface DownloadManagerpublic Downloader getDownloaderForURNString(String urn)
public Downloader getDownloaderForIncompleteFile(File file)
DownloadManagerfile as incomplete file.
getDownloaderForIncompleteFile in interface DownloadManagerfile - the incomplete file candidate
null if no downloader for the file is foundpublic boolean isGuidForQueryDownloading(GUID guid)
isGuidForQueryDownloading in interface DownloadManager
public Downloader download(RemoteFileDesc[] files,
List<? extends RemoteFileDesc> alts,
GUID queryGUID,
boolean overwrite,
File saveDir,
String fileName)
throws SaveLocationException
DownloadManagerIf any of the files already being downloaded (or queued for downloaded) has the same temporary name as any of the files in 'files', throws AlreadyDownloadingException. Note, however, that this doesn't guarantee that a successfully downloaded file can be moved to the library.
If overwrite==false, then if any of the files already exists in the download directory, FileExistsException is thrown and no files are modified. If overwrite==true, the files may be overwritten.
Otherwise returns a Downloader that allows you to stop and resume this download. The DownloadCallback will also be notified of this download, so the return value can usually be ignored. The download begins immediately, unless it is queued. It stops after any of the files succeeds.
download in interface DownloadManagerfiles - a group of "similar" files to smart downloadalts - a List of secondary RFDs to use for other sourcesqueryGUID - the guid of the query that resulted in the RFDs being
downloaded.overwrite - whether or not to overwrite the filesaveDir - can be null, then the default save directory is usedfileName - can be null, then the first filename of one of element of
files is taken.
SaveLocationException - when there was an error setting the
location of the final download destination.
public Downloader download(MagnetOptions magnet,
boolean overwrite,
File saveDir,
String fileName)
throws IllegalArgumentException,
SaveLocationException
DownloadManager
download in interface DownloadManagermagnet - information fields extracted from a magnet linkoverwrite - whether or not to overwrite the filesaveDir - can be null, then the default save directory is used
IllegalArgumentException - if the magnet is not downloadable
SaveLocationException - if the file can't save because of an
existing file in the location
public Downloader downloadFromStore(RemoteFileDesc rfd,
boolean overwrite,
File saveDir,
String fileName)
throws IllegalArgumentException,
SaveLocationException
DownloadManager
downloadFromStore in interface DownloadManagerrfd - Descriptor describing the download from the store including URNoverwrite - true if same file names should be overwritten; false if
the user should be notified of a duplicate file namesaveDir - directory to save the completed file intofileName - name of the completed file
IllegalArgumentException - if there is a bad argument
SaveLocationException - if the file is already downloading
public Downloader download(File incompleteFile)
throws CantResumeException,
SaveLocationException
DownloadManager
download in interface DownloadManagerCantResumeException - incompleteFile is not a valid
incomplete file
SaveLocationException - if the file can't save because of an
existing file in the location
public Downloader download(DownloadInformation info,
long now)
throws SaveLocationException
DownloadManager
download in interface DownloadManagerSaveLocationException
public Downloader downloadTorrent(URI torrentURI,
boolean overwrite)
throws SaveLocationException
DownloadManager
downloadTorrent in interface DownloadManagerSaveLocationException
public Downloader downloadTorrent(File torrentFile,
boolean overwrite)
throws SaveLocationException
DownloadManager
downloadTorrent in interface DownloadManagerSaveLocationException
public Downloader downloadTorrent(BTMetaInfo info,
boolean overwrite)
throws SaveLocationException
DownloadManager
downloadTorrent in interface DownloadManagerSaveLocationExceptionpublic Downloader downloadFromMozilla(MozillaDownload listener)
DownloadManager
downloadFromMozilla in interface DownloadManager
public boolean conflicts(URN urn,
long fileSize,
File... fileName)
DownloadManagertrue if there already is a download with the same urn.
conflicts in interface DownloadManagerurn - may be null, then a check based on the fileName
and the fileSize is performed
public boolean isSaveLocationTaken(File candidateFile)
DownloadManagertrue if there already is a download that is or
will be saving to this file location.
isSaveLocationTaken in interface DownloadManagerisSaveLocationTaken in interface SaveLocationManagercandidateFile - the final file location.
public void handleQueryReply(QueryReply qr,
Address address)
DownloadManagerqr to any downloaders, if
appropriate.
handleQueryReply in interface DownloadManageraddress - can be null, otherwise overrides the address information in qr
public void remove(CoreDownloader downloader,
boolean completed)
DownloadManager
remove in interface DownloadManager
public void bumpPriority(Downloader downl,
boolean up,
int amt)
DownloadManager
bumpPriority in interface DownloadManagerpublic void sendQuery(QueryRequest query)
DownloadManager
sendQuery in interface DownloadManagerquery - the requery to send, which should have a marked GUID.
Queries are subjected to global rate limiting if and only if they have marked
requery GUIDs.public void measureBandwidth()
DownloadManager
measureBandwidth in interface BandwidthTrackermeasureBandwidth in interface DownloadManagerpublic float getMeasuredBandwidth()
DownloadManager
getMeasuredBandwidth in interface BandwidthTrackergetMeasuredBandwidth in interface DownloadManagerpublic float getAverageBandwidth()
DownloadManager
getAverageBandwidth in interface BandwidthTrackergetAverageBandwidth in interface DownloadManagerpublic float getLastMeasuredBandwidth()
DownloadManager
getLastMeasuredBandwidth in interface DownloadManagerpublic final Iterable<CoreDownloader> getAllDownloaders()
getAllDownloaders in interface DownloadManagerpublic void handleEvent(ManagedListStatusEvent evt)
handleEvent in interface EventListener<ManagedListStatusEvent>public void visitDownloads(Visitor<CoreDownloader> visitor)
visitDownloads in interface LWSIntegrationServicesDelegatepublic void addListener(EventListener<DownloadManagerEvent> listener)
ListenerSupport
addListener in interface ListenerSupport<DownloadManagerEvent>public boolean removeListener(EventListener<DownloadManagerEvent> listener)
ListenerSupport
removeListener in interface ListenerSupport<DownloadManagerEvent>public boolean contains(Downloader downloader)
DownloadManager
contains in interface DownloadManager
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||