YARN-4899. Queue metrics of SLS capacity scheduler only activated after app submit to the queue. (Jonathan Hung via wangda)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5ed63e3e Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5ed63e3e Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5ed63e3e Branch: refs/heads/HADOOP-13345 Commit: 5ed63e3e9d9937cf7441b7ceb5feafbf486f3387 Parents: a0a2761 Author: Wangda Tan <wan...@apache.org> Authored: Wed Jan 4 19:17:11 2017 -0800 Committer: Wangda Tan <wan...@apache.org> Committed: Wed Jan 4 19:17:11 2017 -0800 ---------------------------------------------------------------------- .../sls/scheduler/SLSCapacityScheduler.java | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/5ed63e3e/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/SLSCapacityScheduler.java ---------------------------------------------------------------------- diff --git a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/SLSCapacityScheduler.java b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/SLSCapacityScheduler.java index cf08309..89f9ad3 100644 --- a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/SLSCapacityScheduler.java +++ b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/scheduler/SLSCapacityScheduler.java @@ -57,7 +57,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmnode.UpdatedContainerInfo import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplication; +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptAddedSchedulerEvent; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptRemovedSchedulerEvent; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent; @@ -84,6 +86,7 @@ import com.codahale.metrics.Timer; public class SLSCapacityScheduler extends CapacityScheduler implements SchedulerWrapper,Configurable { private static final String EOL = System.getProperty("line.separator"); + private static final String QUEUE_COUNTER_PREFIX = "counter.queue."; private static final int SAMPLING_SIZE = 60; private ScheduledExecutorService pool; // counters for scheduler allocate/handle operations @@ -747,6 +750,47 @@ public class SLSCapacityScheduler extends CapacityScheduler implements } } + private void initQueueMetrics(CSQueue queue) { + if (queue instanceof LeafQueue) { + SortedMap<String, Counter> counterMap = metrics.getCounters(); + String queueName = queue.getQueueName(); + String[] names = new String[]{ + QUEUE_COUNTER_PREFIX + queueName + ".pending.memory", + QUEUE_COUNTER_PREFIX + queueName + ".pending.cores", + QUEUE_COUNTER_PREFIX + queueName + ".allocated.memory", + QUEUE_COUNTER_PREFIX + queueName + ".allocated.cores" }; + + for (int i = names.length - 1; i >= 0; i--) { + if (!counterMap.containsKey(names[i])) { + metrics.counter(names[i]); + counterMap = metrics.getCounters(); + } + } + + queueLock.lock(); + try { + if (!schedulerMetrics.isTracked(queueName)) { + schedulerMetrics.trackQueue(queueName); + } + } finally { + queueLock.unlock(); + } + + return; + } + + for (CSQueue child : queue.getChildQueues()) { + initQueueMetrics(child); + } + } + + @Override + public void serviceInit(Configuration configuration) throws Exception { + super.serviceInit(configuration); + + initQueueMetrics(getRootQueue()); + } + public void setQueueSet(Set<String> queues) { this.queueSet = queues; } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org