/** pings a bunch of hosts if necessary */
  private void pingNewHosts() {
    // if we have reached our desired # of altlocs, don't ping
    if (isCancelled()) return;

    // if we don't have anybody to ping, don't ping
    if (!hasNonBusy()) return;

    // if we haven't found a single RFD with URN, don't ping anybody
    if (sha1 == null) return;

    // if its not time to ping yet, don't ping
    // use the same interval as workers for now
    long now = System.currentTimeMillis();
    if (now - lastPingTime < DownloadSettings.WORKER_INTERVAL.getValue()) return;

    // create a ping for the non-firewalled hosts
    HeadPing ping = new HeadPing(myGUID, sha1, getPingFlags());

    // prepare a batch of hosts to ping
    int batch = DownloadSettings.PING_BATCH.getValue();
    List toSend = new ArrayList(batch);
    int sent = 0;
    for (Iterator iter = newHosts.iterator(); iter.hasNext() && sent < batch; ) {
      RemoteFileDesc rfd = (RemoteFileDesc) iter.next();
      if (rfd.isBusy(now)) continue;
      iter.remove();

      if (rfd.needsPush()) {
        if (rfd.getPushProxies().size() > 0 && rfd.getSHA1Urn() != null) pingProxies(rfd);
      } else {
        pingedHosts.put(rfd, rfd);
        toSend.add(rfd);
      }
      testedLocations.add(rfd);
      sent++;
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "\nverified hosts "
              + verifiedHosts.size()
              + "\npingedHosts "
              + pingedHosts.values().size()
              + "\nnewHosts "
              + newHosts.size()
              + "\npinging hosts: "
              + sent);
    }

    pinger.rank(toSend, null, this, ping);
    lastPingTime = now;
  }
  /** schedules a push ping to each proxy of the given host */
  private void pingProxies(RemoteFileDesc rfd) {
    if (RouterService.acceptedIncomingConnection()
        || (RouterService.getUdpService().canDoFWT() && rfd.supportsFWTransfer())) {
      HeadPing pushPing =
          new HeadPing(
              myGUID,
              rfd.getSHA1Urn(),
              new GUID(rfd.getPushAddr().getClientGUID()),
              getPingFlags());

      for (Iterator iter = rfd.getPushProxies().iterator(); iter.hasNext(); )
        pingedHosts.put(iter.next(), rfd);

      if (LOG.isDebugEnabled()) LOG.debug("pinging push location " + rfd.getPushAddr());

      pinger.rank(rfd.getPushProxies(), null, this, pushPing);
    }
  }