use of java.lang.Thread.State in project platformlayer by platformlayer.
the class PlatformlayerMetricsReporter method printVmMetrics.
protected void printVmMetrics(MetricTreeObject tree) {
MetricTreeObject jvmTree = tree.getSubtree("jvm");
MetricTreeObject memoryTree = jvmTree.getSubtree("memory");
memoryTree.addFloat("heap_usage", vm.heapUsage());
memoryTree.addFloat("non_heap_usage", vm.nonHeapUsage());
MetricTreeObject memoryPoolUsages = memoryTree.getSubtree("memory_pool_usages");
for (Entry<String, Double> pool : vm.memoryPoolUsage().entrySet()) {
memoryPoolUsages.addFloat(pool.getKey(), pool.getValue());
}
jvmTree.addInt("daemon_thread_count", vm.daemonThreadCount());
jvmTree.addInt("thread_count", vm.threadCount());
jvmTree.addInt("uptime", vm.uptime());
jvmTree.addFloat("fd_usage", vm.fileDescriptorUsage());
MetricTreeObject threadStates = jvmTree.getSubtree("thread-states");
for (Entry<State, Double> entry : vm.threadStatePercentages().entrySet()) {
threadStates.addFloat(entry.getKey().toString().toLowerCase(), entry.getValue());
}
MetricTreeObject gcTree = jvmTree.getSubtree("gc");
for (Entry<String, VirtualMachineMetrics.GarbageCollectorStats> entry : vm.garbageCollectors().entrySet()) {
MetricTreeObject collectorTree = gcTree.getSubtree(entry.getKey());
collectorTree.addInt("time", entry.getValue().getTime(TimeUnit.MILLISECONDS));
collectorTree.addInt("runs", entry.getValue().getRuns());
}
}
use of java.lang.Thread.State in project randomizedtesting by randomizedtesting.
the class Threads method append.
/**
* Dump {@link ThreadInfo} information.
*/
public static void append(StringBuilder b, ThreadInfo ti) {
b.append('"').append(ti.getThreadName()).append('"');
b.append(" ID=").append(ti.getThreadId());
final State threadState = ti.getThreadState();
b.append(" ").append(threadState);
if (ti.getLockName() != null) {
b.append(" on ").append(ti.getLockName());
}
if (ti.getLockOwnerName() != null) {
b.append(" owned by \"").append(ti.getLockOwnerName()).append("\" ID=").append(ti.getLockOwnerId());
}
b.append(ti.isSuspended() ? " (suspended)" : "");
b.append(ti.isInNative() ? " (in native code)" : "");
b.append("\n");
final StackTraceElement[] stack = ti.getStackTrace();
final LockInfo lockInfo = ti.getLockInfo();
final MonitorInfo[] monitorInfos = ti.getLockedMonitors();
for (int i = 0; i < stack.length; i++) {
b.append("\tat ").append(stack[i]).append("\n");
if (i == 0 && lockInfo != null) {
b.append("\t- ").append(lockInfoStrings.get(threadState)).append(lockInfo).append("\n");
}
for (MonitorInfo mi : monitorInfos) {
if (mi.getLockedStackDepth() == i) {
b.append("\t- locked ").append(mi).append("\n");
}
}
}
LockInfo[] lockInfos = ti.getLockedSynchronizers();
if (lockInfos.length > 0) {
b.append("\tLocked synchronizers:\n");
for (LockInfo li : ti.getLockedSynchronizers()) {
b.append("\t- ").append(li).append("\n");
}
}
b.append("\n");
}
use of java.lang.Thread.State in project jdk8u_jdk by JetBrains.
the class ThreadInfo method toString.
/**
* Returns a string representation of this thread info.
* The format of this string depends on the implementation.
* The returned string will typically include
* the {@linkplain #getThreadName thread name},
* the {@linkplain #getThreadId thread ID},
* its {@linkplain #getThreadState state},
* and a {@linkplain #getStackTrace stack trace} if any.
*
* @return a string representation of this thread info.
*/
public String toString() {
StringBuilder sb = new StringBuilder("\"" + getThreadName() + "\"" + " Id=" + getThreadId() + " " + getThreadState());
if (getLockName() != null) {
sb.append(" on " + getLockName());
}
if (getLockOwnerName() != null) {
sb.append(" owned by \"" + getLockOwnerName() + "\" Id=" + getLockOwnerId());
}
if (isSuspended()) {
sb.append(" (suspended)");
}
if (isInNative()) {
sb.append(" (in native)");
}
sb.append('\n');
int i = 0;
for (; i < stackTrace.length && i < MAX_FRAMES; i++) {
StackTraceElement ste = stackTrace[i];
sb.append("\tat " + ste.toString());
sb.append('\n');
if (i == 0 && getLockInfo() != null) {
Thread.State ts = getThreadState();
switch(ts) {
case BLOCKED:
sb.append("\t- blocked on " + getLockInfo());
sb.append('\n');
break;
case WAITING:
sb.append("\t- waiting on " + getLockInfo());
sb.append('\n');
break;
case TIMED_WAITING:
sb.append("\t- waiting on " + getLockInfo());
sb.append('\n');
break;
default:
}
}
for (MonitorInfo mi : lockedMonitors) {
if (mi.getLockedStackDepth() == i) {
sb.append("\t- locked " + mi);
sb.append('\n');
}
}
}
if (i < stackTrace.length) {
sb.append("\t...");
sb.append('\n');
}
LockInfo[] locks = 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();
}
Aggregations