Class CacheFileWithCache
java.lang.Object
com.biglybt.core.diskmanager.cache.impl.CacheFileWithCache
- All Implemented Interfaces:
CacheFile
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
private long
private long
protected final TreeSet<CacheEntry>
protected static final Comparator<CacheEntry>
protected int
protected final FMFile
protected long
protected long
protected long
private static final LogIDs
protected final CacheFileManagerImpl
protected CacheFileManagerException
protected int
protected int
protected long
protected long
protected final Average
protected int
protected static final int
protected final Average
protected long[]
protected int
protected static final int
protected static final int
protected static final int
private static final byte
protected final AEMonitor
protected TOTorrent
protected TOTorrentFile
protected static boolean
protected static final boolean
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
ConstructorsModifierConstructorDescriptionprotected
CacheFileWithCache
(CacheFileManagerImpl _manager, FMFile _file, TOTorrentFile _torrent_file) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
flushes the cache and discards entriesvoid
close()
long
compareLength
(long compare_to) void
delete()
boolean
exists()
void
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
protected void
getBytesInCache
(boolean[] result, long[] absolute_offsets, long[] lengths) protected FMFile
long
long
protected String
getName()
long
long
int
boolean
isOpen()
void
moveFile
(File new_file, FileUtil.ProgressListener pl) protected void
multiBlockFlush
(List<CacheEntry> 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
(String new_name) void
setAccessMode
(int mode) void
setLength
(long length) protected void
void
setPieceComplete
(int piece_number, DirectByteBuffer piece_data) void
setStorageType
(int type, boolean force) protected void
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 Details
-
SS_CACHE
private static final byte SS_CACHE- See Also:
-
LOGID
-
comparator
-
TRACE
protected static boolean TRACE -
TRACE_CACHE_CONTENTS
protected static final boolean TRACE_CACHE_CONTENTS- See Also:
-
READAHEAD_LOW_LIMIT
protected static final int READAHEAD_LOW_LIMIT- See Also:
-
READAHEAD_HIGH_LIMIT
protected static final int READAHEAD_HIGH_LIMIT- See Also:
-
READAHEAD_HISTORY
protected static final int READAHEAD_HISTORY- See Also:
-
manager
-
file
-
access_mode
protected int access_mode -
torrent_file
-
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
-
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:
-
read_ahead_stats_wait
protected int read_ahead_stats_wait -
read_ahead_made_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
-
pending_exception
-
bytes_written
private long bytes_written -
bytes_read
private long bytes_read
-
-
Constructor Details
-
CacheFileWithCache
protected CacheFileWithCache(CacheFileManagerImpl _manager, FMFile _file, TOTorrentFile _torrent_file)
-
-
Method Details
-
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(List<CacheEntry> 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
- Throws:
CacheFileManagerException
-
getBytesInCache
protected void getBytesInCache(boolean[] result, long[] absolute_offsets, long[] lengths) -
checkPendingException
- Throws:
CacheFileManagerException
-
setPendingException
-
getName
-
getFMFile
-
exists
public boolean exists() -
moveFile
- Specified by:
moveFile
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
renameFile
- Specified by:
renameFile
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
setAccessMode
- Specified by:
setAccessMode
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
getAccessMode
public int getAccessMode()- Specified by:
getAccessMode
in interfaceCacheFile
-
setStorageType
- Specified by:
setStorageType
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
getStorageType
public int getStorageType()- Specified by:
getStorageType
in interfaceCacheFile
-
getLength
- Specified by:
getLength
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
compareLength
- Specified by:
compareLength
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
setLength
- 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
- Specified by:
write
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
write
- 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
Description copied from interface:CacheFile
flushes the cache to disk but retains entries- Specified by:
flushCache
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
flushCache
- Specified by:
flushCache
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
clearCache
Description copied from interface:CacheFile
flushes the cache and discards entries- Specified by:
clearCache
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
close
- Specified by:
close
in interfaceCacheFile
- Throws:
CacheFileManagerException
-
isOpen
public boolean isOpen() -
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
- Specified by:
delete
in interfaceCacheFile
- Throws:
CacheFileManagerException
-