Interface DiskManager
- All Known Subinterfaces:
DiskManagerHelper
- All Known Implementing Classes:
DiskManagerImpl, LWSDiskManager
public interface DiskManager
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
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) default Stringintintreturns -1 if no recheck in progress, percentage complete in 1000 notation otherwiseintgetFiles()default long[]long[]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 onintintintGet the percentage done during checking, allocation or initializingintgetPiece(int PieceNumber) intintgetPieceLength(int piece_number) getPieceList(int pieceNumber) DON'T CACHE the DMPieceMap - as it is designed to be discarded when not in uselonglong[]booleanlongGet remaining bytes to completion *including* DND fileslonglongintgetState()longlong[]booleanbooleanhasOutstandingCheckRequestForPiece(int piece_number) booleanhasOutstandingReadRequestForPiece(int piece_number) booleanhasOutstandingWriteRequestForPiece(int piece_number) booleanisDone(int pieceNumber) booleanisInteresting(int pieceNumber) booleanvoidmoveDataFiles(File new_parent_dir, String dl_name) voidreadBlock(int pieceNumber, int offset, int length) voidvoidsaveResumeData(boolean interim_save) voidsaveState(boolean interim) Save the individual file priorities map to DownloadManager.getData( "file_priorities" ).voidsetMoveState(int state) voidsetPieceCheckingEnabled(boolean enabled) voidstart()Start checking/allocatingbooleanstop(boolean closing) Stop can go async if the download is in a 'starting' state - if so this method returns true
-
Field Details
-
SNAPSHOT
static final int SNAPSHOT- See Also:
-
INITIALIZING
static final int INITIALIZING- See Also:
-
ALLOCATING
static final int ALLOCATING- See Also:
-
CHECKING
static final int CHECKING- See Also:
-
READY
static final int READY- See Also:
-
FAULTY
static final int FAULTY- See Also:
-
ET_NONE
static final int ET_NONE- See Also:
-
ET_OTHER
static final int ET_OTHER- See Also:
-
ET_INSUFFICIENT_SPACE
static final int ET_INSUFFICIENT_SPACE- See Also:
-
ET_STOP_DURING_INIT
static final int ET_STOP_DURING_INIT- See Also:
-
ET_FILE_MISSING
static final int ET_FILE_MISSING- See Also:
-
ET_READ_ERROR
static final int ET_READ_ERROR- See Also:
-
ET_WRITE_ERROR
static final int ET_WRITE_ERROR- See Also:
-
BLOCK_SIZE_KB
static final int BLOCK_SIZE_KB- See Also:
-
BLOCK_SIZE
static final int BLOCK_SIZE- See Also:
-
-
Method Details
-
getDownload
DownloadManager getDownload()- Returns:
- MAY BE NULL
-
start
void start()Start checking/allocating -
stop
boolean stop(boolean closing) Stop can go async if the download is in a 'starting' state - if so this method returns true- Parameters:
closing-- Returns:
-
isStopped
boolean isStopped() -
filesExist
boolean filesExist()- Returns:
- whether all files exist and sizes match
-
readBlock
-
createWriteRequest
DiskManagerWriteRequest createWriteRequest(int pieceNumber, int offset, DirectByteBuffer data, Object user_data) -
enqueueWriteRequest
enqueue an async write request- Parameters:
listener-pieceNumber-offset-data-user_data- this will be provided to the listener when called back
-
hasOutstandingWriteRequestForPiece
boolean hasOutstandingWriteRequestForPiece(int piece_number) -
createReadRequest
-
enqueueReadRequest
Enqueue an async disk read request.- Parameters:
request-listener-
-
hasOutstandingReadRequestForPiece
boolean hasOutstandingReadRequestForPiece(int piece_number) -
createCheckRequest
Create a request to check a particular piece- Parameters:
pieceNumber- -1 for a complete recheck requestuser_data-- Returns:
-
enqueueCheckRequest
enqueue an asynchronous single piece check- Parameters:
listener-pieceNumber-user_data-
-
hasOutstandingCheckRequestForPiece
boolean hasOutstandingCheckRequestForPiece(int piece_number) -
enqueueCompleteRecheckRequest
void enqueueCompleteRecheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener) recheck the entire torrent asynchronously, reporting each piece to the listener- Parameters:
listener-user_data-
-
setPieceCheckingEnabled
void setPieceCheckingEnabled(boolean enabled) -
saveResumeData
-
getPieces
DiskManagerPiece[] getPieces() -
getNbPieces
int getNbPieces() -
getAvailability
BitFlags getAvailability() -
getFiles
DiskManagerFileInfo[] getFiles() -
getFileSet
DiskManagerFileInfoSet getFileSet() -
getPiece
-
getPieceMap
DMPieceMap getPieceMap()DON'T CACHE the DMPieceMap - as it is designed to be discarded when not in use- Returns:
-
getPieceList
-
getState
int getState() -
getTotalLength
long getTotalLength() -
getPieceLength
int getPieceLength() -
getPieceLength
int getPieceLength(int piece_number) -
getRemaining
long getRemaining()Get remaining bytes to completion *including* DND files -
getRemainingExcludingDND
long getRemainingExcludingDND() -
getPercentDone
int getPercentDone()Get the percentage done during checking, allocation or initializing- Returns:
- percent done * 1000 (1000 = 100%)
-
getPercentAllocated
int getPercentAllocated() -
getLatency
default long[] getLatency() -
getAllocationTask
-
getErrorMessage
String getErrorMessage() -
getErrorType
int getErrorType() -
downloadEnded
-
downloadRemoved
void downloadRemoved() -
moveDataFiles
-
getCompleteRecheckStatus
int getCompleteRecheckStatus()returns -1 if no recheck in progress, percentage complete in 1000 notation otherwise- Returns:
-
getRecheckCancelled
boolean getRecheckCancelled() -
getMoveProgress
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 on- Returns:
-
getMoveSubTask
String getMoveSubTask() -
setMoveState
void setMoveState(int state) -
checkBlockConsistencyForWrite
boolean checkBlockConsistencyForWrite(String originator, int pieceNumber, int offset, DirectByteBuffer data) method for checking that the block details are sensible- Parameters:
pieceNumber-offset-data-- Returns:
-
checkBlockConsistencyForRead
boolean checkBlockConsistencyForRead(String originator, boolean peer_request, int pieceNumber, int offset, int length) method for checking that the block details are sensible- Parameters:
pieceNumber-offset-length-- Returns:
-
checkBlockConsistencyForHint
-
getTorrent
TOTorrent getTorrent() -
getSaveLocation
File getSaveLocation() -
addListener
-
removeListener
-
hasListener
-
saveState
void saveState(boolean interim) Save the individual file priorities map to DownloadManager.getData( "file_priorities" ). -
isInteresting
boolean isInteresting(int pieceNumber) - Parameters:
pieceNumber-- Returns:
- true if the pieceNumber is Needed and not Done
-
isDone
boolean isDone(int pieceNumber) -
getCacheMode
int getCacheMode() -
getReadStats
long[] getReadStats() -
getWriteStats
long[] getWriteStats() -
generateEvidence
-
getSizeExcludingDND
long getSizeExcludingDND() -
getPercentDoneExcludingDND
int getPercentDoneExcludingDND() -
getPriorityChangeMarker
long getPriorityChangeMarker() -
rateLimitChanged
void rateLimitChanged()
-