forked from I2P_Developers/i2p.i2p
use different sort for floodfill profiles display
This commit is contained in:
@ -26,12 +26,10 @@ import net.i2p.stat.RateStat;
|
|||||||
class ProfileOrganizerRenderer {
|
class ProfileOrganizerRenderer {
|
||||||
private final RouterContext _context;
|
private final RouterContext _context;
|
||||||
private final ProfileOrganizer _organizer;
|
private final ProfileOrganizer _organizer;
|
||||||
private final ProfileComparator _comparator;
|
|
||||||
|
|
||||||
public ProfileOrganizerRenderer(ProfileOrganizer organizer, RouterContext context) {
|
public ProfileOrganizerRenderer(ProfileOrganizer organizer, RouterContext context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
_organizer = organizer;
|
_organizer = organizer;
|
||||||
_comparator = new ProfileComparator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,21 +42,19 @@ class ProfileOrganizerRenderer {
|
|||||||
long now = _context.clock().now();
|
long now = _context.clock().now();
|
||||||
long hideBefore = now - 90*60*1000;
|
long hideBefore = now - 90*60*1000;
|
||||||
|
|
||||||
TreeSet<PeerProfile> order = new TreeSet(_comparator);
|
Set<PeerProfile> order = new TreeSet(mode == 2 ? new HashComparator() : new ProfileComparator());
|
||||||
TreeSet<PeerProfile> integratedPeers = new TreeSet(_comparator);
|
|
||||||
int older = 0;
|
int older = 0;
|
||||||
int standard = 0;
|
int standard = 0;
|
||||||
for (Iterator<Hash> iter = peers.iterator(); iter.hasNext();) {
|
for (Iterator<Hash> iter = peers.iterator(); iter.hasNext();) {
|
||||||
Hash peer = iter.next();
|
Hash peer = iter.next();
|
||||||
if (_organizer.getUs().equals(peer)) continue;
|
if (_organizer.getUs().equals(peer)) continue;
|
||||||
PeerProfile prof = _organizer.getProfile(peer);
|
PeerProfile prof = _organizer.getProfile(peer);
|
||||||
//if (_organizer.isWellIntegrated(peer)) {
|
if (mode == 2) {
|
||||||
// integratedPeers.add(prof);
|
|
||||||
//} else {
|
|
||||||
RouterInfo info = _context.netDb().lookupRouterInfoLocally(peer);
|
RouterInfo info = _context.netDb().lookupRouterInfoLocally(peer);
|
||||||
if (info != null && info.getCapabilities().indexOf("f") >= 0)
|
if (info != null && info.getCapabilities().indexOf("f") >= 0)
|
||||||
integratedPeers.add(prof);
|
order.add(prof);
|
||||||
//}
|
continue;
|
||||||
|
}
|
||||||
if (prof.getLastSendSuccessful() <= hideBefore) {
|
if (prof.getLastSendSuccessful() <= hideBefore) {
|
||||||
older++;
|
older++;
|
||||||
continue;
|
continue;
|
||||||
@ -221,7 +217,7 @@ class ProfileOrganizerRenderer {
|
|||||||
buf.append("<th class=\"smallhead\">").append(_("1d Fail Rate")).append("</th>");
|
buf.append("<th class=\"smallhead\">").append(_("1d Fail Rate")).append("</th>");
|
||||||
buf.append("</tr>");
|
buf.append("</tr>");
|
||||||
RateAverages ra = RateAverages.getTemp();
|
RateAverages ra = RateAverages.getTemp();
|
||||||
for (Iterator<PeerProfile> iter = integratedPeers.iterator(); iter.hasNext();) {
|
for (Iterator<PeerProfile> iter = order.iterator(); iter.hasNext();) {
|
||||||
PeerProfile prof = iter.next();
|
PeerProfile prof = iter.next();
|
||||||
Hash peer = prof.getPeer();
|
Hash peer = prof.getPeer();
|
||||||
|
|
||||||
@ -297,11 +293,11 @@ class ProfileOrganizerRenderer {
|
|||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProfileComparator implements Comparator<PeerProfile> {
|
private class ProfileComparator extends HashComparator {
|
||||||
public int compare(PeerProfile left, PeerProfile right) {
|
public int compare(PeerProfile left, PeerProfile right) {
|
||||||
if (_context.profileOrganizer().isFast(left.getPeer())) {
|
if (_context.profileOrganizer().isFast(left.getPeer())) {
|
||||||
if (_context.profileOrganizer().isFast(right.getPeer())) {
|
if (_context.profileOrganizer().isFast(right.getPeer())) {
|
||||||
return compareHashes(left, right);
|
return super.compare(left, right);
|
||||||
} else {
|
} else {
|
||||||
return -1; // fast comes first
|
return -1; // fast comes first
|
||||||
}
|
}
|
||||||
@ -309,13 +305,13 @@ class ProfileOrganizerRenderer {
|
|||||||
if (_context.profileOrganizer().isFast(right.getPeer())) {
|
if (_context.profileOrganizer().isFast(right.getPeer())) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (_context.profileOrganizer().isHighCapacity(right.getPeer())) {
|
} else if (_context.profileOrganizer().isHighCapacity(right.getPeer())) {
|
||||||
return compareHashes(left, right);
|
return super.compare(left, right);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (_context.profileOrganizer().isFailing(left.getPeer())) {
|
} else if (_context.profileOrganizer().isFailing(left.getPeer())) {
|
||||||
if (_context.profileOrganizer().isFailing(right.getPeer())) {
|
if (_context.profileOrganizer().isFailing(right.getPeer())) {
|
||||||
return compareHashes(left, right);
|
return super.compare(left, right);
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -328,12 +324,18 @@ class ProfileOrganizerRenderer {
|
|||||||
} else if (_context.profileOrganizer().isFailing(right.getPeer())) {
|
} else if (_context.profileOrganizer().isFailing(right.getPeer())) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return compareHashes(left, right);
|
return super.compare(left, right);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int compareHashes(PeerProfile left, PeerProfile right) {
|
/**
|
||||||
|
* Used for floodfill-only page
|
||||||
|
* @since 0.9.8
|
||||||
|
*/
|
||||||
|
private static class HashComparator implements Comparator<PeerProfile> {
|
||||||
|
public int compare(PeerProfile left, PeerProfile right) {
|
||||||
return left.getPeer().toBase64().compareTo(right.getPeer().toBase64());
|
return left.getPeer().toBase64().compareTo(right.getPeer().toBase64());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user