Factor some bits out into call down methods so that we can do other

performance tracking.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1656 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2005-06-13 18:12:27 +00:00
parent f79e82002c
commit 2e572a43ae
@@ -128,27 +128,13 @@ public class Invoker extends LoopingThread
}
try {
willInvokeUnit(unit, start);
if (unit.invoke()) {
// if it returned true, we post it to the receiver thread
// to invoke the result processing
_receiver.postRunnable(unit);
}
// track some performance metrics
if (PERF_TRACK) {
long duration = System.currentTimeMillis() - start;
Object key = unit.getClass();
recordMetrics(key, duration);
// report long runners
if (duration > 5000L) {
Log.warning("Invoker unit ran for '" + duration + "ms: " +
unit + "' (" + key + ").");
} else if (duration > 500L) {
Log.info("Invoker unit ran for '" + duration + "ms: " +
unit + "' (" + key + ").");
}
}
didInvokeUnit(unit, start);
} catch (Throwable t) {
Log.warning("Invocation unit failed [unit=" + unit + "].");
@@ -170,6 +156,43 @@ public class Invoker extends LoopingThread
});
}
/**
* Called before we process an invoker unit.
*
* @param unit the unit about to be invoked.
* @param start a timestamp recorded immediately before invocation if
* {@link #PERF_TRACK} is enabled, 0L otherwise.
*/
protected void willInvokeUnit (Unit unit, long start)
{
}
/**
* Called before we process an invoker unit.
*
* @param unit the unit about to be invoked.
* @param start a timestamp recorded immediately before invocation if
* {@link #PERF_TRACK} is enabled, 0L otherwise.
*/
protected void didInvokeUnit (Unit unit, long start)
{
// track some performance metrics
if (PERF_TRACK) {
long duration = System.currentTimeMillis() - start;
Object key = unit.getClass();
recordMetrics(key, duration);
// report long runners
if (duration > 5000L) {
Log.warning("Invoker unit ran for '" + duration + "ms: " +
unit + "' (" + key + ").");
} else if (duration > 500L) {
Log.info("Invoker unit ran for '" + duration + "ms: " +
unit + "' (" + key + ").");
}
}
}
protected void recordMetrics (Object key, long duration)
{
UnitProfile prof = (UnitProfile)_tracker.get(key);