Class LWSDiskManager
java.lang.Object
com.biglybt.core.lws.LWSDiskManager
- All Implemented Interfaces:
DiskManager, DiskManagerHelper
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface DiskManager
DiskManager.DownloadEndedProgress -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BitFlagsprivate DMCheckerprivate final DiskAccessControllerprivate final DownloadManagerStateprivate Stringprivate intprivate DiskManagerFileInfoImpl[]private Stringprivate final LightWeightSeedprivate static final LWSDiskManager.sePieceprivate DMPieceMapprivate DMPieceMapperprivate final LWSDiskManager.sePiece[]private DMReaderprivate final Fileprivate booleanprivate intFields inherited from interface 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, SNAPSHOT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleancheckBlockConsistencyForHint(String originator, int pieceNumber, int offset, int length) booleancheckBlockConsistencyForRead(String originator, boolean peer_request, int pieceNumber, int offset, int length) method for checking that the block details are sensiblebooleancheckBlockConsistencyForWrite(String originator, int pieceNumber, int offset, DirectByteBuffer data) method for checking that the block details are sensiblecreateCheckRequest(int pieceNumber, Object user_data) Create a request to check a particular piececreateReadRequest(int pieceNumber, int offset, int length) createWriteRequest(int pieceNumber, int offset, DirectByteBuffer data, Object user_data) downloadEnded(boolean start_of_day) voidvoidenqueueCheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener) enqueue an asynchronous single piece checkvoidenqueueCompleteRecheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener) recheck the entire torrent asynchronously, reporting each piece to the listenervoidenqueueReadRequest(DiskManagerReadRequest request, DiskManagerReadRequestListener listener) Enqueue an async disk read request.voidenqueueWriteRequest(DiskManagerWriteRequest request, DiskManagerWriteRequestListener listener) enqueue an async write requestbooleanvoidgenerateEvidence(IndentWriter writer) intprotected DMCheckerintreturns -1 if no recheck in progress, percentage complete in 1000 notation otherwiseintprotected DiskManagerFileInfoImpl[]getFileInfo(DMPieceMapperFile[] pm_files, File save_location) getFiles()intlong[]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 ongetName()intintintGet the percentage done during checking, allocation or initializingintgetPiece(int index) byte[]getPieceHash(int piece_number) intintgetPieceLength(int piece_number) getPieceList(int piece_number) DON'T CACHE the DMPieceMap - as it is designed to be discarded when not in uselonglong[]booleanlongGet remaining bytes to completion *including* DND fileslonglongintgetState()getStorageType(int fileIndex) Returns the storage type for file atfileIndex.String[]Returns the storage type for all files.longlong[]booleanbooleanhasOutstandingCheckRequestForPiece(int piece_number) booleanhasOutstandingReadRequestForPiece(int piece_number) booleanhasOutstandingWriteRequestForPiece(int piece_number) booleanisDone(int piece_num) booleanisInteresting(int piece_num) booleanbooleanvoidmoveDataFiles(File new_parent_dir, String new_name) voidvoidreadBlock(int pieceNumber, int offset, int length) voidvoidsaveResumeData(boolean interim_save) voidsaveState(boolean interim) Save the individual file priorities map to DownloadManager.getData( "file_priorities" ).voidStops the disk manager and informs the download manager that things have gone wrong.voidsetFailedAndRecheck(DiskManagerFileInfo file, String reason) voidsetMoveState(int state) voidsetPieceCheckingEnabled(boolean enabled) voidsetPieceDone(DiskManagerPieceImpl dmPiece, boolean done) voidvoidstart()Start checking/allocatingbooleanstop(boolean closing) Stop can go async if the download is in a 'starting' state - if so this method returns truevoidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DiskManager
getAllocationTask, getLatency
-
Field Details
-
piece
-
lws
-
disk_access_controller
-
save_file
-
reader
-
checker_use_accessor
-
piece_mapper
-
piece_map_use_accessor
-
pieces
-
availability
-
files
-
internal_name
-
download_state
-
started
private boolean started -
state
private int state -
error_message
-
error_type
private int error_type
-
-
Constructor Details
-
LWSDiskManager
-
-
Method Details
-
getName
-
getDisplayName
- Specified by:
getDisplayNamein interfaceDiskManagerHelper
-
getDownload
- Specified by:
getDownloadin interfaceDiskManager- Returns:
- MAY BE NULL
-
getCacheMode
public int getCacheMode()- Specified by:
getCacheModein interfaceDiskManager
-
getReadStats
public long[] getReadStats()- Specified by:
getReadStatsin interfaceDiskManager
-
getWriteStats
public long[] getWriteStats()- Specified by:
getWriteStatsin interfaceDiskManager
-
start
public void start()Description copied from interface:DiskManagerStart checking/allocating- Specified by:
startin interfaceDiskManager
-
getFileInfo
-
setPieceDone
- Specified by:
setPieceDonein interfaceDiskManagerHelper
-
stop
public boolean stop(boolean closing) Description copied from interface:DiskManagerStop can go async if the download is in a 'starting' state - if so this method returns true- Specified by:
stopin interfaceDiskManager- Parameters:
closing-- Returns:
-
isStopped
public boolean isStopped()- Specified by:
isStoppedin interfaceDiskManager
-
filesExist
public boolean filesExist()- Specified by:
filesExistin interfaceDiskManager- Returns:
- whether all files exist and sizes match
-
rateLimitChanged
public void rateLimitChanged()- Specified by:
rateLimitChangedin interfaceDiskManager
-
createWriteRequest
public DiskManagerWriteRequest createWriteRequest(int pieceNumber, int offset, DirectByteBuffer data, Object user_data) - Specified by:
createWriteRequestin interfaceDiskManager
-
enqueueWriteRequest
public void enqueueWriteRequest(DiskManagerWriteRequest request, DiskManagerWriteRequestListener listener) Description copied from interface:DiskManagerenqueue an async write request- Specified by:
enqueueWriteRequestin interfaceDiskManager- Parameters:
listener-
-
hasOutstandingWriteRequestForPiece
public boolean hasOutstandingWriteRequestForPiece(int piece_number) - Specified by:
hasOutstandingWriteRequestForPiecein interfaceDiskManager
-
hasOutstandingReadRequestForPiece
public boolean hasOutstandingReadRequestForPiece(int piece_number) - Specified by:
hasOutstandingReadRequestForPiecein interfaceDiskManager
-
hasOutstandingCheckRequestForPiece
public boolean hasOutstandingCheckRequestForPiece(int piece_number) - Specified by:
hasOutstandingCheckRequestForPiecein interfaceDiskManager
-
readBlock
- Specified by:
readBlockin interfaceDiskManager
-
createReadRequest
- Specified by:
createReadRequestin interfaceDiskManager
-
enqueueReadRequest
public void enqueueReadRequest(DiskManagerReadRequest request, DiskManagerReadRequestListener listener) Description copied from interface:DiskManagerEnqueue an async disk read request.- Specified by:
enqueueReadRequestin interfaceDiskManager- Parameters:
request-listener-
-
createCheckRequest
Description copied from interface:DiskManagerCreate a request to check a particular piece- Specified by:
createCheckRequestin interfaceDiskManager- Parameters:
pieceNumber- -1 for a complete recheck requestuser_data-- Returns:
-
enqueueCheckRequest
public void enqueueCheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener) Description copied from interface:DiskManagerenqueue an asynchronous single piece check- Specified by:
enqueueCheckRequestin interfaceDiskManager- Parameters:
listener-
-
enqueueCompleteRecheckRequest
public void enqueueCompleteRecheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener) Description copied from interface:DiskManagerrecheck the entire torrent asynchronously, reporting each piece to the listener- Specified by:
enqueueCompleteRecheckRequestin interfaceDiskManager- Parameters:
listener-
-
setPieceCheckingEnabled
public void setPieceCheckingEnabled(boolean enabled) - Specified by:
setPieceCheckingEnabledin interfaceDiskManager
-
saveResumeData
public void saveResumeData(boolean interim_save) - Specified by:
saveResumeDatain interfaceDiskManager
-
getPieces
- Specified by:
getPiecesin interfaceDiskManager
-
getAvailability
- Specified by:
getAvailabilityin interfaceDiskManager
-
getPiece
- Specified by:
getPiecein interfaceDiskManager
-
isInteresting
public boolean isInteresting(int piece_num) - Specified by:
isInterestingin interfaceDiskManager- Parameters:
piece_num-- Returns:
- true if the pieceNumber is Needed and not Done
-
isDone
public boolean isDone(int piece_num) - Specified by:
isDonein interfaceDiskManager
-
getNbPieces
public int getNbPieces()- Specified by:
getNbPiecesin interfaceDiskManager
-
getFiles
- Specified by:
getFilesin interfaceDiskManager
-
getFileSet
- Specified by:
getFileSetin interfaceDiskManager
-
getState
public int getState()- Specified by:
getStatein interfaceDiskManager
-
getTotalLength
public long getTotalLength()- Specified by:
getTotalLengthin interfaceDiskManager
-
getPieceLength
public int getPieceLength()- Specified by:
getPieceLengthin interfaceDiskManager
-
getPieceLength
public int getPieceLength(int piece_number) - Specified by:
getPieceLengthin interfaceDiskManager
-
getLastPieceLength
public int getLastPieceLength() -
getRemaining
public long getRemaining()Description copied from interface:DiskManagerGet remaining bytes to completion *including* DND files- Specified by:
getRemainingin interfaceDiskManager
-
getRemainingExcludingDND
public long getRemainingExcludingDND()- Specified by:
getRemainingExcludingDNDin interfaceDiskManager
-
getPercentDone
public int getPercentDone()Description copied from interface:DiskManagerGet the percentage done during checking, allocation or initializing- Specified by:
getPercentDonein interfaceDiskManager- Returns:
- percent done * 1000 (1000 = 100%)
-
getPercentAllocated
public int getPercentAllocated()- Specified by:
getPercentAllocatedin interfaceDiskManager
-
getPercentDoneExcludingDND
public int getPercentDoneExcludingDND()- Specified by:
getPercentDoneExcludingDNDin interfaceDiskManager
-
getSizeExcludingDND
public long getSizeExcludingDND()- Specified by:
getSizeExcludingDNDin interfaceDiskManager
-
getErrorMessage
- Specified by:
getErrorMessagein interfaceDiskManager
-
getErrorType
public int getErrorType()- Specified by:
getErrorTypein interfaceDiskManager
-
downloadEnded
- Specified by:
downloadEndedin interfaceDiskManager
-
moveDataFiles
- Specified by:
moveDataFilesin interfaceDiskManager
-
getCompleteRecheckStatus
public int getCompleteRecheckStatus()Description copied from interface:DiskManagerreturns -1 if no recheck in progress, percentage complete in 1000 notation otherwise- Specified by:
getCompleteRecheckStatusin interfaceDiskManager- Returns:
-
getRecheckCancelled
public boolean getRecheckCancelled()- Specified by:
getRecheckCancelledin interfaceDiskManager
-
getMoveProgress
public long[] getMoveProgress()Description copied from interface:DiskManagerWhen 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:
getMoveProgressin interfaceDiskManager- Returns:
-
getMoveSubTask
- Specified by:
getMoveSubTaskin interfaceDiskManager
-
setMoveState
public void setMoveState(int state) - Specified by:
setMoveStatein interfaceDiskManager
-
checkBlockConsistencyForWrite
public boolean checkBlockConsistencyForWrite(String originator, int pieceNumber, int offset, DirectByteBuffer data) Description copied from interface:DiskManagermethod for checking that the block details are sensible- Specified by:
checkBlockConsistencyForWritein interfaceDiskManager- Parameters:
pieceNumber-offset-data-- Returns:
-
checkBlockConsistencyForRead
public boolean checkBlockConsistencyForRead(String originator, boolean peer_request, int pieceNumber, int offset, int length) Description copied from interface:DiskManagermethod for checking that the block details are sensible- Specified by:
checkBlockConsistencyForReadin interfaceDiskManager- Parameters:
pieceNumber-offset-length-- Returns:
-
checkBlockConsistencyForHint
public boolean checkBlockConsistencyForHint(String originator, int pieceNumber, int offset, int length) - Specified by:
checkBlockConsistencyForHintin interfaceDiskManager
-
addListener
- Specified by:
addListenerin interfaceDiskManager
-
removeListener
- Specified by:
removeListenerin interfaceDiskManager
-
hasListener
- Specified by:
hasListenerin interfaceDiskManager
-
saveState
public void saveState(boolean interim) Description copied from interface:DiskManagerSave the individual file priorities map to DownloadManager.getData( "file_priorities" ).- Specified by:
saveStatein interfaceDiskManager
-
getDiskAccessController
- Specified by:
getDiskAccessControllerin interfaceDiskManagerHelper
-
getPieceMap
Description copied from interface:DiskManagerDON'T CACHE the DMPieceMap - as it is designed to be discarded when not in use- Specified by:
getPieceMapin interfaceDiskManager- Returns:
-
getPieceList
- Specified by:
getPieceListin interfaceDiskManager- Specified by:
getPieceListin interfaceDiskManagerHelper
-
getChecker
-
getPieceHash
- Specified by:
getPieceHashin interfaceDiskManagerHelper- Throws:
TOTorrentException
-
getRecheckScheduler
- Specified by:
getRecheckSchedulerin interfaceDiskManagerHelper
-
downloadRemoved
public void downloadRemoved()- Specified by:
downloadRemovedin interfaceDiskManager
-
setFailed
Description copied from interface:DiskManagerHelperStops the disk manager and informs the download manager that things have gone wrong.- Specified by:
setFailedin interfaceDiskManagerHelper- Parameters:
reason-
-
setFailedAndRecheck
- Specified by:
setFailedAndRecheckin interfaceDiskManagerHelper
-
isUploadOnly
public boolean isUploadOnly()- Specified by:
isUploadOnlyin interfaceDiskManagerHelper
-
getTorrent
- Specified by:
getTorrentin interfaceDiskManager- Specified by:
getTorrentin interfaceDiskManagerHelper
-
getStorageTypes
Description copied from interface:DiskManagerHelperReturns 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:
getStorageTypesin interfaceDiskManagerHelper
-
getStorageType
Description copied from interface:DiskManagerHelperReturns 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:
getStorageTypein interfaceDiskManagerHelper
-
skippedFileSetChanged
- Specified by:
skippedFileSetChangedin interfaceDiskManagerHelper
-
priorityChanged
- Specified by:
priorityChangedin interfaceDiskManagerHelper
-
storageTypeChanged
- Specified by:
storageTypeChangedin interfaceDiskManagerHelper
-
getSaveLocation
- Specified by:
getSaveLocationin interfaceDiskManager
-
getInternalName
- Specified by:
getInternalNamein interfaceDiskManagerHelper
-
getDownloadState
- Specified by:
getDownloadStatein interfaceDiskManagerHelper
-
getPriorityChangeMarker
public long getPriorityChangeMarker()- Specified by:
getPriorityChangeMarkerin interfaceDiskManager
-
generateEvidence
- Specified by:
generateEvidencein interfaceDiskManager
-