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 java.lang.Object
- implements ExternalSeedReader, PeerManagerListener2
Method Summary |
void |
addListener(ExternalSeedReaderListener l)
|
void |
addRequests(java.util.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(java.lang.String reason)
|
void |
eventOccurred(PeerManagerEvent event)
|
protected boolean |
getBooleanParam(java.util.Map map,
java.lang.String name,
boolean def)
|
java.util.List<PeerReadRequest> |
getExpiredRequests()
|
protected int |
getFailureCount()
|
protected int |
getIntParam(java.util.Map map,
java.lang.String name,
int def)
|
java.lang.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()
|
java.util.List<PeerReadRequest> |
getRequests()
|
java.lang.String |
getStatus()
|
protected long |
getSystemTime()
|
Torrent |
getTorrent()
|
protected java.lang.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(java.lang.String str)
|
protected void |
processRequests()
|
protected void |
processRequests(java.util.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(java.util.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,
java.lang.String _host,
java.util.Map _params)
getIP
public java.lang.String getIP()
- Specified by:
getIP
in interface ExternalSeedReader
getTorrent
public Torrent getTorrent()
- Specified by:
getTorrent
in interface ExternalSeedReader
getStatus
public java.lang.String getStatus()
- Specified by:
getStatus
in interface ExternalSeedReader
isTransient
public boolean isTransient()
- Specified by:
isTransient
in interface ExternalSeedReader
log
protected void log(java.lang.String str)
getUserAgent
protected java.lang.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(java.lang.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(java.util.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(java.util.List<PeerReadRequest> requests)
addRequests
public void addRequests(java.util.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 java.util.List<PeerReadRequest> getExpiredRequests()
- Specified by:
getExpiredRequests
in interface ExternalSeedReader
getRequests
public java.util.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(java.util.Map map,
java.lang.String name,
int def)
getBooleanParam
protected boolean getBooleanParam(java.util.Map map,
java.lang.String name,
boolean def)