From f476004cf4c523dcd6535957e39e7b18f4076a93 Mon Sep 17 00:00:00 2001 From: Sunil G Date: Tue, 26 Jun 2018 16:12:30 -0700 Subject: [PATCH] YARN-8464 --- .../scheduler/capacity/CapacityScheduler.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java index 50ab70d03ec..54bbf24ef77 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java @@ -521,7 +521,14 @@ static void schedule(CapacityScheduler cs) throws InterruptedException{ // First randomize the start point int current = 0; Collection nodes = cs.nodeTracker.getAllNodes(); - int start = random.nextInt(nodes.size()); + + // If nodes size is 0 (when there are no node managers registered, + // we can return from here itself. + int nodeSize = nodes.size(); + if(nodeSize == 0) { + return; + } + int start = random.nextInt(nodeSize); // To avoid too verbose DEBUG logging, only print debug log once for // every 10 secs. @@ -574,6 +581,7 @@ public AsyncScheduleThread(CapacityScheduler cs) { @Override public void run() { + int debuggingLogCounter = 0; while (!Thread.currentThread().isInterrupted()) { try { if (!runSchedules.get()) { @@ -585,6 +593,14 @@ public void run() { Thread.sleep(1); } else{ schedule(cs); + if(LOG.isDebugEnabled()) { + // Adding a debug log here to ensure that the thread is alive + // and running fine. + if (debuggingLogCounter++ > 10000) { + debuggingLogCounter = 0; + LOG.debug("AsyncScheduleThread[" + getName() + "] is running!"); + } + } } } } catch (InterruptedException ie) { -- 2.14.3 (Apple Git-98)