From a619751966a5e62367eb9b4a50b03d7552033b7a Mon Sep 17 00:00:00 2001 From: mdb Date: Sat, 11 Nov 2006 00:57:52 +0000 Subject: [PATCH] Allow the long threshold to be configured. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1974 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/Invoker.java | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/java/com/samskivert/util/Invoker.java b/src/java/com/samskivert/util/Invoker.java index 0e787ddf..2416cb62 100644 --- a/src/java/com/samskivert/util/Invoker.java +++ b/src/java/com/samskivert/util/Invoker.java @@ -100,6 +100,16 @@ public class Invoker extends LoopingThread _receiver = resultReceiver; } + /** + * Configures the duration after which an invoker unit will be considered + * "long". When they complete, long units have a warning message + * logged. The default long threshold is 500 milliseconds. + */ + public void setLongThresholds (long longThreshold) + { + _longThreshold = longThreshold; + } + /** * Posts a unit to this invoker for subsequent invocation on the * invoker's thread. @@ -185,10 +195,11 @@ public class Invoker extends LoopingThread recordMetrics(key, duration); // report long runners - if (duration > 500L) { - Log.warning(((duration >= 5000L) ? "Really long" : "Long") + - " invoker unit [unit=" + unit + - " (" + key + "), time=" + duration + "ms]."); + if (duration > _longThreshold) { + String howLong = (duration >= 10*_longThreshold) ? + "Really long" : "Long"; + Log.warning(howLong + " invoker unit [unit=" + unit + + " (" + key + "), time=" + duration + "ms]."); } } } @@ -240,6 +251,10 @@ public class Invoker extends LoopingThread /** The total number of invoker units run since the last report. */ protected int _unitsRun; + /** The duration of time after which we consider a unit to be delinquent + * and log a warning. */ + protected long _longThreshold = 500L; + /** Whether or not to track invoker unit performance. */ protected static final boolean PERF_TRACK = true; }