Differentiate between interactive reports and periodically generated reports.
Only reset our accumulating counters for the periodic reports. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4219 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -712,7 +712,8 @@ public class PresentsDObjectMgr
|
||||
}
|
||||
|
||||
// documentation inherited from interface PresentsServer.Reporter
|
||||
public void appendReport (StringBuilder report, long now, long sinceLast)
|
||||
public void appendReport (
|
||||
StringBuilder report, long now, long sinceLast, boolean reset)
|
||||
{
|
||||
report.append("* presents.PresentsDObjectMgr:\n");
|
||||
int queueSize = _evqueue.size();
|
||||
@@ -733,9 +734,11 @@ public class PresentsDObjectMgr
|
||||
}
|
||||
|
||||
// roll over stats
|
||||
_recent = _current;
|
||||
_current = new Stats();
|
||||
_current.maxQueueSize = queueSize;
|
||||
if (reset) {
|
||||
_recent = _current;
|
||||
_current = new Stats();
|
||||
_current.maxQueueSize = queueSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,8 @@ public class PresentsInvoker extends Invoker
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public void appendReport (StringBuilder buf, long now, long sinceLast)
|
||||
public void appendReport (
|
||||
StringBuilder buf, long now, long sinceLast, boolean reset)
|
||||
{
|
||||
buf.append("* presents.util.Invoker:\n");
|
||||
int qsize = _queue.size();
|
||||
@@ -66,13 +67,15 @@ public class PresentsInvoker extends Invoker
|
||||
synchronized (this) {
|
||||
buf.append("- Max queue size: ").append(_maxQueueSize).append("\n");
|
||||
buf.append("- Units executed: ").append(_unitsRun).append("\n");
|
||||
_maxQueueSize = qsize;
|
||||
_unitsRun = 0;
|
||||
if (_currentUnit != null) {
|
||||
String uname = StringUtil.safeToString(_currentUnit);
|
||||
buf.append("- Current unit: ").append(uname).append(" ");
|
||||
buf.append(now-_currentUnitStart).append("ms\n");
|
||||
}
|
||||
if (reset) {
|
||||
_maxQueueSize = qsize;
|
||||
_unitsRun = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (PresentsDObjectMgr.UNIT_PROF_ENABLED) {
|
||||
@@ -83,7 +86,9 @@ public class PresentsInvoker extends Invoker
|
||||
}
|
||||
buf.append(" ").append(key).append(" ");
|
||||
buf.append(profile).append("\n");
|
||||
profile.clear();
|
||||
if (reset) {
|
||||
profile.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,11 @@ public class PresentsServer
|
||||
* epoch millis.
|
||||
* @param sinceLast number of milliseconds since the last time we
|
||||
* generated a report.
|
||||
* @param reset if true, all accumulating stats should be reset, if
|
||||
* false they should be allowed to continue to accumulate.
|
||||
*/
|
||||
public void appendReport (
|
||||
StringBuilder buffer, long now, long sinceLast);
|
||||
StringBuilder buffer, long now, long sinceLast, boolean reset);
|
||||
}
|
||||
|
||||
/** Implementers of this interface will be notified when the server is
|
||||
@@ -135,7 +137,7 @@ public class PresentsServer
|
||||
// queue up an interval which will generate reports
|
||||
new Interval(omgr) {
|
||||
public void expired () {
|
||||
logReport(generateReport(System.currentTimeMillis()));
|
||||
logReport(generateReport(System.currentTimeMillis(), true));
|
||||
}
|
||||
}.schedule(REPORT_INTERVAL, true);
|
||||
}
|
||||
@@ -203,7 +205,7 @@ public class PresentsServer
|
||||
|
||||
case SignalManager.SIGUSR1:
|
||||
// generate a system status report
|
||||
Log.info(generateReport(System.currentTimeMillis()));
|
||||
Log.info(generateReport(System.currentTimeMillis(), false));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -227,7 +229,7 @@ public class PresentsServer
|
||||
/**
|
||||
* Generates and logs a "state of server" report.
|
||||
*/
|
||||
protected String generateReport (long now)
|
||||
protected String generateReport (long now, boolean reset)
|
||||
{
|
||||
long sinceLast = now - _lastReportStamp;
|
||||
long uptime = now - _serverStartTime;
|
||||
@@ -249,7 +251,7 @@ public class PresentsServer
|
||||
for (int ii = 0; ii < _reporters.size(); ii++) {
|
||||
Reporter rptr = (Reporter)_reporters.get(ii);
|
||||
try {
|
||||
rptr.appendReport(report, now, sinceLast);
|
||||
rptr.appendReport(report, now, sinceLast, reset);
|
||||
} catch (Throwable t) {
|
||||
Log.warning("Reporter choked [rptr=" + rptr + "].");
|
||||
Log.logStackTrace(t);
|
||||
@@ -272,7 +274,11 @@ public class PresentsServer
|
||||
report.delete(blen-1, blen);
|
||||
}
|
||||
|
||||
_lastReportStamp = now;
|
||||
// only reset the last report time if this is a periodic report
|
||||
if (reset) {
|
||||
_lastReportStamp = now;
|
||||
}
|
||||
|
||||
return report.toString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user