|
/**** |
|
private Object torrentGet_trackerStats(Snark download) { |
|
List tracker_stats = new ArrayList(); |
|
List<TrackerPeerSource> trackerPeerSources = core_download.getTrackerPeerSources(); |
|
if (trackerPeerSources == null) { |
|
return tracker_stats; |
|
} |
|
for (TrackerPeerSource tps : trackerPeerSources) { |
|
String statusString = tps.getStatusString(); |
|
if (statusString == null) { |
|
statusString = ""; |
|
} |
|
Map<String, Object> map = new HashMap<String, Object>( 64 ); |
|
// how many downloads this tracker knows of (-1 means it does not know) |
|
map.put("downloadCount", -1); // TODO |
|
// whether or not we've ever sent this tracker an announcement |
|
map.put("hasAnnounced", tps.getPeers() >= 0); // TODO |
|
// whether or not we've ever scraped to this tracker |
|
map.put("hasScraped", false); // todo: bool); |
|
String name = ""; |
|
try { |
|
name = tps.getName(); |
|
} catch (Exception e) { |
|
// NPE at com.aelitis.azureus.plugins.extseed.ExternalSeedPlugin$5.getName(ExternalSeedPlugin.java:561 |
|
} |
|
// human-readable string identifying the tracker |
|
map.put("host", name); // TODO |
|
// the full announce URL |
|
map.put("announce", name); // TODO |
|
// the full scrape URL |
|
map.put("scrape", name); // TODO |
|
// Transmission uses one tracker per tier, |
|
// and the others are kept as backups |
|
map.put("isBackup", false); // TODO |
|
// is the tracker announcing, waiting, queued, etc |
|
int status = tps.getStatus(); |
|
int state; |
|
if (status == tps.ST_AVAILABLE || status == tps.ST_ONLINE) { |
|
state = TR_TRACKER_WAITING; |
|
} else if (status == tps.ST_UPDATING) { |
|
state = TR_TRACKER_ACTIVE; |
|
} else if (status == tps.ST_QUEUED) { |
|
state = TR_TRACKER_QUEUED; |
|
} else { |
|
state = TR_TRACKER_INACTIVE; |
|
} |
|
map.put("announceState", state); |
|
// is the tracker scraping, waiting, queued, etc |
|
map.put("scrapeState", state); |
|
// number of peers the tracker told us about last time. |
|
// if "lastAnnounceSucceeded" is false, this field is undefined |
|
map.put("lastAnnouncePeerCount", tps.getPeers()); |
|
// human-readable string with the result of the last announce. |
|
// if "hasAnnounced" is false, this field is undefined |
|
if (statusString != null) { |
|
map.put("lastAnnounceResult", statusString); |
|
} |
|
// when the last announce was sent to the tracker. |
|
// if "hasAnnounced" is false, this field is undefined |
|
map.put("lastAnnounceStartTime", 0); // TODO: time_t); |
|
// whether or not the last announce was a success. |
|
// if "hasAnnounced" is false, this field is undefined |
|
map.put("lastAnnounceSucceeded", tps.getPeers() >= 0); |
|
// whether or not the last announce timed out. |
|
map.put("lastAnnounceTimedOut", false); // TODO |
|
// when the last announce was completed. |
|
.. if "hasAnnounced" is false, this field is undefined |
|
map.put("lastAnnounceTime", 0); // TODO: time_t); |
|
// human-readable string with the result of the last scrape. |
|
// if "hasScraped" is false, this field is undefined |
|
if (statusString != null) { |
|
map.put("lastScrapeResult", statusString); |
|
} |
|
// when the last scrape was sent to the tracker. |
|
// if "hasScraped" is false, this field is undefined/ |
|
map.put("lastScrapeStartTime", 0); // TODO: time_t); |
|
// whether or not the last scrape was a success. |
|
// if "hasAnnounced" is false, this field is undefined |
|
map.put("lastScrapeSucceeded", tps.getPeers() >= 0); |
|
// whether or not the last scrape timed out. |
|
map.put("lastScrapeTimedOut", false); // TODO: bool); |
|
// when the last scrape was completed. |
|
// if "hasScraped" is false, this field is undefined |
|
map.put("lastScrapeTime", 0); // TODO: time_t); |
|
// number of leechers this tracker knows of (-1 means it does not know) |
|
map.put("leecherCount", tps.getLeecherCount()); |
|
// when the next periodic announce message will be sent out. |
|
// if announceState isn't TR_TRACKER_WAITING, this field is undefined |
|
map.put("nextAnnounceTime", 0); // TODO: time_t); |
|
// when the next periodic scrape message will be sent out. |
|
// if scrapeState isn't TR_TRACKER_WAITING, this field is undefined |
|
map.put("nextScrapeTime", 0); // TODO: time_t); |
|
// number of seeders this tracker knows of (-1 means it does not know) |
|
map.put("seederCount", tps.getSeedCount()); |
|
// which tier this tracker is in |
|
map.put("tier", 0); // TODO: int); |
|
// used to match to a tr_tracker_info |
|
map.put("id", tps.hashCode()); |
|
tracker_stats.add(map); |
|
} |
|
return tracker_stats; |
|
} |
|
****/ |