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 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 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, String[] _peer_networks, boolean _manual, TRTrackerAnnouncerImpl.Helper _helper)
           
 
Method Summary
 void addListener(TRTrackerAnnouncerListener l)
           
protected  String announceUDP(URL original_reqUrl, ByteArrayOutputStream message, boolean is_probe)
           
protected  int calculateNumWant()
           
 void clearIPOverride()
           
 void cloneFrom(TRTrackerBTAnnouncerImpl other)
           
 void complete(boolean already_reported)
           
protected  TRTrackerAnnouncerResponseImpl completeSupport()
           
 URL constructUrl(String evt, URL _url)
           
protected  TRTrackerAnnouncerResponseImpl decodeTrackerResponse(URL url, byte[] data)
           
 void destroy()
           
protected  String exceptionToString(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(String url, String param)
           
 long getMinInterval()
           
 byte[] getPeerId()
           
 int getStatus()
           
 String getStatusString()
           
 int getTimeUntilNextUpdate()
           
 TOTorrent getTorrent()
           
 TrackerPeerSource getTrackerPeerSource(TOTorrentAnnounceURLSet set)
          Gets a delegate tracker peer source for reporting against
 Map getTrackerResponseCache()
          returns a Map containing "bencoded" entries representing a cache of tracker responses.
 URL getTrackerURL()
           
protected  String getURLParam(String url, String param)
           
protected  void informURLChange(URL old_url, 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(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(String override)
           
 void setRefreshDelayOverrides(int percentage)
           
 void setTrackerResponseCache(Map map)
          sets the response cache.
 void setTrackerURL(URL new_url)
           
protected  TRTrackerAnnouncerResponseImpl startSupport()
           
 void stop(boolean for_queue)
           
protected  TRTrackerAnnouncerResponseImpl stopSupport()
           
protected  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 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,
                                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 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 String announceUDP(URL original_reqUrl,
                             ByteArrayOutputStream message,
                             boolean is_probe)
                      throws IOException
Throws:
IOException

getLongURLParam

protected long getLongURLParam(String url,
                               String param)

getURLParam

protected String getURLParam(String url,
                             String param)

exceptionToString

protected String exceptionToString(Throwable e)

constructUrl

public URL constructUrl(String evt,
                        URL _url)
                 throws Exception
Throws:
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 URL getTrackerURL()
Specified by:
getTrackerURL in interface TRTrackerAnnouncer

setTrackerURL

public void setTrackerURL(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(String override)
Specified by:
setIPOverride in interface TRTrackerAnnouncer

clearIPOverride

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

trackerURLListToString

protected String trackerURLListToString()

decodeTrackerResponse

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

informURLChange

protected void informURLChange(URL old_url,
                               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(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(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 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