java.lang.Object
org.klomp.snark.UDPTrackerClient.HostPort
org.klomp.snark.UDPTrackerClient.Tracker
Enclosing class:
UDPTrackerClient

private class UDPTrackerClient.Trackerextends UDPTrackerClient.HostPort
One UDP tracker and its connection state.
  • Field Details

    • destLock

      private final Object destLock
      Lock guarding the tracker destination.
    • dest

      private Destination dest
      Destination used for the connection to this tracker.
    • cid

      private Long cid
      Connection id from the tracker, null when none is held.
    • expires

      private long expires
      When the connection id expires.
    • consecFails

      private int consecFails
      Consecutive failed requests to this tracker.
    • state

      Current state of the connection id.
  • Constructor Details

    • Tracker

      public Tracker(String host, int port)
      Prepares to talk to one UDP tracker.
      Parameters:
      host - the tracker host
      port - the tracker port
  • Method Details

    • getDest

      public Destination getDest(boolean fast)
      The destination, or null.
      Parameters:
      fast - if true, do not lookup
      Returns:
      dest or null
    • setConnInProgress

      public void setConnInProgress(boolean yes)
      Store whether a connection to the tracker is in progress.
      Parameters:
      yes - true while a connection is in progress
    • isConnInProgress

      public boolean isConnInProgress()
      Whether a connection is in progress.
      Returns:
      whether conn in progress
    • isConnValid

      public boolean isConnValid()
      Whether the connection is valid.
      Returns:
      whether conn valid
    • connFailed

      public void connFailed()
      Called when tracker connection attempt fails.
    • replyTimeout

      public void replyTimeout()
      Does not change state.
    • setConnection

      public void setConnection(long cid, long lifetime)
      Store the connection ID and expiration.
      Parameters:
      cid - the connection ID to store
      lifetime - milliseconds from now until the ID expires
    • getConnection

      public Long getConnection()
      The connection ID, or null if invalid.
      Returns:
      null if invalid
    • gotError

      public void gotError()
      Mark an error and notify waiters.
    • getTimeout

      public long getTimeout()
      The query timeout for this connection: the default, doubled for each consecutive failure up to eight times the default.
      Returns:
      the timeout in milliseconds
    • toString

      public String toString()
      String form of the waiter.
      Overrides:
      toString in class UDPTrackerClient.HostPort