Source:
<code>@Override public void onKernalStop(boolean cancel) { while(true) { try { if (lock.tryWriteLock(1, TimeUnit.SECONDS)) break; else <START> Thread.sleep(1000); <END> } catch (InterruptedException e) { U.warn(log, e); } } try { stopping = true; waiting = !cancel; } finally { lock.writeUnlock(); } startLatch.countDown(); int size = tasks.size(); if (size > 0) { if (cancel) U.warn(log, "Will cancel unfinished tasks due to stopping of the grid [cnt=" + size + "]"); else U.warn(log, "Will wait for all job responses from worker nodes before stopping grid."); for (GridTaskWorker<?, ?> task : tasks.values()) { if (!cancel) { try { task.getTaskFuture().get(); } catch (ComputeTaskCancelledCheckedException e) { U.warn(log, e.getMessage()); } catch (IgniteCheckedException e) { U.error(log, "Task failed: " + task, e); } } else { for (ClusterNode node : ctx.discovery().nodes(task.getSession().getTopology())) { if (ctx.localNodeId().equals(node.id())) ctx.job().masterLeaveLocal(task.getSession().getId()); } task.cancel(); Throwable ex = new ComputeTaskCancelledCheckedException("Task cancelled due to stopping of the grid: " + task); task.finishTask(null, ex, false); } } U.join(tasks.values(), log); } ctx.event().removeLocalEventListener(discoLsnr); ctx.io().removeMessageListener(TOPIC_JOB_SIBLINGS); ctx.io().removeMessageListener(TOPIC_TASK_CANCEL); if (!cancel) { lock.writeLock(); try { waiting = false; } finally { lock.writeUnlock(); } } assert tasks.isEmpty(); if (log.isDebugEnabled()) log.debug("Finished executing task processor onKernalStop() callback."); }</code><technical_language>sense U.warn("Await lock while node stopping")</technical_language>

Target:
@Override public void onKernalStop(boolean cancel) { while(true) { try { if (lock.tryWriteLock(1, TimeUnit.SECONDS)) { break; } else { LT.warn(log, "Await on lock while node stopping"); Thread.sleep(1000); } } catch (InterruptedException e) { LT.warn(log, "Await for lock on node stop was interrupted"); } } try { stopping = true; waiting = !cancel; } finally { lock.writeUnlock(); } startLatch.countDown(); int size = tasks.size(); if (size > 0) { if (cancel) U.warn(log, "Will cancel unfinished tasks due to stopping of the grid [cnt=" + size + "]"); else U.warn(log, "Will wait for all job responses from worker nodes before stopping grid."); for (GridTaskWorker<?, ?> task : tasks.values()) { if (!cancel) { try { task.getTaskFuture().get(); } catch (ComputeTaskCancelledCheckedException e) { U.warn(log, e.getMessage()); } catch (IgniteCheckedException e) { U.error(log, "Task failed: " + task, e); } } else { for (ClusterNode node : ctx.discovery().nodes(task.getSession().getTopology())) { if (ctx.localNodeId().equals(node.id())) ctx.job().masterLeaveLocal(task.getSession().getId()); } task.cancel(); Throwable ex = new ComputeTaskCancelledCheckedException("Task cancelled due to stopping of the grid: " + task); task.finishTask(null, ex, false); } } U.join(tasks.values(), log); } ctx.event().removeLocalEventListener(discoLsnr); ctx.io().removeMessageListener(TOPIC_JOB_SIBLINGS); ctx.io().removeMessageListener(TOPIC_TASK_CANCEL); if (!cancel) { lock.writeLock(); try { waiting = false; } finally { lock.writeUnlock(); } } assert tasks.isEmpty(); if (log.isDebugEnabled()) log.debug("Finished executing task processor onKernalStop() callback."); }