com.aelitis.azureus.plugins.extseed.impl
Class ExternalSeedReaderImpl
java.lang.Object
com.aelitis.azureus.plugins.extseed.impl.ExternalSeedReaderImpl
- All Implemented Interfaces:
- ExternalSeedReader, PeerManagerListener2
- Direct Known Subclasses:
- ExternalSeedReaderGetRight, ExternalSeedReaderWebSeed
public abstract class ExternalSeedReaderImpl
- extends Object
- implements ExternalSeedReader, PeerManagerListener2
Method Summary |
void |
addListener(ExternalSeedReaderListener l)
|
void |
addRequests(List<PeerReadRequest> new_requests)
|
void |
calculatePriorityOffsets(PeerManager peer_manager,
int[] base_priorities)
|
void |
cancelAllRequests()
|
void |
cancelRequest(PeerReadRequest request)
|
boolean |
checkActivation(PeerManager peer_manager,
Peer peer)
|
void |
deactivate(String reason)
|
void |
eventOccurred(PeerManagerEvent event)
|
protected boolean |
getBooleanParam(Map map,
String name,
boolean def)
|
List<PeerReadRequest> |
getExpiredRequests()
|
protected int |
getFailureCount()
|
protected int |
getIntParam(Map map,
String name,
int def)
|
String |
getIP()
|
protected long |
getLastFailTime()
|
int |
getMaximumNumberOfRequests()
|
int |
getOutgoingRequestCount()
|
int[] |
getOutgoingRequestedPieceNumbers()
|
int |
getPercentDoneOfCurrentIncomingRequest()
|
int |
getPermittedBytes()
|
protected abstract int |
getPieceGroupSize()
|
int[] |
getPriorityOffsets()
|
protected abstract boolean |
getRequestCanSpanPieces()
|
int |
getRequestCount()
|
List<PeerReadRequest> |
getRequests()
|
String |
getStatus()
|
protected long |
getSystemTime()
|
Torrent |
getTorrent()
|
protected String |
getUserAgent()
|
protected void |
informCancelled(PeerReadRequest request)
|
protected void |
informComplete(PeerReadRequest request,
byte[] buffer)
|
protected void |
informFailed(PeerReadRequest request)
|
boolean |
isActive()
|
boolean |
isPermanentlyUnavailable()
|
boolean |
isTransient()
|
protected void |
log(String str)
|
protected void |
processRequests()
|
protected void |
processRequests(List<PeerReadRequest> requests)
|
byte[] |
read(int piece_number,
int piece_offset,
int length,
int timeout)
|
int |
readBytes(int max)
Rate handling |
protected void |
readData(ExternalSeedReaderRequest request)
|
protected abstract void |
readData(int piece_number,
int piece_offset,
int length,
ExternalSeedHTTPDownloaderListener listener)
|
protected boolean |
readyToActivate(PeerManager peer_manager,
Peer peer,
long time_since_start)
|
protected boolean |
readyToDeactivate(PeerManager peer_manager,
Peer peer)
|
void |
removeListener(ExternalSeedReaderListener l)
|
void |
reportBytesRead(int num)
|
protected int |
selectRequests(List<PeerReadRequest> requests)
|
protected void |
setActive(PeerManager _peer_manager,
boolean _active)
|
protected void |
setActiveSupport(PeerManager _peer_manager,
boolean _active)
|
protected void |
setReconnectDelay(int delay,
boolean reset_failures)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RECONNECT_DEFAULT
public static final int RECONNECT_DEFAULT
- See Also:
- Constant Field Values
INITIAL_DELAY
public static final int INITIAL_DELAY
- See Also:
- Constant Field Values
STALLED_DOWNLOAD_SPEED
public static final int STALLED_DOWNLOAD_SPEED
- See Also:
- Constant Field Values
STALLED_PEER_SPEED
public static final int STALLED_PEER_SPEED
- See Also:
- Constant Field Values
TOP_PIECE_PRIORITY
public static final int TOP_PIECE_PRIORITY
- See Also:
- Constant Field Values
ExternalSeedReaderImpl
protected ExternalSeedReaderImpl(ExternalSeedPlugin _plugin,
Torrent _torrent,
String _host,
Map _params)
getIP
public String getIP()
- Specified by:
getIP
in interface ExternalSeedReader
getTorrent
public Torrent getTorrent()
- Specified by:
getTorrent
in interface ExternalSeedReader
getStatus
public String getStatus()
- Specified by:
getStatus
in interface ExternalSeedReader
isTransient
public boolean isTransient()
- Specified by:
isTransient
in interface ExternalSeedReader
log
protected void log(String str)
getUserAgent
protected String getUserAgent()
getSystemTime
protected long getSystemTime()
getFailureCount
protected int getFailureCount()
getLastFailTime
protected long getLastFailTime()
isPermanentlyUnavailable
public boolean isPermanentlyUnavailable()
- Specified by:
isPermanentlyUnavailable
in interface ExternalSeedReader
setReconnectDelay
protected void setReconnectDelay(int delay,
boolean reset_failures)
eventOccurred
public void eventOccurred(PeerManagerEvent event)
- Specified by:
eventOccurred
in interface PeerManagerListener2
readyToActivate
protected boolean readyToActivate(PeerManager peer_manager,
Peer peer,
long time_since_start)
readyToDeactivate
protected boolean readyToDeactivate(PeerManager peer_manager,
Peer peer)
checkActivation
public boolean checkActivation(PeerManager peer_manager,
Peer peer)
- Specified by:
checkActivation
in interface ExternalSeedReader
deactivate
public void deactivate(String reason)
- Specified by:
deactivate
in interface ExternalSeedReader
setActive
protected void setActive(PeerManager _peer_manager,
boolean _active)
setActiveSupport
protected void setActiveSupport(PeerManager _peer_manager,
boolean _active)
isActive
public boolean isActive()
- Specified by:
isActive
in interface ExternalSeedReader
processRequests
protected void processRequests()
readBytes
public int readBytes(int max)
- Rate handling
- Specified by:
readBytes
in interface ExternalSeedReader
getPermittedBytes
public int getPermittedBytes()
throws ExternalSeedException
- Throws:
ExternalSeedException
reportBytesRead
public void reportBytesRead(int num)
getPercentDoneOfCurrentIncomingRequest
public int getPercentDoneOfCurrentIncomingRequest()
- Specified by:
getPercentDoneOfCurrentIncomingRequest
in interface ExternalSeedReader
getMaximumNumberOfRequests
public int getMaximumNumberOfRequests()
- Specified by:
getMaximumNumberOfRequests
in interface ExternalSeedReader
calculatePriorityOffsets
public void calculatePriorityOffsets(PeerManager peer_manager,
int[] base_priorities)
- Specified by:
calculatePriorityOffsets
in interface ExternalSeedReader
getPieceGroupSize
protected abstract int getPieceGroupSize()
getRequestCanSpanPieces
protected abstract boolean getRequestCanSpanPieces()
getPriorityOffsets
public int[] getPriorityOffsets()
- Specified by:
getPriorityOffsets
in interface ExternalSeedReader
selectRequests
protected int selectRequests(List<PeerReadRequest> requests)
read
public byte[] read(int piece_number,
int piece_offset,
int length,
int timeout)
throws ExternalSeedException
- Specified by:
read
in interface ExternalSeedReader
- Throws:
ExternalSeedException
readData
protected void readData(ExternalSeedReaderRequest request)
throws ExternalSeedException
- Throws:
ExternalSeedException
readData
protected abstract void readData(int piece_number,
int piece_offset,
int length,
ExternalSeedHTTPDownloaderListener listener)
throws ExternalSeedException
- Throws:
ExternalSeedException
processRequests
protected void processRequests(List<PeerReadRequest> requests)
addRequests
public void addRequests(List<PeerReadRequest> new_requests)
- Specified by:
addRequests
in interface ExternalSeedReader
cancelRequest
public void cancelRequest(PeerReadRequest request)
- Specified by:
cancelRequest
in interface ExternalSeedReader
cancelAllRequests
public void cancelAllRequests()
- Specified by:
cancelAllRequests
in interface ExternalSeedReader
getRequestCount
public int getRequestCount()
- Specified by:
getRequestCount
in interface ExternalSeedReader
getExpiredRequests
public List<PeerReadRequest> getExpiredRequests()
- Specified by:
getExpiredRequests
in interface ExternalSeedReader
getRequests
public List<PeerReadRequest> getRequests()
- Specified by:
getRequests
in interface ExternalSeedReader
getOutgoingRequestedPieceNumbers
public int[] getOutgoingRequestedPieceNumbers()
- Specified by:
getOutgoingRequestedPieceNumbers
in interface ExternalSeedReader
getOutgoingRequestCount
public int getOutgoingRequestCount()
- Specified by:
getOutgoingRequestCount
in interface ExternalSeedReader
informComplete
protected void informComplete(PeerReadRequest request,
byte[] buffer)
informCancelled
protected void informCancelled(PeerReadRequest request)
informFailed
protected void informFailed(PeerReadRequest request)
addListener
public void addListener(ExternalSeedReaderListener l)
- Specified by:
addListener
in interface ExternalSeedReader
removeListener
public void removeListener(ExternalSeedReaderListener l)
- Specified by:
removeListener
in interface ExternalSeedReader
getIntParam
protected int getIntParam(Map map,
String name,
int def)
getBooleanParam
protected boolean getBooleanParam(Map map,
String name,
boolean def)