* Profiles: Record successes in the DB fail rate
too, so we can calculate a percentage * profiles.jsp: - Change fail rate from count to percent - Hide standard profiles by default
This commit is contained in:
@ -32,7 +32,7 @@ class ProfileOrganizerRenderer {
|
||||
_organizer = organizer;
|
||||
_comparator = new ProfileComparator();
|
||||
}
|
||||
public void renderStatusHTML(Writer out) throws IOException {
|
||||
public void renderStatusHTML(Writer out, boolean full) throws IOException {
|
||||
Set peers = _organizer.selectAllPeers();
|
||||
|
||||
long now = _context.clock().now();
|
||||
@ -40,6 +40,8 @@ class ProfileOrganizerRenderer {
|
||||
|
||||
TreeSet order = new TreeSet(_comparator);
|
||||
TreeSet integratedPeers = new TreeSet(_comparator);
|
||||
int older = 0;
|
||||
int standard = 0;
|
||||
for (Iterator iter = peers.iterator(); iter.hasNext();) {
|
||||
Hash peer = (Hash)iter.next();
|
||||
if (_organizer.getUs().equals(peer)) continue;
|
||||
@ -51,7 +53,14 @@ class ProfileOrganizerRenderer {
|
||||
if (info != null && info.getCapabilities().indexOf("f") >= 0)
|
||||
integratedPeers.add(prof);
|
||||
}
|
||||
if (prof.getLastSendSuccessful() <= hideBefore) continue;
|
||||
if (prof.getLastSendSuccessful() <= hideBefore) {
|
||||
older++;
|
||||
continue;
|
||||
}
|
||||
if ((!full) && !_organizer.isHighCapacity(peer)) {
|
||||
standard++;
|
||||
continue;
|
||||
}
|
||||
order.add(prof);
|
||||
}
|
||||
|
||||
@ -62,7 +71,10 @@ class ProfileOrganizerRenderer {
|
||||
StringBuilder buf = new StringBuilder(16*1024);
|
||||
buf.append("<h2>").append(_("Peer Profiles")).append("</h2>\n<p>");
|
||||
buf.append(_("Showing {0} recent profiles.", order.size())).append('\n');
|
||||
buf.append(_("Hiding {0} older profiles.", peers.size()-order.size()));
|
||||
if (older > 0)
|
||||
buf.append(_("Hiding {0} older profiles.", older)).append('\n');
|
||||
if (standard > 0)
|
||||
buf.append("<a href=\"/profiles.jsp?f=1\">").append(_("Hiding {0} standard profiles.", standard)).append("</a>\n");
|
||||
buf.append("</p>");
|
||||
buf.append("<table>");
|
||||
buf.append("<tr>");
|
||||
@ -169,7 +181,7 @@ class ProfileOrganizerRenderer {
|
||||
}
|
||||
buf.append("</table>");
|
||||
|
||||
buf.append("<h2>").append(_("Floodfill and Integrated Peers")).append("</h2>\n");
|
||||
buf.append("<h2><a name=\"flood\"></a>").append(_("Floodfill and Integrated Peers")).append("</h2>\n");
|
||||
buf.append("<table>");
|
||||
buf.append("<tr>");
|
||||
buf.append("<th class=\"smallhead\">").append(_("Peer")).append("</th>");
|
||||
@ -231,6 +243,7 @@ class ProfileOrganizerRenderer {
|
||||
for (int i = 0; i < 6; i++)
|
||||
buf.append("<td align=\"right\">").append(_(NA));
|
||||
}
|
||||
buf.append("</tr>\n");
|
||||
}
|
||||
buf.append("</table>");
|
||||
|
||||
@ -324,12 +337,15 @@ class ProfileOrganizerRenderer {
|
||||
private String davg (DBHistory dbh, long rate) {
|
||||
RateStat rs = dbh.getFailedLookupRate();
|
||||
if (rs == null)
|
||||
return _(NA);
|
||||
return "0%";
|
||||
Rate r = rs.getRate(rate);
|
||||
if (r == null)
|
||||
return _(NA);
|
||||
return "0%";
|
||||
long c = r.getCurrentEventCount() + r.getLastEventCount();
|
||||
return "" + c;
|
||||
if (c <= 0)
|
||||
return "0%";
|
||||
double avg = 0.5 + 100 * (r.getCurrentTotalValue() + r.getLastTotalValue()) / c;
|
||||
return ((int) avg) + "%";
|
||||
}
|
||||
|
||||
/** translate a string */
|
||||
|
@ -4,13 +4,19 @@ import java.io.IOException;
|
||||
|
||||
|
||||
public class ProfilesHelper extends HelperBase {
|
||||
private boolean _full;
|
||||
|
||||
public ProfilesHelper() {}
|
||||
|
||||
public void setFull(String f) {
|
||||
_full = f != null;
|
||||
}
|
||||
|
||||
/** @return empty string, writes directly to _out */
|
||||
public String getProfileSummary() {
|
||||
try {
|
||||
ProfileOrganizerRenderer rend = new ProfileOrganizerRenderer(_context.profileOrganizer(), _context);
|
||||
rend.renderStatusHTML(_out);
|
||||
rend.renderStatusHTML(_out, _full);
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
<jsp:useBean class="net.i2p.router.web.ProfilesHelper" id="profilesHelper" scope="request" />
|
||||
<jsp:setProperty name="profilesHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
|
||||
<jsp:setProperty name="profilesHelper" property="writer" value="<%=out%>" />
|
||||
<jsp:setProperty name="profilesHelper" property="full" value="<%=request.getParameter("f")%>" />
|
||||
<jsp:getProperty name="profilesHelper" property="profileSummary" />
|
||||
<a name="shitlist"> </a><h2><%=intl._("Banned Peers")%></h2>
|
||||
<jsp:getProperty name="profilesHelper" property="shitlistSummary" />
|
||||
|
@ -114,6 +114,7 @@ public class DBHistory {
|
||||
*/
|
||||
public void lookupSuccessful() {
|
||||
_successfulLookups++;
|
||||
_failedLookupRate.addData(0, 0);
|
||||
_lastLookupSuccessful = _context.clock().now();
|
||||
}
|
||||
|
||||
@ -132,6 +133,9 @@ public class DBHistory {
|
||||
*
|
||||
*/
|
||||
public void storeSuccessful() {
|
||||
// Fixme, redefined this to include both lookup and store fails,
|
||||
// need to fix the javadocs
|
||||
_failedLookupRate.addData(0, 0);
|
||||
_lastStoreSuccessful = _context.clock().now();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user