Class CacheFileWithCache
- java.lang.Object
-
- com.biglybt.core.diskmanager.cache.impl.CacheFileWithCache
-
-
Field Summary
Fields Modifier and Type Field Description protected int
access_mode
private long
bytes_read
private long
bytes_written
protected java.util.TreeSet<CacheEntry>
cache
protected static java.util.Comparator<CacheEntry>
comparator
protected int
current_read_ahead_size
protected FMFile
file
protected long
file_offset_in_torrent
protected long
last_read_ahead_bytes_made
protected long
last_read_ahead_bytes_used
private static LogIDs
LOGID
protected CacheFileManagerImpl
manager
protected CacheFileManagerException
pending_exception
protected int
piece_offset
protected int
piece_size
protected long
read_ahead_bytes_made
protected long
read_ahead_bytes_used
protected Average
read_ahead_made_average
protected int
read_ahead_stats_wait
protected static int
READ_AHEAD_STATS_WAIT_TICKS
protected Average
read_ahead_used_average
protected long[]
read_history
protected int
read_history_next
protected static int
READAHEAD_HIGH_LIMIT
protected static int
READAHEAD_HISTORY
protected static int
READAHEAD_LOW_LIMIT
private static byte
SS_CACHE
protected AEMonitor
this_mon
protected TOTorrent
torrent
protected TOTorrentFile
torrent_file
protected static boolean
TRACE
protected static boolean
TRACE_CACHE_CONTENTS
-
Fields inherited from interface com.biglybt.core.diskmanager.cache.CacheFile
CF_READ, CF_WRITE, CP_FLUSH, CP_NONE, CP_READ_CACHE, CT_COMPACT, CT_LINEAR, CT_PIECE_REORDER, CT_PIECE_REORDER_COMPACT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CacheFileWithCache(CacheFileManagerImpl _manager, FMFile _file, TOTorrentFile _torrent_file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkPendingException()
void
clearCache()
flushes the cache and discards entriesvoid
close()
long
compareLength(long compare_to)
void
delete()
boolean
exists()
void
flushCache()
flushes the cache to disk but retains entriesprotected void
flushCache(long file_start_position, boolean release_entries, long minumum_to_release)
void
flushCache(long file_position, int length)
protected void
flushCache(long file_position, long length, boolean release_entries, long minimum_to_release, long oldest_dirty_time, long min_chunk_size)
protected void
flushCachePublic(boolean release_entries, long minumum_to_release)
protected void
flushCacheSupport(long file_position, long length, boolean release_entries, long minimum_to_release, long oldest_dirty_time, long min_chunk_size)
protected void
flushOldDirtyData(long oldest_dirty_time)
protected void
flushOldDirtyData(long oldest_dirty_time, long min_chunk_size)
int
getAccessMode()
protected void
getBytesInCache(boolean[] result, long[] absolute_offsets, long[] lengths)
protected FMFile
getFMFile()
long
getLastModified()
long
getLength()
protected java.lang.String
getName()
long
getSessionBytesRead()
long
getSessionBytesWritten()
int
getStorageType()
TOTorrentFile
getTorrentFile()
boolean
isOpen()
void
moveFile(java.io.File new_file, FileUtil.ProgressListener pl)
protected void
multiBlockFlush(java.util.List multi_block_entries, long multi_block_start, long multi_block_next, boolean release_entries)
void
read(DirectByteBuffer[] buffers, long position, short policy)
void
read(DirectByteBuffer buffer, long position, short policy)
protected void
readCache(DirectByteBuffer file_buffer, long file_position, boolean recursive, boolean disable_read_cache)
void
renameFile(java.lang.String new_name)
void
setAccessMode(int mode)
void
setLength(long length)
protected void
setPendingException(CacheFileManagerException e)
void
setPieceComplete(int piece_number, DirectByteBuffer piece_data)
void
setStorageType(int type, boolean force)
protected void
updateStats()
void
write(DirectByteBuffer[] buffers, long position)
void
write(DirectByteBuffer buffer, long position)
void
writeAndHandoverBuffer(DirectByteBuffer buffer, long position)
writes the block to the cache and gives control of the buffer to the cache.void
writeAndHandoverBuffers(DirectByteBuffer[] buffers, long position)
protected void
writeCache(DirectByteBuffer file_buffer, long file_position, boolean buffer_handed_over)
-
-
-
Field Detail
-
SS_CACHE
private static final byte SS_CACHE
- See Also:
- Constant Field Values
-
LOGID
private static final LogIDs LOGID
-
comparator
protected static final java.util.Comparator<CacheEntry> comparator
-
TRACE
protected static boolean TRACE
-
TRACE_CACHE_CONTENTS
protected static final boolean TRACE_CACHE_CONTENTS
- See Also:
- Constant Field Values
-
READAHEAD_LOW_LIMIT
protected static final int READAHEAD_LOW_LIMIT
- See Also:
- Constant Field Values
-
READAHEAD_HIGH_LIMIT
protected static final int READAHEAD_HIGH_LIMIT
- See Also:
- Constant Field Values
-
READAHEAD_HISTORY
protected static final int READAHEAD_HISTORY
- See Also:
- Constant Field Values
-
manager
protected final CacheFileManagerImpl manager
-
file
protected final FMFile file
-
access_mode
protected int access_mode
-
torrent_file
protected TOTorrentFile torrent_file
-
torrent
protected TOTorrent torrent
-
file_offset_in_torrent
protected long file_offset_in_torrent
-
read_history
protected long[] read_history
-
read_history_next
protected int read_history_next
-
cache
protected final java.util.TreeSet<CacheEntry> cache
-
current_read_ahead_size
protected int current_read_ahead_size
-
READ_AHEAD_STATS_WAIT_TICKS
protected static final int READ_AHEAD_STATS_WAIT_TICKS
- See Also:
- Constant Field Values
-
read_ahead_stats_wait
protected int read_ahead_stats_wait
-
read_ahead_made_average
protected final Average read_ahead_made_average
-
read_ahead_used_average
protected final Average read_ahead_used_average
-
read_ahead_bytes_made
protected long read_ahead_bytes_made
-
last_read_ahead_bytes_made
protected long last_read_ahead_bytes_made
-
read_ahead_bytes_used
protected long read_ahead_bytes_used
-
last_read_ahead_bytes_used
protected long last_read_ahead_bytes_used
-
piece_size
protected int piece_size
-
piece_offset
protected int piece_offset
-
this_mon
protected final AEMonitor this_mon
-
pending_exception
protected volatile CacheFileManagerException pending_exception
-
bytes_written
private long bytes_written
-
bytes_read
private long bytes_read
-
-
Constructor Detail
-
CacheFileWithCache
protected CacheFileWithCache(CacheFileManagerImpl _manager, FMFile _file, TOTorrentFile _torrent_file)
-
-
Method Detail
-
getTorrentFile
public TOTorrentFile getTorrentFile()
- Specified by:
getTorrentFile
in interfaceCacheFile
-
updateStats
protected void updateStats()
-
readCache
protected void readCache(DirectByteBuffer file_buffer, long file_position, boolean recursive, boolean disable_read_cache) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
writeCache
protected void writeCache(DirectByteBuffer file_buffer, long file_position, boolean buffer_handed_over) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
flushCache
protected void flushCache(long file_position, long length, boolean release_entries, long minimum_to_release, long oldest_dirty_time, long min_chunk_size) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
flushCacheSupport
protected void flushCacheSupport(long file_position, long length, boolean release_entries, long minimum_to_release, long oldest_dirty_time, long min_chunk_size) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
multiBlockFlush
protected void multiBlockFlush(java.util.List multi_block_entries, long multi_block_start, long multi_block_next, boolean release_entries) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
flushCache
protected void flushCache(long file_start_position, boolean release_entries, long minumum_to_release) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
flushCachePublic
protected void flushCachePublic(boolean release_entries, long minumum_to_release) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
flushOldDirtyData
protected void flushOldDirtyData(long oldest_dirty_time, long min_chunk_size) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
flushOldDirtyData
protected void flushOldDirtyData(long oldest_dirty_time) throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
getBytesInCache
protected void getBytesInCache(boolean[] result, long[] absolute_offsets, long[] lengths)
-
checkPendingException
protected void checkPendingException() throws CacheFileManagerException
- Throws:
CacheFileManagerException
-
setPendingException
protected void setPendingException(CacheFileManagerException e)
-
getName
protected java.lang.String getName()
-
getFMFile
protected FMFile getFMFile()
-
moveFile
public void moveFile(java.io.File new_file, FileUtil.ProgressListener pl) throws CacheFileManagerException
- Specified by:
moveFile
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
renameFile
public void renameFile(java.lang.String new_name) throws CacheFileManagerException
- Specified by:
renameFile
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
setAccessMode
public void setAccessMode(int mode) throws CacheFileManagerException
- Specified by:
setAccessMode
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
getAccessMode
public int getAccessMode()
- Specified by:
getAccessMode
in interfaceCacheFile
-
setStorageType
public void setStorageType(int type, boolean force) throws CacheFileManagerException
- Specified by:
setStorageType
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
getStorageType
public int getStorageType()
- Specified by:
getStorageType
in interfaceCacheFile
-
getLength
public long getLength() throws CacheFileManagerException
- Specified by:
getLength
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
compareLength
public long compareLength(long compare_to) throws CacheFileManagerException
- Specified by:
compareLength
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
setLength
public void setLength(long length) throws CacheFileManagerException
- Specified by:
setLength
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
setPieceComplete
public void setPieceComplete(int piece_number, DirectByteBuffer piece_data) throws CacheFileManagerException
- Specified by:
setPieceComplete
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
read
public void read(DirectByteBuffer[] buffers, long position, short policy) throws CacheFileManagerException
- Specified by:
read
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
read
public void read(DirectByteBuffer buffer, long position, short policy) throws CacheFileManagerException
- Specified by:
read
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
write
public void write(DirectByteBuffer buffer, long position) throws CacheFileManagerException
- Specified by:
write
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
write
public void write(DirectByteBuffer[] buffers, long position) throws CacheFileManagerException
- Specified by:
write
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
writeAndHandoverBuffer
public void writeAndHandoverBuffer(DirectByteBuffer buffer, long position) throws CacheFileManagerException
Description copied from interface:CacheFile
writes the block to the cache and gives control of the buffer to the cache.- Specified by:
writeAndHandoverBuffer
in interfaceCacheFile
- Throws:
CacheFileManagerException
- write failed and buffer *not* taken - i.e. caller must de-allocate
-
writeAndHandoverBuffers
public void writeAndHandoverBuffers(DirectByteBuffer[] buffers, long position) throws CacheFileManagerException
- Specified by:
writeAndHandoverBuffers
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
flushCache
public void flushCache() throws CacheFileManagerException
Description copied from interface:CacheFile
flushes the cache to disk but retains entries- Specified by:
flushCache
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
flushCache
public void flushCache(long file_position, int length) throws CacheFileManagerException
- Specified by:
flushCache
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
clearCache
public void clearCache() throws CacheFileManagerException
Description copied from interface:CacheFile
flushes the cache and discards entries- Specified by:
clearCache
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
close
public void close() throws CacheFileManagerException
- Specified by:
close
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
getSessionBytesRead
public long getSessionBytesRead()
- Specified by:
getSessionBytesRead
in interfaceCacheFile
-
getSessionBytesWritten
public long getSessionBytesWritten()
- Specified by:
getSessionBytesWritten
in interfaceCacheFile
-
getLastModified
public long getLastModified()
- Specified by:
getLastModified
in interfaceCacheFile
-
delete
public void delete() throws CacheFileManagerException
- Specified by:
delete
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
-