protected int getPeerCacheLimit() { synchronized (this) { if (activated.size() < announcers.size()) { return (0); } } if (SystemTime.getMonotonousTime() - create_time < 15 * 1000) { return (0); } TRTrackerAnnouncer active = getBestActive(); if (active != null && provider != null && active.getStatus() == TRTrackerAnnouncerResponse.ST_ONLINE) { if (provider.getMaxNewConnectionsAllowed() > 0 && provider.getPendingConnectionCount() == 0) { return (5); } else { return (0); } } return (10); }
public TRTrackerAnnouncer getBestAnnouncer() { int max = -1; TRTrackerAnnouncer max_announcer = null; for (TRTrackerAnnouncer announcer : announcers) { int status = announcer.getStatus(); if (status > max) { max_announcer = announcer; max = status; } } return (max_announcer == null ? this : max_announcer); }
public int getStatus() { TRTrackerAnnouncer max_announcer = getBestAnnouncer(); return (max_announcer == null ? -1 : max_announcer.getStatus()); }