org.gudy.azureus2.core3.tracker.client.impl.bt
Class TRTrackerBTAnnouncerImpl

java.lang.Object
  extended by org.gudy.azureus2.core3.tracker.client.impl.bt.TRTrackerBTAnnouncerImpl
All Implemented Interfaces:
TRTrackerAnnouncerHelper, TRTrackerAnnouncer

public class TRTrackerBTAnnouncerImpl
extends java.lang.Object
implements TRTrackerAnnouncerHelper

This class handles communication with the tracker

Author:
Olivier

Field Summary
static LogIDs LOGID
           
protected  AEMonitor this_mon
           
protected  int tracker_state
           
protected static Timer tracker_timer
           
static java.lang.String UDP_REALM
           
 
Fields inherited from interface org.gudy.azureus2.core3.tracker.client.TRTrackerAnnouncer
AZ_TRACKER_VERSION_1, AZ_TRACKER_VERSION_2, AZ_TRACKER_VERSION_3, AZ_TRACKER_VERSION_CURRENT, DEFAULT_PEERS_TO_CACHE, REFRESH_MINIMUM_SECS, TS_COMPLETED, TS_DOWNLOADING, TS_INITIALISED, TS_STOPPED
 
Constructor Summary
TRTrackerBTAnnouncerImpl(TOTorrent _torrent, TOTorrentAnnounceURLSet[] _announce_urls, java.lang.String[] _peer_networks, boolean _manual, TRTrackerAnnouncerImpl.Helper _helper)
           
 
Method Summary
 void addListener(TRTrackerAnnouncerListener l)
           
protected  java.lang.String announceUDP(java.net.URL original_reqUrl, java.io.ByteArrayOutputStream message, boolean is_probe)
           
protected  int calculateNumWant()
           
 void clearIPOverride()
           
 void cloneFrom(TRTrackerBTAnnouncerImpl other)
           
 void complete(boolean already_reported)
           
protected  TRTrackerAnnouncerResponseImpl completeSupport()
           
 java.net.URL constructUrl(java.lang.String evt, java.net.URL _url)
           
protected  TRTrackerAnnouncerResponseImpl decodeTrackerResponse(java.net.URL url, byte[] data)
           
 void destroy()
           
protected  java.lang.String exceptionToString(java.lang.Throwable e)
           
 void generateEvidence(IndentWriter writer)
           
protected  long getAdjustedSecsToWait()
           
 TOTorrentAnnounceURLSet[] getAnnounceSets()
           
 TRTrackerAnnouncer getBestAnnouncer()
           
 TrackerPeerSource getCacheTrackerPeerSource()
           
protected  int getErrorRetryInterval()
          Retrieve the retry interval to use on announce errors.
 long getInterval()
           
 TRTrackerAnnouncerResponse getLastResponse()
           
 int getLastUpdateTime()
          Last Update Time in seconds
protected  long getLongURLParam(java.lang.String url, java.lang.String param)
           
 long getMinInterval()
           
 byte[] getPeerId()
           
 int getStatus()
           
 java.lang.String getStatusString()
           
 int getTimeUntilNextUpdate()
           
 TOTorrent getTorrent()
           
 TrackerPeerSource getTrackerPeerSource(TOTorrentAnnounceURLSet set)
          Gets a delegate tracker peer source for reporting against
 java.util.Map getTrackerResponseCache()
          returns a Map containing "bencoded" entries representing a cache of tracker responses.
 java.net.URL getTrackerURL()
           
protected  java.lang.String getURLParam(java.lang.String url, java.lang.String param)
           
protected  void informURLChange(java.net.URL old_url, java.net.URL new_url, boolean explicit)
           
protected  void informURLRefresh()
           
 boolean isManual()
           
 boolean isUpdating()
           
 void refreshListeners()
          This method forces all listeners to get an explicit "urlChanged" event to get them to re-examine the tracker
 void removeFromTrackerResponseCache(java.lang.String ip, int tcpPort)
          remove a specific entry from the cache if present
 void removeListener(TRTrackerAnnouncerListener l)
           
protected  void requestUpdate()
           
protected  long requestUpdateSupport()
           
 void resetTrackerUrl(boolean shuffle)
           
 void setAnnounceDataProvider(TRTrackerAnnouncerDataProvider _provider)
           
 void setAnnounceResult(DownloadAnnounceResult result)
           
 void setIPOverride(java.lang.String override)
           
 void setRefreshDelayOverrides(int percentage)
           
 void setTrackerResponseCache(java.util.Map map)
          sets the response cache.
 void setTrackerURL(java.net.URL new_url)
           
