Class DownloadManagerImpl
java.lang.Object
com.biglybt.core.logging.LogRelation
com.biglybt.core.download.impl.DownloadManagerImpl
- All Implemented Interfaces:
DiskManagerUtil.MoveTaskAapter, DownloadManager, Taggable, DataSourceResolver.ExportableDataSource, Taggable
public class DownloadManagerImpl
extends LogRelation
implements DownloadManager, Taggable, DataSourceResolver.ExportableDataSource, DiskManagerUtil.MoveTaskAapter
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TRTrackerAnnouncerprivate TRTrackerAnnouncerprivate final CopyOnWriteList<DownloadManagerActivationListener> private static final AllTrackersManager.AllTrackersprivate booleanPretend this download is complete while not running, even if it has no data.private Fileprivate Fileprivate static final Stringprivate static final ClientIDManagerImplprivate boolean(package private) final DownloadManagerControllerprivate longprivate intprivate intprivate booleanprivate static intprivate static final Download.SeedingRankprivate booleanprivate Stringprivate byte[]private intprivate booleanstatic Stringstatic String(package private) DownloadManagerStateprivate static final DownloadManagerListener(package private) static final CopyOnWriteList<DownloadManagerListener> (package private) final GlobalManagerprivate Objectprivate booleanprivate Stringprivate intforceStarted torrents can't/shouldn't be automatically stoppedprivate longprivate longprivate booleanprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate intprivate static final ThreadLocal<Boolean> private final ListenerManager<DownloadManagerListener> (package private) static final ListenerManager<DownloadManagerListener> private final AEMonitorprivate intprivate static intprivate intprivate booleanprivate intprivate intprivate intprivate intprivate booleanprivate intprivate long[]private intprivate Stringprivate booleanprivate final ListenerManager<DownloadManagerPeerListener> (package private) static final ListenerManager<DownloadManagerPeerListener> (package private) final AEMonitorprivate final booleanprivate final ListenerManager<DownloadManagerPieceListener> (package private) static final ListenerManager<DownloadManagerPieceListener> private final AEMonitorprivate static Objectprivate intprivate Object[]private booleanprivate longprivate static TimerEventPeriodicprivate static final longprivate static final longprivate static final longprivate static final longprivate final longprivate Download.SeedingRankprivate intprivate intprivate final DownloadManagerStatsImplprivate AtomicLongprivate intprotected final AEMonitorprivate TOTorrentprivate Stringprivate Stringprivate Fileprivate booleanprivate String(package private) static final Objectprivate List<DownloadManagerTPSListener> private final TRTrackerAnnouncerListenerprivate final TRTrackerAnnouncerListener(package private) final ListenerManager<DownloadManagerTrackerListener> private static Objectprivate intprivate intprivate static intprivate longFields inherited from interface DataSourceResolver.ExportableDataSource
OPT_CAN_MINIMIZE, OPT_ON_TOPFields inherited from interface DownloadManager
EF_WAS_FORCE_START, ET_FILE_MISSING, ET_INSUFFICIENT_SPACE, ET_NONE, ET_OTHER, ET_STOP_DURING_INIT, STATE_ALLOCATING, STATE_CHECKING, STATE_CLOSED, STATE_DOWNLOADING, STATE_ERROR, STATE_FINISHING, STATE_INITIALIZED, STATE_INITIALIZING, STATE_QUEUED, STATE_READY, STATE_SEEDING, STATE_START_OF_DAY, STATE_STOPPED, STATE_STOPPING, STATE_WAITING, UD_KEY_QUEUE_REASON, UD_KEY_START_REASON, UD_KEY_STOP_REASON, WEALTH_ERROR, WEALTH_KO, WEALTH_NO_REMOTE, WEALTH_NO_TRACKER, WEALTH_OK, WEALTH_STOPPEDFields inherited from interface Taggable
TT_DOWNLOAD, TT_NONE, TT_PEER -
Constructor Summary
ConstructorsConstructorDescriptionDownloadManagerImpl(GlobalManager _gm, byte[] _torrent_hash, String _torrentFileName, String _torrent_save_dir, String _torrent_save_file, int _initialState, boolean _persistent, boolean _recovered, boolean _open_for_seeding, boolean _has_ever_been_started, List _file_priorities) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanactivateRequest(int count) voidvoidaddDiskListener(DownloadManagerDiskListener listener) static voidvoidaddListener(DownloadManagerListener listener) voidaddListener(DownloadManagerListener listener, boolean triggerStateChange) voidvoidaddPeerListener(DownloadManagerPeerListener listener) voidaddPeerListener(DownloadManagerPeerListener listener, boolean bDispatchForExisting) voidvoidaddPieceListener(DownloadManagerPieceListener listener) voidaddPieceListener(DownloadManagerPieceListener listener, boolean bDispatchForExisting) voidaddRateLimiter(LimitedRateGroup group, boolean upload) voidaddTPSListener(DownloadManagerTPSListener listener) voidprivate voidbuildURLGroupMap(TOTorrent torrent) private voidbooleanbooleanbooleanprivate voidcheckFilePriorities(boolean global_change) voidcheckLightSeeding(boolean full_sync) private booleanprotected voidvoidcopyDataFiles(File dest_parent_dir, CoreOperationTask.ProgressCallback cb) private voidcopyTorrentFile(File parent_dir) protected voidprivate voidprotected voidprotected voidvoiddestroy(boolean is_duplicate) Indicates that the download manager is no longer neededprotected voiddownloadEnded(boolean never_downloaded) Is called when a download is finished.booleanvoidexportDownload(File parent_dir) protected voidbooleanfilesExist(boolean expected_to_be_allocated, boolean test_only) voidfireGlobalManagerEvent(int eventType, Object eventData) voidvoidgenerateEvidence(IndentWriter writer, boolean full) Returns the file location where we save the torrent, this includes the parent directory and the actual file name.intprotected Object[]Returns the "first" online scrape response found, and its active URL, otherwise one of the failing scrapesbooleanRetrieve whether this download is assumed complete.longlonggives the time this download was created (not the torrent but the download itself)intPEPeer[]PEPiece[]Deprecated.use getDiskManagerFileInfoSet() insteadintReturns the max uploads depending on whether the download is seeding and it has a separate rate for thisintintreturns the currently in force upload speed limit which may vary from the stats.intintintintprivate byte[]returns a name based on the torrent hash or an empty string if torrent invalidprivate intprotected int[]getMaxConnections(boolean mixed) protected int[]getMaxConnectionsWhenSeeding(boolean mixed) protected int[]getMaxSeedConnections(boolean mixed) intprotected intlong[]Progress of a move operationObject[]See plugin ConnectionManager.NAT_ constants for return valuesintintintintintObject[]Query this class for a reference to another class that it may holdgetRateLimiters(boolean upload) A short description of what your class holds that can be printed by the loggerlonggetSize()intgetState()getStats()int[]getStorageType(DiskManagerFileInfo[] info) intFor stopping this returns the target state after stopping (stopped/queued)intlongintprotected intgetTCPPortOverride(boolean only_if_allocated) longThis includes the full path to the torrent file.protected HashWrapperintWhen the next call to the tracker will occur (in seconds)protected intgetTrackerURLGroup(String key) getUserData(Object key) To retreive arbitrary objects against a download.inthashCode()protected voidprotected voidprotected voidinformLocationChange(int file_index) protected voidprotected voidprotected voidinformPositionChanged(int new_position) protected voidinformPrioritiesChange(List files) protected voidprotected voidprotected voidDoesn't not inform if state didn't change from last inform callprotected voidinformStopped(PEPeerManager pm, boolean for_queue) voidprotected voidvoidbooleanbooleanDetermine whether disk allocation has already been done.booleanbooleanisDownloadComplete(boolean bIncludeDND) Retrieves whether the download is completebooleanbooleanbooleanReturns true if the download is being saved to one of the default save directories.protected booleanprotected booleanprotected booleanbooleanisPaused()booleanbooleanbooleanbooleanvoidmoveDataFiles(File new_parent_dir) Move data files to new location.voidmoveDataFiles(File destination, String new_name) Move the files and rename a download in one go.voidmoveDataFiles(File destination, String new_name, boolean live) voidmoveDataFilesLive(File new_parent_dir) At some point someone made the file-move operations stop+restart the download when it was designed to work without doing this (see move-on-complete for example).(package private) voidmoveDataFilesSupport(File new_parent_dir, String new_filename) (package private) voidmoveDataFilesSupport0(File new_parent_dir, String new_filename) voidmoveTorrentFile(File new_parent_dir) Move torrent file to new location.voidmoveTorrentFile(File new_parent_dir, String new_name) private voidmoveTorrentFile0(File new_parent_dir, String new_name) booleanpause(boolean only_if_active) booleanpause(boolean only_if_active, long _resume_time) protected voidprivate voidreadFilePriorityConfig(boolean init, boolean global_change) protected voidprotected voidprivate voidreadTorrent(String torrent_save_dir, String torrent_save_file, byte[] torrent_hash, boolean new_torrent, boolean for_seeding, boolean has_ever_been_started, int initial_state) voidRecheck a particular file.voidvoidstatic voidvoidremoveListener(DownloadManagerListener listener) voidremovePeer(PEPeer peer) voidvoidremovePiece(PEPiece piece) voidvoidremoveRateLimiter(LimitedRateGroup group, boolean upload) voidremoveTPSListener(DownloadManagerTPSListener listener) voidvoidRenames the save file, torrent file and the displayed name.voidrenameDownload(String new_name) Rename the download - this means the name of the file being downloaded (for single file torrents), or the name of the directory holding the files (in a multi-file torrent).voidrenameTorrent(String name) voidrenameTorrentSafe(String name) Same as renameTorrent, but appends numbers if torrent already existsvoidrequestAllocation(List<DiskManagerFileInfo> files) Instructions that file given files need allocation - used when switching file storage types/skipped state Will pause and resume the download if it is activebooleanWill set this download to be "assumed complete" for if the download is already complete (excluding DND)protected booleanrequestAssumedCompleteMode(boolean filePriorityChanged) voidvoidrequestTrackerAnnounce(boolean force) voidrequestTrackerScrape(boolean force) voidresetFile(DiskManagerFileInfo file) Reset the file download state to totally undownloaded.protected voidrestoreResumeData(Map data) voidresume()booleanresume(int target_state) resume the download and wait until it reaches the target state.voidsaveDownload(boolean interim) persist any general download related information, excluding resume data which is managed separately by saveResumeDatavoidpersist resume databooleanGives the download an opportunity to schedule seeding mode piece rechecks if desiredvoidprotected voidsetAssumedComplete(boolean _assumedComplete) protected voidsetAssumedComplete(boolean _assumedComplete, boolean filePriorityChanged) voidsetAutoResumeTime(long time) voidvoidsetCreationTime(long t) voidsetCryptoLevel(int level) voidsetDataAlreadyAllocated(boolean already_allocated) Set whether data allocation has already been done, so we know when to allocate and when to throw a missing-data error message.voidsetErrorState(int errorType, String errorDetails, int errorFlags) Download must be stopped - used at start-of-day to recover error stateprotected voidprotected voidprotected voidvoidsetForceStart(boolean forceStart) voidsetManualUploadPriority(int priority) voidsetMaxUploads(int max) voidsetMoveState(int state) voidsetPieceCheckingEnabled(boolean enabled) Use with care - introduced to support speed tests whereby we want to avoid checking the virtual torrent used for the testvoidsetPosition(int new_position) voidsetQueueReason(String reason) voidsetScrapeResult(DownloadScrapeResult result) voidvoidsetStartReason(String reason) voidvoidvoidvoidsetStopReason(String reason) voidsetTaggableTransientProperty(String key, Object value) voidsetTorrentFile(File new_parent_dir, String new_name) Sets the torrent file name (will perform a move of the torrent file) - this shouldn't be used unless you know what you are doing (it requires the download to be stopped!) - it is safer to use moveTorrentFile instead.voidsetTorrentFileName(String string) protected voidsetTorrentInvalid(Throwable cause) voidsetTorrentSaveDir(File _new_location, boolean locationIncludesName) changes the save directory.protected voidsetTrackerRefreshDelayOverrides(int percent) voidvoidsetUserData(Object key, Object value) To store arbitrary objects against a download.voidprivate voidvoidstopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data) Stop the download manager, and do any file/torrent removals.voidstopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data, boolean for_removal) As above but definitely indicates that the stop is for removal (if for_removal is true) and therefore that any removal specific actions such as removing partial files should be performedbooleanprivate voidvoidCalled for certain config change events so that individual managers don't have to separately listener for changestoString()voidupdateAutoUploadPriority(Object key, boolean inc) private voidupdateFileLink(int file_index, File old_path, File new_path, File from_loc_maybe_null, File to_loc, List<Integer> from_indexes, List<File> from_links, List<File> to_links) private voidupdateFileLinks(File old_save_path, File new_save_path) voidMethods inherited from class LogRelation
propogatedRelationText, queryForClassMethods inherited from interface DataSourceResolver.ExportableDataSource
getBooleanOptionMethods inherited from interface DownloadManager
filesExist, fireGlobalManagerEvent, isMetadataDownload, setTorrentSaveDir
-
Field Details
-
SCRAPE_DELAY_ERROR_TORRENTS
private static final long SCRAPE_DELAY_ERROR_TORRENTS- See Also:
-
SCRAPE_DELAY_STOPPED_TORRENTS
private static final long SCRAPE_DELAY_STOPPED_TORRENTS- See Also:
-
SCRAPE_INITDELAY_ERROR_TORRENTS
private static final long SCRAPE_INITDELAY_ERROR_TORRENTS- See Also:
-
SCRAPE_INITDELAY_STOPPED_TORRENTS
private static final long SCRAPE_INITDELAY_STOPPED_TORRENTS- See Also:
-
upload_when_busy_min_secs
private static int upload_when_busy_min_secs -
max_connections_npp_extra
private static int max_connections_npp_extra -
default_light_seeding_status
private static int default_light_seeding_status -
client_id_manager
-
CFG_MOVE_COMPLETED_TOP
- See Also:
-
LDT_STATECHANGED
private static final int LDT_STATECHANGED- See Also:
-
LDT_DOWNLOADCOMPLETE
private static final int LDT_DOWNLOADCOMPLETE- See Also:
-
LDT_COMPLETIONCHANGED
private static final int LDT_COMPLETIONCHANGED- See Also:
-
LDT_POSITIONCHANGED
private static final int LDT_POSITIONCHANGED- See Also:
-
LDT_FILEPRIORITYCHANGED
private static final int LDT_FILEPRIORITYCHANGED- See Also:
-
LDT_FILELOCATIONCHANGED
private static final int LDT_FILELOCATIONCHANGED- See Also:
-
port_init_lock
-
listeners_mon
-
listeners_aggregator
-
global_dm_listeners
-
global_dm_listener
-
defaultSeedingRank
-
all_trackers
-
listeners
-
LDT_TL_ANNOUNCERESULT
private static final int LDT_TL_ANNOUNCERESULT- See Also:
-
LDT_TL_SCRAPERESULT
private static final int LDT_TL_SCRAPERESULT- See Also:
-
tracker_listeners
-
LDT_PE_PEER_ADDED
private static final int LDT_PE_PEER_ADDED- See Also:
-
LDT_PE_PEER_REMOVED
private static final int LDT_PE_PEER_REMOVED- See Also:
-
LDT_PE_PM_ADDED
private static final int LDT_PE_PM_ADDED- See Also:
-
LDT_PE_PM_REMOVED
private static final int LDT_PE_PM_REMOVED- See Also:
-
peer_listeners_aggregator
-
TPS_Key
-
dnd_subfolder
-
dnd_alt_loc
-
save_dir_check_cache
-
save_dir_check_timer
-
peer_listeners
-
peer_listeners_mon
-
current_peers
-
current_peers_unmatched_removal
-
LDT_PE_PIECE_ADDED
private static final int LDT_PE_PIECE_ADDED- See Also:
-
LDT_PE_PIECE_REMOVED
private static final int LDT_PE_PIECE_REMOVED- See Also:
-
piece_listeners_aggregator
-
piece_listeners
-
constructed
private boolean constructed -
init_lock
-
initialised
private boolean initialised -
post_init_tasks
-
tps_listeners
-
piece_listeners_mon
-
current_pieces
-
controller
-
stats
-
this_mon
-
persistent
private final boolean persistent -
assumedComplete
private volatile boolean assumedCompletePretend this download is complete while not running, even if it has no data. When the torrent starts up, the real complete level will be checked (probably by DiskManager), and if the torrent actually does have missing data at that point, the download will be thrown into error state.Only a forced-recheck should clear this flag.
Current Implementation:
- implies that the user completed the download at one point
- Checks if there's Data Missing when torrent is done (or torrent load) -
last_informed_state
private int last_informed_stateforceStarted torrents can't/shouldn't be automatically stopped -
latest_informed_force_start
private boolean latest_informed_force_start -
resume_time
private long resume_time -
globalManager
-
torrentFileName
-
torrentFileExplicitlyDeleted
private boolean torrentFileExplicitlyDeleted -
open_for_seeding
private boolean open_for_seeding -
display_name
-
internal_name
-
torrent_save_location
-
position
private int position -
read_torrent_state
-
download_manager_state
DownloadManagerState download_manager_state -
torrent
-
torrent_comment
-
torrent_created_by
-
url_group_map
-
url_group_map_uid
private volatile long url_group_map_uid -
_tracker_client
-
_tracker_client_for_queued_download
-
light_seeding_status
private volatile int light_seeding_status -
tracker_client_listener
-
tracker_client_stats_listener
-
activation_listeners
-
scrape_random_seed
private final long scrape_random_seed -
data
-
data_already_allocated
private boolean data_already_allocated -
creation_time
private long creation_time -
seedingRank
-
dl_identity_obtained
private boolean dl_identity_obtained -
dl_identity
private byte[] dl_identity -
dl_identity_hashcode
private int dl_identity_hashcode -
max_uploads
private int max_uploads -
max_connections
private int max_connections -
max_connections_when_seeding
private int max_connections_when_seeding -
max_connections_when_seeding_enabled
private boolean max_connections_when_seeding_enabled -
max_seed_connections
private int max_seed_connections -
max_uploads_when_seeding
private int max_uploads_when_seeding -
max_uploads_when_seeding_enabled
private boolean max_uploads_when_seeding_enabled -
max_upload_when_busy_bps
private int max_upload_when_busy_bps -
current_upload_when_busy_bps
private int current_upload_when_busy_bps -
last_upload_when_busy_update
private long last_upload_when_busy_update -
last_upload_when_busy_dec_time
private long last_upload_when_busy_dec_time -
upload_priority_manual
private int upload_priority_manual -
upload_priority_auto
private int upload_priority_auto -
crypto_level
private int crypto_level -
message_mode
private int message_mode -
tcp_port_override
private volatile int tcp_port_override -
set_file_priority_high_pieces_rem
private volatile int set_file_priority_high_pieces_rem -
set_file_priority_high_percent_rem
private volatile int set_file_priority_high_percent_rem -
tagMutationCounter
-
removing
private volatile boolean removing -
destroyed
private volatile boolean destroyed -
links_changing
-
cached_save_location
-
cached_save_location_result
-
TTP_KEY
-
move_progress
private volatile long[] move_progress -
move_subtask
-
move_state
private volatile int move_state
-
-
Constructor Details
-
DownloadManagerImpl
public DownloadManagerImpl(GlobalManager _gm, byte[] _torrent_hash, String _torrentFileName, String _torrent_save_dir, String _torrent_save_file, int _initialState, boolean _persistent, boolean _recovered, boolean _open_for_seeding, boolean _has_ever_been_started, List _file_priorities)
-
-
Method Details
-
addGlobalDownloadListener
-
removeGlobalDownloadListener
-
setConstructed
public void setConstructed()- Specified by:
setConstructedin interfaceDownloadManager
-
isConstructed
public boolean isConstructed()- Specified by:
isConstructedin interfaceDownloadManager
-
buildURLGroupMap
-
getLightSeedTrackerStatus
-
getTrackerURLGroup
-
getTaggableType
public int getTaggableType()- Specified by:
getTaggableTypein interfaceTaggable
-
getTaggableResolver
- Specified by:
getTaggableResolverin interfaceTaggable
-
getTagMutationCount
public long getTagMutationCount()- Specified by:
getTagMutationCountin interfaceTaggable
-
updateTagMutationCount
public void updateTagMutationCount()- Specified by:
updateTagMutationCountin interfaceTaggable
-
getTaggableID
- Specified by:
getTaggableIDin interfaceTaggable
-
getTaggableName
- Specified by:
getTaggableNamein interfaceTaggable
-
exportDataSource
- Specified by:
exportDataSourcein interfaceDataSourceResolver.ExportableDataSource
-
readTorrent
-
readTorrent
protected void readTorrent() -
syncGlobalConfig
public void syncGlobalConfig()Description copied from interface:DownloadManagerCalled for certain config change events so that individual managers don't have to separately listener for changes- Specified by:
syncGlobalConfigin interfaceDownloadManager
-
readParameters
protected void readParameters() -
readFilePriorityConfig
private void readFilePriorityConfig(boolean init, boolean global_change) -
getMaxConnections
protected int[] getMaxConnections(boolean mixed) -
getMaxConnectionsWhenSeeding
protected int[] getMaxConnectionsWhenSeeding(boolean mixed) -
isMaxConnectionsWhenSeedingEnabled
protected boolean isMaxConnectionsWhenSeedingEnabled() -
getMaxSeedConnections
protected int[] getMaxSeedConnections(boolean mixed) -
isMaxUploadsWhenSeedingEnabled
protected boolean isMaxUploadsWhenSeedingEnabled() -
getMaxUploadsWhenSeeding
protected int getMaxUploadsWhenSeeding() -
updateAutoUploadPriority
- Specified by:
updateAutoUploadPriorityin interfaceDownloadManager
-
getEffectiveUploadPriority
public int getEffectiveUploadPriority()- Specified by:
getEffectiveUploadPriorityin interfaceDownloadManager
-
getMaxUploads
public int getMaxUploads()- Specified by:
getMaxUploadsin interfaceDownloadManager
-
setMaxUploads
public void setMaxUploads(int max) - Specified by:
setMaxUploadsin interfaceDownloadManager
-
setManualUploadPriority
public void setManualUploadPriority(int priority) -
getEffectiveMaxUploads
public int getEffectiveMaxUploads()Description copied from interface:DownloadManagerReturns the max uploads depending on whether the download is seeding and it has a separate rate for this- Specified by:
getEffectiveMaxUploadsin interfaceDownloadManager- Returns:
-
rateLimitChanged
protected void rateLimitChanged() -
getEffectiveUploadRateLimitBytesPerSecond
public int getEffectiveUploadRateLimitBytesPerSecond()Description copied from interface:DownloadManagerreturns the currently in force upload speed limit which may vary from the stats. value as this gives the fixed per-torrent limit- Specified by:
getEffectiveUploadRateLimitBytesPerSecondin interfaceDownloadManager- Returns:
-
fileLinksUpdated
protected void fileLinksUpdated() -
clearFileLinks
protected void clearFileLinks() -
updateFileLinks
-
updateFileLink
-
filesExist
public boolean filesExist(boolean expected_to_be_allocated, boolean test_only) - Specified by:
filesExistin interfaceDownloadManager
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistentin interfaceDownloadManager
-
getDisplayName
- Specified by:
getDisplayNamein interfaceDownloadManager
-
getInternalName
Description copied from interface:DownloadManagerreturns a name based on the torrent hash or an empty string if torrent invalid- Specified by:
getInternalNamein interfaceDownloadManager- Returns:
-
setErrorState
Description copied from interface:DownloadManagerDownload must be stopped - used at start-of-day to recover error state- Specified by:
setErrorStatein interfaceDownloadManager- Parameters:
errorType-errorDetails-
-
getErrorDetails
- Specified by:
getErrorDetailsin interfaceDownloadManager
-
getErrorType
public int getErrorType()- Specified by:
getErrorTypein interfaceDownloadManager
-
getErrorFlags
public int getErrorFlags()- Specified by:
getErrorFlagsin interfaceDownloadManager
-
getSize
public long getSize()- Specified by:
getSizein interfaceDownloadManager
-
setFailed
-
setFailed
-
setFailed
-
setTorrentInvalid
-
getTCPPortOverride
protected int getTCPPortOverride(boolean only_if_allocated) -
getTorrentHashOverride
-
getTCPListeningPortNumber
public int getTCPListeningPortNumber()- Specified by:
getTCPListeningPortNumberin interfaceDownloadManager
-
saveResumeData
public void saveResumeData()Description copied from interface:DownloadManagerpersist resume data- Specified by:
saveResumeDatain interfaceDownloadManager
-
saveDownload
public void saveDownload(boolean interim) Description copied from interface:DownloadManagerpersist any general download related information, excluding resume data which is managed separately by saveResumeData- Specified by:
saveDownloadin interfaceDownloadManager
-
initialize
public void initialize()- Specified by:
initializein interfaceDownloadManager
-
checkLightSeeding
public void checkLightSeeding(boolean full_sync) - Specified by:
checkLightSeedingin interfaceDownloadManager
-
isLightSeedTracker
-
startQueuedTrackerClient
private void startQueuedTrackerClient() -
stopQueuedTrackerClient
private void stopQueuedTrackerClient() -
setStateWaiting
public void setStateWaiting()- Specified by:
setStateWaitingin interfaceDownloadManager
-
setStateFinishing
public void setStateFinishing() -
setStateQueued
public void setStateQueued()- Specified by:
setStateQueuedin interfaceDownloadManager
-
getState
public int getState()- Specified by:
getStatein interfaceDownloadManager
-
getSubState
public int getSubState()Description copied from interface:DownloadManagerFor stopping this returns the target state after stopping (stopped/queued)- Specified by:
getSubStatein interfaceDownloadManager- Returns:
-
canForceRecheck
public boolean canForceRecheck()- Specified by:
canForceRecheckin interfaceDownloadManager
-
restoreResumeData
-
forceRecheck
public void forceRecheck()- Specified by:
forceRecheckin interfaceDownloadManager
-
isForceRechecking
public boolean isForceRechecking()- Specified by:
isForceRecheckingin interfaceDownloadManager
-
setPieceCheckingEnabled
public void setPieceCheckingEnabled(boolean enabled) Description copied from interface:DownloadManagerUse with care - introduced to support speed tests whereby we want to avoid checking the virtual torrent used for the test- Specified by:
setPieceCheckingEnabledin interfaceDownloadManager- Parameters:
enabled-
-
resetFile
Description copied from interface:DownloadManagerReset the file download state to totally undownloaded. Download must be stopped- Specified by:
resetFilein interfaceDownloadManager- Parameters:
file-
-
recheckFile
Description copied from interface:DownloadManagerRecheck a particular file. Download must be stopped- Specified by:
recheckFilein interfaceDownloadManager- Parameters:
file-
-
requestAllocation
Description copied from interface:DownloadManagerInstructions that file given files need allocation - used when switching file storage types/skipped state Will pause and resume the download if it is active- Specified by:
requestAllocationin interfaceDownloadManager- Parameters:
files-
-
startDownload
public void startDownload()- Specified by:
startDownloadin interfaceDownloadManager
-
stopIt
public void stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data) Description copied from interface:DownloadManagerStop the download manager, and do any file/torrent removals.- Specified by:
stopItin interfaceDownloadManager- Parameters:
state_after_stopping-remove_torrent- remove the .torrent file after stoppingremove_data- remove the data file after stopping
-
setStartReason
- Specified by:
setStartReasonin interfaceDownloadManager
-
getStartReason
- Specified by:
getStartReasonin interfaceDownloadManager
-
setQueueReason
- Specified by:
setQueueReasonin interfaceDownloadManager
-
getQueueReason
- Specified by:
getQueueReasonin interfaceDownloadManager
-
setStopReason
- Specified by:
setStopReasonin interfaceDownloadManager
-
getStopReason
- Specified by:
getStopReasonin interfaceDownloadManager
-
stopIt
public void stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data, boolean for_removal) Description copied from interface:DownloadManagerAs above but definitely indicates that the stop is for removal (if for_removal is true) and therefore that any removal specific actions such as removing partial files should be performed- Specified by:
stopItin interfaceDownloadManager- Parameters:
state_after_stopping-remove_torrent-remove_data-for_removal-
-
checkResuming
private boolean checkResuming() -
pause
public boolean pause(boolean only_if_active) - Specified by:
pausein interfaceDownloadManager- Parameters:
only_if_active-- Returns:
- true -> download was placed into a paused state (including if it was already paused)
-
pause
public boolean pause(boolean only_if_active, long _resume_time) - Specified by:
pausein interfaceDownloadManager- Parameters:
_resume_time-- Returns:
- true -> download was placed into a paused state (including if it was already paused)
-
getAutoResumeTime
public long getAutoResumeTime()- Specified by:
getAutoResumeTimein interfaceDownloadManager
-
setAutoResumeTime
public void setAutoResumeTime(long time) - Specified by:
setAutoResumeTimein interfaceDownloadManager
-
stopPausedDownload
public boolean stopPausedDownload()- Specified by:
stopPausedDownloadin interfaceDownloadManager
-
isPaused
public boolean isPaused()- Specified by:
isPausedin interfaceDownloadManager
-
resume
public void resume()- Specified by:
resumein interfaceDownloadManager
-
resume
public boolean resume(int target_state) Description copied from interface:DownloadManagerresume the download and wait until it reaches the target state. It may fail to reach this state (e.g. goes into an error state). It will however block if it looks like progress towards the state is being made (allocating/checking)- Specified by:
resumein interfaceDownloadManager- Parameters:
target_state-- Returns:
- whether or not the state was reached
-
getAssumedComplete
public boolean getAssumedComplete()Description copied from interface:DownloadManagerRetrieve whether this download is assumed complete.Assumed complete status is kept while the torrent is in a non-running state, even if it has no data.
When the torrent starts up, the real complete level will be checked, and if the torrent actually does have missing data, the download will be thrown into error state.
Only a forced-recheck should clear this flag.
- Specified by:
getAssumedCompletein interfaceDownloadManager
-
requestAssumedCompleteMode
public boolean requestAssumedCompleteMode()Description copied from interface:DownloadManagerWill set this download to be "assumed complete" for if the download is already complete (excluding DND)- Specified by:
requestAssumedCompleteModein interfaceDownloadManager- Returns:
- true- success; false- failure, download not complete
-
requestAssumedCompleteMode
protected boolean requestAssumedCompleteMode(boolean filePriorityChanged) -
setAssumedComplete
protected void setAssumedComplete(boolean _assumedComplete) -
setAssumedComplete
protected void setAssumedComplete(boolean _assumedComplete, boolean filePriorityChanged) -
getNbSeeds
public int getNbSeeds()- Specified by:
getNbSeedsin interfaceDownloadManager
-
getNbPeers
public int getNbPeers()- Specified by:
getNbPeersin interfaceDownloadManager
-
getTrackerStatus
- Specified by:
getTrackerStatusin interfaceDownloadManager
-
getTrackerClient
- Specified by:
getTrackerClientin interfaceDownloadManager
-
setAnnounceResult
- Specified by:
setAnnounceResultin interfaceDownloadManager
-
setScrapeResult
- Specified by:
setScrapeResultin interfaceDownloadManager
-
getNbPieces
public int getNbPieces()- Specified by:
getNbPiecesin interfaceDownloadManager
-
getTrackerTime
public int getTrackerTime()Description copied from interface:DownloadManagerWhen the next call to the tracker will occur (in seconds)- Specified by:
getTrackerTimein interfaceDownloadManager
-
getTorrent
- Specified by:
getTorrentin interfaceDownloadManager
-
getSaveLocation
- Specified by:
getSaveLocationin interfaceDownloadManager
-
getAbsoluteSaveLocation
Description copied from interface:DownloadManagerReturns the file location where we save the torrent, this includes the parent directory and the actual file name.- Specified by:
getAbsoluteSaveLocationin interfaceDownloadManager
-
setTorrentSaveDir
Description copied from interface:DownloadManagerchanges the save directory. Only call this if you know what you are doing!!!! When locationIncludesName, torrent name will also change (Data files will be stored under new_location)
When !locationIncludesName, only save dire is changed, name remains (Data files will be stored under new_location + / + old_location.getName())- Specified by:
setTorrentSaveDirin interfaceDownloadManager
-
getPieceLength
- Specified by:
getPieceLengthin interfaceDownloadManager
-
getTorrentFileName
Description copied from interface:DownloadManagerThis includes the full path to the torrent file.- Specified by:
getTorrentFileNamein interfaceDownloadManager- Returns:
-
setTorrentFileName
- Specified by:
setTorrentFileNamein interfaceDownloadManager
-
setTrackerScrapeResponse
- Specified by:
setTrackerScrapeResponsein interfaceDownloadManager
-
getTrackerScrapeResponse
- Specified by:
getTrackerScrapeResponsein interfaceDownloadManager
-
getActiveScrapeResponse
Returns the "first" online scrape response found, and its active URL, otherwise one of the failing scrapes- Returns:
-
getGoodTrackerScrapeResponses
- Specified by:
getGoodTrackerScrapeResponsesin interfaceDownloadManager
-
requestTrackerAnnounce
public void requestTrackerAnnounce(boolean force) - Specified by:
requestTrackerAnnouncein interfaceDownloadManager
-
requestTrackerScrape
public void requestTrackerScrape(boolean force) - Specified by:
requestTrackerScrapein interfaceDownloadManager
-
setTrackerRefreshDelayOverrides
protected void setTrackerRefreshDelayOverrides(int percent) -
activateRequest
protected boolean activateRequest(int count) -
getActivationCount
public int getActivationCount()- Specified by:
getActivationCountin interfaceDownloadManager
-
getTorrentComment
- Specified by:
getTorrentCommentin interfaceDownloadManager
-
getTorrentCreatedBy
- Specified by:
getTorrentCreatedByin interfaceDownloadManager
-
getTorrentCreationDate
public long getTorrentCreationDate()- Specified by:
getTorrentCreationDatein interfaceDownloadManager
-
getGlobalManager
- Specified by:
getGlobalManagerin interfaceDownloadManager
-
getDiskManager
- Specified by:
getDiskManagerin interfaceDownloadManager
-
getDiskManagerPiecesSnapshot
- Specified by:
getDiskManagerPiecesSnapshotin interfaceDownloadManager
-
getDiskManagerFileInfoSet
- Specified by:
getDiskManagerFileInfoSetin interfaceDownloadManager
-
getDiskManagerFileInfo
Deprecated.use getDiskManagerFileInfoSet() instead- Specified by:
getDiskManagerFileInfoin interfaceDownloadManager
-
getNumFileInfos
public int getNumFileInfos()- Specified by:
getNumFileInfosin interfaceDownloadManager
-
getPeerManager
- Specified by:
getPeerManagerin interfaceDownloadManager
-
isDownloadComplete
public boolean isDownloadComplete(boolean bIncludeDND) Description copied from interface:DownloadManagerRetrieves whether the download is complete- Specified by:
isDownloadCompletein interfaceDownloadManager- Parameters:
bIncludeDND- true- include files marked as Do Not Download.
false- don't include files marked DND.If there are DND files and you choose to include DND in the calculation, false will always be returned.
- Returns:
- whether download is complete
-
addListener
- Specified by:
addListenerin interfaceDownloadManager
-
addListener
- Specified by:
addListenerin interfaceDownloadManager- Parameters:
listener-triggerStateChange-
-
removeListener
- Specified by:
removeListenerin interfaceDownloadManager
-
checkFilePriorities
private void checkFilePriorities(boolean global_change) -
informStateChanged
protected void informStateChanged()Doesn't not inform if state didn't change from last inform call -
informDownloadEnded
protected void informDownloadEnded() -
informPrioritiesChange
-
informLocationChange
protected void informLocationChange(int file_index) -
informLocationChange
-
informPriorityChange
-
informPieceDoneChanged
-
informFileCompletionChange
-
informPositionChanged
protected void informPositionChanged(int new_position) -
addPeerListener
- Specified by:
addPeerListenerin interfaceDownloadManager
-
addPeerListener
- Specified by:
addPeerListenerin interfaceDownloadManager
-
removePeerListener
- Specified by:
removePeerListenerin interfaceDownloadManager
-
addPieceListener
- Specified by:
addPieceListenerin interfaceDownloadManager
-
addPieceListener
- Specified by:
addPieceListenerin interfaceDownloadManager
-
removePieceListener
- Specified by:
removePieceListenerin interfaceDownloadManager
-
addPeer
-
removePeer
-
getCurrentPeers
- Specified by:
getCurrentPeersin interfaceDownloadManager
-
addPiece
-
removePiece
-
getCurrentPieces
- Specified by:
getCurrentPiecesin interfaceDownloadManager
-
informWillBeStarted
-
informStarted
-
informStopped
-
getStats
- Specified by:
getStatsin interfaceDownloadManager
-
calcFilePriorityStats
private void calcFilePriorityStats() -
isForceStart
public boolean isForceStart()- Specified by:
isForceStartin interfaceDownloadManager
-
setForceStart
public void setForceStart(boolean forceStart) - Specified by:
setForceStartin interfaceDownloadManager
-
downloadEnded
protected void downloadEnded(boolean never_downloaded) Is called when a download is finished. Activates alerts for the user.- Parameters:
never_downloaded- true indicates that we never actually downloaded anything in this session, but we determined that the download is complete (usually via startDownload())
-
addDiskListener
- Specified by:
addDiskListenerin interfaceDownloadManager
-
removeDiskListener
- Specified by:
removeDiskListenerin interfaceDownloadManager
-
addActivationListener
- Specified by:
addActivationListenerin interfaceDownloadManager
-
removeActivationListener
- Specified by:
removeActivationListenerin interfaceDownloadManager
-
getHealthStatus
public int getHealthStatus()- Specified by:
getHealthStatusin interfaceDownloadManager- Returns:
- the wealthy status of this download
-
getNATStatus
Description copied from interface:DownloadManagerSee plugin ConnectionManager.NAT_ constants for return values- Specified by:
getNATStatusin interfaceDownloadManager- Returns:
-
getPosition
public int getPosition()- Specified by:
getPositionin interfaceDownloadManager
-
setPosition
public void setPosition(int new_position) - Specified by:
setPositionin interfaceDownloadManager
-
addTrackerListener
- Specified by:
addTrackerListenerin interfaceDownloadManager
-
removeTrackerListener
- Specified by:
removeTrackerListenerin interfaceDownloadManager
-
deleteDataFiles
protected void deleteDataFiles() -
deletePartialDataFiles
protected void deletePartialDataFiles() -
deleteDNDAltLoc
private void deleteDNDAltLoc() -
deleteTorrentFile
protected void deleteTorrentFile() -
getDownloadState
- Specified by:
getDownloadStatein interfaceDownloadManager
-
getUserData
To retreive arbitrary objects against a download.- Specified by:
getUserDatain interfaceDownloadManager
-
setUserData
To store arbitrary objects against a download.- Specified by:
setUserDatain interfaceDownloadManager
-
getTaggableTransientProperty
- Specified by:
getTaggableTransientPropertyin interfaceTaggable
-
setTaggableTransientProperty
- Specified by:
setTaggableTransientPropertyin interfaceTaggable
-
isDataAlreadyAllocated
public boolean isDataAlreadyAllocated()Description copied from interface:DownloadManagerDetermine whether disk allocation has already been done. Used for checking if data is missing on a previously-loaded torrent.- Specified by:
isDataAlreadyAllocatedin interfaceDownloadManager- Returns:
- true if data files have already been allocated
-
setDataAlreadyAllocated
public void setDataAlreadyAllocated(boolean already_allocated) Description copied from interface:DownloadManagerSet whether data allocation has already been done, so we know when to allocate and when to throw a missing-data error message.- Specified by:
setDataAlreadyAllocatedin interfaceDownloadManager- Parameters:
already_allocated-
-
setSeedingRank
- Specified by:
setSeedingRankin interfaceDownloadManager
-
getSeedingRank
- Specified by:
getSeedingRankin interfaceDownloadManager
-
getCreationTime
public long getCreationTime()Description copied from interface:DownloadManagergives the time this download was created (not the torrent but the download itself)- Specified by:
getCreationTimein interfaceDownloadManager- Returns:
-
setCreationTime
public void setCreationTime(long t) - Specified by:
setCreationTimein interfaceDownloadManager
-
isSwarmMerging
public boolean isSwarmMerging()- Specified by:
isSwarmMergingin interfaceDownloadManager
-
getSwarmMergingInfo
- Specified by:
getSwarmMergingInfoin interfaceDownloadManager
-
getExtendedMessagingMode
public int getExtendedMessagingMode()- Specified by:
getExtendedMessagingModein interfaceDownloadManager- Returns:
- messaging mode = az, lt or bt
-
setCryptoLevel
public void setCryptoLevel(int level) - Specified by:
setCryptoLevelin interfaceDownloadManager
-
getCryptoLevel
public int getCryptoLevel()- Specified by:
getCryptoLevelin interfaceDownloadManager
-
getMoveProgress
public long[] getMoveProgress()Description copied from interface:DownloadManagerProgress of a move operation- Specified by:
getMoveProgressin interfaceDiskManagerUtil.MoveTaskAapter- Specified by:
getMoveProgressin interfaceDownloadManager- Returns:
- null: not moving otherwise [ 0->1000, size ]
-
getMoveSubTask
- Specified by:
getMoveSubTaskin interfaceDiskManagerUtil.MoveTaskAapter
-
setMoveState
public void setMoveState(int state) - Specified by:
setMoveStatein interfaceDiskManagerUtil.MoveTaskAapter
-
moveDataFiles
Description copied from interface:DownloadManagerMove data files to new location. Torrent must be in stopped/error state- Specified by:
moveDataFilesin interfaceDownloadManager- Parameters:
new_parent_dir-- Throws:
DownloadManagerException
-
moveDataFilesLive
Description copied from interface:DownloadManagerAt some point someone made the file-move operations stop+restart the download when it was designed to work without doing this (see move-on-complete for example). As I don't know the reason for this change I've (parg) added a new method to do this in the hope that we might in time migrate back to the 'proper' behaviour. grrr- Specified by:
moveDataFilesLivein interfaceDownloadManager- Parameters:
new_parent_dir-- Throws:
DownloadManagerException
-
renameDownload
Description copied from interface:DownloadManagerRename the download - this means the name of the file being downloaded (for single file torrents), or the name of the directory holding the files (in a multi-file torrent). This does not alter the displayed name of the download.- Specified by:
renameDownloadin interfaceDownloadManager- Parameters:
new_name-- Throws:
DownloadManagerException
-
moveDataFiles
Description copied from interface:DownloadManagerMove the files and rename a download in one go. For convenience - either argument can be null, but not both.- Specified by:
moveDataFilesin interfaceDownloadManager- Parameters:
destination- new location to move torrent data files to. If null, and simple torrent, torrent data file will be renamed new_name. If null, and not simple torrent, torrent end path will be changed to new_name.new_name- For simple torrent, changes the filename of the downloaded file. For non-simple torrent, changes the end path for the downloaded files. If null, torrent data files will be moved to new_parent_dir, with a subfolder of the existing name.- Throws:
DownloadManagerException- See Also:
-
moveDataFiles
public void moveDataFiles(File destination, String new_name, boolean live) throws DownloadManagerException - Throws:
DownloadManagerException
-
moveDataFilesSupport
- Throws:
DownloadManagerException
-
moveDataFilesSupport0
void moveDataFilesSupport0(File new_parent_dir, String new_filename) throws DownloadManagerException - Throws:
DownloadManagerException
-
copyDataFiles
public void copyDataFiles(File dest_parent_dir, CoreOperationTask.ProgressCallback cb) throws DownloadManagerException - Specified by:
copyDataFilesin interfaceDownloadManager- Throws:
DownloadManagerException
-
copyTorrentFile
- Throws:
DownloadManagerException
-
canExportDownload
public boolean canExportDownload()- Specified by:
canExportDownloadin interfaceDownloadManager
-
exportDownload
- Specified by:
exportDownloadin interfaceDownloadManager- Throws:
DownloadManagerException
-
moveTorrentFile
Description copied from interface:DownloadManagerMove torrent file to new location. Download must be stopped/error- Specified by:
moveTorrentFilein interfaceDownloadManager- Parameters:
new_parent_dir-- Throws:
DownloadManagerException
-
moveTorrentFile
- Specified by:
moveTorrentFilein interfaceDownloadManager- Throws:
DownloadManagerException
-
moveTorrentFile0
- Throws:
DownloadManagerException
-
setTorrentFile
Description copied from interface:DownloadManagerSets the torrent file name (will perform a move of the torrent file) - this shouldn't be used unless you know what you are doing (it requires the download to be stopped!) - it is safer to use moveTorrentFile instead.- Specified by:
setTorrentFilein interfaceDownloadManager- Throws:
DownloadManagerException
-
isInDefaultSaveDir
public boolean isInDefaultSaveDir()Description copied from interface:DownloadManagerReturns true if the download is being saved to one of the default save directories.- Specified by:
isInDefaultSaveDirin interfaceDownloadManager
-
seedPieceRecheck
public boolean seedPieceRecheck()Description copied from interface:DownloadManagerGives the download an opportunity to schedule seeding mode piece rechecks if desired- Specified by:
seedPieceRecheckin interfaceDownloadManager- Returns:
- true if a piece has been rechecked
-
addRateLimiter
- Specified by:
addRateLimiterin interfaceDownloadManager
-
getRateLimiters
- Specified by:
getRateLimitersin interfaceDownloadManager
-
removeRateLimiter
- Specified by:
removeRateLimiterin interfaceDownloadManager
-
isTrackerError
public boolean isTrackerError()- Specified by:
isTrackerErrorin interfaceDownloadManager
-
isUnauthorisedOnTracker
public boolean isUnauthorisedOnTracker()- Specified by:
isUnauthorisedOnTrackerin interfaceDownloadManager
-
getTrackerPeerSources
- Specified by:
getTrackerPeerSourcesin interfaceDownloadManager
-
addTPSListener
- Specified by:
addTPSListenerin interfaceDownloadManager
-
removeTPSListener
- Specified by:
removeTPSListenerin interfaceDownloadManager
-
informTPSChanged
public void informTPSChanged()- Specified by:
informTPSChangedin interfaceDownloadManager
-
getIdentity
private byte[] getIdentity() -
equals
-
hashCode
-
getRelationText
Description copied from class:LogRelationA short description of what your class holds that can be printed by the logger- Overrides:
getRelationTextin classLogRelation- Returns:
-
getQueryableInterfaces
Description copied from class:LogRelationQuery this class for a reference to another class that it may hold- Overrides:
getQueryableInterfacesin classLogRelation- Returns:
- If found, the class desired. Otherwise, null.
-
toString
-
generateEvidence
- Specified by:
generateEvidencein interfaceDownloadManager
-
destroy
public void destroy(boolean is_duplicate) Description copied from interface:DownloadManagerIndicates that the download manager is no longer needed- Specified by:
destroyin interfaceDownloadManager- Parameters:
is_duplicate- indicates whether this dm is being destroyed because it is a duplicate
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDownloadManager
-
getStorageType
- Specified by:
getStorageTypein interfaceDownloadManager
-
canMoveDataFiles
public boolean canMoveDataFiles()- Specified by:
canMoveDataFilesin interfaceDownloadManager
-
rename
Description copied from interface:DownloadManagerRenames the save file, torrent file and the displayed name.- Specified by:
renamein interfaceDownloadManager- Throws:
DownloadManagerException
-
renameTorrent
- Specified by:
renameTorrentin interfaceDownloadManager- Throws:
DownloadManagerException
-
renameTorrentSafe
Description copied from interface:DownloadManagerSame as renameTorrent, but appends numbers if torrent already exists- Specified by:
renameTorrentSafein interfaceDownloadManager- Throws:
DownloadManagerException
-
requestAttention
public void requestAttention()- Specified by:
requestAttentionin interfaceDownloadManager
-
fireGlobalManagerEvent
- Specified by:
fireGlobalManagerEventin interfaceDownloadManager
-