use of java.lang.management.LockInfo in project hudson-2.x by hudson.
the class Functions method dumpThreadInfo.
// ThreadInfo.toString() truncates the stack trace by first 8, so needed my own version
@IgnoreJRERequirement
public static String dumpThreadInfo(ThreadInfo ti, ThreadGroupMap map) {
String grp = map.getThreadGroup(ti);
StringBuilder sb = new StringBuilder("\"" + ti.getThreadName() + "\"" + " Id=" + ti.getThreadId() + " Group=" + (grp != null ? grp : "?") + " " + ti.getThreadState());
if (ti.getLockName() != null) {
sb.append(" on " + ti.getLockName());
}
if (ti.getLockOwnerName() != null) {
sb.append(" owned by \"" + ti.getLockOwnerName() + "\" Id=" + ti.getLockOwnerId());
}
if (ti.isSuspended()) {
sb.append(" (suspended)");
}
if (ti.isInNative()) {
sb.append(" (in native)");
}
sb.append('\n');
StackTraceElement[] stackTrace = ti.getStackTrace();
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement ste = stackTrace[i];
sb.append("\tat " + ste.toString());
sb.append('\n');
if (i == 0 && ti.getLockInfo() != null) {
Thread.State ts = ti.getThreadState();
switch(ts) {
case BLOCKED:
sb.append("\t- blocked on " + ti.getLockInfo());
sb.append('\n');
break;
case WAITING:
sb.append("\t- waiting on " + ti.getLockInfo());
sb.append('\n');
break;
case TIMED_WAITING:
sb.append("\t- waiting on " + ti.getLockInfo());
sb.append('\n');
break;
default:
}
}
for (MonitorInfo mi : ti.getLockedMonitors()) {
if (mi.getLockedStackDepth() == i) {
sb.append("\t- locked " + mi);
sb.append('\n');
}
}
}
LockInfo[] locks = ti.getLockedSynchronizers();
if (locks.length > 0) {
sb.append("\n\tNumber of locked synchronizers = " + locks.length);
sb.append('\n');
for (LockInfo li : locks) {
sb.append("\t- " + li);
sb.append('\n');
}
}
sb.append('\n');
return sb.toString();
}
use of java.lang.management.LockInfo in project spring-boot by spring-projects.
the class PlainTextThreadDumpFormatter method writeStackTraceElement.
private void writeStackTraceElement(PrintWriter writer, StackTraceElement element, ThreadInfo info, List<MonitorInfo> lockedMonitors, boolean firstElement) {
writer.printf("\tat %s%n", element.toString());
LockInfo lockInfo = info.getLockInfo();
if (firstElement && lockInfo != null) {
if (element.getClassName().equals(Object.class.getName()) && element.getMethodName().equals("wait")) {
writer.printf("\t- waiting on %s%n", format(lockInfo));
} else {
String lockOwner = info.getLockOwnerName();
if (lockOwner != null) {
writer.printf("\t- waiting to lock %s owned by \"%s\" t@%d%n", format(lockInfo), lockOwner, info.getLockOwnerId());
} else {
writer.printf("\t- parking to wait for %s%n", format(lockInfo));
}
}
}
writeMonitors(writer, lockedMonitors);
}
use of java.lang.management.LockInfo in project angel by Tencent.
the class ThreadUtils method toString.
public static String toString(ThreadInfo tInfo) {
StringBuilder sb = new StringBuilder("\"" + tInfo.getThreadName() + "\"" + " Id=" + tInfo.getThreadId() + " " + tInfo.getThreadState());
if (tInfo.getLockName() != null) {
sb.append(" on " + tInfo.getLockName());
}
if (tInfo.getLockOwnerName() != null) {
sb.append(" owned by \"" + tInfo.getLockOwnerName() + "\" Id=" + tInfo.getLockOwnerId());
}
if (tInfo.isSuspended()) {
sb.append(" (suspended)");
}
if (tInfo.isInNative()) {
sb.append(" (in native)");
}
sb.append('\n');
int i = 0;
StackTraceElement[] stackTrace = tInfo.getStackTrace();
for (; i < stackTrace.length; i++) {
StackTraceElement ste = stackTrace[i];
sb.append("\tat " + ste.toString());
sb.append('\n');
if (i == 0 && tInfo.getLockInfo() != null) {
Thread.State ts = tInfo.getThreadState();
switch(ts) {
case BLOCKED:
sb.append("\t- blocked on " + tInfo.getLockInfo());
sb.append('\n');
break;
case WAITING:
sb.append("\t- waiting on " + tInfo.getLockInfo());
sb.append('\n');
break;
case TIMED_WAITING:
sb.append("\t- waiting on " + tInfo.getLockInfo());
sb.append('\n');
break;
default:
}
}
MonitorInfo[] lockedMonitors = tInfo.getLockedMonitors();
for (MonitorInfo mi : lockedMonitors) {
if (mi.getLockedStackDepth() == i) {
sb.append("\t- locked " + mi);
sb.append('\n');
}
}
}
LockInfo[] locks = tInfo.getLockedSynchronizers();
if (locks.length > 0) {
sb.append("\n\tNumber of locked synchronizers = " + locks.length);
sb.append('\n');
for (LockInfo li : locks) {
sb.append("\t- " + li);
sb.append('\n');
}
}
sb.append('\n');
return sb.toString();
}
use of java.lang.management.LockInfo in project scheduling by ow2-proactive.
the class TimedOutTestsListener method printLockInfo.
private static void printLockInfo(LockInfo[] locks, StringBuilder sb) {
sb.append(INDENT);
sb.append("Locked synchronizers: count = ");
sb.append(locks.length);
sb.append(System.getProperty("line.separator"));
for (LockInfo li : locks) {
sb.append(INDENT);
sb.append(" - ");
sb.append(li);
sb.append(System.getProperty("line.separator"));
}
sb.append(System.getProperty("line.separator"));
}
use of java.lang.management.LockInfo in project incubator-pulsar by apache.
the class ThreadDumpUtil method printLockInfo.
private static void printLockInfo(LockInfo[] locks, PrintWriter out) {
out.println(INDENT + "Locked synchronizers: count = " + locks.length);
for (LockInfo li : locks) {
out.println(INDENT + " - " + li);
}
out.println();
}
Aggregations