Class FMFileAccessPieceReorderer
- java.lang.Object
-
- com.biglybt.core.diskmanager.file.impl.FMFileAccessPieceReorderer
-
- All Implemented Interfaces:
FMFileAccess
public class FMFileAccessPieceReorderer extends java.lang.Object implements FMFileAccess
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.biglybt.core.diskmanager.file.impl.FMFileAccess
FMFileAccess.FileAccessor
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
control_dir
private java.lang.String
control_file
private long
current_length
private FMFileAccess
delegate
private static int
DIRT_CLEAN
private static int
DIRT_DIRTY
private static long
DIRT_FLUSH_MILLIS
private static int
DIRT_NEVER_WRITTEN
private int
dirt_state
private long
dirt_time
private int
first_piece_length
private int
first_piece_number
private int
last_piece_length
private static int
MIN_PIECES_REORDERABLE
private int
next_piece_index
private int
num_pieces
private int[]
piece_map
private int[]
piece_reverse_map
private int
piece_size
private int
previous_storage_type
private static byte
SS_FILE
private int
storage_type
private static boolean
TRACE
-
Constructor Summary
Constructors Modifier Constructor Description protected
FMFileAccessPieceReorderer(TOTorrentFile _torrent_file, java.io.File _control_dir, java.lang.String _control_file, int _storage_type, FMFileAccess _delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
aboutToOpen()
private void
configBorked(java.lang.String error)
private static java.util.Map
encodeConfig(int storage_type, long current_length, long next_piece_index, int[] piece_map)
void
flush()
FMFileImpl
getFile()
long
getLength(FMFileAccess.FileAccessor fa)
protected int
getPieceIndex(FMFileAccess.FileAccessor fa, int piece_number, boolean allocate_if_needed)
protected long
getPieceOffset(FMFileAccess.FileAccessor fa, int piece_number, boolean allocate_if_needed)
java.lang.String
getString()
boolean
isPieceCompleteProcessingNeeded(int piece_number)
void
read(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position)
private void
readConfig()
protected void
readWrite(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position, boolean is_read)
protected int
readWritePiece(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, int piece_number, int piece_offset, boolean is_read)
protected static void
recoverConfig(TOTorrentFile torrent_file, java.io.File data_file, java.io.File config_file, int storage_type)
protected void
setDirty()
void
setLength(FMFileAccess.FileAccessor fa, long length)
void
setPieceComplete(FMFileAccess.FileAccessor fa, int piece_number, DirectByteBuffer piece_data)
void
write(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position)
private void
writeConfig()
-
-
-
Field Detail
-
TRACE
private static final boolean TRACE
- See Also:
- Constant Field Values
-
MIN_PIECES_REORDERABLE
private static final int MIN_PIECES_REORDERABLE
- See Also:
- Constant Field Values
-
SS_FILE
private static final byte SS_FILE
- See Also:
- Constant Field Values
-
DIRT_CLEAN
private static final int DIRT_CLEAN
- See Also:
- Constant Field Values
-
DIRT_DIRTY
private static final int DIRT_DIRTY
- See Also:
- Constant Field Values
-
DIRT_NEVER_WRITTEN
private static final int DIRT_NEVER_WRITTEN
- See Also:
- Constant Field Values
-
DIRT_FLUSH_MILLIS
private static final long DIRT_FLUSH_MILLIS
- See Also:
- Constant Field Values
-
delegate
private final FMFileAccess delegate
-
control_dir
private final java.io.File control_dir
-
control_file
private final java.lang.String control_file
-
storage_type
private final int storage_type
-
piece_size
private int piece_size
-
first_piece_length
private int first_piece_length
-
first_piece_number
private int first_piece_number
-
last_piece_length
private int last_piece_length
-
num_pieces
private int num_pieces
-
previous_storage_type
private int previous_storage_type
-
current_length
private long current_length
-
piece_map
private int[] piece_map
-
piece_reverse_map
private int[] piece_reverse_map
-
next_piece_index
private int next_piece_index
-
dirt_state
private int dirt_state
-
dirt_time
private long dirt_time
-
-
Constructor Detail
-
FMFileAccessPieceReorderer
protected FMFileAccessPieceReorderer(TOTorrentFile _torrent_file, java.io.File _control_dir, java.lang.String _control_file, int _storage_type, FMFileAccess _delegate) throws FMFileManagerException
- Throws:
FMFileManagerException
-
-
Method Detail
-
aboutToOpen
public void aboutToOpen() throws FMFileManagerException
- Specified by:
aboutToOpen
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
getLength
public long getLength(FMFileAccess.FileAccessor fa) throws FMFileManagerException
- Specified by:
getLength
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
setLength
public void setLength(FMFileAccess.FileAccessor fa, long length) throws FMFileManagerException
- Specified by:
setLength
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
getPieceOffset
protected long getPieceOffset(FMFileAccess.FileAccessor fa, int piece_number, boolean allocate_if_needed) throws FMFileManagerException
- Throws:
FMFileManagerException
-
readWritePiece
protected int readWritePiece(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, int piece_number, int piece_offset, boolean is_read) throws FMFileManagerException
- Throws:
FMFileManagerException
-
readWrite
protected void readWrite(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position, boolean is_read) throws FMFileManagerException
- Throws:
FMFileManagerException
-
read
public void read(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position) throws FMFileManagerException
- Specified by:
read
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
write
public void write(FMFileAccess.FileAccessor fa, DirectByteBuffer[] buffers, long position) throws FMFileManagerException
- Specified by:
write
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
flush
public void flush() throws FMFileManagerException
- Specified by:
flush
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
isPieceCompleteProcessingNeeded
public boolean isPieceCompleteProcessingNeeded(int piece_number)
- Specified by:
isPieceCompleteProcessingNeeded
in interfaceFMFileAccess
-
setPieceComplete
public void setPieceComplete(FMFileAccess.FileAccessor fa, int piece_number, DirectByteBuffer piece_data) throws FMFileManagerException
- Specified by:
setPieceComplete
in interfaceFMFileAccess
- Throws:
FMFileManagerException
-
getPieceIndex
protected int getPieceIndex(FMFileAccess.FileAccessor fa, int piece_number, boolean allocate_if_needed) throws FMFileManagerException
- Throws:
FMFileManagerException
-
readConfig
private void readConfig() throws FMFileManagerException
- Throws:
FMFileManagerException
-
configBorked
private void configBorked(java.lang.String error) throws FMFileManagerException
- Throws:
FMFileManagerException
-
setDirty
protected void setDirty() throws FMFileManagerException
- Throws:
FMFileManagerException
-
encodeConfig
private static java.util.Map encodeConfig(int storage_type, long current_length, long next_piece_index, int[] piece_map)
-
recoverConfig
protected static void recoverConfig(TOTorrentFile torrent_file, java.io.File data_file, java.io.File config_file, int storage_type) throws FMFileManagerException
- Throws:
FMFileManagerException
-
writeConfig
private void writeConfig() throws FMFileManagerException
- Throws:
FMFileManagerException
-
getFile
public FMFileImpl getFile()
- Specified by:
getFile
in interfaceFMFileAccess
-
getString
public java.lang.String getString()
- Specified by:
getString
in interfaceFMFileAccess
-
-