protected  TRTrackerAnnouncerResponseImpl startSupport()
           
 void stop(boolean for_queue)
           
protected  TRTrackerAnnouncerResponseImpl stopSupport()
           
protected  java.lang.String trackerURLListToString()
           
 void update(boolean force)
           
protected  TRTrackerAnnouncerResponseImpl updateSupport()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGID

public static final LogIDs LOGID

tracker_timer

protected static final Timer tracker_timer

UDP_REALM

public static final java.lang.String UDP_REALM
See Also:
Constant Field Values

tracker_state

protected int tracker_state

this_mon

protected final AEMonitor this_mon
Constructor Detail

TRTrackerBTAnnouncerImpl

public TRTrackerBTAnnouncerImpl(TOTorrent _torrent,
                                TOTorrentAnnounceURLSet[] _announce_urls,
                                java.lang.String[] _peer_networks,
                                boolean _manual,
                                TRTrackerAnnouncerImpl.Helper _helper)
                         throws TRTrackerAnnouncerException
Throws:
TRTrackerAnnouncerException
Method Detail

cloneFrom

public void cloneFrom(TRTrackerBTAnnouncerImpl other)

getAdjustedSecsToWait

protected long getAdjustedSecsToWait()

getStatus

public int getStatus()
Specified by:
getStatus in interface TRTrackerAnnouncer

getStatusString

public java.lang.String getStatusString()
Specified by:
getStatusString in interface TRTrackerAnnouncer

getBestAnnouncer

public TRTrackerAnnouncer getBestAnnouncer()
Specified by:
getBestAnnouncer in interface TRTrackerAnnouncer

setRefreshDelayOverrides

public void setRefreshDelayOverrides(int percentage)
Specified by:
setRefreshDelayOverrides in interface TRTrackerAnnouncer

isUpdating

public boolean isUpdating()
Specified by:
isUpdating in interface TRTrackerAnnouncerHelper

getInterval

public long getInterval()
Specified by:
getInterval in interface TRTrackerAnnouncerHelper

getMinInterval

public long getMinInterval()
Specified by:
getMinInterval in interface TRTrackerAnnouncerHelper

getTimeUntilNextUpdate

public int getTimeUntilNextUpdate()
Specified by:
getTimeUntilNextUpdate in interface TRTrackerAnnouncerHelper
Specified by:
getTimeUntilNextUpdate in interface TRTrackerAnnouncer

getLastUpdateTime

public int getLastUpdateTime()
Description copied from interface: TRTrackerAnnouncer
Last Update Time in seconds

Specified by:
getLastUpdateTime in interface TRTrackerAnnouncer

update

public void update(boolean force)
Specified by:
update in interface TRTrackerAnnouncer

complete

public void complete(boolean already_reported)
Specified by:
complete in interface TRTrackerAnnouncer

stop

public void stop(boolean for_queue)
Specified by:
stop in interface TRTrackerAnnouncer

requestUpdate

protected void requestUpdate()

requestUpdateSupport

protected long requestUpdateSupport()

startSupport

protected TRTrackerAnnouncerResponseImpl startSupport()

completeSupport

protected TRTrackerAnnouncerResponseImpl completeSupport()

stopSupport

protected TRTrackerAnnouncerResponseImpl stopSupport()

updateSupport

protected TRTrackerAnnouncerResponseImpl updateSupport()

announceUDP

protected java.lang.String announceUDP(java.net.URL original_reqUrl,
                                       java.io.ByteArrayOutputStream message,
                                       boolean is_probe)
                                throws java.io.IOException
Throws:
java.io.IOException

getLongURLParam

protected long getLongURLParam(java.lang.String url,
                               java.lang.String param)

getURLParam

protected java.lang.String getURLParam(java.lang.String url,
                                       java.lang.String param)

exceptionToString

protected java.lang.String exceptionToString(java.lang.Throwable e)

constructUrl

public java.net.URL constructUrl(java.lang.String evt,
                                 java.net.URL _url)
                          throws java.lang.Exception
Throws:
java.lang.Exception

calculateNumWant

protected int calculateNumWant()

getPeerId

