private static int callTimeout = 30000;
public String getSlowCallsAsString(String trackerName) {
Tracker tracker = TrackerFactory.getTracker(trackerName);
Map<Thread, Stack<CallInProgress>> map = tracker.getCalls();
Indentor indentor = new Indentor();
for (Map.Entry<Thread, Stack<CallInProgress>> threadEntry : map.entrySet()) {
Thread thread = threadEntry.getKey();
Stack<CallInProgress> calls = threadEntry.getValue();
CallInProgress firstCall;
try {
firstCall = calls.peek();
} catch (EmptyStackException e) {
continue;
}
long startTime = firstCall.timestamp;
long elapsed = System.currentTimeMillis() - startTime;
if (elapsed > callTimeout) {
indentor.newline();
indentor.append("Maximum time allowed for application call [" + firstCall.call + "] elapsed (" + elapsed + " ms)");
indentor.newline();
ThreadUtils.dumpThreadStatus(thread.getId(), indentor);
appendCalls(calls, indentor);
}
}
String message = indentor.toString();
if (!StringUtils.isEmpty(message)) {
indentor.newline();
indentor.append(ThreadUtils.getThreadDump());
return indentor.toString();
}
return "";
}