Search in sources :

Example 6 with HealthCheckResult

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;
}
Also used : ThreadMXBean(java.lang.management.ThreadMXBean) ThreadInfo(java.lang.management.ThreadInfo) HealthCheckResult(fish.payara.nucleus.healthcheck.HealthCheckResult) HealthCheckResultEntry(fish.payara.notification.healthcheck.HealthCheckResultEntry)

Aggregations

HealthCheckResult (fish.payara.nucleus.healthcheck.HealthCheckResult)6 HealthCheckResultEntry (fish.payara.notification.healthcheck.HealthCheckResultEntry)5 ThreadMXBean (java.lang.management.ThreadMXBean)3 ThreadTimes (fish.payara.nucleus.healthcheck.entity.ThreadTimes)2 ThreadInfo (java.lang.management.ThreadInfo)2 DecimalFormat (java.text.DecimalFormat)2 IOException (java.io.IOException)1 MemoryMXBean (java.lang.management.MemoryMXBean)1 MemoryUsage (java.lang.management.MemoryUsage)1 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1 JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)1 JdbcResource (org.glassfish.jdbc.config.JdbcResource)1 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)1 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)1