Source:
@Override public void onIdle(GridWorker w) { if (!livenessCheckEnabled) return; Thread prevCheckerThread = lastChecker.get(); if (prevCheckerThread == null || U.currentTimeMillis() - lastCheckTs <= checkInterval || !lastChecker.compareAndSet(prevCheckerThread, null)) return; try { lastCheckTs = U.currentTimeMillis(); long workersToCheck = Math.max(registeredWorkers.size() * checkInterval / sysWorkerBlockedTimeout, 1); int workersChecked = 0; while (workersChecked < workersToCheck) { if (!checkIter.hasNext()) checkIter = registeredWorkers.entrySet().iterator(); GridWorker worker; try { worker = checkIter.next().getValue(); } catch (NoSuchElementException e) { return; } Thread runner = worker.runner(); if (runner != null && runner != Thread.currentThread() && !worker.isCancelled()) { if (!runner.isAlive()) { GridWorker worker0 = registeredWorkers.get(runner.getName()); if (worker0 != null && worker0 == worker) workerFailedHnd.apply(worker, SYSTEM_WORKER_TERMINATION); } long heartbeatDelay = U.currentTimeMillis() - worker.heartbeatTs(); if (heartbeatDelay > sysWorkerBlockedTimeout) { GridWorker worker0 = registeredWorkers.get(worker.runner().getName()); if (worker0 != null && worker0 == worker) { log.error("Blocked system-critical thread has been detected. " + "This can lead to cluster-wide undefined behaviour " + "[workerName=" + worker.name() + ", threadName=" + worker.runner().getName() + ", blockedFor=" + heartbeatDelay / 1000 + "s]"); U.dumpThread(worker.runner(), log); workerFailedHnd.apply(worker, SYSTEM_WORKER_BLOCKED); } } } if (runner != Thread.currentThread()) workersChecked++; } } finally { boolean set = lastChecker.compareAndSet(null, Thread.currentThread()); assert set; } }

Target:
@Override public void onIdle(GridWorker w) { if (!livenessCheckEnabled) return; Thread prevCheckerThread = lastChecker.get(); if (prevCheckerThread == null || U.currentTimeMillis() - lastCheckTs <= checkInterval || !lastChecker.compareAndSet(prevCheckerThread, null)) return; try { lastCheckTs = U.currentTimeMillis(); long workersToCheck = Math.max(registeredWorkers.size() * checkInterval / sysWorkerBlockedTimeout, 1); int workersChecked = 0; while (workersChecked < workersToCheck) { if (!checkIter.hasNext()) checkIter = registeredWorkers.entrySet().iterator(); GridWorker worker; try { worker = checkIter.next().getValue(); } catch (NoSuchElementException e) { return; } Thread runner = worker.runner(); if (runner != null && runner != Thread.currentThread() && !worker.isCancelled()) { if (!runner.isAlive()) { GridWorker worker0 = registeredWorkers.get(runner.getName()); if (worker0 != null && worker0 == worker) workerFailedHnd.apply(worker, SYSTEM_WORKER_TERMINATION); } long heartbeatDelay = U.currentTimeMillis() - worker.heartbeatTs(); if (heartbeatDelay > sysWorkerBlockedTimeout) { GridWorker worker0 = registeredWorkers.get(runner.getName()); if (worker0 != null && worker0 == worker) { log.error("Blocked system-critical thread has been detected. " + "This can lead to cluster-wide undefined behaviour " + "[workerName=" + worker.name() + ", threadName=" + runner.getName() + ", blockedFor=" + heartbeatDelay / 1000 + "s]"); U.dumpThread(worker.runner(), log); workerFailedHnd.apply(worker, SYSTEM_WORKER_BLOCKED); } } } if (runner != Thread.currentThread()) workersChecked++; } } finally { boolean set = lastChecker.compareAndSet(null, Thread.currentThread()); assert set; } }