Package com.biglybt.core.disk.impl
Class DiskManagerFileInfoImpl
- java.lang.Object
-
- com.biglybt.core.disk.impl.DiskManagerFileInfoImpl
-
- All Implemented Interfaces:
DiskManagerFileInfo
,CacheFileOwner
public class DiskManagerFileInfoImpl extends java.lang.Object implements DiskManagerFileInfo, CacheFileOwner
-
-
Field Summary
-
Fields inherited from interface com.biglybt.core.diskmanager.cache.CacheFileOwner
CACHE_MODE_EXPERIMENTAL, CACHE_MODE_NO_CACHE, CACHE_MODE_NORMAL
-
Fields inherited from interface com.biglybt.core.disk.DiskManagerFileInfo
READ, ST_COMPACT, ST_LINEAR, ST_REORDER, ST_REORDER_COMPACT, WRITE
-
-
Constructor Summary
Constructors Constructor Description DiskManagerFileInfoImpl(DiskManagerHelper _disk_manager, java.io.File _root_dir, java.lang.String _relative_file, int _file_index, TOTorrentFile _torrent_file, int _storage_type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(DiskManagerFileInfoListener listener)
void
close()
void
dataChecked(long offset, long size)
void
dataWritten(long offset, long size, java.lang.Object originator)
boolean
exists()
Checks that the linked file exists (always returns true for pad files)void
flushCache()
int
getAccessMode()
CacheFile
getCacheFile()
java.io.File
getCacheFileControlFileDir()
java.lang.String
getCacheFileOwnerName()
TOTorrentFile
getCacheFileTorrentFile()
int
getCacheMode()
DiskManager
getDiskManager()
long
getDownloaded()
DownloadManager
getDownloadManager()
long
getETA()
java.lang.String
getExtension()
java.io.File
getFile(boolean follow_link)
int
getFirstPieceNumber()
int
getIndex()
java.lang.String
getLastError()
long
getLastModified()
int
getLastPieceNumber()
long
getLength()
java.io.File
getLink()
int
getNbPieces()
int
getPriority()
File Download Priorityint
getReadBytesPerSecond()
int
getStorageType()
Returns the storage type for this fileTOTorrentFile
getTorrentFile()
int
getWriteBytesPerSecond()
protected boolean
isLinked()
boolean
isSkipped()
Skipped files don't get downloaded.protected void
load(int _priority, boolean _skipped)
void
moveFile(java.io.File new_root_dir, java.io.File new_absolute_file, boolean link_only, FileUtil.ProgressListener pl)
DirectByteBuffer
read(long offset, int length)
void
recheck()
void
removeListener(DiskManagerFileInfoListener listener)
void
renameFile(java.lang.String new_name)
void
setAccessMode(int mode)
void
setDownloaded(long l)
void
setExtension(java.lang.String string)
boolean
setLink(java.io.File link_destination)
Relink the file to the destination given - this method deals with if the file is part of a simple torrent or not (so it may set the download name to keep it in sync).boolean
setLinkAtomic(java.io.File link_destination)
boolean
setLinkAtomic(java.io.File link_destination, FileUtil.ProgressListener pl)
void
setPriority(int b)
void
setSkipped(boolean skipped)
protected void
setSkippedInternal(boolean _skipped)
boolean
setStorageType(int type, boolean force)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.biglybt.core.disk.DiskManagerFileInfo
setStorageType
-
-
-
-
Field Detail
-
root_dir
private java.io.File root_dir
-
relative_file
private final java.lang.String relative_file
-
file_index
final int file_index
-
cache_file
CacheFile cache_file
-
extension
private java.lang.String extension
-
downloaded
private long downloaded
-
diskManager
final DiskManagerHelper diskManager
-
torrent_file
final TOTorrentFile torrent_file
-
priority
private int priority
-
skipped_internal
protected boolean skipped_internal
-
last_error
private java.lang.String last_error
-
listeners
private volatile CopyOnWriteList<DiskManagerFileInfoListener> listeners
-
read_average_state
volatile AverageFactory.LazyMovingImmediateAverageState read_average_state
-
write_average_state
volatile AverageFactory.LazyMovingImmediateAverageState write_average_state
-
eta_average_state
volatile AverageFactory.LazyMovingImmediateAverageState eta_average_state
-
read_adapter
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> read_adapter
-
write_adapter
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> write_adapter
-
eta_adapter
private static final AverageFactory.LazyMovingImmediateAverageAdapter<DiskManagerFileInfoImpl> eta_adapter
-
-
Constructor Detail
-
DiskManagerFileInfoImpl
public DiskManagerFileInfoImpl(DiskManagerHelper _disk_manager, java.io.File _root_dir, java.lang.String _relative_file, int _file_index, TOTorrentFile _torrent_file, int _storage_type) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
-
Method Detail
-
load
protected void load(int _priority, boolean _skipped)
-
getCacheFileOwnerName
public java.lang.String getCacheFileOwnerName()
- Specified by:
getCacheFileOwnerName
in interfaceCacheFileOwner
-
getCacheFileTorrentFile
public TOTorrentFile getCacheFileTorrentFile()
- Specified by:
getCacheFileTorrentFile
in interfaceCacheFileOwner
-
getCacheFileControlFileDir
public java.io.File getCacheFileControlFileDir()
- Specified by:
getCacheFileControlFileDir
in interfaceCacheFileOwner
-
getCacheMode
public int getCacheMode()
- Specified by:
getCacheMode
in interfaceCacheFileOwner
-
flushCache
public void flushCache() throws java.lang.Exception
- Specified by:
flushCache
in interfaceDiskManagerFileInfo
- Throws:
java.lang.Exception
-
exists
public boolean exists()
Description copied from interface:DiskManagerFileInfo
Checks that the linked file exists (always returns true for pad files)- Specified by:
exists
in interfaceDiskManagerFileInfo
- Returns:
-
moveFile
public void moveFile(java.io.File new_root_dir, java.io.File new_absolute_file, boolean link_only, FileUtil.ProgressListener pl) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
renameFile
public void renameFile(java.lang.String new_name) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
getCacheFile
public CacheFile getCacheFile()
-
setAccessMode
public void setAccessMode(int mode) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
getAccessMode
public int getAccessMode()
- Specified by:
getAccessMode
in interfaceDiskManagerFileInfo
-
getDownloaded
public long getDownloaded()
- Specified by:
getDownloaded
in interfaceDiskManagerFileInfo
- Returns:
-
getLastModified
public long getLastModified()
- Specified by:
getLastModified
in interfaceDiskManagerFileInfo
-
getExtension
public java.lang.String getExtension()
- Specified by:
getExtension
in interfaceDiskManagerFileInfo
- Returns:
-
getFile
public java.io.File getFile(boolean follow_link)
- Specified by:
getFile
in interfaceDiskManagerFileInfo
- Returns:
-
getTorrentFile
public TOTorrentFile getTorrentFile()
- Specified by:
getTorrentFile
in interfaceDiskManagerFileInfo
-
setLink
public boolean setLink(java.io.File link_destination)
Description copied from interface:DiskManagerFileInfo
Relink the file to the destination given - this method deals with if the file is part of a simple torrent or not (so it may set the download name to keep it in sync). If you just want a simple relink, use setLinkAtomic.- Specified by:
setLink
in interfaceDiskManagerFileInfo
- Returns:
- true - worked, false - failed, use getLastError to possibly get some extra info
-
getLastError
public java.lang.String getLastError()
- Specified by:
getLastError
in interfaceDiskManagerFileInfo
-
setLinkAtomic
public boolean setLinkAtomic(java.io.File link_destination)
- Specified by:
setLinkAtomic
in interfaceDiskManagerFileInfo
-
setLinkAtomic
public boolean setLinkAtomic(java.io.File link_destination, FileUtil.ProgressListener pl)
- Specified by:
setLinkAtomic
in interfaceDiskManagerFileInfo
-
getLink
public java.io.File getLink()
- Specified by:
getLink
in interfaceDiskManagerFileInfo
-
setStorageType
public boolean setStorageType(int type, boolean force)
- Specified by:
setStorageType
in interfaceDiskManagerFileInfo
force
- discards any existing file content if it exists - use with care...- Returns:
-
getStorageType
public int getStorageType()
Description copied from interface:DiskManagerFileInfo
Returns the storage type for this file- Specified by:
getStorageType
in interfaceDiskManagerFileInfo
- Returns:
DiskManagerFileInfo.ST_LINEAR
,DiskManagerFileInfo.ST_COMPACT
,DiskManagerFileInfo.ST_REORDER
,DiskManagerFileInfo.ST_REORDER_COMPACT
-
isLinked
protected boolean isLinked()
-
getFirstPieceNumber
public int getFirstPieceNumber()
- Specified by:
getFirstPieceNumber
in interfaceDiskManagerFileInfo
- Returns:
-
getLastPieceNumber
public int getLastPieceNumber()
- Specified by:
getLastPieceNumber
in interfaceDiskManagerFileInfo
-
getLength
public long getLength()
- Specified by:
getLength
in interfaceDiskManagerFileInfo
- Returns:
-
getIndex
public int getIndex()
- Specified by:
getIndex
in interfaceDiskManagerFileInfo
-
getNbPieces
public int getNbPieces()
- Specified by:
getNbPieces
in interfaceDiskManagerFileInfo
- Returns:
-
setDownloaded
public void setDownloaded(long l)
- Parameters:
l
-
-
setExtension
public void setExtension(java.lang.String string)
- Parameters:
string
-
-
getPriority
public int getPriority()
Description copied from interface:DiskManagerFileInfo
File Download Priority- Specified by:
getPriority
in interfaceDiskManagerFileInfo
- Returns:
-
setPriority
public void setPriority(int b)
- Specified by:
setPriority
in interfaceDiskManagerFileInfo
- Parameters:
b
-
-
isSkipped
public boolean isSkipped()
Description copied from interface:DiskManagerFileInfo
Skipped files don't get downloaded. The state of the existing data is dependent uponDiskManagerFileInfo.getStorageType()
. StatesDiskManagerFileInfo.ST_COMPACT
andDiskManagerFileInfo.ST_REORDER_COMPACT
will delete (or trim) the file. Other states will retain existing data (ie. Do Not Download).- Specified by:
isSkipped
in interfaceDiskManagerFileInfo
- Returns:
-
setSkipped
public void setSkipped(boolean skipped)
- Specified by:
setSkipped
in interfaceDiskManagerFileInfo
- Parameters:
skipped
-
-
setSkippedInternal
protected void setSkippedInternal(boolean _skipped)
-
getDiskManager
public DiskManager getDiskManager()
- Specified by:
getDiskManager
in interfaceDiskManagerFileInfo
-
getDownloadManager
public DownloadManager getDownloadManager()
- Specified by:
getDownloadManager
in interfaceDiskManagerFileInfo
-
dataWritten
public void dataWritten(long offset, long size, java.lang.Object originator)
-
dataChecked
public void dataChecked(long offset, long size)
-
read
public DirectByteBuffer read(long offset, int length) throws java.io.IOException
- Specified by:
read
in interfaceDiskManagerFileInfo
- Throws:
java.io.IOException
-
getReadBytesPerSecond
public int getReadBytesPerSecond()
- Specified by:
getReadBytesPerSecond
in interfaceDiskManagerFileInfo
-
getWriteBytesPerSecond
public int getWriteBytesPerSecond()
- Specified by:
getWriteBytesPerSecond
in interfaceDiskManagerFileInfo
-
getETA
public long getETA()
- Specified by:
getETA
in interfaceDiskManagerFileInfo
-
recheck
public void recheck()
- Specified by:
recheck
in interfaceDiskManagerFileInfo
-
close
public void close()
- Specified by:
close
in interfaceDiskManagerFileInfo
-
addListener
public void addListener(DiskManagerFileInfoListener listener)
- Specified by:
addListener
in interfaceDiskManagerFileInfo
-
removeListener
public void removeListener(DiskManagerFileInfoListener listener)
- Specified by:
removeListener
in interfaceDiskManagerFileInfo
-
-