Package com.biglybt.core.disk.impl
Class DiskManagerImpl
- java.lang.Object
-
- com.biglybt.core.logging.LogRelation
-
- com.biglybt.core.disk.impl.DiskManagerImpl
-
- All Implemented Interfaces:
DiskManager
,DiskManagerHelper
,DiskManagerUtil.MoveTaskAapter
public class DiskManagerImpl extends LogRelation implements DiskManagerHelper, DiskManagerUtil.MoveTaskAapter
The disk Wrapper.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DiskManagerImpl.DownloadEndedProgressImpl
-
Nested classes/interfaces inherited from interface com.biglybt.core.disk.DiskManager
DiskManager.DownloadEndedProgress
-
-
Field Summary
-
Fields inherited from interface com.biglybt.core.disk.DiskManager
ALLOCATING, BLOCK_SIZE, BLOCK_SIZE_KB, CHECKING, ET_FILE_MISSING, ET_INSUFFICIENT_SPACE, ET_NONE, ET_OTHER, ET_READ_ERROR, ET_STOP_DURING_INIT, ET_WRITE_ERROR, FAULTY, INITIALIZING, READY
-
-
Constructor Summary
Constructors Constructor Description DiskManagerImpl(TOTorrent _torrent, DownloadManager _dmanager)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(DiskManagerListener l)
private boolean
allocateFile(DiskManagerAllocationScheduler.AllocationInstance allocation_instance, DiskManagerFileInfoImpl fileInfo, java.io.File data_file, long existing_length, long target_length, boolean[] stop_after_start, long alloc_strategy)
private int[]
allocateFiles(boolean[] stop_after_start)
boolean
checkBlockConsistencyForHint(java.lang.String originator, int pieceNumber, int offset, int length)
boolean
checkBlockConsistencyForRead(java.lang.String originator, boolean peer_request, int pieceNumber, int offset, int length)
method for checking that the block details are sensibleboolean
checkBlockConsistencyForWrite(java.lang.String originator, int pieceNumber, int offset, DirectByteBuffer data)
method for checking that the block details are sensiblevoid
checkFreePieceList(boolean force_discard)
private static int
countDataFiles(TOTorrent torrent, java.lang.String torrent_save_dir, java.lang.String torrent_save_file)
private static int
countFiles(java.io.File f, int stopAfterCount)
DiskManagerCheckRequest
createCheckRequest(int pieceNumber, java.lang.Object user_data)
Create a request to check a particular pieceprivate DiskManagerFileInfoImpl
createFileInfo(DownloadManagerState state, DMPieceMapperFile pm_info, int file_index, java.io.File root_dir, java.lang.String relative_file, int storage_type)
DiskManagerReadRequest
createReadRequest(int pieceNumber, int offset, int length)
DiskManagerWriteRequest
createWriteRequest(int pieceNumber, int offset, DirectByteBuffer data, java.lang.Object user_data)
private static void
deleteDataFileContents(TOTorrent torrent, java.lang.String torrent_save_dir, java.lang.String torrent_save_file, boolean force_no_recycle)
static void
deleteDataFiles(TOTorrent torrent, java.lang.String torrent_save_dir, java.lang.String torrent_save_file, boolean force_no_recycle)
Deletes all data files associated with torrent.DiskManager.DownloadEndedProgress
downloadEnded()
void
downloadRemoved()
void
enqueueCheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener)
enqueue an asynchronous single piece checkvoid
enqueueCompleteRecheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener)
recheck the entire torrent asynchronously, reporting each piece to the listenervoid
enqueueReadRequest(DiskManagerReadRequest request, DiskManagerReadRequestListener listener)
Enqueue an async disk read request.void
enqueueWriteRequest(DiskManagerWriteRequest request, DiskManagerWriteRequestListener listener)
enqueue an async write requestprivate void
fileAllocFailed(java.io.File file, long length, boolean is_new, java.lang.Throwable e)
boolean
filesExist()
protected boolean
filesExist(java.io.File root_dir, boolean exact)
private void
fixupSkippedCalculation()
void
generateEvidence(IndentWriter writer)
java.lang.String
getAllocationTask()
BitFlags
getAvailability()
int
getCacheMode()
int
getCompleteRecheckStatus()
returns -1 if no recheck in progress, percentage complete in 1000 notation otherwisestatic DiskAccessController
getDefaultDiskAccessController()
DiskAccessController
getDiskAccessController()
java.lang.String
getDisplayName()
DownloadManager
getDownload()
DownloadManager
getDownloadManager()
DownloadManagerState
getDownloadState()
java.lang.String
getErrorMessage()
int
getErrorType()
DiskManagerFileInfo[]
getFiles()
DiskManagerFileInfoSet
getFileSet()
java.lang.String
getInternalName()
int
getLastPieceLength()
long[]
getLatency()
long[]
getMoveProgress()
When a download's data is moving (for completion or removal events) this gives the [progress in 1000 notation,total_size] null if nothing's going onjava.lang.String
getMoveSubTask()
int
getNbPieces()
int
getPercentAllocated()
int
getPercentDone()
Get the percentage done during checking, allocation or initializingint
getPercentDoneExcludingDND()
DiskManagerPiece
getPiece(int PieceNumber)
byte[]
getPieceHash(int piece_number)
int
getPieceLength()
int
getPieceLength(int piece_number)
DMPieceList
getPieceList(int piece_number)
DMPieceMap
getPieceMap()
DON'T CACHE the DMPieceMap - as it is designed to be discarded when not in useDiskManagerPiece[]
getPieces()
long
getPriorityChangeMarker()
java.lang.Object[]
getQueryableInterfaces()
Query this class for a reference to another class that it may holdlong[]
getReadStats()
DiskManagerRecheckScheduler
getRecheckScheduler()
java.lang.String
getRelationText()
A short description of what your class holds that can be printed by the loggerlong
getRemaining()
Get remaining bytes to completion *including* DND fileslong
getRemainingExcludingDND()
java.io.File
getSaveLocation()
long
getSizeExcludingDND()
int
getState()
java.lang.String
getStorageType(int fileIndex)
Returns the storage type for file atfileIndex
.static java.lang.String
getStorageType(DownloadManager download_manager, int fileIndex)
Returns the storage type for aDownloadManager
's file atfileIndex
.java.lang.String[]
getStorageTypes()
Returns the storage type for all files.static java.lang.String[]
getStorageTypes(DownloadManager download_manager)
Returns the storage type for each file inDownloadManager
.TOTorrent
getTorrent()
long
getTotalLength()
long[]
getWriteStats()
boolean
hasListener(DiskManagerListener l)
boolean
hasOutstandingCheckRequestForPiece(int piece_number)
boolean
hasOutstandingReadRequestForPiece(int piece_number)
boolean
hasOutstandingWriteRequestForPiece(int piece_number)
boolean
isDone(int pieceNumber)
private boolean
isFileDestinationIsItself(SaveLocationChange loc_change)
boolean
isInteresting(int pieceNumber)
boolean
isStopped()
private void
logMoveFileError(java.io.File destination_path, java.lang.String message)
void
moveDataFiles(java.io.File new_parent_dir, java.lang.String new_name)
private boolean
moveDataFiles0(SaveLocationChange loc_change, boolean change_to_read_only)
private void
moveDownloadFilesWhenEndedOrRemoved(boolean removing, boolean torrent_file_exists, DiskManagerImpl.DownloadEndedProgressImpl progress)
private void
moveDownloadFilesWhenEndedOrRemoved0(SaveLocationChange loc_change, DiskManagerImpl.DownloadEndedProgressImpl progress)
protected void
moveFiles(SaveLocationChange loc_change, boolean change_to_read_only)
private void
moveTorrentFile(SaveLocationChange loc_change)
void
priorityChanged(DiskManagerFileInfo file)
DirectByteBuffer
readBlock(int pieceNumber, int offset, int length)
void
removeListener(DiskManagerListener l)
void
saveResumeData(boolean interim_save)
void
saveState(boolean interim)
Save the individual file priorities map to DownloadManager.getData( "file_priorities" ).protected void
saveStateSupport(boolean persist, boolean interim)
private void
setErrorMessage(long file_length, java.lang.Throwable e, java.lang.String str)
private void
setErrorMessage(java.lang.String str)
private void
setErrorMessage(java.lang.Throwable e, java.lang.String str)
private void
setErrorState()
private void
setErrorState(int type)
private void
setErrorState(int type, java.lang.String msg)
private void
setErrorState(int type, java.lang.String msg, java.lang.Throwable cause)
private void
setErrorState(java.lang.String msg)
private void
setErrorState(java.lang.String msg, java.lang.Throwable cause)
void
setFailed(int type, java.lang.String reason, java.lang.Throwable cause)
Stops the disk manager and informs the download manager that things have gone wrong.void
setFailedAndRecheck(DiskManagerFileInfo file, java.lang.String reason)
static void
setFileLinks(DownloadManager download_manager, LinkFileMap links)
void
setMoveState(int state)
void
setPieceCheckingEnabled(boolean enabled)
void
setPieceDone(DiskManagerPieceImpl dmPiece, boolean done)
Called when status has CHANGED and should only be called by DiskManagerPieceImplprivate void
setState(int _state)
void
skippedFileSetChanged(DiskManagerFileInfo file)
void
start()
Start checking/allocating(package private) void
startSupport()
boolean
stop(boolean closing)
Stop can go async if the download is in a 'starting' state - if so this method returns truevoid
storageTypeChanged(DiskManagerFileInfo file)
protected static void
storeFileDownloaded(DownloadManager download_manager, DiskManagerFileInfo[] files, boolean persist, boolean interim)
protected void
storeFilePriorities()
protected static void
storeFilePriorities(DownloadManager download_manager, DiskManagerFileInfo[] files)
-
Methods inherited from class com.biglybt.core.logging.LogRelation
propogatedRelationText, queryForClass
-
-
-
-
Field Detail
-
DM_FREE_PIECELIST_TIMEOUT
private static final int DM_FREE_PIECELIST_TIMEOUT
- See Also:
- Constant Field Values
-
LOGID
private static final LogIDs LOGID
-
disk_access_controller
private static final DiskAccessController disk_access_controller
-
reorder_storage_mode
static boolean reorder_storage_mode
-
reorder_storage_mode_min_mb
static int reorder_storage_mode_min_mb
-
priority_file_exts
static volatile java.util.Set<java.lang.String> priority_file_exts
-
priority_file_exts_ignore_case
static volatile boolean priority_file_exts_ignore_case
-
missing_file_dl_restart_enabled
static volatile boolean missing_file_dl_restart_enabled
-
skip_comp_dl_file_checks
static boolean skip_comp_dl_file_checks
-
recheck_scheduler
private static final DiskManagerRecheckScheduler recheck_scheduler
-
allocation_scheduler
private static final DiskManagerAllocationScheduler allocation_scheduler
-
start_pool
private static final ThreadPool start_pool
-
used
private boolean used
-
started
private boolean started
-
started_sem
final AESemaphore started_sem
-
starting
private boolean starting
-
stopping
private volatile boolean stopping
-
state_set_via_method
private volatile int state_set_via_method
-
errorMessage_set_via_method
private volatile java.lang.String errorMessage_set_via_method
-
errorType
private volatile int errorType
-
pieceLength
private int pieceLength
-
lastPieceLength
private int lastPieceLength
-
nbPieces
private int nbPieces
-
totalLength
private long totalLength
-
percentDone
private int percentDone
-
allocated
private long allocated
-
allocate_not_required
private long allocate_not_required
-
remaining
private long remaining
-
allocation_task
private volatile java.lang.String allocation_task
-
remaining_excluding_dnd
private volatile long remaining_excluding_dnd
-
torrent
private final TOTorrent torrent
-
reader
private DMReader reader
-
checker
private DMChecker checker
-
writer
private DMWriter writer
-
resume_handler
private RDResumeHandler resume_handler
-
piece_mapper
private DMPieceMapper piece_mapper
-
pieces
private DiskManagerPieceImpl[] pieces
-
piece_map_use_accessor
private DMPieceMap piece_map_use_accessor
-
piece_map_use_accessor_time
private long piece_map_use_accessor_time
-
files
private DiskManagerFileInfoImpl[] files
-
fileset
private DiskManagerFileInfoSet fileset
-
download_manager
protected final DownloadManager download_manager
-
alreadyMoved
private boolean alreadyMoved
-
skipped_file_set_changed
private boolean skipped_file_set_changed
-
skipped_file_set_size
private long skipped_file_set_size
-
skipped_but_downloaded
private long skipped_but_downloaded
-
priority_change_marker
private final java.util.concurrent.atomic.AtomicLong priority_change_marker
-
checking_enabled
private boolean checking_enabled
-
move_in_progress
private volatile boolean move_in_progress
-
move_progress
private volatile long[] move_progress
-
move_subtask
private volatile java.io.File move_subtask
-
move_state
private volatile int move_state
-
LDT_STATECHANGED
private static final int LDT_STATECHANGED
- See Also:
- Constant Field Values
-
LDT_PRIOCHANGED
private static final int LDT_PRIOCHANGED
- See Also:
- Constant Field Values
-
LDT_PIECE_DONE_CHANGED
private static final int LDT_PIECE_DONE_CHANGED
- See Also:
- Constant Field Values
-
LDT_FILE_COMPLETED
private static final int LDT_FILE_COMPLETED
- See Also:
- Constant Field Values
-
listeners_aggregator
protected static final ListenerManager<DiskManagerListener> listeners_aggregator
-
listeners
private final ListenerManager<DiskManagerListener> listeners
-
start_stop_mon
final AEMonitor start_stop_mon
-
file_piece_lock
private final java.lang.Object file_piece_lock
-
availability
private final BitFlags availability
-
garbage
public long garbage
-
-
Constructor Detail
-
DiskManagerImpl
public DiskManagerImpl(TOTorrent _torrent, DownloadManager _dmanager)
-
-
Method Detail
-
getDefaultDiskAccessController
public static DiskAccessController getDefaultDiskAccessController()
-
getDisplayName
public java.lang.String getDisplayName()
- Specified by:
getDisplayName
in interfaceDiskManagerHelper
-
getDownload
public DownloadManager getDownload()
- Specified by:
getDownload
in interfaceDiskManager
- Returns:
- MAY BE NULL
-
start
public void start()
Description copied from interface:DiskManager
Start checking/allocating- Specified by:
start
in interfaceDiskManager
-
startSupport
void startSupport()
-
stop
public boolean stop(boolean closing)
Description copied from interface:DiskManager
Stop can go async if the download is in a 'starting' state - if so this method returns true- Specified by:
stop
in interfaceDiskManager
- Returns:
-
isStopped
public boolean isStopped()
- Specified by:
isStopped
in interfaceDiskManager
-
filesExist
public boolean filesExist()
- Specified by:
filesExist
in interfaceDiskManager
- Returns:
- whether all files exist and sizes match
-
filesExist
protected boolean filesExist(java.io.File root_dir, boolean exact)
-
createFileInfo
private DiskManagerFileInfoImpl createFileInfo(DownloadManagerState state, DMPieceMapperFile pm_info, int file_index, java.io.File root_dir, java.lang.String relative_file, int storage_type) throws java.lang.Exception
- Throws:
java.lang.Exception
-
allocateFiles
private int[] allocateFiles(boolean[] stop_after_start)
-
allocateFile
private boolean allocateFile(DiskManagerAllocationScheduler.AllocationInstance allocation_instance, DiskManagerFileInfoImpl fileInfo, java.io.File data_file, long existing_length, long target_length, boolean[] stop_after_start, long alloc_strategy) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
fileAllocFailed
private void fileAllocFailed(java.io.File file, long length, boolean is_new, java.lang.Throwable e)
-
getDiskAccessController
public DiskAccessController getDiskAccessController()
- Specified by:
getDiskAccessController
in interfaceDiskManagerHelper
-
enqueueReadRequest
public void enqueueReadRequest(DiskManagerReadRequest request, DiskManagerReadRequestListener listener)
Description copied from interface:DiskManager
Enqueue an async disk read request.- Specified by:
enqueueReadRequest
in interfaceDiskManager
-
hasOutstandingReadRequestForPiece
public boolean hasOutstandingReadRequestForPiece(int piece_number)
- Specified by:
hasOutstandingReadRequestForPiece
in interfaceDiskManager
-
getNbPieces
public int getNbPieces()
- Specified by:
getNbPieces
in interfaceDiskManager
-
getPercentDone
public int getPercentDone()
Description copied from interface:DiskManager
Get the percentage done during checking, allocation or initializing- Specified by:
getPercentDone
in interfaceDiskManager
- Returns:
- percent done * 1000 (1000 = 100%)
-
getPercentAllocated
public int getPercentAllocated()
- Specified by:
getPercentAllocated
in interfaceDiskManager
-
getLatency
public long[] getLatency()
- Specified by:
getLatency
in interfaceDiskManager
-
getAllocationTask
public java.lang.String getAllocationTask()
- Specified by:
getAllocationTask
in interfaceDiskManager
-
getRemaining
public long getRemaining()
Description copied from interface:DiskManager
Get remaining bytes to completion *including* DND files- Specified by:
getRemaining
in interfaceDiskManager
-
fixupSkippedCalculation
private void fixupSkippedCalculation()
-
getRemainingExcludingDND
public long getRemainingExcludingDND()
- Specified by:
getRemainingExcludingDND
in interfaceDiskManager
-
getSizeExcludingDND
public long getSizeExcludingDND()
- Specified by:
getSizeExcludingDND
in interfaceDiskManager
-
getPercentDoneExcludingDND
public int getPercentDoneExcludingDND()
- Specified by:
getPercentDoneExcludingDND
in interfaceDiskManager
-
setPieceDone
public void setPieceDone(DiskManagerPieceImpl dmPiece, boolean done)
Called when status has CHANGED and should only be called by DiskManagerPieceImpl- Specified by:
setPieceDone
in interfaceDiskManagerHelper
-
getAvailability
public BitFlags getAvailability()
- Specified by:
getAvailability
in interfaceDiskManager
-
getPieces
public DiskManagerPiece[] getPieces()
- Specified by:
getPieces
in interfaceDiskManager
-
getPiece
public DiskManagerPiece getPiece(int PieceNumber)
- Specified by:
getPiece
in interfaceDiskManager
-
getPieceLength
public int getPieceLength()
- Specified by:
getPieceLength
in interfaceDiskManager
-
getPieceLength
public int getPieceLength(int piece_number)
- Specified by:
getPieceLength
in interfaceDiskManager
-
getTotalLength
public long getTotalLength()
- Specified by:
getTotalLength
in interfaceDiskManager
-
getLastPieceLength
public int getLastPieceLength()
-
getState
public int getState()
- Specified by:
getState
in interfaceDiskManager
-
setErrorMessage
private void setErrorMessage(java.lang.String str)
-
setErrorMessage
private void setErrorMessage(java.lang.Throwable e, java.lang.String str)
-
setErrorMessage
private void setErrorMessage(long file_length, java.lang.Throwable e, java.lang.String str)
-
setErrorState
private void setErrorState()
-
setErrorState
private void setErrorState(java.lang.String msg)
-
setErrorState
private void setErrorState(int type, java.lang.String msg)
-
setErrorState
private void setErrorState(java.lang.String msg, java.lang.Throwable cause)
-
setErrorState
private void setErrorState(int type, java.lang.String msg, java.lang.Throwable cause)
-
setErrorState
private void setErrorState(int type)
-
setState
private void setState(int _state)
-
getFiles
public DiskManagerFileInfo[] getFiles()
- Specified by:
getFiles
in interfaceDiskManager
-
getFileSet
public DiskManagerFileInfoSet getFileSet()
- Specified by:
getFileSet
in interfaceDiskManager
-
getErrorMessage
public java.lang.String getErrorMessage()
- Specified by:
getErrorMessage
in interfaceDiskManager
-
getErrorType
public int getErrorType()
- Specified by:
getErrorType
in interfaceDiskManager
-
setFailed
public void setFailed(int type, java.lang.String reason, java.lang.Throwable cause)
Description copied from interface:DiskManagerHelper
Stops the disk manager and informs the download manager that things have gone wrong.- Specified by:
setFailed
in interfaceDiskManagerHelper
-
setFailedAndRecheck
public void setFailedAndRecheck(DiskManagerFileInfo file, java.lang.String reason)
- Specified by:
setFailedAndRecheck
in interfaceDiskManagerHelper
-
getCacheMode
public int getCacheMode()
- Specified by:
getCacheMode
in interfaceDiskManager
-
getReadStats
public long[] getReadStats()
- Specified by:
getReadStats
in interfaceDiskManager
-
getWriteStats
public long[] getWriteStats()
- Specified by:
getWriteStats
in interfaceDiskManager
-
getPieceMap
public DMPieceMap getPieceMap()
Description copied from interface:DiskManager
DON'T CACHE the DMPieceMap - as it is designed to be discarded when not in use- Specified by:
getPieceMap
in interfaceDiskManager
- Returns:
-
getPieceList
public DMPieceList getPieceList(int piece_number)
- Specified by:
getPieceList
in interfaceDiskManager
- Specified by:
getPieceList
in interfaceDiskManagerHelper
-
checkFreePieceList
public void checkFreePieceList(boolean force_discard)
-
getPieceHash
public byte[] getPieceHash(int piece_number) throws TOTorrentException
- Specified by:
getPieceHash
in interfaceDiskManagerHelper
- Throws:
TOTorrentException
-
createReadRequest
public DiskManagerReadRequest createReadRequest(int pieceNumber, int offset, int length)
- Specified by:
createReadRequest
in interfaceDiskManager
-
createCheckRequest
public DiskManagerCheckRequest createCheckRequest(int pieceNumber, java.lang.Object user_data)
Description copied from interface:DiskManager
Create a request to check a particular piece- Specified by:
createCheckRequest
in interfaceDiskManager
- Parameters:
pieceNumber
- -1 for a complete recheck request- Returns:
-
hasOutstandingCheckRequestForPiece
public boolean hasOutstandingCheckRequestForPiece(int piece_number)
- Specified by:
hasOutstandingCheckRequestForPiece
in interfaceDiskManager
-
enqueueCompleteRecheckRequest
public void enqueueCompleteRecheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener)
Description copied from interface:DiskManager
recheck the entire torrent asynchronously, reporting each piece to the listener- Specified by:
enqueueCompleteRecheckRequest
in interfaceDiskManager
-
enqueueCheckRequest
public void enqueueCheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener)
Description copied from interface:DiskManager
enqueue an asynchronous single piece check- Specified by:
enqueueCheckRequest
in interfaceDiskManager
-
getCompleteRecheckStatus
public int getCompleteRecheckStatus()
Description copied from interface:DiskManager
returns -1 if no recheck in progress, percentage complete in 1000 notation otherwise- Specified by:
getCompleteRecheckStatus
in interfaceDiskManager
- Returns:
-
getMoveProgress
public long[] getMoveProgress()
Description copied from interface:DiskManager
When a download's data is moving (for completion or removal events) this gives the [progress in 1000 notation,total_size] null if nothing's going on- Specified by:
getMoveProgress
in interfaceDiskManager
- Specified by:
getMoveProgress
in interfaceDiskManagerUtil.MoveTaskAapter
-
getMoveSubTask
public java.lang.String getMoveSubTask()
- Specified by:
getMoveSubTask
in interfaceDiskManager
- Specified by:
getMoveSubTask
in interfaceDiskManagerUtil.MoveTaskAapter
-
setMoveState
public void setMoveState(int state)
- Specified by:
setMoveState
in interfaceDiskManager
- Specified by:
setMoveState
in interfaceDiskManagerUtil.MoveTaskAapter
-
setPieceCheckingEnabled
public void setPieceCheckingEnabled(boolean enabled)
- Specified by:
setPieceCheckingEnabled
in interfaceDiskManager
-
readBlock
public DirectByteBuffer readBlock(int pieceNumber, int offset, int length)
- Specified by:
readBlock
in interfaceDiskManager
-
createWriteRequest
public DiskManagerWriteRequest createWriteRequest(int pieceNumber, int offset, DirectByteBuffer data, java.lang.Object user_data)
- Specified by:
createWriteRequest
in interfaceDiskManager
-
enqueueWriteRequest
public void enqueueWriteRequest(DiskManagerWriteRequest request, DiskManagerWriteRequestListener listener)
Description copied from interface:DiskManager
enqueue an async write request- Specified by:
enqueueWriteRequest
in interfaceDiskManager
-
hasOutstandingWriteRequestForPiece
public boolean hasOutstandingWriteRequestForPiece(int piece_number)
- Specified by:
hasOutstandingWriteRequestForPiece
in interfaceDiskManager
-
checkBlockConsistencyForWrite
public boolean checkBlockConsistencyForWrite(java.lang.String originator, int pieceNumber, int offset, DirectByteBuffer data)
Description copied from interface:DiskManager
method for checking that the block details are sensible- Specified by:
checkBlockConsistencyForWrite
in interfaceDiskManager
- Returns:
-
checkBlockConsistencyForRead
public boolean checkBlockConsistencyForRead(java.lang.String originator, boolean peer_request, int pieceNumber, int offset, int length)
Description copied from interface:DiskManager
method for checking that the block details are sensible- Specified by:
checkBlockConsistencyForRead
in interfaceDiskManager
- Returns:
-
checkBlockConsistencyForHint
public boolean checkBlockConsistencyForHint(java.lang.String originator, int pieceNumber, int offset, int length)
- Specified by:
checkBlockConsistencyForHint
in interfaceDiskManager
-
saveResumeData
public void saveResumeData(boolean interim_save) throws java.lang.Exception
- Specified by:
saveResumeData
in interfaceDiskManager
- Throws:
java.lang.Exception
-
downloadEnded
public DiskManager.DownloadEndedProgress downloadEnded()
- Specified by:
downloadEnded
in interfaceDiskManager
-
downloadRemoved
public void downloadRemoved()
- Specified by:
downloadRemoved
in interfaceDiskManager
-
moveDownloadFilesWhenEndedOrRemoved
private void moveDownloadFilesWhenEndedOrRemoved(boolean removing, boolean torrent_file_exists, DiskManagerImpl.DownloadEndedProgressImpl progress)
-
moveDownloadFilesWhenEndedOrRemoved0
private void moveDownloadFilesWhenEndedOrRemoved0(SaveLocationChange loc_change, DiskManagerImpl.DownloadEndedProgressImpl progress)
-
moveDataFiles
public void moveDataFiles(java.io.File new_parent_dir, java.lang.String new_name)
- Specified by:
moveDataFiles
in interfaceDiskManager
-
moveFiles
protected void moveFiles(SaveLocationChange loc_change, boolean change_to_read_only)
-
logMoveFileError
private void logMoveFileError(java.io.File destination_path, java.lang.String message)
-
isFileDestinationIsItself
private boolean isFileDestinationIsItself(SaveLocationChange loc_change)
-
moveDataFiles0
private boolean moveDataFiles0(SaveLocationChange loc_change, boolean change_to_read_only) throws java.lang.Exception
- Throws:
java.lang.Exception
-
moveTorrentFile
private void moveTorrentFile(SaveLocationChange loc_change)
-
getTorrent
public TOTorrent getTorrent()
- Specified by:
getTorrent
in interfaceDiskManager
- Specified by:
getTorrent
in interfaceDiskManagerHelper
-
addListener
public void addListener(DiskManagerListener l)
- Specified by:
addListener
in interfaceDiskManager
-
removeListener
public void removeListener(DiskManagerListener l)
- Specified by:
removeListener
in interfaceDiskManager
-
hasListener
public boolean hasListener(DiskManagerListener l)
- Specified by:
hasListener
in interfaceDiskManager
-
deleteDataFiles
public static void deleteDataFiles(TOTorrent torrent, java.lang.String torrent_save_dir, java.lang.String torrent_save_file, boolean force_no_recycle)
Deletes all data files associated with torrent. Currently, deletes all files, then tries to delete the path recursively if the paths are empty. An unexpected result may be that a empty directory that the user created will be removed. TODO: only remove empty directories that are created for the torrent
-
countFiles
private static int countFiles(java.io.File f, int stopAfterCount)
-
countDataFiles
private static int countDataFiles(TOTorrent torrent, java.lang.String torrent_save_dir, java.lang.String torrent_save_file)
-
deleteDataFileContents
private static void deleteDataFileContents(TOTorrent torrent, java.lang.String torrent_save_dir, java.lang.String torrent_save_file, boolean force_no_recycle) throws TOTorrentException, java.io.UnsupportedEncodingException, LocaleUtilEncodingException
- Throws:
TOTorrentException
java.io.UnsupportedEncodingException
LocaleUtilEncodingException
-
skippedFileSetChanged
public void skippedFileSetChanged(DiskManagerFileInfo file)
- Specified by:
skippedFileSetChanged
in interfaceDiskManagerHelper
-
priorityChanged
public void priorityChanged(DiskManagerFileInfo file)
- Specified by:
priorityChanged
in interfaceDiskManagerHelper
-
storageTypeChanged
public void storageTypeChanged(DiskManagerFileInfo file)
- Specified by:
storageTypeChanged
in interfaceDiskManagerHelper
-
storeFilePriorities
protected void storeFilePriorities()
-
storeFilePriorities
protected static void storeFilePriorities(DownloadManager download_manager, DiskManagerFileInfo[] files)
-
storeFileDownloaded
protected static void storeFileDownloaded(DownloadManager download_manager, DiskManagerFileInfo[] files, boolean persist, boolean interim)
-
saveState
public void saveState(boolean interim)
Description copied from interface:DiskManager
Save the individual file priorities map to DownloadManager.getData( "file_priorities" ).- Specified by:
saveState
in interfaceDiskManager
-
saveStateSupport
protected void saveStateSupport(boolean persist, boolean interim)
-
getDownloadManager
public DownloadManager getDownloadManager()
-
getInternalName
public java.lang.String getInternalName()
- Specified by:
getInternalName
in interfaceDiskManagerHelper
-
getDownloadState
public DownloadManagerState getDownloadState()
- Specified by:
getDownloadState
in interfaceDiskManagerHelper
-
getSaveLocation
public java.io.File getSaveLocation()
- Specified by:
getSaveLocation
in interfaceDiskManager
-
getStorageTypes
public java.lang.String[] getStorageTypes()
Description copied from interface:DiskManagerHelper
Returns the storage type for all files. According toDiskManagerUtil.convertDMStorageTypeFromString(String)
, values are:
"R"DiskManagerFileInfo.ST_REORDER
"L"DiskManagerFileInfo.ST_LINEAR
"C"DiskManagerFileInfo.ST_COMPACT
"X"DiskManagerFileInfo.ST_REORDER_COMPACT
- Specified by:
getStorageTypes
in interfaceDiskManagerHelper
-
getStorageType
public java.lang.String getStorageType(int fileIndex)
Description copied from interface:DiskManagerHelper
Returns the storage type for file atfileIndex
. According toDiskManagerUtil.convertDMStorageTypeFromString(String)
, values are:
"R"DiskManagerFileInfo.ST_REORDER
"L"DiskManagerFileInfo.ST_LINEAR
"C"DiskManagerFileInfo.ST_COMPACT
"X"DiskManagerFileInfo.ST_REORDER_COMPACT
- Specified by:
getStorageType
in interfaceDiskManagerHelper
-
getStorageTypes
public static java.lang.String[] getStorageTypes(DownloadManager download_manager)
Returns the storage type for each file inDownloadManager
. According toDiskManagerUtil.convertDMStorageTypeFromString(String)
, String values are:
"R"DiskManagerFileInfo.ST_REORDER
"L"DiskManagerFileInfo.ST_LINEAR
"C"DiskManagerFileInfo.ST_COMPACT
"X"DiskManagerFileInfo.ST_REORDER_COMPACT
-
getStorageType
public static java.lang.String getStorageType(DownloadManager download_manager, int fileIndex)
Returns the storage type for aDownloadManager
's file atfileIndex
. According toDiskManagerUtil.convertDMStorageTypeFromString(String)
, values are:
"R"DiskManagerFileInfo.ST_REORDER
"L"DiskManagerFileInfo.ST_LINEAR
"C"DiskManagerFileInfo.ST_COMPACT
"X"DiskManagerFileInfo.ST_REORDER_COMPACT
-
setFileLinks
public static void setFileLinks(DownloadManager download_manager, LinkFileMap links)
-
getRelationText
public java.lang.String 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
public java.lang.Object[] 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.
-
getRecheckScheduler
public DiskManagerRecheckScheduler getRecheckScheduler()
- Specified by:
getRecheckScheduler
in interfaceDiskManagerHelper
-
isInteresting
public boolean isInteresting(int pieceNumber)
- Specified by:
isInteresting
in interfaceDiskManager
- Returns:
- true if the pieceNumber is Needed and not Done
-
isDone
public boolean isDone(int pieceNumber)
- Specified by:
isDone
in interfaceDiskManager
-
getPriorityChangeMarker
public long getPriorityChangeMarker()
- Specified by:
getPriorityChangeMarker
in interfaceDiskManager
-
generateEvidence
public void generateEvidence(IndentWriter writer)
- Specified by:
generateEvidence
in interfaceDiskManager
-
-