public TRTrackerAnnouncerResponse getLastResponse() {
    TRTrackerAnnouncerResponse result = null;

    TRTrackerAnnouncerHelper best = getBestActive();

    if (best != null) {

      result = best.getLastResponse();
    }

    if (result == null) {

      result = last_response_informed;
    }

    return (result);
  }
  protected TRTrackerAnnouncerHelper getBestActiveSupport() {
    List<TRTrackerAnnouncerHelper> x = announcers.getList();

    TRTrackerAnnouncerHelper error_resp = null;

    for (TRTrackerAnnouncerHelper announcer : x) {

      TRTrackerAnnouncerResponse response = announcer.getLastResponse();

      if (response != null) {

        int resp_status = response.getStatus();

        if (resp_status == TRTrackerAnnouncerResponse.ST_ONLINE) {

          return (announcer);

        } else if (error_resp == null
            && resp_status == TRTrackerAnnouncerResponse.ST_REPORTED_ERROR) {

          error_resp = announcer;
        }
      }
    }

    if (error_resp != null) {

      return (error_resp);
    }

    if (x.size() > 0) {

      return (x.get(0));
    }

    return (null);
  }
  protected void checkActivation(boolean force) {
    synchronized (this) {
      int next_check_delay;

      if (destroyed || stopped || announcers.size() <= activated.size()) {

        return;
      }

      if (provider == null) {

        next_check_delay = ACT_CHECK_INIT_DELAY;

      } else {

        boolean activate = force;

        boolean seeding = provider.getRemaining() == 0;

        if (seeding && activated.size() > 0) {

          // when seeding we only activate on tracker fail or major lack of connections
          // as normally we rely on downloaders rotating and finding us

          int connected = provider.getConnectedConnectionCount();

          if (connected < 1) {

            activate = SystemTime.getMonotonousTime() - last_activation_time >= 60 * 1000;

            next_check_delay = ACT_CHECK_SEEDING_SHORT_DELAY;

          } else if (connected < 3) {

            next_check_delay = ACT_CHECK_SEEDING_LONG_DELAY;

          } else {

            next_check_delay = 0;
          }
        } else {

          int allowed = provider.getMaxNewConnectionsAllowed();
          int pending = provider.getPendingConnectionCount();
          int connected = provider.getConnectedConnectionCount();

          int online = 0;

          for (TRTrackerAnnouncerHelper a : activated) {

            TRTrackerAnnouncerResponse response = a.getLastResponse();

            if (response != null && response.getStatus() == TRTrackerAnnouncerResponse.ST_ONLINE) {

              online++;
            }
          }

          /*
          System.out.println(
          	"checkActivation: announcers=" + announcers.size() +
          	", active=" + activated.size() +
          	", online=" + online +
          	", allowed=" + allowed +
          	", pending=" + pending +
          	", connected=" + connected +
          	", seeding=" + seeding );
          */

          if (online == 0) {

            activate = true;

            // no trackers online, start next and recheck soon

            next_check_delay = ACT_CHECK_INIT_DELAY;

          } else {

            int potential = connected + pending;

            if (potential < 10) {

              // minimal connectivity

              activate = true;

              next_check_delay = ACT_CHECK_INIT_DELAY;

            } else if (allowed >= 5 && pending < 3 * allowed / 4) {

              // not enough to fulfill our needs

              activate = true;

              next_check_delay = ACT_CHECK_INTERIM_DELAY;

            } else {
              // things look good, recheck in a bit

              next_check_delay = ACT_CHECK_IDLE_DELAY;
            }
          }
        }

        if (activate) {

          for (TRTrackerAnnouncerHelper a : announcers) {

            if (!activated.contains(a)) {

              if (Logger.isEnabled()) {
                Logger.log(
                    new LogEvent(
                        getTorrent(), LOGID, "Activating " + getString(a.getAnnounceSets())));
              }

              activated.add(a);

              last_activation_time = SystemTime.getMonotonousTime();

              if (complete) {

                a.complete(true);

              } else {

                a.update(false);
              }

              break;
            }
          }
        }
      }

      if (next_check_delay > 0) {

        setupActivationCheck(next_check_delay);
      }
    }
  }