Class DiskManagerReadRequestImpl
- java.lang.Object
-
- com.biglybt.core.disk.impl.access.impl.DiskManagerRequestImpl
-
- com.biglybt.core.disk.impl.access.impl.DiskManagerReadRequestImpl
-
- All Implemented Interfaces:
DiskManagerReadRequest
,DiskManagerRequest
,PeerReadRequest
public class DiskManagerReadRequestImpl extends DiskManagerRequestImpl implements DiskManagerReadRequest
This class represents a Bittorrent Request. and a time stamp to know when it was created. Request may expire after some time, which is used to determine who is snubbed.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
cancelled
private static int
EXPIRATION_TIME
private boolean
flush
private int
hashcode
private boolean
latency_test
private int
length
private int
offset
private int
pieceNumber
private long
timeCreated
private long
timeSent
private boolean
use_cache
-
Fields inherited from class com.biglybt.core.disk.impl.access.impl.DiskManagerRequestImpl
DEBUG
-
Fields inherited from interface com.biglybt.pif.peers.PeerReadRequest
NORMAL_REQUEST_SIZE
-
-
Constructor Summary
Constructors Constructor Description DiskManagerReadRequestImpl(int _pieceNumber, int _offset, int _length)
Parameters correspond to bittorrent parameters
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
boolean
equals(java.lang.Object o)
We override the equals method 2 requests are equals if all their bt fields (piece number, offset, length) are equalboolean
getFlush()
int
getLength()
protected java.lang.String
getName()
int
getOffset()
int
getPieceNumber()
long
getTimeCreated(long now)
long
getTimeSent()
boolean
getUseCache()
int
hashCode()
boolean
isCancelled()
boolean
isExpired()
Method to determine if a Request has expiredboolean
isLatencyTest()
void
resetTime(long now)
Allow some more time to the request.void
setFlush(boolean _flush)
If flush is set then data held in memory will be flushed to disk during the read operationvoid
setLatencyTest()
void
setTimeSent(long time)
void
setUseCache(boolean cache)
-
Methods inherited from class com.biglybt.core.disk.impl.access.impl.DiskManagerRequestImpl
getErrorIsFatal, requestEnds, requestStarts, setErrorIsFatal
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.biglybt.core.disk.DiskManagerRequest
getErrorIsFatal, requestEnds, requestStarts, setErrorIsFatal
-
-
-
-
Field Detail
-
EXPIRATION_TIME
private static final int EXPIRATION_TIME
- See Also:
- Constant Field Values
-
pieceNumber
private final int pieceNumber
-
offset
private final int offset
-
length
private final int length
-
hashcode
private final int hashcode
-
timeCreated
private long timeCreated
-
timeSent
private long timeSent
-
flush
private boolean flush
-
cancelled
private boolean cancelled
-
use_cache
private boolean use_cache
-
latency_test
private boolean latency_test
-
-
Method Detail
-
getName
protected java.lang.String getName()
- Specified by:
getName
in classDiskManagerRequestImpl
-
isExpired
public boolean isExpired()
Method to determine if a Request has expired- Specified by:
isExpired
in interfacePeerReadRequest
- Returns:
- true if the request is expired
-
resetTime
public void resetTime(long now)
Allow some more time to the request. Typically used on peers that have just sent some data, we reset all other requests to give them extra time.- Specified by:
resetTime
in interfacePeerReadRequest
-
getPieceNumber
public int getPieceNumber()
- Specified by:
getPieceNumber
in interfaceDiskManagerReadRequest
- Specified by:
getPieceNumber
in interfacePeerReadRequest
-
getOffset
public int getOffset()
- Specified by:
getOffset
in interfaceDiskManagerReadRequest
- Specified by:
getOffset
in interfacePeerReadRequest
-
getLength
public int getLength()
- Specified by:
getLength
in interfaceDiskManagerReadRequest
- Specified by:
getLength
in interfacePeerReadRequest
-
setFlush
public void setFlush(boolean _flush)
Description copied from interface:DiskManagerReadRequest
If flush is set then data held in memory will be flushed to disk during the read operation- Specified by:
setFlush
in interfaceDiskManagerReadRequest
-
getFlush
public boolean getFlush()
- Specified by:
getFlush
in interfaceDiskManagerReadRequest
-
setUseCache
public void setUseCache(boolean cache)
- Specified by:
setUseCache
in interfaceDiskManagerReadRequest
-
getUseCache
public boolean getUseCache()
- Specified by:
getUseCache
in interfaceDiskManagerReadRequest
-
cancel
public void cancel()
- Specified by:
cancel
in interfacePeerReadRequest
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacePeerReadRequest
-
equals
public boolean equals(java.lang.Object o)
We override the equals method 2 requests are equals if all their bt fields (piece number, offset, length) are equal- Specified by:
equals
in interfaceDiskManagerReadRequest
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceDiskManagerReadRequest
- Overrides:
hashCode
in classjava.lang.Object
-
getTimeCreated
public long getTimeCreated(long now)
- Specified by:
getTimeCreated
in interfaceDiskManagerReadRequest
-
setTimeSent
public void setTimeSent(long time)
- Specified by:
setTimeSent
in interfaceDiskManagerReadRequest
-
getTimeSent
public long getTimeSent()
- Specified by:
getTimeSent
in interfaceDiskManagerReadRequest
-
setLatencyTest
public void setLatencyTest()
- Specified by:
setLatencyTest
in interfaceDiskManagerReadRequest
-
isLatencyTest
public boolean isLatencyTest()
- Specified by:
isLatencyTest
in interfaceDiskManagerReadRequest
-
-