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:
@@ -128,27 +128,13 @@ public class Invoker extends LoopingThread
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
willInvokeUnit(unit, start);
|
||||||
if (unit.invoke()) {
|
if (unit.invoke()) {
|
||||||
// if it returned true, we post it to the receiver thread
|
// if it returned true, we post it to the receiver thread
|
||||||
// to invoke the result processing
|
// to invoke the result processing
|
||||||
_receiver.postRunnable(unit);
|
_receiver.postRunnable(unit);
|
||||||
}
|
}
|
||||||
|
didInvokeUnit(unit, 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 + ").");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.warning("Invocation unit failed [unit=" + unit + "].");
|
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)
|
protected void recordMetrics (Object key, long duration)
|
||||||
{
|
{
|
||||||
UnitProfile prof = (UnitProfile)_tracker.get(key);
|
UnitProfile prof = (UnitProfile)_tracker.get(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user