use of fish.payara.nucleus.healthcheck.HealthCheckResult in project Payara by payara.
the class StuckThreadsHealthCheck method doCheck.
@Override
public HealthCheckResult doCheck() {
HealthCheckResult result = new HealthCheckResult();
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
Long thresholdNanos = TimeUnit.NANOSECONDS.convert(options.getTimeStuck(), options.getUnitStuck());
ConcurrentHashMap<Long, Long> threads = stuckThreadsStore.getThreads();
for (Long thread : threads.keySet()) {
Long timeHeld = threads.get(thread);
if (timeHeld > thresholdNanos) {
ThreadInfo info = bean.getThreadInfo(thread, Integer.MAX_VALUE);
if (info != null) {
// check thread hasn't died already
result.add(new HealthCheckResultEntry(HealthCheckResultStatus.WARNING, "Stuck Thread: " + info.toString()));
}
}
}
return result;
}
Aggregations