Package com.biglybt.core.download.impl
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 TRTrackerAnnouncer
private TRTrackerAnnouncer
private final CopyOnWriteList
<DownloadManagerActivationListener> private static final AllTrackersManager.AllTrackers
private boolean
Pretend this download is complete while not running, even if it has no data.private File
private File
private static final String
private static final ClientIDManagerImpl
private boolean
(package private) final DownloadManagerController
private long
private int
private int
private boolean
private static int
private static final Download.SeedingRank
private boolean
private String
private byte[]
private int
private boolean
static String
(package private) DownloadManagerState
private static final DownloadManagerListener
(package private) static final CopyOnWriteList
<DownloadManagerListener> (package private) final GlobalManager
private Object
private boolean
private String
private int
forceStarted torrents can't/shouldn't be automatically stoppedprivate long
private long
private boolean
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private int
private final ListenerManager
<DownloadManagerListener> (package private) static final ListenerManager
<DownloadManagerListener> private final AEMonitor
private int
private static int
private int
private boolean
private int
private int
private int
private int
private boolean
private int
private long[]
private int
private String
private boolean
private final ListenerManager
<DownloadManagerPeerListener> (package private) static final ListenerManager
<DownloadManagerPeerListener> (package private) final AEMonitor
private final boolean
private final ListenerManager
<DownloadManagerPieceListener> (package private) static final ListenerManager
<DownloadManagerPieceListener> private final AEMonitor
private static Object
private int
private Object[]
private boolean
private long
private static TimerEventPeriodic
private static final long
private static final long
private static final long
private static final long
private final long
private Download.SeedingRank
private int
private final DownloadManagerStatsImpl
private int
protected final AEMonitor
private TOTorrent
private String
private String
private File
private boolean
private String
(package private) static final Object
private List
<DownloadManagerTPSListener> private final TRTrackerAnnouncerListener
private final TRTrackerAnnouncerListener
(package private) final ListenerManager
<DownloadManagerTrackerListener> private static Object
private int
private int
private static int
private long
Fields inherited from interface com.biglybt.core.util.DataSourceResolver.ExportableDataSource
OPT_CAN_MINIMIZE, OPT_ON_TOP
Fields inherited from interface com.biglybt.core.download.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_STOP_REASON, WEALTH_ERROR, WEALTH_KO, WEALTH_NO_REMOTE, WEALTH_NO_TRACKER, WEALTH_OK, WEALTH_STOPPED
Fields inherited from interface com.biglybt.core.tag.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 boolean
activateRequest
(int count) void
void
addDiskListener
(DownloadManagerDiskListener listener) static void
void
addListener
(DownloadManagerListener listener) void
addListener
(DownloadManagerListener listener, boolean triggerStateChange) void
void
addPeerListener
(DownloadManagerPeerListener listener) void
addPeerListener
(DownloadManagerPeerListener listener, boolean bDispatchForExisting) void
void
addPieceListener
(DownloadManagerPieceListener listener) void
addPieceListener
(DownloadManagerPieceListener listener, boolean bDispatchForExisting) void
addRateLimiter
(LimitedRateGroup group, boolean upload) void
addTPSListener
(DownloadManagerTPSListener listener) void
private void
buildURLGroupMap
(TOTorrent torrent) private void
boolean
boolean
boolean
private void
checkFilePriorities
(boolean global_change) void
checkLightSeeding
(boolean full_sync) private boolean
protected void
void
copyDataFiles
(File dest_parent_dir, CoreOperationTask.ProgressCallback cb) private void
copyTorrentFile
(File parent_dir) protected void
protected void
protected void
void
destroy
(boolean is_duplicate) Indicates that the download manager is no longer neededprotected void
downloadEnded
(boolean never_downloaded) Is called when a download is finished.boolean
void
exportDownload
(File parent_dir) boolean
filesExist
(boolean expected_to_be_allocated, boolean test_only) void
fireGlobalManagerEvent
(int eventType, Object eventData) void
void
generateEvidence
(IndentWriter writer, boolean full) Returns the file location where we save the torrent, this includes the parent directory and the actual file name.int
protected Object[]
Returns the "first" online scrape response found, and its active URL, otherwise one of the failing scrapesboolean
Retrieve whether this download is assumed complete.long
long
gives the time this download was created (not the torrent but the download itself)int
PEPeer[]
PEPiece[]
Deprecated.use getDiskManagerFileInfoSet() insteadint
Returns the max uploads depending on whether the download is seeding and it has a separate rate for thisint
int
returns the currently in force upload speed limit which may vary from the stats.int
int
int
int
private byte[]
returns a name based on the torrent hash or an empty string if torrent invalidprivate int
protected int[]
getMaxConnections
(boolean mixed) protected int[]
getMaxConnectionsWhenSeeding
(boolean mixed) protected int[]
getMaxSeedConnections
(boolean mixed) int
protected int
long[]
Progress of a move operationObject[]
See plugin ConnectionManager.NAT_ constants for return valuesint
int
int
int
int
Object[]
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 loggerlong
getSize()
int
getState()
getStats()
int[]
getStorageType
(DiskManagerFileInfo[] info) int
For stopping this returns the target state after stopping (stopped/queued)int
int
protected int
getTCPPortOverride
(boolean only_if_allocated) long
This includes the full path to the torrent file.protected HashWrapper
int
When the next call to the tracker will occur (in seconds)protected int
getTrackerURLGroup
(String key) getUserData
(Object key) To retreive arbitrary objects against a download.int
hashCode()
protected void
protected void
protected void
informLocationChange
(int file_index) protected void
protected void
protected void
informPositionChanged
(int new_position) protected void
informPrioritiesChange
(List files) protected void
protected void
protected void
Doesn't not inform if state didn't change from last inform callprotected void
informStopped
(PEPeerManager pm, boolean for_queue) void
protected void
void
boolean
boolean
Determine whether disk allocation has already been done.boolean
boolean
isDownloadComplete
(boolean bIncludeDND) Retrieves whether the download is completeboolean
boolean
boolean
Returns true if the download is being saved to one of the default save directories.protected boolean
protected boolean
protected boolean
boolean
isPaused()
boolean
boolean
boolean
boolean
void
moveDataFiles
(File new_parent_dir) Move data files to new location.void
moveDataFiles
(File destination, String new_name) Move the files and rename a download in one go.void
moveDataFiles
(File destination, String new_name, boolean live) void
moveDataFilesLive
(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) void
moveDataFilesSupport
(File new_parent_dir, String new_filename) (package private) void
moveDataFilesSupport0
(File new_parent_dir, String new_filename) void
moveTorrentFile
(File new_parent_dir) Move torrent file to new location.void
moveTorrentFile
(File new_parent_dir, String new_name) private void
moveTorrentFile0
(File new_parent_dir, String new_name) boolean
pause
(boolean only_if_active) boolean
pause
(boolean only_if_active, long _resume_time) protected void
private void
readFilePriorityConfig
(boolean init, boolean global_change) protected void
protected void
private void
readTorrent
(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) void
Recheck a particular file.void
void
static void
void
removeListener
(DownloadManagerListener listener) void
removePeer
(PEPeer peer) void
void
removePiece
(PEPiece piece) void
void
removeRateLimiter
(LimitedRateGroup group, boolean upload) void
removeTPSListener
(DownloadManagerTPSListener listener) void
void
Renames the save file, torrent file and the displayed name.void
renameDownload
(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).void
renameTorrent
(String name) void
renameTorrentSafe
(String name) Same as renameTorrent, but appends numbers if torrent already existsvoid
requestAllocation
(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 activeboolean
Will set this download to be "assumed complete" for if the download is already complete (excluding DND)protected boolean
requestAssumedCompleteMode
(boolean filePriorityChanged) void
void
requestTrackerAnnounce
(boolean force) void
requestTrackerScrape
(boolean force) void
resetFile
(DiskManagerFileInfo file) Reset the file download state to totally undownloaded.protected void
restoreResumeData
(Map data) void
resume()
boolean
resume
(int target_state) resume the download and wait until it reaches the target state.void
saveDownload
(boolean interim) persist any general download related information, excluding resume data which is managed separately by saveResumeDatavoid
persist resume databoolean
Gives the download an opportunity to schedule seeding mode piece rechecks if desiredvoid
protected void
setAssumedComplete
(boolean _assumedComplete) protected void
setAssumedComplete
(boolean _assumedComplete, boolean filePriorityChanged) void
setAutoResumeTime
(long time) void
void
setCreationTime
(long t) void
setCryptoLevel
(int level) void
setDataAlreadyAllocated
(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.void
setErrorState
(int errorType, String errorDetails, int errorFlags) Download must be stopped - used at start-of-day to recover error stateprotected void
protected void
protected void
protected void
void
setFilePriorities
(DiskManagerFileInfo[] fileInfos, int priority) Sets the priority for an array for filesvoid
setForceStart
(boolean forceStart) void
setManualUploadPriority
(int priority) void
setMaxUploads
(int max) void
setMoveState
(int state) void
setPieceCheckingEnabled
(boolean enabled) Use with care - introduced to support speed tests whereby we want to avoid checking the virtual torrent used for the testvoid
setPosition
(int new_position) void
setScrapeResult
(DownloadScrapeResult result) void
void
void
void
void
setStopReason
(String reason) void
setTaggableTransientProperty
(String key, Object value) void
setTorrentFile
(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.void
setTorrentFileName
(String string) protected void
setTorrentInvalid
(Throwable cause) void
setTorrentSaveDir
(File _new_location, boolean locationIncludesName) changes the save directory.protected void
setTrackerRefreshDelayOverrides
(int percent) void
void
setUserData
(Object key, Object value) To store arbitrary objects against a download.void
private void
void
stopIt
(int state_after_stopping, boolean remove_torrent, boolean remove_data) Stop the download manager, and do any file/torrent removals.void
stopIt
(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 performedboolean
private void
void
Called for certain config change events so that individual managers don't have to separately listener for changestoString()
void
updateAutoUploadPriority
(Object key, boolean inc) private void
updateFileLink
(int file_index, File old_path, File new_path, File from_loc, File to_loc, List<Integer> from_indexes, List<File> from_links, List<File> to_links) private void
updateFileLinks
(File old_save_path, File new_save_path) Methods inherited from class com.biglybt.core.logging.LogRelation
propogatedRelationText, queryForClass
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.biglybt.core.util.DataSourceResolver.ExportableDataSource
getBooleanOption
Methods inherited from interface com.biglybt.core.download.DownloadManager
filesExist, fireGlobalManagerEvent, 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
-
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 -
removing
private volatile boolean removing -
destroyed
private volatile boolean destroyed -
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:
setConstructed
in interfaceDownloadManager
-
isConstructed
public boolean isConstructed()- Specified by:
isConstructed
in interfaceDownloadManager
-
buildURLGroupMap
-
getLightSeedTrackerStatus
-
getTrackerURLGroup
-
getTaggableType
public int getTaggableType()- Specified by:
getTaggableType
in interfaceTaggable
-
getTaggableResolver
- Specified by:
getTaggableResolver
in interfaceTaggable
-
getTaggableID
- Specified by:
getTaggableID
in interfaceTaggable
-
getTaggableName
- Specified by:
getTaggableName
in interfaceTaggable
-
exportDataSource
- Specified by:
exportDataSource
in interfaceDataSourceResolver.ExportableDataSource
-
readTorrent
-
readTorrent
protected void readTorrent() -
syncGlobalConfig
public void syncGlobalConfig()Description copied from interface:DownloadManager
Called for certain config change events so that individual managers don't have to separately listener for changes- Specified by:
syncGlobalConfig
in 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:
updateAutoUploadPriority
in interfaceDownloadManager
-
getEffectiveUploadPriority
public int getEffectiveUploadPriority()- Specified by:
getEffectiveUploadPriority
in interfaceDownloadManager
-
getMaxUploads
public int getMaxUploads()- Specified by:
getMaxUploads
in interfaceDownloadManager
-
setMaxUploads
public void setMaxUploads(int max) - Specified by:
setMaxUploads
in interfaceDownloadManager
-
setManualUploadPriority
public void setManualUploadPriority(int priority) -
getEffectiveMaxUploads
public int getEffectiveMaxUploads()Description copied from interface:DownloadManager
Returns the max uploads depending on whether the download is seeding and it has a separate rate for this- Specified by:
getEffectiveMaxUploads
in interfaceDownloadManager
- Returns:
-
rateLimitChanged
protected void rateLimitChanged() -
getEffectiveUploadRateLimitBytesPerSecond
public int getEffectiveUploadRateLimitBytesPerSecond()Description copied from interface:DownloadManager
returns the currently in force upload speed limit which may vary from the stats. value as this gives the fixed per-torrent limit- Specified by:
getEffectiveUploadRateLimitBytesPerSecond
in interfaceDownloadManager
- Returns:
-
setFileLinks
protected void setFileLinks() -
clearFileLinks
protected void clearFileLinks() -
updateFileLinks
-
updateFileLink
-
filesExist
public boolean filesExist(boolean expected_to_be_allocated, boolean test_only) - Specified by:
filesExist
in interfaceDownloadManager
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistent
in interfaceDownloadManager
-
getDisplayName
- Specified by:
getDisplayName
in interfaceDownloadManager
-
getInternalName
Description copied from interface:DownloadManager
returns a name based on the torrent hash or an empty string if torrent invalid- Specified by:
getInternalName
in interfaceDownloadManager
- Returns:
-
setErrorState
Description copied from interface:DownloadManager
Download must be stopped - used at start-of-day to recover error state- Specified by:
setErrorState
in interfaceDownloadManager
- Parameters:
errorType
-errorDetails
-
-
getErrorDetails
- Specified by:
getErrorDetails
in interfaceDownloadManager
-
getErrorType
public int getErrorType()- Specified by:
getErrorType
in interfaceDownloadManager
-
getErrorFlags
public int getErrorFlags()- Specified by:
getErrorFlags
in interfaceDownloadManager
-
getSize
public long getSize()- Specified by:
getSize
in interfaceDownloadManager
-
setFailed
-
setFailed
-
setFailed
-
setTorrentInvalid
-
getTCPPortOverride
protected int getTCPPortOverride(boolean only_if_allocated) -
getTorrentHashOverride
-
getTCPListeningPortNumber
public int getTCPListeningPortNumber()- Specified by:
getTCPListeningPortNumber
in interfaceDownloadManager
-
saveResumeData
public void saveResumeData()Description copied from interface:DownloadManager
persist resume data- Specified by:
saveResumeData
in interfaceDownloadManager
-
saveDownload
public void saveDownload(boolean interim) Description copied from interface:DownloadManager
persist any general download related information, excluding resume data which is managed separately by saveResumeData- Specified by:
saveDownload
in interfaceDownloadManager
-
initialize
public void initialize()- Specified by:
initialize
in interfaceDownloadManager
-
checkLightSeeding
public void checkLightSeeding(boolean full_sync) - Specified by:
checkLightSeeding
in interfaceDownloadManager
-
isLightSeedTracker
-
startQueuedTrackerClient
private void startQueuedTrackerClient() -
stopQueuedTrackerClient
private void stopQueuedTrackerClient() -
setStateWaiting
public void setStateWaiting()- Specified by:
setStateWaiting
in interfaceDownloadManager
-
setStateFinishing
public void setStateFinishing() -
setStateQueued
public void setStateQueued()- Specified by:
setStateQueued
in interfaceDownloadManager
-
getState
public int getState()- Specified by:
getState
in interfaceDownloadManager
-
getSubState
public int getSubState()Description copied from interface:DownloadManager
For stopping this returns the target state after stopping (stopped/queued)- Specified by:
getSubState
in interfaceDownloadManager
- Returns:
-
canForceRecheck
public boolean canForceRecheck()- Specified by:
canForceRecheck
in interfaceDownloadManager
-
restoreResumeData
-
forceRecheck
public void forceRecheck()- Specified by:
forceRecheck
in interfaceDownloadManager
-
isForceRechecking
public boolean isForceRechecking()- Specified by:
isForceRechecking
in interfaceDownloadManager
-
setPieceCheckingEnabled
public void setPieceCheckingEnabled(boolean enabled) Description copied from interface:DownloadManager
Use with care - introduced to support speed tests whereby we want to avoid checking the virtual torrent used for the test- Specified by:
setPieceCheckingEnabled
in interfaceDownloadManager
- Parameters:
enabled
-
-
resetFile
Description copied from interface:DownloadManager
Reset the file download state to totally undownloaded. Download must be stopped- Specified by:
resetFile
in interfaceDownloadManager
- Parameters:
file
-
-
recheckFile
Description copied from interface:DownloadManager
Recheck a particular file. Download must be stopped- Specified by:
recheckFile
in interfaceDownloadManager
- Parameters:
file
-
-
requestAllocation
Description copied from interface:DownloadManager
Instructions 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:
requestAllocation
in interfaceDownloadManager
- Parameters:
files
-
-
startDownload
public void startDownload()- Specified by:
startDownload
in interfaceDownloadManager
-
stopIt
public void stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data) Description copied from interface:DownloadManager
Stop the download manager, and do any file/torrent removals.- Specified by:
stopIt
in interfaceDownloadManager
- Parameters:
state_after_stopping
-remove_torrent
- remove the .torrent file after stoppingremove_data
- remove the data file after stopping
-
setStopReason
- Specified by:
setStopReason
in interfaceDownloadManager
-
getStopReason
- Specified by:
getStopReason
in interfaceDownloadManager
-
stopIt
public void stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data, boolean for_removal) Description copied from interface:DownloadManager
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 performed- Specified by:
stopIt
in 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:
pause
in 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:
pause
in 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:
getAutoResumeTime
in interfaceDownloadManager
-
setAutoResumeTime
public void setAutoResumeTime(long time) - Specified by:
setAutoResumeTime
in interfaceDownloadManager
-
stopPausedDownload
public boolean stopPausedDownload()- Specified by:
stopPausedDownload
in interfaceDownloadManager
-
isPaused
public boolean isPaused()- Specified by:
isPaused
in interfaceDownloadManager
-
resume
public void resume()- Specified by:
resume
in interfaceDownloadManager
-
resume
public boolean resume(int target_state) Description copied from interface:DownloadManager
resume 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:
resume
in interfaceDownloadManager
- Parameters:
target_state
-- Returns:
- whether or not the state was reached
-
getAssumedComplete
public boolean getAssumedComplete()Description copied from interface:DownloadManager
Retrieve 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:
getAssumedComplete
in interfaceDownloadManager
-
requestAssumedCompleteMode
public boolean requestAssumedCompleteMode()Description copied from interface:DownloadManager
Will set this download to be "assumed complete" for if the download is already complete (excluding DND)- Specified by:
requestAssumedCompleteMode
in 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:
getNbSeeds
in interfaceDownloadManager
-
getNbPeers
public int getNbPeers()- Specified by:
getNbPeers
in interfaceDownloadManager
-
getTrackerStatus
- Specified by:
getTrackerStatus
in interfaceDownloadManager
-
getTrackerClient
- Specified by:
getTrackerClient
in interfaceDownloadManager
-
setAnnounceResult
- Specified by:
setAnnounceResult
in interfaceDownloadManager
-
setScrapeResult
- Specified by:
setScrapeResult
in interfaceDownloadManager
-
getNbPieces
public int getNbPieces()- Specified by:
getNbPieces
in interfaceDownloadManager
-
getTrackerTime
public int getTrackerTime()Description copied from interface:DownloadManager
When the next call to the tracker will occur (in seconds)- Specified by:
getTrackerTime
in interfaceDownloadManager
-
getTorrent
- Specified by:
getTorrent
in interfaceDownloadManager
-
getSaveLocation
- Specified by:
getSaveLocation
in interfaceDownloadManager
-
getAbsoluteSaveLocation
Description copied from interface:DownloadManager
Returns the file location where we save the torrent, this includes the parent directory and the actual file name.- Specified by:
getAbsoluteSaveLocation
in interfaceDownloadManager
-
setTorrentSaveDir
Description copied from interface:DownloadManager
changes 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:
setTorrentSaveDir
in interfaceDownloadManager
-
getPieceLength
- Specified by:
getPieceLength
in interfaceDownloadManager
-
getTorrentFileName
Description copied from interface:DownloadManager
This includes the full path to the torrent file.- Specified by:
getTorrentFileName
in interfaceDownloadManager
- Returns:
-
setTorrentFileName
- Specified by:
setTorrentFileName
in interfaceDownloadManager
-
setTrackerScrapeResponse
- Specified by:
setTrackerScrapeResponse
in interfaceDownloadManager
-
getTrackerScrapeResponse
- Specified by:
getTrackerScrapeResponse
in interfaceDownloadManager
-
getActiveScrapeResponse
Returns the "first" online scrape response found, and its active URL, otherwise one of the failing scrapes- Returns:
-
getGoodTrackerScrapeResponses
- Specified by:
getGoodTrackerScrapeResponses
in interfaceDownloadManager
-
requestTrackerAnnounce
public void requestTrackerAnnounce(boolean force) - Specified by:
requestTrackerAnnounce
in interfaceDownloadManager
-
requestTrackerScrape
public void requestTrackerScrape(boolean force) - Specified by:
requestTrackerScrape
in interfaceDownloadManager
-
setTrackerRefreshDelayOverrides
protected void setTrackerRefreshDelayOverrides(int percent) -
activateRequest
protected boolean activateRequest(int count) -
getActivationCount
public int getActivationCount()- Specified by:
getActivationCount
in interfaceDownloadManager
-
getTorrentComment
- Specified by:
getTorrentComment
in interfaceDownloadManager
-
getTorrentCreatedBy
- Specified by:
getTorrentCreatedBy
in interfaceDownloadManager
-
getTorrentCreationDate
public long getTorrentCreationDate()- Specified by:
getTorrentCreationDate
in interfaceDownloadManager
-
getGlobalManager
- Specified by:
getGlobalManager
in interfaceDownloadManager
-
getDiskManager
- Specified by:
getDiskManager
in interfaceDownloadManager
-
getDiskManagerPiecesSnapshot
- Specified by:
getDiskManagerPiecesSnapshot
in interfaceDownloadManager
-
getDiskManagerFileInfoSet
- Specified by:
getDiskManagerFileInfoSet
in interfaceDownloadManager
-
getDiskManagerFileInfo
Deprecated.use getDiskManagerFileInfoSet() instead- Specified by:
getDiskManagerFileInfo
in interfaceDownloadManager
-
getNumFileInfos
public int getNumFileInfos()- Specified by:
getNumFileInfos
in interfaceDownloadManager
-
getPeerManager
- Specified by:
getPeerManager
in interfaceDownloadManager
-
isDownloadComplete
public boolean isDownloadComplete(boolean bIncludeDND) Description copied from interface:DownloadManager
Retrieves whether the download is complete- Specified by:
isDownloadComplete
in 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:
addListener
in interfaceDownloadManager
-
addListener
- Specified by:
addListener
in interfaceDownloadManager
- Parameters:
listener
-triggerStateChange
-
-
removeListener
- Specified by:
removeListener
in 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:
addPeerListener
in interfaceDownloadManager
-
addPeerListener
- Specified by:
addPeerListener
in interfaceDownloadManager
-
removePeerListener
- Specified by:
removePeerListener
in interfaceDownloadManager
-
addPieceListener
- Specified by:
addPieceListener
in interfaceDownloadManager
-
addPieceListener
- Specified by:
addPieceListener
in interfaceDownloadManager
-
removePieceListener
- Specified by:
removePieceListener
in interfaceDownloadManager
-
addPeer
-
removePeer
-
getCurrentPeers
- Specified by:
getCurrentPeers
in interfaceDownloadManager
-
addPiece
-
removePiece
-
getCurrentPieces
- Specified by:
getCurrentPieces
in interfaceDownloadManager
-
informWillBeStarted
-
informStarted
-
informStopped
-
getStats
- Specified by:
getStats
in interfaceDownloadManager
-
calcFilePriorityStats
private void calcFilePriorityStats() -
isForceStart
public boolean isForceStart()- Specified by:
isForceStart
in interfaceDownloadManager
-
setForceStart
public void setForceStart(boolean forceStart) - Specified by:
setForceStart
in 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:
addDiskListener
in interfaceDownloadManager
-
removeDiskListener
- Specified by:
removeDiskListener
in interfaceDownloadManager
-
addActivationListener
- Specified by:
addActivationListener
in interfaceDownloadManager
-
removeActivationListener
- Specified by:
removeActivationListener
in interfaceDownloadManager
-
getHealthStatus
public int getHealthStatus()- Specified by:
getHealthStatus
in interfaceDownloadManager
- Returns:
- the wealthy status of this download
-
getNATStatus
Description copied from interface:DownloadManager
See plugin ConnectionManager.NAT_ constants for return values- Specified by:
getNATStatus
in interfaceDownloadManager
- Returns:
-
getPosition
public int getPosition()- Specified by:
getPosition
in interfaceDownloadManager
-
setPosition
public void setPosition(int new_position) - Specified by:
setPosition
in interfaceDownloadManager
-
addTrackerListener
- Specified by:
addTrackerListener
in interfaceDownloadManager
-
removeTrackerListener
- Specified by:
removeTrackerListener
in interfaceDownloadManager
-
deleteDataFiles
protected void deleteDataFiles() -
deletePartialDataFiles
protected void deletePartialDataFiles() -
deleteTorrentFile
protected void deleteTorrentFile() -
getDownloadState
- Specified by:
getDownloadState
in interfaceDownloadManager
-
getUserData
To retreive arbitrary objects against a download.- Specified by:
getUserData
in interfaceDownloadManager
-
setUserData
To store arbitrary objects against a download.- Specified by:
setUserData
in interfaceDownloadManager
-
getTaggableTransientProperty
- Specified by:
getTaggableTransientProperty
in interfaceTaggable
-
setTaggableTransientProperty
- Specified by:
setTaggableTransientProperty
in interfaceTaggable
-
isDataAlreadyAllocated
public boolean isDataAlreadyAllocated()Description copied from interface:DownloadManager
Determine whether disk allocation has already been done. Used for checking if data is missing on a previously-loaded torrent.- Specified by:
isDataAlreadyAllocated
in interfaceDownloadManager
- Returns:
- true if data files have already been allocated
-
setDataAlreadyAllocated
public void setDataAlreadyAllocated(boolean already_allocated) Description copied from interface:DownloadManager
Set whether data allocation has already been done, so we know when to allocate and when to throw a missing-data error message.- Specified by:
setDataAlreadyAllocated
in interfaceDownloadManager
- Parameters:
already_allocated
-
-
setSeedingRank
- Specified by:
setSeedingRank
in interfaceDownloadManager
-
getSeedingRank
- Specified by:
getSeedingRank
in interfaceDownloadManager
-
getCreationTime
public long getCreationTime()Description copied from interface:DownloadManager
gives the time this download was created (not the torrent but the download itself)- Specified by:
getCreationTime
in interfaceDownloadManager
- Returns:
-
setCreationTime
public void setCreationTime(long t) - Specified by:
setCreationTime
in interfaceDownloadManager
-
isSwarmMerging
public boolean isSwarmMerging()- Specified by:
isSwarmMerging
in interfaceDownloadManager
-
getSwarmMergingInfo
- Specified by:
getSwarmMergingInfo
in interfaceDownloadManager
-
getExtendedMessagingMode
public int getExtendedMessagingMode()- Specified by:
getExtendedMessagingMode
in interfaceDownloadManager
- Returns:
- messaging mode = az, lt or bt
-
setCryptoLevel
public void setCryptoLevel(int level) - Specified by:
setCryptoLevel
in interfaceDownloadManager
-
getCryptoLevel
public int getCryptoLevel()- Specified by:
getCryptoLevel
in interfaceDownloadManager
-
getMoveProgress
public long[] getMoveProgress()Description copied from interface:DownloadManager
Progress of a move operation- Specified by:
getMoveProgress
in interfaceDiskManagerUtil.MoveTaskAapter
- Specified by:
getMoveProgress
in interfaceDownloadManager
- Returns:
- null: not moving otherwise [ 0->1000, size ]
-
getMoveSubTask
- Specified by:
getMoveSubTask
in interfaceDiskManagerUtil.MoveTaskAapter
-
setMoveState
public void setMoveState(int state) - Specified by:
setMoveState
in interfaceDiskManagerUtil.MoveTaskAapter
-
moveDataFiles
Description copied from interface:DownloadManager
Move data files to new location. Torrent must be in stopped/error state- Specified by:
moveDataFiles
in interfaceDownloadManager
- Parameters:
new_parent_dir
-- Throws:
DownloadManagerException
-
moveDataFilesLive
Description copied from interface:DownloadManager
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). 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:
moveDataFilesLive
in interfaceDownloadManager
- Parameters:
new_parent_dir
-- Throws:
DownloadManagerException
-
renameDownload
Description copied from interface:DownloadManager
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). This does not alter the displayed name of the download.- Specified by:
renameDownload
in interfaceDownloadManager
- Parameters:
new_name
-- Throws:
DownloadManagerException
-
moveDataFiles
Description copied from interface:DownloadManager
Move the files and rename a download in one go. For convenience - either argument can be null, but not both.- Specified by:
moveDataFiles
in 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:
copyDataFiles
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
copyTorrentFile
- Throws:
DownloadManagerException
-
canExportDownload
public boolean canExportDownload()- Specified by:
canExportDownload
in interfaceDownloadManager
-
exportDownload
- Specified by:
exportDownload
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
moveTorrentFile
Description copied from interface:DownloadManager
Move torrent file to new location. Download must be stopped/error- Specified by:
moveTorrentFile
in interfaceDownloadManager
- Parameters:
new_parent_dir
-- Throws:
DownloadManagerException
-
moveTorrentFile
- Specified by:
moveTorrentFile
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
moveTorrentFile0
- Throws:
DownloadManagerException
-
setTorrentFile
Description copied from interface:DownloadManager
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.- Specified by:
setTorrentFile
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
isInDefaultSaveDir
public boolean isInDefaultSaveDir()Description copied from interface:DownloadManager
Returns true if the download is being saved to one of the default save directories.- Specified by:
isInDefaultSaveDir
in interfaceDownloadManager
-
seedPieceRecheck
public boolean seedPieceRecheck()Description copied from interface:DownloadManager
Gives the download an opportunity to schedule seeding mode piece rechecks if desired- Specified by:
seedPieceRecheck
in interfaceDownloadManager
- Returns:
- true if a piece has been rechecked
-
addRateLimiter
- Specified by:
addRateLimiter
in interfaceDownloadManager
-
getRateLimiters
- Specified by:
getRateLimiters
in interfaceDownloadManager
-
removeRateLimiter
- Specified by:
removeRateLimiter
in interfaceDownloadManager
-
isTrackerError
public boolean isTrackerError()- Specified by:
isTrackerError
in interfaceDownloadManager
-
isUnauthorisedOnTracker
public boolean isUnauthorisedOnTracker()- Specified by:
isUnauthorisedOnTracker
in interfaceDownloadManager
-
getTrackerPeerSources
- Specified by:
getTrackerPeerSources
in interfaceDownloadManager
-
addTPSListener
- Specified by:
addTPSListener
in interfaceDownloadManager
-
removeTPSListener
- Specified by:
removeTPSListener
in interfaceDownloadManager
-
informTPSChanged
public void informTPSChanged()- Specified by:
informTPSChanged
in interfaceDownloadManager
-
getIdentity
private byte[] getIdentity() -
equals
-
hashCode
public int hashCode() -
getRelationText
Description copied from class:LogRelation
A short description of what your class holds that can be printed by the logger- Overrides:
getRelationText
in classLogRelation
- Returns:
-
getQueryableInterfaces
Description copied from class:LogRelation
Query this class for a reference to another class that it may hold- Overrides:
getQueryableInterfaces
in classLogRelation
- Returns:
- If found, the class desired. Otherwise, null.
-
toString
-
generateEvidence
- Specified by:
generateEvidence
in interfaceDownloadManager
-
destroy
public void destroy(boolean is_duplicate) Description copied from interface:DownloadManager
Indicates that the download manager is no longer needed- Specified by:
destroy
in interfaceDownloadManager
- Parameters:
is_duplicate
- indicates whether this dm is being destroyed because it is a duplicate
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyed
in interfaceDownloadManager
-
getStorageType
- Specified by:
getStorageType
in interfaceDownloadManager
-
canMoveDataFiles
public boolean canMoveDataFiles()- Specified by:
canMoveDataFiles
in interfaceDownloadManager
-
rename
Description copied from interface:DownloadManager
Renames the save file, torrent file and the displayed name.- Specified by:
rename
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
renameTorrent
- Specified by:
renameTorrent
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
renameTorrentSafe
Description copied from interface:DownloadManager
Same as renameTorrent, but appends numbers if torrent already exists- Specified by:
renameTorrentSafe
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
requestAttention
public void requestAttention()- Specified by:
requestAttention
in interfaceDownloadManager
-
fireGlobalManagerEvent
- Specified by:
fireGlobalManagerEvent
in interfaceDownloadManager
-
setFilePriorities
Description copied from interface:DownloadManager
Sets the priority for an array for files- Specified by:
setFilePriorities
in interfaceDownloadManager
- Parameters:
fileInfos
-priority
-
-