public byte[] getPeerId()
Specified by:
getPeerId in interface TRTrackerAnnouncer

setAnnounceDataProvider

public void setAnnounceDataProvider(TRTrackerAnnouncerDataProvider _provider)
Specified by:
setAnnounceDataProvider in interface TRTrackerAnnouncer

getTorrent

public TOTorrent getTorrent()
Specified by:
getTorrent in interface TRTrackerAnnouncer

getTrackerURL

public java.net.URL getTrackerURL()
Specified by:
getTrackerURL in interface TRTrackerAnnouncer

setTrackerURL

public void setTrackerURL(java.net.URL new_url)
Specified by:
setTrackerURL in interface TRTrackerAnnouncer

getAnnounceSets

public TOTorrentAnnounceURLSet[] getAnnounceSets()
Specified by:
getAnnounceSets in interface TRTrackerAnnouncerHelper

resetTrackerUrl

public void resetTrackerUrl(boolean shuffle)
Specified by:
resetTrackerUrl in interface TRTrackerAnnouncer

refreshListeners

public void refreshListeners()
Description copied from interface: TRTrackerAnnouncer
This method forces all listeners to get an explicit "urlChanged" event to get them to re-examine the tracker

Specified by:
refreshListeners in interface TRTrackerAnnouncer

setIPOverride

public void setIPOverride(java.lang.String override)
Specified by:
setIPOverride in interface TRTrackerAnnouncer

clearIPOverride

public void clearIPOverride()
Specified by:
clearIPOverride in interface TRTrackerAnnouncer

trackerURLListToString

protected java.lang.String trackerURLListToString()

decodeTrackerResponse

protected TRTrackerAnnouncerResponseImpl decodeTrackerResponse(java.net.URL url,
                                                               byte[] data)

informURLChange

protected void informURLChange(java.net.URL old_url,
                               java.net.URL new_url,
                               boolean explicit)

informURLRefresh

protected void informURLRefresh()

getLastResponse

public TRTrackerAnnouncerResponse getLastResponse()
Specified by:
getLastResponse in interface TRTrackerAnnouncer

isManual

public boolean isManual()
Specified by:
isManual in interface TRTrackerAnnouncer

destroy

public void destroy()
Specified by:
destroy in interface TRTrackerAnnouncer

getErrorRetryInterval

protected int getErrorRetryInterval()
Retrieve the retry interval to use on announce errors.


setAnnounceResult

public void setAnnounceResult(DownloadAnnounceResult result)
Specified by:
setAnnounceResult in interface TRTrackerAnnouncer

addListener

public void addListener(TRTrackerAnnouncerListener l)
Specified by:
addListener in interface TRTrackerAnnouncer

removeListener

public void removeListener(TRTrackerAnnouncerListener l)
Specified by:
removeListener in interface TRTrackerAnnouncer

setTrackerResponseCache

public void setTrackerResponseCache(java.util.Map map)
Description copied from interface: TRTrackerAnnouncer
sets the response cache. This may be used by the tracker client to return peer details when the tracker is offline

Specified by:
setTrackerResponseCache in interface TRTrackerAnnouncer

removeFromTrackerResponseCache

public void removeFromTrackerResponseCache(java.lang.String ip,
                                           int tcpPort)
Description copied from interface: TRTrackerAnnouncer
remove a specific entry from the cache if present

Specified by:
removeFromTrackerResponseCache in interface TRTrackerAnnouncer

getTrackerResponseCache

public java.util.Map getTrackerResponseCache()
Description copied from interface: TRTrackerAnnouncer
returns a Map containing "bencoded" entries representing a cache of tracker responses.

Specified by:
getTrackerResponseCache in interface TRTrackerAnnouncer
Returns:

getTrackerPeerSource

public TrackerPeerSource getTrackerPeerSource(TOTorrentAnnounceURLSet set)
Description copied from interface: TRTrackerAnnouncer
Gets a delegate tracker peer source for reporting against

Specified by:
getTrackerPeerSource in interface TRTrackerAnnouncer
Returns:

getCacheTrackerPeerSource

public TrackerPeerSource getCacheTrackerPeerSource()
Specified by:
getCacheTrackerPeerSource in interface TRTrackerAnnouncer

generateEvidence

public void generateEvidence(IndentWriter writer)
Specified by:
generateEvidence in interface TRTrackerAnnouncer