org.gudy.azureus2.core3.disk.impl.access.impl
Class DiskManagerReadRequestImpl

java.lang.Object
  extended by org.gudy.azureus2.core3.disk.impl.access.impl.DiskManagerRequestImpl
      extended by org.gudy.azureus2.core3.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.

Author:
Olivier

Field Summary
 
Fields inherited from interface org.gudy.azureus2.plugins.peers.PeerReadRequest
NORMAL_REQUEST_SIZE
 
Constructor Summary
DiskManagerReadRequestImpl(int _pieceNumber, int _offset, int _length)
          Parameters correspond to bittorrent parameters
 
Method Summary
 void cancel()
           
 boolean equals(Object o)
          We override the equals method 2 requests are equals if all their bt fields (piece number, offset, length) are equal
 boolean getFlush()
           
 int getLength()
           
protected  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 expired
 boolean 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 operation
 void setLatencyTest()
           
 void setTimeSent(long time)
           
 void setUseCache(boolean cache)
           
 
Methods inherited from class org.gudy.azureus2.core3.disk.impl.access.impl.DiskManagerRequestImpl
requestEnds, requestStarts
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gudy.azureus2.core3.disk.DiskManagerRequest
requestEnds, requestStarts
 

Constructor Detail

DiskManagerReadRequestImpl

public DiskManagerReadRequestImpl(int _pieceNumber,
                                  int _offset,
                                  int _length)
Parameters correspond to bittorrent parameters

Parameters:
pieceNumber -
offset -
length -
Method Detail

getName

protected String getName()
Specified by:
getName in class DiskManagerRequestImpl

isExpired

public boolean isExpired()
Method to determine if a Request has expired

Specified by:
isExpired in interface PeerReadRequest
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 interface PeerReadRequest

getPieceNumber

public int getPieceNumber()
Specified by:
getPieceNumber in interface DiskManagerReadRequest
Specified by:
getPieceNumber in interface PeerReadRequest

getOffset

public int getOffset()
Specified by:
getOffset in interface DiskManagerReadRequest
Specified by:
getOffset in interface PeerReadRequest

getLength

public int getLength()
Specified by:
getLength in interface DiskManagerReadRequest
Specified by:
getLength in interface PeerReadRequest

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 interface DiskManagerReadRequest

getFlush

public boolean getFlush()
Specified by:
getFlush in interface DiskManagerReadRequest

setUseCache

public void setUseCache(boolean cache)
Specified by:
setUseCache in interface DiskManagerReadRequest

getUseCache

public boolean getUseCache()
Specified by:
getUseCache in interface DiskManagerReadRequest

cancel

public void cancel()
Specified by:
cancel in interface PeerReadRequest

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface PeerReadRequest

equals

public boolean equals(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 interface DiskManagerReadRequest
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface DiskManagerReadRequest
Overrides:
hashCode in class Object

getTimeCreated

public long getTimeCreated(long now)
Specified by:
getTimeCreated in interface DiskManagerReadRequest

setTimeSent

public void setTimeSent(long time)
Specified by:
setTimeSent in interface DiskManagerReadRequest

getTimeSent

public long getTimeSent()
Specified by:
getTimeSent in interface DiskManagerReadRequest

setLatencyTest

public void setLatencyTest()
Specified by:
setLatencyTest in interface DiskManagerReadRequest

isLatencyTest

public boolean isLatencyTest()
Specified by:
isLatencyTest in interface DiskManagerReadRequest