Package com.biglybt.core.disk
Interface DiskManager
-
- All Known Subinterfaces:
DiskManagerHelper
- All Known Implementing Classes:
DiskManagerImpl
,LWSDiskManager
public interface DiskManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DiskManager.DownloadEndedProgress
-
Field Summary
Fields Modifier and Type Field Description static int
ALLOCATING
static int
BLOCK_SIZE
static int
BLOCK_SIZE_KB
static int
CHECKING
static int
ET_FILE_MISSING
static int
ET_INSUFFICIENT_SPACE
static int
ET_NONE
static int
ET_OTHER
static int
ET_READ_ERROR
static int
ET_STOP_DURING_INIT
static int
ET_WRITE_ERROR
static int
FAULTY
static int
INITIALIZING
static int
READY
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addListener(DiskManagerListener l)
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 sensibleDiskManagerCheckRequest
createCheckRequest(int pieceNumber, java.lang.Object user_data)
Create a request to check a particular pieceDiskManagerReadRequest
createReadRequest(int pieceNumber, int offset, int length)
DiskManagerWriteRequest
createWriteRequest(int pieceNumber, int offset, DirectByteBuffer data, java.lang.Object user_data)
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 requestboolean
filesExist()
void
generateEvidence(IndentWriter writer)
default java.lang.String
getAllocationTask()
BitFlags
getAvailability()
int
getCacheMode()
int
getCompleteRecheckStatus()
returns -1 if no recheck in progress, percentage complete in 1000 notation otherwiseDownloadManager
getDownload()
java.lang.String
getErrorMessage()
int
getErrorType()
DiskManagerFileInfo[]
getFiles()
DiskManagerFileInfoSet
getFileSet()
default 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)
int
getPieceLength()
int
getPieceLength(int piece_number)
DMPieceList
getPieceList(int pieceNumber)
DMPieceMap
getPieceMap()
DON'T CACHE the DMPieceMap - as it is designed to be discarded when not in useDiskManagerPiece[]
getPieces()
long
getPriorityChangeMarker()
long[]
getReadStats()
long
getRemaining()
Get remaining bytes to completion *including* DND fileslong
getRemainingExcludingDND()
java.io.File
getSaveLocation()
long
getSizeExcludingDND()
int
getState()
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)
boolean
isInteresting(int pieceNumber)
boolean
isStopped()
void
moveDataFiles(java.io.File new_parent_dir, java.lang.String dl_name)
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" ).void
setMoveState(int state)
void
setPieceCheckingEnabled(boolean enabled)
void
start()
Start checking/allocatingboolean
stop(boolean closing)
Stop can go async if the download is in a 'starting' state - if so this method returns true
-
-
-
Field Detail
-
INITIALIZING
static final int INITIALIZING
- See Also:
- Constant Field Values
-
ALLOCATING
static final int ALLOCATING
- See Also:
- Constant Field Values
-
CHECKING
static final int CHECKING
- See Also:
- Constant Field Values
-
READY
static final int READY
- See Also:
- Constant Field Values
-
FAULTY
static final int FAULTY
- See Also:
- Constant Field Values
-
ET_NONE
static final int ET_NONE
- See Also:
- Constant Field Values
-
ET_OTHER
static final int ET_OTHER
- See Also:
- Constant Field Values
-
ET_INSUFFICIENT_SPACE
static final int ET_INSUFFICIENT_SPACE
- See Also:
- Constant Field Values
-
ET_STOP_DURING_INIT
static final int ET_STOP_DURING_INIT
- See Also:
- Constant Field Values
-
ET_FILE_MISSING
static final int ET_FILE_MISSING
- See Also:
- Constant Field Values
-
ET_READ_ERROR
static final int ET_READ_ERROR
- See Also:
- Constant Field Values
-
ET_WRITE_ERROR
static final int ET_WRITE_ERROR
- See Also:
- Constant Field Values
-
BLOCK_SIZE_KB
static final int BLOCK_SIZE_KB
- See Also:
- Constant Field Values
-
BLOCK_SIZE
static final int BLOCK_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
DirectByteBuffer readBlock(int pieceNumber, int offset, int length)
-
createWriteRequest
DiskManagerWriteRequest createWriteRequest(int pieceNumber, int offset, DirectByteBuffer data, java.lang.Object user_data)
-
enqueueWriteRequest
void enqueueWriteRequest(DiskManagerWriteRequest request, DiskManagerWriteRequestListener listener)
enqueue an async write request- Parameters:
pieceNumber
-offset
-data
-user_data
- this will be provided to the listener when called backlistener
-
-
hasOutstandingWriteRequestForPiece
boolean hasOutstandingWriteRequestForPiece(int piece_number)
-
createReadRequest
DiskManagerReadRequest createReadRequest(int pieceNumber, int offset, int length)
-
enqueueReadRequest
void enqueueReadRequest(DiskManagerReadRequest request, DiskManagerReadRequestListener listener)
Enqueue an async disk read request.- Parameters:
request
-listener
-
-
hasOutstandingReadRequestForPiece
boolean hasOutstandingReadRequestForPiece(int piece_number)
-
createCheckRequest
DiskManagerCheckRequest createCheckRequest(int pieceNumber, java.lang.Object user_data)
Create a request to check a particular piece- Parameters:
pieceNumber
- -1 for a complete recheck requestuser_data
-- Returns:
-
enqueueCheckRequest
void enqueueCheckRequest(DiskManagerCheckRequest request, DiskManagerCheckRequestListener listener)
enqueue an asynchronous single piece check- Parameters:
pieceNumber
-listener
-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
void saveResumeData(boolean interim_save) throws java.lang.Exception
- Throws:
java.lang.Exception
-
getPieces
DiskManagerPiece[] getPieces()
-
getNbPieces
int getNbPieces()
-
getAvailability
BitFlags getAvailability()
-
getFiles
DiskManagerFileInfo[] getFiles()
-
getFileSet
DiskManagerFileInfoSet getFileSet()
-
getPiece
DiskManagerPiece getPiece(int PieceNumber)
-
getPieceMap
DMPieceMap getPieceMap()
DON'T CACHE the DMPieceMap - as it is designed to be discarded when not in use- Returns:
-
getPieceList
DMPieceList getPieceList(int pieceNumber)
-
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
default java.lang.String getAllocationTask()
-
getErrorMessage
java.lang.String getErrorMessage()
-
getErrorType
int getErrorType()
-
downloadEnded
DiskManager.DownloadEndedProgress downloadEnded()
-
downloadRemoved
void downloadRemoved()
-
moveDataFiles
void moveDataFiles(java.io.File new_parent_dir, java.lang.String dl_name)
-
getCompleteRecheckStatus
int getCompleteRecheckStatus()
returns -1 if no recheck in progress, percentage complete in 1000 notation otherwise- Returns:
-
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
java.lang.String getMoveSubTask()
-
setMoveState
void setMoveState(int state)
-
checkBlockConsistencyForWrite
boolean checkBlockConsistencyForWrite(java.lang.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(java.lang.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
boolean checkBlockConsistencyForHint(java.lang.String originator, int pieceNumber, int offset, int length)
-
getTorrent
TOTorrent getTorrent()
-
getSaveLocation
java.io.File getSaveLocation()
-
addListener
void addListener(DiskManagerListener l)
-
removeListener
void removeListener(DiskManagerListener l)
-
hasListener
boolean hasListener(DiskManagerListener l)
-
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
void generateEvidence(IndentWriter writer)
-
getSizeExcludingDND
long getSizeExcludingDND()
-
getPercentDoneExcludingDND
int getPercentDoneExcludingDND()
-
getPriorityChangeMarker
long getPriorityChangeMarker()
-
-