com.aelitis.azureus.core.diskmanager.cache.impl
Class CacheFileWithCache

java.lang.Object
  extended by com.aelitis.azureus.core.diskmanager.cache.impl.CacheFileWithCache
All Implemented Interfaces:
CacheFile

public class CacheFileWithCache
extends Object
implements CacheFile


Field Summary
protected  int access_mode
           
protected  TreeSet cache
           
protected static Comparator 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
           
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
           
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.aelitis.azureus.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
protected CacheFileWithCache(CacheFileManagerImpl _manager, FMFile _file, TOTorrentFile _torrent_file)
           
 
Method Summary
protected  void checkPendingException()
           
 void clearCache()
          flushes the cache and discards entries
 void close()
           
 long compareLength(long compare_to)
           
 void delete()
           
 boolean exists()
           
 void flushCache()
          flushes the cache to disk but retains entries
protected  void flushCache(long file_start_position, boolean release_entries, long minumum_to_release)
           
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[] toModify, long[] absoluteOffsets, long[] lengths)
           
protected  FMFile getFMFile()
           
 long getLength()
           
protected  String getName()
           
 long getSessionBytesRead()
           
 long getSessionBytesWritten()
           
 int getStorageType()
           
 TOTorrentFile getTorrentFile()
           
 boolean isOpen()
           
 void moveFile(File new_file)
           
protected  void multiBlockFlush(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(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)
           
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comparator

protected static final Comparator 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 TreeSet 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
Constructor Detail

CacheFileWithCache

protected CacheFileWithCache(CacheFileManagerImpl _manager,
                             FMFile _file,
                             TOTorrentFile _torrent_file)
Method Detail

getTorrentFile

public TOTorrentFile getTorrentFile()
Specified by:
getTorrentFile in interface CacheFile

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 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[] toModify,
                               long[] absoluteOffsets,
                               long[] lengths)

checkPendingException

protected void checkPendingException()
                              throws CacheFileManagerException
Throws:
CacheFileManagerException

setPendingException

protected void setPendingException(CacheFileManagerException e)

getName

protected String getName()

getFMFile

protected FMFile getFMFile()

exists

public boolean exists()
Specified by:
exists in interface CacheFile

moveFile

public void moveFile(File new_file)
              throws CacheFileManagerException
Specified by:
moveFile in interface CacheFile
Throws:
CacheFileManagerException

renameFile

public void renameFile(String new_name)
                throws CacheFileManagerException
Specified by:
renameFile in interface CacheFile
Throws:
CacheFileManagerException

setAccessMode

public void setAccessMode(int mode)
                   throws CacheFileManagerException
Specified by:
setAccessMode in interface CacheFile
Throws:
CacheFileManagerException

getAccessMode

public int getAccessMode()
Specified by:
getAccessMode in interface CacheFile

setStorageType

public void setStorageType(int type)
                    throws CacheFileManagerException
Specified by:
setStorageType in interface CacheFile
Throws:
CacheFileManagerException

getStorageType

public int getStorageType()
Specified by:
getStorageType in interface CacheFile

getLength

public long getLength()
               throws CacheFileManagerException
Specified by:
getLength in interface CacheFile
Throws:
CacheFileManagerException

compareLength

public long compareLength(long compare_to)
                   throws CacheFileManagerException
Specified by:
compareLength in interface CacheFile
Throws:
CacheFileManagerException

setLength

public void setLength(long length)
               throws CacheFileManagerException
Specified by:
setLength in interface CacheFile
Throws:
CacheFileManagerException

setPieceComplete

public void setPieceComplete(int piece_number,
                             DirectByteBuffer piece_data)
                      throws CacheFileManagerException
Specified by:
setPieceComplete in interface CacheFile
Throws:
CacheFileManagerException

read

public void read(DirectByteBuffer[] buffers,
                 long position,
                 short policy)
          throws CacheFileManagerException
Specified by:
read in interface CacheFile
Throws:
CacheFileManagerException

read

public void read(DirectByteBuffer buffer,
                 long position,
                 short policy)
          throws CacheFileManagerException
Specified by:
read in interface CacheFile
Throws:
CacheFileManagerException

write

public void write(DirectByteBuffer buffer,
                  long position)
           throws CacheFileManagerException
Specified by:
write in interface CacheFile
Throws:
CacheFileManagerException

write

public void write(DirectByteBuffer[] buffers,
                  long position)
           throws CacheFileManagerException
Specified by:
write in interface CacheFile
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 interface CacheFile
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 interface CacheFile
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 interface CacheFile
Throws:
CacheFileManagerException

clearCache

public void clearCache()
                throws CacheFileManagerException
Description copied from interface: CacheFile
flushes the cache and discards entries

Specified by:
clearCache in interface CacheFile
Throws:
CacheFileManagerException

close

public void close()
           throws CacheFileManagerException
Specified by:
close in interface CacheFile
Throws:
CacheFileManagerException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface CacheFile

getSessionBytesRead

public long getSessionBytesRead()
Specified by:
getSessionBytesRead in interface CacheFile

getSessionBytesWritten

public long getSessionBytesWritten()
Specified by:
getSessionBytesWritten in interface CacheFile

delete

public void delete()
            throws CacheFileManagerException
Specified by:
delete in interface CacheFile
Throws:
CacheFileManagerException