org.klomp.snark
Class TrackerClient

java.lang.Object
  extended by org.klomp.snark.TrackerClient
All Implemented Interfaces:
Runnable

public class TrackerClient
extends Object
implements Runnable

Informs metainfo tracker of events and gets new peers for peer coordinator. start() creates a thread and starts it. At the end of each run, a TimedEvent is queued on the SimpleTimer2 queue. The TimedEvent creates a new thread and starts it, so it does not clog SimpleTimer2. The thread runs one pass through the trackers, the PEX, and the DHT, then queues a new TimedEvent and exits. Thus there are only threads that are actively announcing, not one thread per torrent forever. start() may be called again after halt().

Author:
Mark Wielaard (mark@klomp.org)

Constructor Summary
TrackerClient(I2PSnarkUtil util, MetaInfo meta, String additionalTrackerURL, PeerCoordinator coordinator, Snark snark)
          Call start() to start it.
 
Method Summary
 void halt(boolean fast)
          Interrupts this Thread to stop it.
 boolean halted()
           
static boolean isValidAnnounce(String ann)
           
 void run()
          Setup the first time only, then one pass (usually) through the trackers, PEX, and DHT.
 void start()
           
 boolean started()
           
static String urlencode(byte[] bs)
          Very lazy byte[] to URL encoder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrackerClient

public TrackerClient(I2PSnarkUtil util,
                     MetaInfo meta,
                     String additionalTrackerURL,
                     PeerCoordinator coordinator,
                     Snark snark)
Call start() to start it.

Parameters:
meta - null if in magnet mode
additionalTrackerURL - may be null, from the ?tr= param in magnet mode, otherwise ignored
Method Detail

start

public void start()

halted

public boolean halted()

started

public boolean started()

halt

public void halt(boolean fast)
Interrupts this Thread to stop it.

Parameters:
fast - if true, limit the life of the unannounce threads

run

public void run()
Setup the first time only, then one pass (usually) through the trackers, PEX, and DHT. This will take several seconds to several minutes.

Specified by:
run in interface Runnable

urlencode

public static String urlencode(byte[] bs)
Very lazy byte[] to URL encoder. Just encodes almost everything, even some "normal" chars. By not encoding about 1/4 of the chars, we make random data like hashes about 16% smaller. RFC1738: 0-9a-zA-Z$-_.+!*'(), Us: 0-9a-zA-Z


isValidAnnounce

public static boolean isValidAnnounce(String ann)
Returns:
true for i2p hosts only
Since:
0.7.12