use of net.i2p.stat.FrequencyStat in project i2p.i2p by i2p.
the class ConfigStatsHelper method hasMoreStats.
/**
* move the cursor to the next known stat, returning true if a valid
* stat is available.
*
* @return true if a valid stat is available, otherwise false
*/
public boolean hasMoreStats() {
if (_stats.isEmpty())
return false;
_currentIsGraphed = false;
_currentStatName = _stats.remove(0);
RateStat rs = _context.statManager().getRate(_currentStatName);
if (rs != null) {
_currentStatDescription = rs.getDescription();
if (_currentGroup == null)
_currentIsFirstInGroup = true;
else if (!rs.getGroupName().equals(_currentGroup))
_currentIsFirstInGroup = true;
else
_currentIsFirstInGroup = false;
_currentGroup = rs.getGroupName();
// should be the minimum
long period = rs.getPeriods()[0];
if (period <= 10 * 60 * 1000) {
Rate r = rs.getRate(period);
_currentCanBeGraphed = r != null;
if (_currentCanBeGraphed) {
// see above
// _currentIsGraphed = r.getSummaryListener() != null;
_currentGraphName = _currentStatName + "." + period;
_currentIsGraphed = _graphs.contains(_currentGraphName);
}
} else {
_currentCanBeGraphed = false;
}
} else {
FrequencyStat fs = _context.statManager().getFrequency(_currentStatName);
if (fs != null) {
_currentStatDescription = fs.getDescription();
if (_currentGroup == null)
_currentIsFirstInGroup = true;
else if (!fs.getGroupName().equals(_currentGroup))
_currentIsFirstInGroup = true;
else
_currentIsFirstInGroup = false;
_currentGroup = fs.getGroupName();
_currentCanBeGraphed = false;
} else {
if (_log.shouldLog(Log.ERROR))
_log.error("Stat does not exist?! [" + _currentStatName + "]");
return false;
}
}
if (_filters.contains("*") || _filters.contains(_currentStatName))
_currentIsLogged = true;
else
_currentIsLogged = false;
return true;
}
use of net.i2p.stat.FrequencyStat in project i2p.i2p by i2p.
the class StatsGenerator method renderFrequency.
private void renderFrequency(String name, StringBuilder buf) {
FrequencyStat freq = _context.statManager().getFrequency(name);
buf.append("<i>");
buf.append(freq.getDescription());
buf.append("</i><br>");
if (freq.getEventCount() <= 0) {
buf.append("<ul><li class=\"noevents\">").append(_t("No lifetime events")).append("</li></ul>\n");
return;
}
long uptime = _context.router().getUptime();
long[] periods = freq.getPeriods();
Arrays.sort(periods);
buf.append("<ul>");
for (int i = 0; i < periods.length; i++) {
if (periods[i] > uptime)
break;
buf.append("<li>");
renderPeriod(buf, periods[i], _t("frequency"));
Frequency curFreq = freq.getFrequency(periods[i]);
buf.append(DataHelper.formatDuration2(Math.round(curFreq.getAverageInterval())));
buf.append("; ");
buf.append(_t("Rolling average events per period"));
buf.append(": ");
buf.append(num(curFreq.getAverageEventsPerPeriod()));
buf.append("; ");
buf.append(_t("Highest events per period"));
buf.append(": ");
buf.append(num(curFreq.getMaxAverageEventsPerPeriod()));
buf.append("; ");
// if (showAll && (curFreq.getMaxAverageEventsPerPeriod() > 0) && (curFreq.getAverageEventsPerPeriod() > 0) ) {
// buf.append("(current is ");
// buf.append(pct(curFreq.getAverageEventsPerPeriod()/curFreq.getMaxAverageEventsPerPeriod()));
// buf.append(" of max)");
// }
// buf.append(" <i>avg interval between updates:</i> (").append(num(curFreq.getAverageInterval())).append("ms, min ");
// buf.append(num(curFreq.getMinAverageInterval())).append("ms)");
buf.append(_t("Lifetime average events per period")).append(": ");
buf.append(num(curFreq.getStrictAverageEventsPerPeriod()));
buf.append("</li>\n");
}
// Display the strict average
buf.append("<li><b>").append(_t("Lifetime average frequency")).append(":</b> ");
buf.append(DataHelper.formatDuration2(freq.getFrequency()));
buf.append(" (");
buf.append(ngettext("1 event", "{0} events", (int) freq.getEventCount()));
buf.append(")</li></ul><br>\n");
}
Aggregations